From 8c2e7435dafd7ba29467da249d9455afd9466407 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Thu, 20 Apr 2017 10:01:51 +0200 Subject: [PATCH] Fix the Jetty start statement used in compute live tests --- .../test/java/org/jclouds/compute/JettyStatements.java | 7 ++----- .../compute/StubComputeServiceIntegrationTest.java | 10 +++++++--- .../compute/internal/BaseComputeServiceLiveTest.java | 6 +++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/JettyStatements.java b/compute/src/test/java/org/jclouds/compute/JettyStatements.java index 7ac0f8cdf3..63adf97461 100644 --- a/compute/src/test/java/org/jclouds/compute/JettyStatements.java +++ b/compute/src/test/java/org/jclouds/compute/JettyStatements.java @@ -57,14 +57,11 @@ public class JettyStatements { public static Statement start() { return new StatementList( - literal("cd " + JETTY_HOME), - literal("nohup java -jar start.jar jetty.port=" + port + " > start.out 2> start.err < /dev/null &"), + literal(String.format("JETTY_PORT=%d %s/bin/jetty.sh start", port, JETTY_HOME)), literal("test $? && sleep 1")); // in case it is slow starting the proc } public static Statement stop() { - return new StatementList( - literal("cd " + JETTY_HOME), - literal("./bin/jetty.sh stop")); + return literal(JETTY_HOME + "/bin/jetty.sh stop"); } } diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index e2468e3cfb..9f20d6531a 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -303,8 +303,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes clientNew.disconnect(); String startJetty = new StringBuilder() - .append("cd /usr/local/jetty").append('\n') - .append("nohup java -jar start.jar jetty.port=8080 > start.out 2> start.err < /dev/null &").append('\n') + .append("JETTY_PORT=8080 /usr/local/jetty/bin/jetty.sh start").append('\n') .append("test $? && sleep 1").append('\n').toString(); clientNew.connect(); @@ -312,7 +311,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes clientNew.disconnect(); clientNew.connect(); - expect(clientNew.exec("cd /usr/local/jetty\n./bin/jetty.sh stop\n")).andReturn(EXEC_GOOD); + expect(clientNew.exec("/usr/local/jetty/bin/jetty.sh stop\n")).andReturn(EXEC_GOOD); clientNew.disconnect(); clientNew.connect(); @@ -534,4 +533,9 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes super.testDestroyNodes(); } + @Override + protected void waitGracePeriodForDestroyedNodes() { + // Do not wait + } + } diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index 9e41a64b77..e90fd4f910 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -684,7 +684,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte int toDestroy = refreshNodes().size(); Set destroyed = client.destroyNodesMatching(inGroup(group)); assertEquals(toDestroy, destroyed.size()); - Uninterruptibles.sleepUninterruptibly(100, TimeUnit.SECONDS); + waitGracePeriodForDestroyedNodes(); for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) { assert node.getStatus() == Status.TERMINATED : node; assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for " @@ -692,6 +692,10 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte } } + protected void waitGracePeriodForDestroyedNodes() { + Uninterruptibles.sleepUninterruptibly(100, TimeUnit.SECONDS); + } + private Set refreshNodes() { return filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))); }