aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-10 20:51:38 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-10 20:51:38 +0100
commit09d297a383b60cfdba6b6388cc54c9c8fa603e75 (patch)
tree38f2d131bcbb352717c6b7e65cb5fd397071239c
parent7838a06e5521db39aee8b3b87785fcb5e32cd7ad (diff)
downloadesper-testing-09d297a383b60cfdba6b6388cc54c9c8fa603e75.tar.gz
esper-testing-09d297a383b60cfdba6b6388cc54c9c8fa603e75.tar.bz2
esper-testing-09d297a383b60cfdba6b6388cc54c9c8fa603e75.tar.xz
esper-testing-09d297a383b60cfdba6b6388cc54c9c8fa603e75.zip
o Fixing another bug in the unbreakable poller, stored one build too many in some progress objects too.
o Got the logback.xml + system properties combination to finally work.
-rwxr-xr-xpom.xml4
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/Config.java12
-rw-r--r--src/main/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgress.java10
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java17
-rw-r--r--src/main/resources/logback.xml4
-rw-r--r--src/main/unix/files/scripts/postinstall7
-rw-r--r--src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java11
7 files changed, 42 insertions, 23 deletions
diff --git a/pom.xml b/pom.xml
index 55f192b..f5ebb74 100755
--- a/pom.xml
+++ b/pom.xml
@@ -182,8 +182,8 @@
<dbms>${dbdeploy.dbms}</dbms>
<delimiter>;</delimiter>
<delimiterType>row</delimiterType>
- <outputfile>dbdeploy-outputfile.tmp.sql</outputfile>
- <undoOutputfile>dbdeploy-undoOutputfile.tmp.sql</undoOutputfile>
+ <outputfile>dbdeploy.tmp.sql</outputfile>
+ <undoOutputfile>dbdeploy-undo.tmp.sql</undoOutputfile>
</configuration>
</plugin>
<plugin>
diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java
index 7da14fa..68c4f1a 100755
--- a/src/main/java/io/trygvis/esper/testing/Config.java
+++ b/src/main/java/io/trygvis/esper/testing/Config.java
@@ -70,9 +70,9 @@ public class Config {
}
public static Config loadFromDisk(String appName) throws IOException {
- initSystemProperties();
+ initSystemProperties(appName);
- initLogging(appName);
+ initLogging();
Properties properties = new Properties();
try (FileInputStream inputStream = new FileInputStream("etc/config.properties")) {
@@ -88,15 +88,15 @@ public class Config {
trimToNull(properties.getProperty("database.password")));
}
- private static void initSystemProperties() {
+ private static void initSystemProperties(String appName) {
// Java 7 is more strict on checking matching host names or something similar.
// http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/JSSERefGuide.html#Customization
System.setProperty("jsse.enableSNIExtension", "false");
- }
- private static void initLogging(String appName) {
- System.setProperty("logging.app", appName);
+ System.setProperty("loggingApp", appName);
+ }
+ private static void initLogging() {
File logs = new File("logs");
if(!logs.isDirectory()) {
diff --git a/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgress.java b/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgress.java
index f43ec94..209cc81 100644
--- a/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgress.java
+++ b/src/main/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgress.java
@@ -4,7 +4,6 @@ import static fj.P.*;
import fj.*;
import fj.data.*;
import static fj.data.Option.*;
-import static java.util.Collections.singletonList;
import io.trygvis.esper.testing.*;
import io.trygvis.esper.testing.core.db.*;
@@ -42,17 +41,16 @@ public class UnbreakableBadgeProgress extends BadgeProgress {
List<UUID> builds = new ArrayList<>(this.builds);
builds.add(build.uuid);
- if (progression() == UnbreakableBadge.LEVEL_3_COUNT) {
+ if (builds.size() == UnbreakableBadge.LEVEL_3_COUNT) {
// You have to start from scratch now.
- builds = singletonList(build.uuid);
- return p(new UnbreakableBadgeProgress(person, builds), some(new UnbreakableBadge(person, 3, builds)));
+ return p(new UnbreakableBadgeProgress(person, Collections.<UUID>emptyList()), some(new UnbreakableBadge(person, 3, builds)));
}
- if (progression() == UnbreakableBadge.LEVEL_2_COUNT) {
+ if (builds.size() == UnbreakableBadge.LEVEL_2_COUNT) {
return p(new UnbreakableBadgeProgress(person, builds), some(new UnbreakableBadge(person, 2, builds)));
}
- if (progression() == UnbreakableBadge.LEVEL_1_COUNT) {
+ if (builds.size() == UnbreakableBadge.LEVEL_1_COUNT) {
return p(new UnbreakableBadgeProgress(person, builds), some(new UnbreakableBadge(person, 1, builds)));
}
diff --git a/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
index 6a7e1b4..f06b4e6 100755
--- a/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
+++ b/src/main/java/io/trygvis/esper/testing/core/jenkins/JenkinsBuildPoller.java
@@ -27,14 +27,14 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
private final XmlParser xmlParser = new XmlParser();
public static void main(String[] args) throws Exception {
+ Config config = loadFromDisk("jenkins-build-poller");
+
String pollerName = "jenkins_build";
String tableName = "jenkins_build";
String columnNames = JenkinsDao.JENKINS_BUILD;
SqlF<ResultSet, JenkinsBuildDto> f = JenkinsDao.jenkinsBuild;
TablePoller.NewRowCallback<JenkinsBuildDto> callback = new JenkinsBuildPoller();
- Config config = loadFromDisk("jenkins-build-poller");
-
BoneCPDataSource dataSource = config.createBoneCp();
new TablePoller<>(pollerName, tableName, columnNames, some("array_length(users, 1) > 0"), f, callback).work(dataSource);
@@ -44,6 +44,8 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
Daos daos = new Daos(c);
final BuildDao buildDao = daos.buildDao;
+ logger.info("Processing Jenkins Build uuid={}", jenkinsBuild.uuid);
+
JenkinsJobDto jobDto = daos.jenkinsDao.selectJob(jenkinsBuild.job).get();
SqlOption<InputStream> jobXmlFileO = daos.fileDao.load(jobDto.file);
@@ -87,6 +89,8 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
final JenkinsBuildXml jenkinsBuildXml = o.some();
+ logger.info("Build details: number={}, url={}", jenkinsBuildXml.number, jenkinsBuildXml.url);
+
SqlOption<UUID> uuidBuildO = buildDao.findBuildByReference(jenkinsBuild.toRef());
UUID uuidBuild = uuidBuildO.getOrElse(new SqlP0<UUID>() {
@@ -116,13 +120,12 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback<JenkinsBui
Uuid person = personO.get().uuid;
- if (!insertedParticipants.add(person)) {
+ if (insertedParticipants.add(person)) {
+ logger.info("Created build participant, person={}", person);
+ buildDao.insertBuildParticipant(uuidBuild, person);
+ } else {
logger.info("Participant already inserted, person={}", person);
- continue;
}
-
- logger.info("Created build participant, person={}", person);
- buildDao.insertBuildParticipant(uuidBuild, person);
}
logger.info("Created build uuid={}, #participants={}, #knownPersons={}, #unknonwnPersons={}", uuidBuild,
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index b502003..0af2e89 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,10 +1,10 @@
<configuration debug="false">
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>logs/${logging.app}.log</file>
+ <file>logs/${loggingApp}.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>logs/${logging.app}-%d.log</fileNamePattern>
+ <fileNamePattern>logs/${loggingApp}-%d.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %-30logger{1} - %msg%n</pattern>
diff --git a/src/main/unix/files/scripts/postinstall b/src/main/unix/files/scripts/postinstall
index 07b1abc..8699bd0 100644
--- a/src/main/unix/files/scripts/postinstall
+++ b/src/main/unix/files/scripts/postinstall
@@ -1,3 +1,10 @@
#!/bin/bash
ln -s ../../../etc
+
+if [ ! -d ../../../logs ]
+then
+ mkdir ../../../logs
+fi
+
+ln -s ../../../logs
diff --git a/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java b/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java
index 3ee0c05..f7993b1 100644
--- a/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java
+++ b/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java
@@ -29,6 +29,14 @@ public class UnbreakableBadgeProgressTest extends TestCase {
for (int i = 0; i < 55; i++) {
P2<UnbreakableBadgeProgress, Option<UnbreakableBadge>> p2 = p.onBuild(success);
+ if (i < 50) {
+ assertEquals(i, p.builds.size());
+ }
+
+ if (i == 50) {
+ assertEquals(0, p.builds.size());
+ }
+
if (p2._2().isSome()) {
badges.add(p2._2().some());
}
@@ -39,8 +47,11 @@ public class UnbreakableBadgeProgressTest extends TestCase {
assertEquals(5, p.builds.size());
assertEquals(3, badges.size());
assertEquals(1, badges.get(0).level);
+ assertEquals(10, badges.get(0).builds.size());
assertEquals(2, badges.get(1).level);
+ assertEquals(20, badges.get(1).builds.size());
assertEquals(3, badges.get(2).level);
+ assertEquals(50, badges.get(2).builds.size());
P2<UnbreakableBadgeProgress, Option<UnbreakableBadge>> p2 = p.onBuild(failure);