aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-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
5 files changed, 29 insertions, 21 deletions
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