You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2017/03/13 11:38:18 UTC

[2/3] brooklyn-server git commit: Revert "Make BailOutJcloudsLocation logic a bit simpler"

Revert "Make BailOutJcloudsLocation logic a bit simpler"

This reverts commit ac9d9e990077b50b64ee89bcd60e4caf84489693.

The BailOutException thrown in the location is wrapped in
multiple levels of exceptions, the last one being ExecutionException
due to the "future.get()" call. The catch clause in the test
doesn't acticate for this reason (no matching exception there)
so the test fails.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3cef8968
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3cef8968
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3cef8968

Branch: refs/heads/master
Commit: 3cef8968f7fa1c743955c916a5f550113ee1cfe4
Parents: 09f8332
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Tue Mar 7 23:44:14 2017 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Tue Mar 7 23:44:14 2017 +0200

----------------------------------------------------------------------
 .../location/jclouds/BailOutJcloudsLocation.java        | 12 +++++-------
 .../lifecycle/MachineLifecycleEffectorTasksTest.java    | 11 ++++++++---
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3cef8968/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
index fa0a18a..d824c8e 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/BailOutJcloudsLocation.java
@@ -22,6 +22,7 @@ package org.apache.brooklyn.location.jclouds;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+
 import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.location.LocationSpec;
@@ -48,6 +49,9 @@ import com.google.common.reflect.TypeToken;
 
 public class BailOutJcloudsLocation extends JcloudsLocation {
 
+    public static final String ERROR_MESSAGE = "early termination for test";
+    public static final RuntimeException BAIL_OUT_FOR_TESTING = new RuntimeException(ERROR_MESSAGE);
+    
     // Don't care which image; not actually provisioning
     private static final String US_EAST_IMAGE_ID = "us-east-1/ami-7d7bfc14";
 
@@ -78,7 +82,7 @@ public class BailOutJcloudsLocation extends JcloudsLocation {
         if (Boolean.TRUE.equals(getConfig(BUILD_TEMPLATE))) {
             template = super.buildTemplate(computeService, config, customizers);
         }
-        throw new BailOutException("early termination for test");
+        throw new RuntimeException(BAIL_OUT_FOR_TESTING);
     }
 
     public Template getTemplate() {
@@ -188,10 +192,4 @@ public class BailOutJcloudsLocation extends JcloudsLocation {
         return newBailOutJcloudsLocation(mgmt, allConfig);
     }
 
-    public static class BailOutException extends RuntimeException {
-        public BailOutException(String message) {
-            super(message);
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3cef8968/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasksTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasksTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasksTest.java
index a89d493..4d51db0 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasksTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasksTest.java
@@ -44,6 +44,7 @@ import org.apache.brooklyn.location.jclouds.BailOutJcloudsLocation;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.core.task.TaskInternal;
 import org.apache.brooklyn.util.core.task.ValueResolver;
+import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.time.Duration;
 import org.apache.brooklyn.util.time.Time;
 import org.testng.annotations.DataProvider;
@@ -107,9 +108,13 @@ public class MachineLifecycleEffectorTasksTest {
         try {
             triggerEntity.sensors().set(ready, true);
             task.get(Duration.THIRTY_SECONDS);
-            Asserts.shouldHaveFailedPreviously("BailOutJcloudsLocation should have thrown");
-        } catch (BailOutJcloudsLocation.BailOutException t) {
-            // expected
+        } catch (Throwable t) {
+            Exceptions.propagateIfFatal(t);
+            if ((t.toString().contains(BailOutJcloudsLocation.ERROR_MESSAGE))) {
+                // expected - BailOut location throws - just swallow
+            } else {
+                Exceptions.propagate(t);
+            }
         } finally {
             Entities.destroyAll(app.getManagementContext());
         }