diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-10 14:27:04 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2012-12-10 14:27:04 +0100 |
commit | 34f5ac99c81dfe39f986e8133fb7fff22c0d30bc (patch) | |
tree | c91d2a0b1ffe4e120a56f7c31905648b2e2e1f61 | |
parent | f6e357ef18a0c44038fc0ea723c1ec7910bb3f30 (diff) | |
download | esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.tar.gz esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.tar.bz2 esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.tar.xz esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.zip |
o Adding Maven module as a build type.
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java | 7 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java (renamed from src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java) | 39 | ||||
-rwxr-xr-x | src/main/resources/ddl-jenkins.sql | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java (renamed from src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerTest.java) | 8 |
6 files changed, 28 insertions, 40 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java index 2b3ca13..0aa63c1 100755 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java @@ -119,7 +119,9 @@ public class JenkinsClient { case "freeStyleProject": return some(JenkinsJobXml.parse(url, JenkinsJobType.FREE_STYLE, root)); case "mavenModuleSet": - return some(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN, root)); + return some(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN_MODULE_SET, root)); + case "mavenModule": + return some(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN_MODULE, root)); case "matrixProject": return some(JenkinsJobXml.parse(url, JenkinsJobType.MATRIX, root)); default: @@ -241,7 +243,7 @@ class JenkinsJobEntryXml { class JenkinsJobXml { enum JenkinsJobType { - MAVEN, FREE_STYLE, MATRIX + FREE_STYLE, MAVEN_MODULE_SET, MAVEN_MODULE, MATRIX } public final JenkinsJobType type; @@ -313,4 +315,3 @@ class JenkinsJobXml { child(root, "lastUnsuccessfulBuild").bind(BuildXml.buildXml)); } } - diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java index 9f3c752..bd99768 100644..100755 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java @@ -20,7 +20,7 @@ public class JenkinsDao { private static final String JENKINS_SERVER = "uuid, created_date, url"; - private static final String JENKINS_JOB = "uuid, created_date, server, url, display_name"; + private static final String JENKINS_JOB = "uuid, created_date, server, url, job_type, display_name"; private static final String JENKINS_BUILD = "uuid, created_date, job, entry_id, url, result, number, duration, timestamp"; @@ -88,14 +88,15 @@ public class JenkinsDao { } } - public UUID insertJob(UUID server, URI url, Option<String> displayName) throws SQLException { - try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_job(" + JENKINS_JOB + ") VALUES(?, ?, ?, ?, ?)")) { + public UUID insertJob(UUID server, URI url, JenkinsJobXml.JenkinsJobType type, Option<String> displayName) throws SQLException { + try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_job(" + JENKINS_JOB + ") VALUES(?, ?, ?, ?, ?, ?)")) { UUID uuid = UUID.randomUUID(); int i = 1; s.setString(i++, uuid.toString()); s.setTimestamp(i++, new Timestamp(currentTimeMillis())); s.setString(i++, server.toString()); s.setString(i++, url.toASCIIString()); + s.setString(i++, type.name()); s.setString(i, displayName.toNull()); s.executeUpdate(); diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java index 713982f..680e593 100755 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java @@ -26,10 +26,10 @@ public class JenkinsImporter { HashSet<JenkinsServerDto> servers = new HashSet<>(); - ObjectManager<JenkinsServerDto, ActorRef<JenkinsServer>> serverManager = new ObjectManager<>("JenkinsServerOld", servers, new ObjectFactory<JenkinsServerDto, ActorRef<JenkinsServer>>() { - public ActorRef<JenkinsServer> create(JenkinsServerDto server) { + ObjectManager<JenkinsServerDto, ActorRef<JenkinsServerActor>> serverManager = new ObjectManager<>("JenkinsServerOld", servers, new ObjectFactory<JenkinsServerDto, ActorRef<JenkinsServerActor>>() { + public ActorRef<JenkinsServerActor> create(JenkinsServerDto server) { String name = "Jenkins: " + server.url; - return threadedActor(name, config.jenkinsUpdateInterval, boneCp, name, new JenkinsServer(jenkinsClient, server)); + return threadedActor(name, config.jenkinsUpdateInterval, boneCp, name, new JenkinsServerActor(jenkinsClient, server)); } }); diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java index 089c7d0..fa30f14 100644..100755 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java @@ -12,12 +12,12 @@ import java.util.*; import static io.trygvis.esper.testing.jenkins.JenkinsClient.*; import static java.lang.System.*; -public class JenkinsServer implements TransactionalActor { - private static final Logger logger = LoggerFactory.getLogger(JenkinsServer.class); +public class JenkinsServerActor implements TransactionalActor { + private static final Logger logger = LoggerFactory.getLogger(JenkinsServerActor.class); private final JenkinsClient client; public final JenkinsServerDto server; - public JenkinsServer(JenkinsClient client, JenkinsServerDto server) { + public JenkinsServerActor(JenkinsClient client, JenkinsServerDto server) { this.client = client; this.server = server; } @@ -42,7 +42,7 @@ public class JenkinsServer implements TransactionalActor { Option<JenkinsBuildDto> o = dao.selectBuildByEntryId(entry.id); if (o.isSome()) { - logger.debug("Old event: " + entry.id); + logger.debug("Old build: " + entry.id); continue; } @@ -75,7 +75,7 @@ public class JenkinsServer implements TransactionalActor { JenkinsJobXml xml = jobXmlOption.some(); - job = dao.insertJob(server.uuid, xml.url, xml.displayName); + job = dao.insertJob(server.uuid, xml.url, xml.type, xml.displayName); logger.info("New job: " + xml.displayName.orSome(xml.url.toASCIIString()) + ", uuid=" + job); } @@ -91,40 +91,25 @@ public class JenkinsServer implements TransactionalActor { build.duration, build.timestamp); - logger.info("Build inserted: " + uuid + ", i=" + i); + logger.info("Build inserted: " + uuid + ", item #" + i + "/" + list.size()); } long end = currentTimeMillis(); - logger.info("Inserted " + i + " new builds in " + (end - start) + "ms."); + logger.info("Inserted " + i + " of " + list.size() + " builds in " + (end - start) + "ms."); } /** * This sucks, a build should really include the URL to the job. */ public static URI createJobUrl(String u) { - if (u.matches(".*/[-_a-zA-Z]*=.*/[0-9]*/")) { - u = u.substring(0, u.lastIndexOf("/")); - u = u.substring(0, u.lastIndexOf("/")); - u = u.substring(0, u.lastIndexOf("/") + 1); - - return URI.create(u); + if (!u.matches(".*/[0-9]*/")) { + throw new RuntimeException("Not a valid build url: " + u); } - if (u.matches(".*/[.-_a-zA-Z]*\\$.*/[0-9]*/")) { - u = u.substring(0, u.lastIndexOf("/")); - u = u.substring(0, u.lastIndexOf("/")); - u = u.substring(0, u.lastIndexOf("/") + 1); - - return URI.create(u); - } - - if (u.endsWith("/")) { - u = u.substring(0, u.length() - 1); - } - int i = u.lastIndexOf("/"); - u = u.substring(0, i); + u = u.substring(0, u.lastIndexOf("/")); + u = u.substring(0, u.lastIndexOf("/") + 1); - return URI.create(u + "/"); + return URI.create(u); } } diff --git a/src/main/resources/ddl-jenkins.sql b/src/main/resources/ddl-jenkins.sql index 70db7f9..01275eb 100755 --- a/src/main/resources/ddl-jenkins.sql +++ b/src/main/resources/ddl-jenkins.sql @@ -20,6 +20,7 @@ CREATE TABLE jenkins_job ( server CHAR(36) NOT NULL, url VARCHAR(1000) NOT NULL, + job_type VARCHAR(100) NOT NULL, display_name VARCHAR(100), CONSTRAINT pk_jenkins_job PRIMARY KEY (UUID), diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerTest.java b/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java index d0630b8..9a673e9 100644..100755 --- a/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerTest.java +++ b/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java @@ -2,15 +2,15 @@ package io.trygvis.esper.testing.jenkins; import junit.framework.*; -import static io.trygvis.esper.testing.jenkins.JenkinsServer.*; +import static io.trygvis.esper.testing.jenkins.JenkinsServerActor.*; -public class JenkinsServerTest extends TestCase { +public class JenkinsServerActorTest extends TestCase { public void testUrlGeneration() { // assertEquals("https://jenkins.puppetlabs.com/job/Hiera%20%28master%29/74/api/xml", createJobUrl("https://jenkins.puppetlabs.com/job/Hiera%20%28master%29/facter=1.6.x,puppet=2.7.x,ruby=ruby-1.8.7,rvm=%23rvm/74/api/xml").toASCIIString()); - assertEquals("https://builds.apache.org/job/james-server-trunk/", createJobUrl("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/3417/").toASCIIString()); + assertEquals("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/", createJobUrl("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/3417/").toASCIIString()); - assertEquals("http://ci.jruby.org/job/rails-master/", createJobUrl("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/3577/").toASCIIString()); + assertEquals("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/", createJobUrl("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/3577/").toASCIIString()); assertEquals("http://ci.jruby.org/job/rails-master/", createJobUrl("http://ci.jruby.org/job/rails-master/3577/").toASCIIString()); } |