You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2016/08/10 22:09:49 UTC

[05/12] jclouds git commit: Isolate the task cancellation in a test

Isolate the task cancellation in a test


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/87154bf8
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/87154bf8
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/87154bf8

Branch: refs/heads/gsoc2016-ivan
Commit: 87154bf89e66e7a101b4c5c28103775c9d80b548
Parents: 42079e1
Author: Ignasi Barrera <na...@apache.org>
Authored: Mon Jul 11 16:10:44 2016 +0200
Committer: Ignasi Barrera <na...@apache.org>
Committed: Mon Jul 18 08:09:30 2016 +0200

----------------------------------------------------------------------
 .../StubComputeServiceIntegrationTest.java      |  5 ++--
 .../internal/BaseComputeServiceLiveTest.java    | 26 +++++++++++++++-----
 2 files changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/87154bf8/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java
index 9c9157b..9c546f4 100644
--- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java
+++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java
@@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals;
 import java.io.IOException;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
 import org.easymock.IArgumentMatcher;
@@ -452,10 +451,10 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
    public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
       super.testAScriptExecutionAfterBootWithBasicTemplate();
    }
-   
+
    @Test(enabled = false)
    @Override
-   public void weCanCancelTasks(NodeMetadata node) throws InterruptedException, ExecutionException {
+   public void testWeCanCancelTasks() throws Exception {
       // not sure how to do multithreading in a mock so that tests can work
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/87154bf8/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java
----------------------------------------------------------------------
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 c4f3833..3169c81 100644
--- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java
+++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java
@@ -251,7 +251,6 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
                .adminUsername("foo").adminHome("/over/ridden/foo").build(), nameTask("adminUpdate"));
 
          response = future.get(3, TimeUnit.MINUTES);
-
          assert response.getExitStatus() == 0 : node.getId() + ": " + response;
 
          node = client.getNodeMetadata(node.getId());
@@ -259,18 +258,31 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
          assertEquals(node.getCredentials().identity, "foo");
          assert node.getCredentials().credential != null : nodes;
 
-         weCanCancelTasks(node);
-
-         assert response.getExitStatus() == 0 : node.getId() + ": " + response;
-
          response = client.runScriptOnNode(node.getId(), "echo $USER", wrapInInitScript(false).runAsRoot(false));
-
          assert response.getOutput().trim().equals("foo") : node.getId() + ": " + response;
 
       } finally {
          client.destroyNodesMatching(inGroup(group));
       }
    }
+   
+   @Test
+   public void testWeCanCancelTasks() throws Exception {
+      String group = this.group + "w";
+      try {
+         client.destroyNodesMatching(inGroup(group));
+      } catch (Exception e) {
+
+      }
+      template = buildTemplate(client.templateBuilder());
+      try {
+         Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template);
+         NodeMetadata node = getOnlyElement(nodes);
+         weCanCancelTasks(node);
+      } finally {
+         client.destroyNodesMatching(inGroup(group));
+      }
+   }
 
    @Test(enabled = false)
    protected void tryBadPassword(String group, Credentials good) throws AssertionError {
@@ -806,6 +818,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
                provider2 = location.getParent().getParent();
             assertProvider(provider2);
             break;
+         default:
+            break;
          }
       }
    }