From 09d297a383b60cfdba6b6388cc54c9c8fa603e75 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 10 Jan 2013 20:51:38 +0100 Subject: 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. --- src/main/java/io/trygvis/esper/testing/Config.java | 12 ++++++------ .../testing/core/badge/UnbreakableBadgeProgress.java | 10 ++++------ .../esper/testing/core/jenkins/JenkinsBuildPoller.java | 17 ++++++++++------- src/main/resources/logback.xml | 4 ++-- src/main/unix/files/scripts/postinstall | 7 +++++++ .../core/badge/UnbreakableBadgeProgressTest.java | 11 +++++++++++ 6 files changed, 40 insertions(+), 21 deletions(-) (limited to 'src') 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 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.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 f = JenkinsDao.jenkinsBuild; TablePoller.NewRowCallback 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 jobXmlFileO = daos.fileDao.load(jobDto.file); @@ -87,6 +89,8 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback uuidBuildO = buildDao.findBuildByReference(jenkinsBuild.toRef()); UUID uuidBuild = uuidBuildO.getOrElse(new SqlP0() { @@ -116,13 +120,12 @@ public class JenkinsBuildPoller implements TablePoller.NewRowCallback - logs/${logging.app}.log + logs/${loggingApp}.log true - logs/${logging.app}-%d.log + logs/${loggingApp}-%d.log %d{HH:mm:ss.SSS} [%thread] %-5level %-30logger{1} - %msg%n 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> 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> p2 = p.onBuild(failure); -- cgit v1.2.3