brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/2] incubator-brooklyn git commit: Fix REST api app’s status as ERROR when ON_FIRE
Date Thu, 30 Jul 2015 12:19:51 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master e761f428f -> 906ea254c


Fix REST api app’s status as ERROR when ON_FIRE

Previously, if the app’s status was ON_FIRE, the rest api translated
that into “UNKNOWN”. Now it will report it as “ERROR”.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/29ae1e2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/29ae1e2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/29ae1e2a

Branch: refs/heads/master
Commit: 29ae1e2a9076a036d3c4ce7f39dc4040dc20b960
Parents: e761f42
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Jul 29 23:27:43 2015 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Jul 29 23:28:49 2015 +0100

----------------------------------------------------------------------
 .../rest/transform/ApplicationTransformer.java  |  2 +
 .../rest/resources/ApplicationResourceTest.java | 49 +++++++++++++++-----
 .../rest/testing/BrooklynRestApiTest.java       |  2 +-
 3 files changed, 40 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29ae1e2a/usage/rest-server/src/main/java/brooklyn/rest/transform/ApplicationTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/ApplicationTransformer.java
b/usage/rest-server/src/main/java/brooklyn/rest/transform/ApplicationTransformer.java
index 88e8da4..aaecaa4 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/ApplicationTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/ApplicationTransformer.java
@@ -25,6 +25,7 @@ import static brooklyn.rest.domain.Status.STOPPED;
 import static brooklyn.rest.domain.Status.STOPPING;
 import static brooklyn.rest.domain.Status.UNKNOWN;
 import static brooklyn.rest.domain.Status.DESTROYED;
+import static brooklyn.rest.domain.Status.ERROR;
 
 import java.net.URI;
 import java.util.Collection;
@@ -81,6 +82,7 @@ public class ApplicationTransformer {
             case DESTROYED:
                 return DESTROYED;
             case ON_FIRE:
+                return ERROR;
             default:
                 return UNKNOWN;
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29ae1e2a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
index 21d9bac..8645e38 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/ApplicationResourceTest.java
@@ -39,11 +39,26 @@ import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.GenericType;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+
 import brooklyn.entity.Application;
+import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.BasicApplication;
 import brooklyn.entity.basic.BasicEntity;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityFunctions;
+import brooklyn.entity.basic.EntityLocal;
+import brooklyn.entity.basic.EntityPredicates;
 import brooklyn.entity.basic.Lifecycle;
 import brooklyn.location.basic.AbstractLocation;
 import brooklyn.location.basic.LocationConfigKeys;
@@ -58,6 +73,7 @@ import brooklyn.rest.domain.EntitySpec;
 import brooklyn.rest.domain.EntitySummary;
 import brooklyn.rest.domain.PolicySummary;
 import brooklyn.rest.domain.SensorSummary;
+import brooklyn.rest.domain.Status;
 import brooklyn.rest.domain.TaskSummary;
 import brooklyn.rest.testing.BrooklynRestResourceTest;
 import brooklyn.rest.testing.mocks.CapitalizePolicy;
@@ -71,18 +87,6 @@ import brooklyn.util.collections.CollectionFunctionals;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.time.Duration;
 
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.GenericType;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-
 @Test(singleThreaded = true)
 public class ApplicationResourceTest extends BrooklynRestResourceTest {
 
@@ -318,6 +322,27 @@ public class ApplicationResourceTest extends BrooklynRestResourceTest
{
         Assert.fail("simple-app not found in list of applications: "+applications);
     }
 
+    @Test(dependsOnMethods = "testDeployApplication")
+    public void testGetApplicationOnFire() {
+        Application app = Iterables.find(manager.getApplications(), EntityPredicates.displayNameEqualTo(simpleSpec.getName()));
+        Lifecycle origState = app.getAttribute(Attributes.SERVICE_STATE_ACTUAL);
+        
+        ApplicationSummary summary = client().resource("/v1/applications/"+app.getId())
+                .get(ApplicationSummary.class);
+        assertEquals(summary.getStatus(), Status.RUNNING);
+
+        ((EntityLocal)app).setAttribute(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
+        try {
+            ApplicationSummary summary2 = client().resource("/v1/applications/"+app.getId())
+                    .get(ApplicationSummary.class);
+            log.info("Application: " + summary2);
+            assertEquals(summary2.getStatus(), Status.ERROR);
+            
+        } finally {
+            ((EntityLocal)app).setAttribute(Attributes.SERVICE_STATE_ACTUAL, origState);
+        }
+    }
+
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Test(dependsOnMethods = "testDeployApplication")
     public void testFetchApplicationsAndEntity() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/29ae1e2a/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestApiTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestApiTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestApiTest.java
index 446eef0..af8909a 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestApiTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/testing/BrooklynRestApiTest.java
@@ -49,7 +49,7 @@ import io.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherNoServer;
 
 public abstract class BrooklynRestApiTest {
 
-    private ManagementContext manager;
+    protected ManagementContext manager;
     
     protected boolean useLocalScannedCatalog = false;
     protected TestShutdownHandler shutdownListener = createShutdownHandler();


Mime
View raw message