aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-09 22:43:23 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-09 22:43:23 +0100
commitf6e357ef18a0c44038fc0ea723c1ec7910bb3f30 (patch)
treea49db402fea01bd305dcbd03434db3c4531d4425 /src/main
parentdb068714e64bcb1b0e78279287ea891d29f687f7 (diff)
downloadesper-testing-f6e357ef18a0c44038fc0ea723c1ec7910bb3f30.tar.gz
esper-testing-f6e357ef18a0c44038fc0ea723c1ec7910bb3f30.tar.bz2
esper-testing-f6e357ef18a0c44038fc0ea723c1ec7910bb3f30.tar.xz
esper-testing-f6e357ef18a0c44038fc0ea723c1ec7910bb3f30.zip
woot
Diffstat (limited to 'src/main')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/esper/Test3.java110
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java2
-rw-r--r--src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java2
-rwxr-xr-xsrc/main/resources/logback.xml (renamed from src/main/resources/logback-test.xml)0
4 files changed, 113 insertions, 1 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/esper/Test3.java b/src/main/java/io/trygvis/esper/testing/esper/Test3.java
new file mode 100755
index 0000000..70c4dc3
--- /dev/null
+++ b/src/main/java/io/trygvis/esper/testing/esper/Test3.java
@@ -0,0 +1,110 @@
+package io.trygvis.esper.testing.esper;
+
+import com.espertech.esper.client.*;
+import io.trygvis.esper.testing.*;
+import org.slf4j.*;
+
+import java.util.*;
+
+import static java.lang.Thread.*;
+
+public class Test3 {
+ private static final String JDBC_URL = "jdbc:h2:mem:esper;DB_CLOSE_DELAY=-1";
+// private static final String JDBC_URL = "jdbc:h2:tcp://127.0.0.1/esper;DB_CLOSE_DELAY=-1";
+
+ Logger logger;
+ EPRuntime runtime;
+
+ public static void main(String[] args) throws Exception {
+ Config.loadFromDisk();
+ new Test3().work();
+ }
+
+ private void work() throws Exception {
+ logger = LoggerFactory.getLogger("app");
+
+ Configuration config = new Configuration();
+
+ ConfigurationDBRef configurationDBRef = new ConfigurationDBRef();
+ configurationDBRef.setDriverManagerConnection("org.h2.Driver", JDBC_URL, "", "");
+ configurationDBRef.setConnectionAutoCommit(false);
+ config.addDatabaseReference("db1", configurationDBRef);
+ config.addEventTypeAutoName(getClass().getPackage().getName());
+ EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
+ runtime = epService.getEPRuntime();
+ EPAdministrator administrator = epService.getEPAdministrator();
+
+// String expression = "select avg(price) from OrderEvent.win:time(30 sec)";
+// String expression = "select * from pattern [every b=NewBuildEvent() -> (timer:interval(3 seconds) and not NewBuildEvent(uuid = b.uuid))]";
+
+// String expression = "insert into BuildLastHour " +
+// "select job, " +
+// "sum(case result when 'SUCCESS' then 1 else 0 end) as successes, " +
+// "sum(case result when 'FAILURE' then 1 else 0 end) as failures " +
+// "from NewBuildEvent.win:time_batch(3 sec) group by job";
+
+ String expression = "insert into BuildLastHour " +
+ "select job, " +
+ "sum(case result when 'SUCCESS' then 1 else 0 end) as successes, " +
+ "sum(case result when 'FAILURE' then 1 else 0 end) as failures " +
+ "from NewBuildEvent.win:length(10) " +
+ "group by job " +
+ "having " +
+ "sum(case result when 'SUCCESS' then 1 else 0 end) > 1 AND " +
+ "count(result) > 3";
+
+ EPStatement statement = administrator.createEPL(expression);
+
+ statement.addListener(new GenericListener(logger));
+
+ UUID job1 = UUID.fromString("11111111-1111-1111-1111-111111111111");
+ UUID job2 = UUID.fromString("22222222-2222-2222-2222-222222222222");
+
+ send(job1, "SUCCESS"); sleep(100);
+ send(job2, "SUCCESS"); sleep(100);
+ send(job2, "FAILURE"); sleep(100);
+ send(job2, "SUCCESS"); sleep(100);
+ send(job2, "SUCCESS"); sleep(100);
+
+ Timer timer = new Timer();
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ logger.info("tick");
+ }
+ }, 0, 1000);
+
+ while(true) {
+ sleep(1000);
+ }
+ }
+
+ public void send(UUID job, String result) {
+ logger.info("Inserting " + result);
+ runtime.sendEvent(new NewBuildEvent(job, UUID.randomUUID(), result));
+ }
+
+ class NewBuildEvent {
+ private UUID job;
+ private UUID uuid;
+ private String result;
+
+ NewBuildEvent(UUID job, UUID uuid, String result) {
+ this.job = job;
+ this.uuid = uuid;
+ this.result = result;
+ }
+
+ public UUID getJob() {
+ return job;
+ }
+
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ public String getResult() {
+ return result;
+ }
+ }
+}
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 0b2883f..2b3ca13 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
@@ -140,7 +140,9 @@ public class JenkinsClient {
String name = root.getName();
switch (name) {
+ // I don't know the different between a "matrix build" and "matrix run"
case "matrixBuild":
+ case "matrixRun":
case "mavenModuleSetBuild":
case "mavenBuild":
case "freeStyleBuild":
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java
index 1d11aa8..089c7d0 100644
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java
@@ -26,7 +26,7 @@ public class JenkinsServer implements TransactionalActor {
long start = currentTimeMillis();
JenkinsDao dao = new JenkinsDao(c);
- Option<List<JenkinsEntryXml>> option = client.fetchRss(URI.create(server.url.toASCIIString() + "/rssLatest"));
+ Option<List<JenkinsEntryXml>> option = client.fetchRss(URI.create(server.url.toASCIIString() + "/rssAll"));
if (option.isNone()) {
return;
diff --git a/src/main/resources/logback-test.xml b/src/main/resources/logback.xml
index 1a63a5f..1a63a5f 100755
--- a/src/main/resources/logback-test.xml
+++ b/src/main/resources/logback.xml