You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2015/11/21 12:03:33 UTC

[1/9] stratos git commit: integration test for STRATOS-1620

Repository: stratos
Updated Branches:
  refs/heads/stratos-4.1.x 196ffcc10 -> 999f0f25f


integration test for STRATOS-1620


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/28e65f2b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/28e65f2b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/28e65f2b

Branch: refs/heads/stratos-4.1.x
Commit: 28e65f2bf9c9b2f8f62173160b773368ac3b88f1
Parents: 885bf56
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Nov 20 01:13:44 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:57:56 2015 +0530

----------------------------------------------------------------------
 .../common/StratosTestServerManager.java        |  16 ++
 .../tests/StratosIntegrationTest.java           |   5 +
 .../tests/other/IaasProviderAttributeTest.java  | 257 +++++++++++++++++++
 ...tion-policy-iaasprovider-attribute-test.json |  17 ++
 .../app-iaasprovider-attribute-test.json        |  24 ++
 ...ling-policy-iaasprovider-attribute-test.json |  14 +
 ...dge-iaasprovider-attribute-test-updated.json |  54 ++++
 .../cartridge-iaasprovider-attribute-test.json  |  54 ++++
 ...ment-policy-iaasprovider-attribute-test.json |  15 ++
 ...k-partition-iaasprovider-attribute-test.json |  19 ++
 .../test/resources/common/cloud-controller.xml  |  11 +-
 11 files changed, 484 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
index d2db900..e5bb7f8 100644
--- a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
@@ -263,6 +263,14 @@ public class StratosTestServerManager extends TestServerManager {
     public void setWebAppURLHttps(String webAppURLHttps) {
         this.webAppURLHttps = webAppURLHttps;
     }
+
+    public ServerLogReader getLogReader () {
+        return ((StratosServerManager)carbonServer).getInputLogStreamReader();
+    }
+
+    public ServerLogReader getErrorLogReader () {
+        return ((StratosServerManager)carbonServer).getErrorStreamReader();
+    }
 }
 
 // TODO: get rid of this class once startup script issue is fixed in automation engine
@@ -620,4 +628,12 @@ class StratosServerManager extends CarbonServerManager {
         }
 
     }
+
+    public ServerLogReader getInputLogStreamReader () {
+        return inputStreamHandler;
+    }
+
+    public ServerLogReader getErrorStreamReader () {
+        return errorStreamHandler;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
index 2836f93..3983835 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
@@ -18,6 +18,7 @@ package org.apache.stratos.integration.tests;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.integration.common.StratosTestServerManager;
 import org.apache.stratos.integration.common.TopologyHandler;
 import org.apache.stratos.integration.common.extensions.StratosServerExtension;
 import org.apache.stratos.integration.common.rest.RestClient;
@@ -25,6 +26,8 @@ import org.apache.stratos.mock.iaas.client.MockIaasApiClient;
 import org.wso2.carbon.automation.engine.context.AutomationContext;
 import org.wso2.carbon.automation.engine.context.TestUserMode;
 
+import java.util.List;
+
 public class StratosIntegrationTest {
     private static final Log log = LogFactory.getLog(StratosIntegrationTest.class);
     protected AutomationContext stratosAutomationCtx;
@@ -36,6 +39,7 @@ public class StratosIntegrationTest {
     protected MockIaasApiClient mockIaasApiClient;
     public static final int GLOBAL_TEST_TIMEOUT = 5 * 60 * 1000; // 5 mins
     public static final int APPLICATION_TEST_TIMEOUT = 20 * 60 * 1000; // 20 mins
+    protected StratosTestServerManager stratosTestServerManager;
 
     public StratosIntegrationTest() {
         try {
@@ -50,6 +54,7 @@ public class StratosIntegrationTest {
             stratosSecuredBackendURL = StratosServerExtension.getStratosTestServerManager().getWebAppURLHttps();
             restClient = new RestClient(stratosBackendURL, stratosSecuredBackendURL, adminUsername, adminPassword);
             mockIaasApiClient = new MockIaasApiClient(stratosBackendURL + "/mock-iaas/api");
+            stratosTestServerManager = StratosServerExtension.getStratosTestServerManager();
             // initialize topology handler before running the tests
             TopologyHandler.getInstance();
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
new file mode 100644
index 0000000..70b089b
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.tests.other;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeBean;
+import org.apache.stratos.common.beans.cartridge.IaasProviderBean;
+import org.apache.stratos.integration.common.RestConstants;
+import org.apache.stratos.integration.common.TopologyHandler;
+import org.apache.stratos.integration.tests.StratosIntegrationTest;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+public class IaasProviderAttributeTest extends StratosIntegrationTest {
+
+    private static final Log log = LogFactory.getLog(IaasProviderAttributeTest.class);
+    private static final String RESOURCES_PATH = "/cartridge-iaas-attribute-test";
+    private static final String AUTOSCALING_POLICY = "autoscaling-policy-iaasprovider-attribute-test";
+    private static final String NETWORK_PARTITION = "network-partition-iaasprovider-attribute-test";
+    private static final String DEPLOYMENT_POLICY = "deployment-policy-iaasprovider-attribute-test";
+    private static final String APPLICATION_POLICY = "application-policy-iaasprovider-attribute-test";
+    private static final String CARTRIDGE = "cartridge-iaasprovider-attribute-test";
+    private static final String UPDATED_CARTRIDGE = "cartridge-iaasprovider-attribute-test-updated";
+    private static final String APPLICATION = "app-iaasprovider-attribute-test";
+
+    @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.iaas.attributes", "all"})
+    public void testIaasProviderAttributesForDefaultCartridge () throws Exception {
+
+        // add autoscaling policy
+        log.info("Adding autoscaling policy [autoscale policy id] " + AUTOSCALING_POLICY);
+        boolean addedScalingPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.
+                        AUTOSCALING_POLICIES_PATH + "/" + AUTOSCALING_POLICY + ".json",
+                RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+        assertTrue(addedScalingPolicy);
+
+        // add network partition
+        log.info("Adding network partition [network partition id] " + NETWORK_PARTITION);
+        boolean addedN1 = restClient.addEntity(RESOURCES_PATH + "/network-partitions" + "/" +
+                        NETWORK_PARTITION + ".json", RestConstants.NETWORK_PARTITIONS,
+                RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(addedN1);
+
+        // add deployment policy
+        log.info("Adding deployment policy [deployment policy id] " + DEPLOYMENT_POLICY);
+        boolean addedDep = restClient.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+                        DEPLOYMENT_POLICY + ".json", RestConstants.DEPLOYMENT_POLICIES,
+                RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(addedDep);
+
+        // add application policy
+        log.info("Adding application policy [application policy id] " + APPLICATION_POLICY);
+        boolean addAppPolicy = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+                        APPLICATION_POLICY + ".json", RestConstants.APPLICATION_POLICIES,
+                RestConstants.APPLICATION_POLICIES_NAME);
+        assertTrue(addAppPolicy);
+
+        // deploy a default cartridge
+        boolean defaultCartridgeAdded = restClient.addEntity(RESOURCES_PATH + "/cartridges/" + CARTRIDGE + ".json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue("Default cartridge not deployed properly", defaultCartridgeAdded);
+
+        // deploy application
+        log.info("Adding application [application id] " + APPLICATION);
+        boolean addedApp = restClient.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+                APPLICATION + ".json", RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
+        assertEquals(addedApp, true);
+
+        // Test Iaas Provider attributes
+        CartridgeBean defaultCartridgeBean = (CartridgeBean) restClient.getEntity(RestConstants.CARTRIDGES, CARTRIDGE, CartridgeBean.class,
+                RestConstants.CARTRIDGES_NAME);
+
+        assertEquals(CARTRIDGE, defaultCartridgeBean.getType());
+        List<IaasProviderBean> iaasProviders = defaultCartridgeBean.getIaasProvider();
+        assertNotNull(iaasProviders, "No Iaas Providers found in default cartridge definition");
+        IaasProviderBean mockIaasProvider = getMockIaasProvider(iaasProviders);
+        assertNotNull(mockIaasProvider, "Mock Iaas Provider not found in default cartridge definition");
+        assertNotNull(mockIaasProvider.getProperty(), "No properties found in Iaas Provider " +
+                "config of default cartridge definition");
+
+        ///applications/{applicationId}/deploy/{applicationPolicyId}
+        log.info("Deploying application [application id] app-iaasprovider-attribute-test using [application policy id] "
+                + "application-policy-iaasprovider-attribute-test");
+        String resourcePath = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+                RestConstants.APPLICATIONS_DEPLOY + "/" + APPLICATION_POLICY;
+        boolean appDeployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
+        assertTrue(appDeployed);
+
+        ApplicationBean applicationBean = (ApplicationBean) restClient
+                .getEntity(RestConstants.APPLICATIONS, APPLICATION, ApplicationBean.class,
+                        RestConstants.APPLICATIONS_NAME);
+        assertEquals(applicationBean.getApplicationId(), APPLICATION);
+
+        TopologyHandler topologyHandler = TopologyHandler.getInstance();
+
+        long time = System.currentTimeMillis() + 300000L;
+
+        boolean found = false;
+        while (System.currentTimeMillis() < time) {
+            if (!stratosTestServerManager.getLogReader().getOutput().contains("cc_property_value_1")
+                    && stratosTestServerManager.getLogReader().getOutput().contains("cartridge_property_value_1")) {
+                found = true;
+                break;
+            }
+        }
+
+        assertTrue("Property 'property1' not found | value not equal to 'cartridge_property_value_1'", found);
+
+//        log.info("Waiting for application status to become ACTIVE...");
+//        topologyHandler.assertApplicationStatus(applicationBean.getApplicationId(),
+//                ApplicationStatus.Active);
+//
+//        // undeploy application
+//        log.info("Un-deploying the application [application id] app-iaasprovider-attribute-test");
+//        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+//                RestConstants.APPLICATIONS_UNDEPLOY;
+//
+//        boolean undeployedApp = restClient.undeployEntity(resourcePathUndeploy, RestConstants
+//                .APPLICATIONS_NAME);
+//        assertTrue(undeployedApp);
+//        log.info("Undeployed application 'app-iaasprovider-attribute-test'");
+//
+//        // force undeploy to make sure its undeployed
+//        log.info("Force undeployment is going to start for the [application] app-iaasprovider-attribute-test");
+//        restClient.undeployEntity(RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+//                RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+//
+//        boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("app-iaasprovider-attribute-test");
+//        assertTrue(String.format("Forceful undeployment failed for the application %s",
+//                "app-iaasprovider-attribute-test"), forceUndeployed);
+//
+//        // update cartridge
+//        boolean updated = restClient.updateEntity(RESOURCES_PATH + "/cartridges/" + UPDATED_CARTRIDGE + ".json",
+//                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+//        assertTrue(updated);
+//        log.info("Updated cartridge 'cartridge-iaasprovider-attribute-test'");
+//
+//        // re-deplpoy the application
+//        resourcePath = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+//                RestConstants.APPLICATIONS_DEPLOY + "/" + APPLICATION_POLICY;
+//        appDeployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
+//        assertTrue(appDeployed);
+//        log.info("Re-deployed application 'app-iaasprovider-attribute-test'");
+//
+//        time = System.currentTimeMillis() + 300000L;
+//
+//        found = false;
+//        while (System.currentTimeMillis() < time) {
+//            if (stratosTestServerManager.getLogReader().getOutput().contains("cartridge_property_value_1")) {
+//                found = true;
+//                break;
+//            }
+//        }
+//
+//        assertTrue("Property 'property1' not found | value not equal to 'cartridge_property_value_1'", found);
+
+        terminateAndRemoveAllArtifacts();
+    }
+
+    private IaasProviderBean getMockIaasProvider(List<IaasProviderBean> iaasProviders) {
+        for (IaasProviderBean iaasProvider : iaasProviders) {
+            if ("mock".equals(iaasProvider.getType())) {
+                return iaasProvider;
+            }
+        }
+        return null;
+    }
+
+    private void terminateAndRemoveAllArtifacts () throws Exception {
+
+        TopologyHandler topologyHandler = TopologyHandler.getInstance();
+
+        log.info("Un-deploying the application [application id] app-iaasprovider-attribute-test");
+        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+                RestConstants.APPLICATIONS_UNDEPLOY;
+
+        boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME);
+        assertTrue(unDeployed);
+
+        boolean undeploy = topologyHandler.assertApplicationUndeploy("app-iaasprovider-attribute-test");
+        if (!undeploy) {
+            //Need to forcefully undeploy the application
+            log.info("Force undeployment is going to start for the [application] app-iaasprovider-attribute-test");
+
+            restClient.undeployEntity(RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+                    RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+            boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("app-iaasprovider-attribute-test");
+            assertTrue(String.format("Forceful undeployment failed for the application %s",
+                    "app-iaasprovider-attribute-test"), forceUndeployed);
+        }
+
+        log.info("Removing the application [application id] app-iaasprovider-attribute-test");
+        boolean removedApp = restClient.removeEntity(RestConstants.APPLICATIONS, "app-iaasprovider-attribute-test",
+                RestConstants.APPLICATIONS_NAME);
+        assertTrue(removedApp);
+
+        ApplicationBean beanRemoved = (ApplicationBean) restClient
+                .getEntity(RestConstants.APPLICATIONS, "app-iaasprovider-attribute-test", ApplicationBean.class,
+                        RestConstants.APPLICATIONS_NAME);
+        assertNull(beanRemoved);
+
+        log.info("Removing the application policy [application policy id] "
+                + "application-policy-iaasprovider-attribute-test");
+        boolean removeAppPolicy = restClient
+                .removeEntity(RestConstants.APPLICATION_POLICIES, "application-policy-iaasprovider-attribute-test",
+                        RestConstants.APPLICATION_POLICIES_NAME);
+        assertTrue(removeAppPolicy);
+
+        log.info("Removing the cartridge [cartridge type] cartridge-iaasprovider-attribute-test");
+        boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "cartridge-iaasprovider-attribute-test",
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC1);
+
+        log.info("Removing the autoscaling policy [autoscaling policy id] " + AUTOSCALING_POLICY);
+        boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, AUTOSCALING_POLICY,
+                RestConstants.AUTOSCALING_POLICIES_NAME);
+        assertTrue(removedAuto);
+
+        log.info("Removing the deployment policy [deployment policy id] deployment-policy-iaasprovider-attribute-test");
+        boolean removedDep = restClient
+                .removeEntity(RestConstants.DEPLOYMENT_POLICIES, "deployment-policy-iaasprovider-attribute-test",
+                        RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(removedDep);
+
+        log.info("Removing the network partition [network partition id] network-partition-iaasprovider-attribute-test");
+        boolean removedNet = restClient
+                .removeEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-iaasprovider-attribute-test",
+                        RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(removedNet);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/application-policies/application-policy-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/application-policies/application-policy-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/application-policies/application-policy-iaasprovider-attribute-test.json
new file mode 100644
index 0000000..1413446
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/application-policies/application-policy-iaasprovider-attribute-test.json
@@ -0,0 +1,17 @@
+{
+  "id": "application-policy-iaasprovider-attribute-test",
+  "algorithm": "one-after-another",
+  "networkPartitions": [
+    "network-partition-iaasprovider-attribute-test"
+  ],
+  "properties": [
+    {
+      "name": "networkPartitionGroups",
+      "value": "network-partition-iaasprovider-attribute-test"
+    },
+    {
+      "name": "key-2",
+      "value": "value-2"
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/applications/app-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/applications/app-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/applications/app-iaasprovider-attribute-test.json
new file mode 100644
index 0000000..fe1ff69
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/applications/app-iaasprovider-attribute-test.json
@@ -0,0 +1,24 @@
+{
+  "alias": "app-iaasprovider-attribute-test",
+  "applicationId": "app-iaasprovider-attribute-test",
+  "components": {
+    "cartridges": [
+      {
+        "type": "cartridge-iaasprovider-attribute-test",
+        "cartridgeMin": 1,
+        "cartridgeMax": 1,
+        "subscribableInfo": {
+          "alias": "cartridge-alias-default-iaasprovider-attribute-test",
+          "autoscalingPolicy": "autoscaling-policy-iaasprovider-attribute-test",
+          "deploymentPolicy": "deployment-policy-iaasprovider-attribute-test",
+          "artifactRepository": {
+            "privateRepo": false,
+            "repoUrl": "https://github.com/lakwarus/single-cartridge.git",
+            "repoUsername": "",
+            "repoPassword": ""
+          }
+        }
+      }
+    ]
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/autoscaling-policies/autoscaling-policy-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/autoscaling-policies/autoscaling-policy-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/autoscaling-policies/autoscaling-policy-iaasprovider-attribute-test.json
new file mode 100644
index 0000000..e609c4f
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/autoscaling-policies/autoscaling-policy-iaasprovider-attribute-test.json
@@ -0,0 +1,14 @@
+{
+  "id": "autoscaling-policy-iaasprovider-attribute-test",
+  "loadThresholds": {
+    "requestsInFlight": {
+      "threshold": 35
+    },
+    "memoryConsumption": {
+      "threshold": 45
+    },
+    "loadAverage": {
+      "threshold": 25
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test-updated.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test-updated.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test-updated.json
new file mode 100644
index 0000000..f9f883b
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test-updated.json
@@ -0,0 +1,54 @@
+{
+  "type": "cartridge-iaasprovider-attribute-test",
+  "category": "framework",
+  "provider": "wso2",
+  "host": "as.wso2.org",
+  "displayName": "WSO2 Default Cartridge",
+  "description": "WSO2 Default Cartridge",
+  "version": "1.0.0",
+  "multiTenant": false,
+  "loadBalancingIPType": "public",
+  "portMapping": [
+    {
+      "name": "mgt-http",
+      "protocol": "http",
+      "port": 9763,
+      "proxyPort": 80
+    }
+  ],
+  "iaasProvider": [
+    {
+      "type": "mock",
+      "property": [
+        {
+          "name":"tag:Name",
+          "value":"WSO2 PPaaS Default Server"
+        },
+        {
+          "name":"property1",
+          "value":"cartridge_property_value_1"
+        }
+      ]
+    }
+  ],
+  "deployment": {
+  },
+  "property": [
+    {
+      "name": "payload_parameter.CONFIG_PARAM_WORKER_HOST_NAME",
+      "value": "default.wso2.com"
+    },
+    {
+      "name": "payload_parameter.CONFIG_PARAM_CLUSTERING",
+      "value": "false"
+    },
+    {
+      "name": "payload_parameter.CONFIG_PARAM_MEMBERSHIP_SCHEME",
+      "value": "stratos"
+    },
+    {
+      "name": "payload_parameter.APPLICATION_PATH",
+      "value": "/var/www"
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
new file mode 100644
index 0000000..f9f883b
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
@@ -0,0 +1,54 @@
+{
+  "type": "cartridge-iaasprovider-attribute-test",
+  "category": "framework",
+  "provider": "wso2",
+  "host": "as.wso2.org",
+  "displayName": "WSO2 Default Cartridge",
+  "description": "WSO2 Default Cartridge",
+  "version": "1.0.0",
+  "multiTenant": false,
+  "loadBalancingIPType": "public",
+  "portMapping": [
+    {
+      "name": "mgt-http",
+      "protocol": "http",
+      "port": 9763,
+      "proxyPort": 80
+    }
+  ],
+  "iaasProvider": [
+    {
+      "type": "mock",
+      "property": [
+        {
+          "name":"tag:Name",
+          "value":"WSO2 PPaaS Default Server"
+        },
+        {
+          "name":"property1",
+          "value":"cartridge_property_value_1"
+        }
+      ]
+    }
+  ],
+  "deployment": {
+  },
+  "property": [
+    {
+      "name": "payload_parameter.CONFIG_PARAM_WORKER_HOST_NAME",
+      "value": "default.wso2.com"
+    },
+    {
+      "name": "payload_parameter.CONFIG_PARAM_CLUSTERING",
+      "value": "false"
+    },
+    {
+      "name": "payload_parameter.CONFIG_PARAM_MEMBERSHIP_SCHEME",
+      "value": "stratos"
+    },
+    {
+      "name": "payload_parameter.APPLICATION_PATH",
+      "value": "/var/www"
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/deployment-policies/deployment-policy-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/deployment-policies/deployment-policy-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/deployment-policies/deployment-policy-iaasprovider-attribute-test.json
new file mode 100644
index 0000000..54e4672
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/deployment-policies/deployment-policy-iaasprovider-attribute-test.json
@@ -0,0 +1,15 @@
+{
+  "id": "deployment-policy-iaasprovider-attribute-test",
+  "networkPartitions": [
+    {
+      "id": "network-partition-iaasprovider-attribute-test",
+      "partitionAlgo": "one-after-another",
+      "partitions": [
+        {
+          "id": "partition-1",
+          "partitionMax": 20
+        }
+      ]
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/network-partitions/network-partition-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/network-partitions/network-partition-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/network-partitions/network-partition-iaasprovider-attribute-test.json
new file mode 100644
index 0000000..b7c5ce8
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/network-partitions/network-partition-iaasprovider-attribute-test.json
@@ -0,0 +1,19 @@
+{
+  "id": "network-partition-iaasprovider-attribute-test",
+  "provider": "mock",
+  "partitions": [
+    {
+      "id": "partition-1",
+      "property": [
+        {
+          "name": "region",
+          "value": "default"
+        },
+        {
+          "name": "zone",
+          "value": "default-1"
+        }
+      ]
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/28e65f2b/products/stratos/modules/integration/test-integration/src/test/resources/common/cloud-controller.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/common/cloud-controller.xml b/products/stratos/modules/integration/test-integration/src/test/resources/common/cloud-controller.xml
index 7620fbe..826b19a 100644
--- a/products/stratos/modules/integration/test-integration/src/test/resources/common/cloud-controller.xml
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/common/cloud-controller.xml
@@ -53,17 +53,18 @@
             <property name="keyPair" value="keypair-name" />
             <property name="securityGroups" value="default" />
         </iaasProvider -->
-        <!-- iaasProvider type="ec2" name="Amazon EC2">
+        <!--iaasProvider type="ec2" name="Amazon EC2">
             <className>org.apache.stratos.cloud.controller.iaases.ec2.EC2Iaas</className>
             <provider>aws-ec2</provider>
             <identity svns:secretAlias="cloud.controller.ec2.identity">identity</identity>
             <credential svns:secretAlias="cloud.controller.ec2.credential">credential</credential>
+            <imageId>ap-southeast-1/ami-660ccb05</imageId>
             <property name="jclouds.ec2.ami-query" value="owner-id=owner-id;state=available;image-type=machine"/>
             <property name="availabilityZone" value="ap-southeast-1b"/>
             <property name="securityGroups" value="default"/>
             <property name="autoAssignIp" value="true" />
             <property name="keyPair" value="keypair-name"/>
-        </iaasProvider -->
+        </iaasProvider-->
         <iaasProvider type="kubernetes" name="Kubernetes">
             <className>org.apache.stratos.cloud.controller.iaases.kubernetes.KubernetesIaas</className>
             <provider>kubernetes</provider>
@@ -75,7 +76,13 @@
             <provider>mock</provider>
             <identity svns:secretAlias="cloud.controller.mock.identity">identity</identity>
             <credential svns:secretAlias="cloud.controller.mock.credential">credential</credential>
+            <imageId>RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e</imageId>
             <property name="api.endpoint" value="https://localhost:STRATOS_SECURE_DYNAMIC_PORT/mock-iaas/api"/>
+            <property name="availabilityZone" value="avaialbility_zone_in_cc"/>
+            <property name="securityGroups" value="default"/>
+            <property name="autoAssignIp" value="true" />
+            <property name="keyPair" value="keypair-name"/>
+            <property name="property1" value="cc_property_value_1"/>
         </iaasProvider>
     </iaasProviders>
 </cloudController>
\ No newline at end of file


[8/9] stratos git commit: Add a log appender for PCA test case log messages

Posted by is...@apache.org.
Add a log appender for PCA test case log messages


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

Branch: refs/heads/stratos-4.1.x
Commit: f42217e01453bf3c418c82343271602f8b19d825
Parents: c72e955
Author: Akila Perera <ra...@gmail.com>
Authored: Sat Nov 21 12:03:59 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../src/test/resources/log4j.properties         | 55 ++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/f42217e0/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/log4j.properties b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/log4j.properties
new file mode 100644
index 0000000..759bbb4
--- /dev/null
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/log4j.properties
@@ -0,0 +1,55 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+#
+# This is the log4j configuration file used by Stratos integration tests
+#
+
+log4j.rootLogger=INFO, stdout
+
+log4j.logger.org.apache.stratos.python.cartridge.agent.integration.tests=INFO, INTEGRATION_TEST
+log4j.logger.org.apache.stratos.python.cartridge.agent.integration.tests.PythonAgentIntegrationTest=DEBUG, stdout
+log4j.additivity.org.apache.stratos.python.cartridge.agent.integration.tests.PythonAgentIntegrationTest=false
+
+# stdout is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+#log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p {%c}:%L - %m%n
+log4j.appender.stdout.threshold=DEBUG
+
+
+# INTEGRATION_TEST is set to be a DailyRollingFileAppender using a PatternLayout.
+log4j.appender.INTEGRATION_TEST=org.apache.log4j.RollingFileAppender
+log4j.appender.INTEGRATION_TEST.MaxFileSize=10000KB
+log4j.appender.INTEGRATION_TEST.MaxBackupIndex=10
+log4j.appender.INTEGRATION_TEST.File=pca-live-test.log
+log4j.appender.INTEGRATION_TEST.Append=true
+log4j.appender.INTEGRATION_TEST.layout=org.apache.log4j.PatternLayout
+log4j.appender.INTEGRATION_TEST.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p {%c}:%L - %m%n
+log4j.appender.INTEGRATION_TEST.threshold=INFO
+
+
+# This file is used to override the default logger settings, and is used to remove unwanted logs from Shindig appearing on the console.
+
+# Specification of Handler used by Console Logger
+handlers=java.util.logging.ConsoleHandler
+
+# Replacing default INFO level with SEVERE
+java.util.logging.ConsoleHandler.level=SEVERE


[5/9] stratos git commit: Remove unnecessary publish logs in PCA. Add a generic log message when publishing events

Posted by is...@apache.org.
Remove unnecessary publish logs in PCA. Add a generic log message when publishing events


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

Branch: refs/heads/stratos-4.1.x
Commit: c72e955141a266a60a36a3b83456ef610fe8fe87
Parents: 5166099
Author: Akila Perera <ra...@gmail.com>
Authored: Sat Nov 21 12:02:37 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/modules/event/eventhandler.py | 18 +++++++-----------
 .../cartridge.agent/cartridge.agent/publisher.py  | 17 ++++++-----------
 2 files changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/c72e9551/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index 1dfe834..85624ae 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -18,14 +18,15 @@
 import json
 from threading import Thread
 
-from ..util import cartridgeagentutils
-from ..artifactmgt.git.agentgithandler import *
-from ..artifactmgt.repository import Repository
-from config import Config
 import publisher
 from entity import *
-from ..util.log import LogFactory
+
 import constants
+from config import Config
+from ..artifactmgt.git.agentgithandler import *
+from ..artifactmgt.repository import Repository
+from ..util import cartridgeagentutils
+from ..util.log import LogFactory
 
 SUPER_TENANT_ID = "-1234"
 SUPER_TENANT_REPO_PATH = "/repository/deployment/server/"
@@ -368,14 +369,9 @@ class EventHandler:
         self.execute_event_extendables(constants.APPLICATION_SIGNUP_REMOVAL_EVENT, {})
 
     def cleanup(self, event):
-        self.__log.debug("Executing cleanup extension for event %s" % event)
-
+        self.__log.debug("Executing cleanup extension for event %s..." % event)
         publisher.publish_maintenance_mode_event()
-
         self.execute_event_extendables("clean", {})
-        self.__log.info("Cleaning up finished in the cartridge instance...")
-
-        self.__log.info("Publishing ready to shutdown event...")
         publisher.publish_instance_ready_to_shutdown_event()
 
     def execute_event_extendables(self, event, input_values):

http://git-wip-us.apache.org/repos/asf/stratos/blob/c72e9551/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py
index dcafe47..a24650a 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py
@@ -16,6 +16,7 @@
 # under the License.
 
 import threading
+
 import paho.mqtt.publish as publish
 import time
 
@@ -58,7 +59,6 @@ def publish_instance_started_event():
         publisher = get_publisher(constants.INSTANCE_STATUS_TOPIC + constants.INSTANCE_STARTED_EVENT)
         publisher.publish(instance_started_event)
         Config.started = True
-        log.info("Instance started event published")
     else:
         log.warn("Instance already started")
 
@@ -95,9 +95,7 @@ def publish_instance_activated_event():
             publisher = get_publisher(constants.INSTANCE_STATUS_TOPIC + constants.INSTANCE_ACTIVATED_EVENT)
             publisher.publish(instance_activated_event)
 
-            log.info("Instance activated event published")
             log.info("Starting health statistics notifier")
-
             health_stat_publishing_enabled = Config.read_property(constants.CEP_PUBLISHER_ENABLED, True)
 
             if health_stat_publishing_enabled:
@@ -151,14 +149,13 @@ def publish_maintenance_mode_event():
         publisher.publish(instance_maintenance_mode_event)
 
         Config.maintenance = True
-        log.info("Instance maintenance mode event published")
     else:
         log.warn("Instance already in a maintenance mode")
 
 
 def publish_instance_ready_to_shutdown_event():
     if not Config.ready_to_shutdown:
-        log.info("Publishing instance activated event...")
+        log.info("Publishing instance ready to shutdown event...")
 
         service_name = Config.service_name
         cluster_id = Config.cluster_id
@@ -181,7 +178,6 @@ def publish_instance_ready_to_shutdown_event():
         publisher.publish(instance_shutdown_event)
 
         Config.ready_to_shutdown = True
-        log.info("Instance ReadyToShutDown event published")
     else:
         log.warn("Instance already in a ReadyToShutDown event...")
 
@@ -190,14 +186,12 @@ def publish_complete_topology_request_event():
     complete_topology_request_event = CompleteTopologyRequestEvent()
     publisher = get_publisher(constants.INITIALIZER_TOPIC + constants.COMPLETE_TOPOLOGY_REQUEST_EVENT)
     publisher.publish(complete_topology_request_event)
-    log.info("Complete topology request event published")
 
 
 def publish_complete_tenant_request_event():
     complete_tenant_request_event = CompleteTenantRequestEvent()
     publisher = get_publisher(constants.INITIALIZER_TOPIC + constants.COMPLETE_TENANT_REQUEST_EVENT)
     publisher.publish(complete_tenant_request_event)
-    log.info("Complete tenant request event published")
 
 
 def get_publisher(topic):
@@ -252,10 +246,11 @@ class EventPublisher:
 
                 try:
                     publish.single(self.__topic, payload, hostname=mb_ip, port=mb_port, auth=auth)
-                    self.__log.debug("Event published to %s:%s" % (mb_ip, mb_port))
+                    self.__log.debug("Event type: %s published to MB: %s:%s" % (str(event.__class__), mb_ip, mb_port))
                     return True
                 except:
-                    self.__log.debug("Could not publish event to message broker %s:%s." % (mb_ip, mb_port))
+                    self.__log.debug(
+                        "Could not publish event to message broker %s:%s." % (mb_ip, mb_port))
 
             self.__log.debug(
                 "Could not publish event to any of the provided message brokers. Retrying in %s seconds."
@@ -263,6 +258,6 @@ class EventPublisher:
 
             time.sleep(retry_interval)
 
-        self.__log.warn("Could not publish even to any of the provided message brokers before "
+        self.__log.warn("Could not publish event to any of the provided message brokers before "
                         "the timeout [%s] exceeded. The event will be dropped." % Config.mb_publisher_timeout)
         return False


[3/9] stratos git commit: changes for integration tests - STRATOS-1620

Posted by is...@apache.org.
changes for integration tests - STRATOS-1620


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

Branch: refs/heads/stratos-4.1.x
Commit: 516609907b76b0078c0b0eef0c768793a8239720
Parents: 22ac8e2
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Sat Nov 21 08:27:32 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../integration/common/ServerLogClient.java     | 96 +++++++++++++-------
 .../tests/other/IaasProviderAttributeTest.java  | 31 +++++--
 2 files changed, 84 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/51660990/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
index 2ac6ce9..12c40f8 100644
--- a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
@@ -22,25 +22,22 @@ package org.apache.stratos.integration.common;
 import org.apache.axis2.AxisFault;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.automation.engine.context.AutomationContext;
 import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
 import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
+import org.wso2.carbon.logging.view.stub.LogViewerLogViewerException;
+import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
 
-import javax.xml.xpath.XPathExpressionException;
+import java.rmi.RemoteException;
 
 public class ServerLogClient {
 
     private static final Log log = LogFactory.getLog(ServerLogClient.class);
     private LogViewerClient logViewerClient;
-    private AutomationContext automationContext;
-
-    public ServerLogClient () throws AutomationUtilException {
-        createAutomationContext();
-        createlogViewerClient(getBackEndUrl(), getUsername(), getPassword());
-    }
+    private int logCount;
 
     public ServerLogClient (String backEndUrl, String username, String password) throws
             AutomationUtilException {
+        logCount = 0;
         createlogViewerClient(backEndUrl, username, password);
     }
 
@@ -54,48 +51,81 @@ public class ServerLogClient {
         }
     }
 
-    private void createAutomationContext() throws AutomationUtilException {
+    public LogEvent[] getLogLines () throws AutomationUtilException {
         try {
-            automationContext = new AutomationContext();
-        } catch (XPathExpressionException e) {
-            String errorMsg = "Error in creating AutomationContext";
+            return logViewerClient.getAllRemoteSystemLogs();
+
+        } catch (RemoteException e) {
+            String errorMsg = "Error in creating getting remote system logs";
             log.error(errorMsg, e);
             throw new AutomationUtilException(errorMsg, e);
-        }
-    }
 
-    private String getBackEndUrl () throws AutomationUtilException {
-        try {
-            return automationContext.getContextUrls().getBackEndUrl();
-        } catch (XPathExpressionException e) {
-            String errorMsg = "Error in getting beck end URL";
+        } catch (LogViewerLogViewerException e) {
+            String errorMsg = "Error in creating getting remote system logs";
             log.error(errorMsg, e);
             throw new AutomationUtilException(errorMsg, e);
         }
     }
 
-    private String getUsername () throws AutomationUtilException {
+    public LogEvent[] getLogLines (String logType, String searchKey, String domain, String serverKey)
+            throws AutomationUtilException {
         try {
-            return automationContext.getSuperTenant().getTenantAdmin().getUserName();
-        } catch (XPathExpressionException e) {
-            String errorMsg = "Error in getting super tenant username";
+            return logViewerClient.getRemoteLogs(logType, searchKey, domain, serverKey);
+        } catch (RemoteException e) {
+            String errorMsg = "Error in creating getting remote system logs";
             log.error(errorMsg, e);
             throw new AutomationUtilException(errorMsg, e);
-        }
-    }
 
-    private String getPassword () throws AutomationUtilException {
-        try {
-            return automationContext.getSuperTenant().getTenantAdmin().getPassword();
-        } catch (XPathExpressionException e) {
-            String errorMsg = "Error in getting super tenant password";
+        } catch (LogViewerLogViewerException e) {
+            String errorMsg = "Error in creating getting remote system logs";
             log.error(errorMsg, e);
             throw new AutomationUtilException(errorMsg, e);
         }
     }
 
+//    public String[] getLogLines() throws AutomationUtilException {
+//
+//        LogEvent[] allLogs = null;
+//        try {
+//            allLogs = logViewerClient.getAllRemoteSystemLogs();
+//
+//       } catch (RemoteException e) {
+//            String errorMsg = "Error in creating getting remote system logs";
+//            log.error(errorMsg, e);
+//            throw new AutomationUtilException(errorMsg, e);
+//
+//       } catch (LogViewerLogViewerException e) {
+//            String errorMsg = "Error in creating getting remote system logs";
+//            log.error(errorMsg, e);
+//            throw new AutomationUtilException(errorMsg, e);
+//        }
+//
+//        if (allLogs.length == 0) {
+//            allLogs = new LogEvent[0];
+//        }
+//
+//        if (logCount > allLogs.length) {
+//            // cannot happen, return
+//            return getLogsAsStrings(allLogs);
+//        }
+//
+//        log.info("Total no. of log lines: " + Integer.toString(allLogs.length));
+//        log.info("Previously returned count : " + Integer.toString(logCount));
+//        log.info("Current count : " + Integer.toString(allLogs.length - logCount));
+//
+//        LogEvent[] selectedLogs = Arrays.copyOfRange(allLogs, logCount, allLogs.length);
+//        logCount += (allLogs.length - logCount);
+//
+//        return getLogsAsStrings(selectedLogs);
+//    }
+//
+//    private String[] getLogsAsStrings(LogEvent[] selectedLogs) {
+//
+//        String [] logs = new String[selectedLogs.length];
+//        for (int i = 0 ; i < selectedLogs.length ; i++) {
+//            logs [i] = selectedLogs [i].getMessage();
+//        }
+//        return logs;
+//    }
 
-    public LogViewerClient getLogViewerClient () {
-        return logViewerClient;
-    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/51660990/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
index 1f7b042..5a44c62 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
@@ -29,6 +29,8 @@ import org.apache.stratos.integration.common.ServerLogClient;
 import org.apache.stratos.integration.common.TopologyHandler;
 import org.apache.stratos.integration.tests.StratosIntegrationTest;
 import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
 
@@ -50,6 +52,12 @@ public class IaasProviderAttributeTest extends StratosIntegrationTest {
     private static final String CARTRIDGE = "cartridge-iaasprovider-attribute-test";
     private static final String UPDATED_CARTRIDGE = "cartridge-iaasprovider-attribute-test-updated";
     private static final String APPLICATION = "app-iaasprovider-attribute-test";
+    private ServerLogClient serverLogClient;
+
+    @BeforeClass
+    public void setup () throws Exception {
+        serverLogClient = new ServerLogClient(stratosSecuredBackendURL + "/services/", adminUsername, adminPassword);
+    }
 
     @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.iaas.attributes", "all"})
     public void testIaasProviderAttributes () throws Exception {
@@ -125,14 +133,10 @@ public class IaasProviderAttributeTest extends StratosIntegrationTest {
 
         // create a ServerLogClientInstance and get logs
         boolean found = false;
-        ServerLogClient serverLogClient = new ServerLogClient(stratosSecuredBackendURL + "/services/",
-                adminUsername,
-                adminPassword);
-        LogEvent [] logEvents = serverLogClient.getLogViewerClient().getAllRemoteSystemLogs();
+        LogEvent[] logEvents = serverLogClient.getLogLines();
         if (logEvents.length > 0) {
-            for (int i = 0; i < logEvents.length; i++) {
-                if (!logEvents[i].getMessage().contains("cartridge_property_value_1") &&
-                logEvents[i].getMessage().contains("cc_property_value_1")) {
+            for (LogEvent log : logEvents) {
+                if (!log.getMessage().contains("cartridge_property_value_1") && log.getMessage().contains("cc_property_value_1")) {
                     found = true;
                     break;
                 }
@@ -173,10 +177,14 @@ public class IaasProviderAttributeTest extends StratosIntegrationTest {
         assertTrue(appDeployed);
         log.info("Re-deployed application 'app-iaasprovider-attribute-test'");
 
-        logEvents = serverLogClient.getLogViewerClient().getAllRemoteSystemLogs();
+        log.info("Waiting for application status to become ACTIVE...");
+        topologyHandler.assertApplicationStatus(applicationBean.getApplicationId(), ApplicationStatus.Active);
+
+        logEvents = serverLogClient.getLogLines();
+        found = false;
         if (logEvents.length > 0) {
-            for (int i = 0; i < logEvents.length; i++) {
-                if (logEvents[i].getMessage().contains("cartridge_property_value_1")) {
+            for (LogEvent log : logEvents) {
+                if (log.getMessage().contains("cartridge_property_value_1")) {
                     found = true;
                     break;
                 }
@@ -184,7 +192,10 @@ public class IaasProviderAttributeTest extends StratosIntegrationTest {
         }
 
         assertTrue("Property 'property1' not found | value not equal to 'cartridge_property_value_1'", found);
+    }
 
+    @AfterClass
+    public void tearDown () throws Exception {
         terminateAndRemoveAllArtifacts();
     }
 


[6/9] stratos git commit: fixing git-hook integration test

Posted by is...@apache.org.
fixing git-hook integration test


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

Branch: refs/heads/stratos-4.1.x
Commit: a121351d0adc2752e780e9c00d35dbe35b25c37f
Parents: 64eadfb
Author: rajkumar <rr...@gmail.com>
Authored: Sat Nov 21 13:37:03 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../integration/tests/adc/GitHookTestCase.java  | 107 ++++++++++++++++---
 .../application-policy-1.json                   |  17 ---
 .../application-policy-git-hook-test.json       |  17 +++
 .../git-hook-test/applications/application.json |  25 -----
 .../applications/git-hook-test.json             |  25 +++++
 .../autoscaling-policy-1.json                   |  14 ---
 .../autoscaling-policy-git-hook-test.json       |  14 +++
 .../cartridges/mock/c1-git-hook-test.json       |  51 +++++++++
 .../git-hook-test/cartridges/mock/php.json      |  51 ---------
 .../deployment-policy-1.json                    |  15 ---
 .../deployment-policy-git-hook-test.json        |  15 +++
 .../mock/network-partition-1.json               |  15 ---
 .../mock/network-partition-git-hook-test.json   |  15 +++
 13 files changed, 227 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/adc/GitHookTestCase.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/adc/GitHookTestCase.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/adc/GitHookTestCase.java
index e931f8a..873fe86 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/adc/GitHookTestCase.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/adc/GitHookTestCase.java
@@ -21,9 +21,12 @@ package org.apache.stratos.integration.tests.adc;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
 import org.apache.stratos.common.threading.StratosThreadPool;
 import org.apache.stratos.integration.common.RestConstants;
+import org.apache.stratos.integration.common.TopologyHandler;
 import org.apache.stratos.integration.tests.StratosIntegrationTest;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
 import org.apache.stratos.messaging.event.Event;
 import org.apache.stratos.messaging.listener.instance.notifier.ArtifactUpdateEventListener;
 import org.apache.stratos.messaging.message.receiver.instance.notifier.InstanceNotifierEventReceiver;
@@ -32,6 +35,8 @@ import org.testng.annotations.Test;
 import java.net.URI;
 import java.util.concurrent.ExecutorService;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
 import static org.testng.AssertJUnit.assertTrue;
 
 /**
@@ -42,6 +47,12 @@ public class GitHookTestCase extends StratosIntegrationTest {
     private static Log log = LogFactory.getLog(GitHookTestCase.class);
     private static final String RESOURCES_PATH = "/git-hook-test";
     private int artifactUpdateEvents = 0;
+    private static final String autoscalePolicyId = "autoscaling-policy-git-hook-test";
+    private static final String cartridgeId = "c1-git-hook-test";
+    private static final String networkPartitionId = "network-partition-git-hook-test";
+    private static final String depPolicyId = "deployment-policy-git-hook-test";
+    private static final String applicationId = "git-hook-test";
+    private static final String appPolicyId = "application-policy-git-hook-test";
 
     @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"adc", "smoke"})
     public void sendRepoNotify() throws Exception {
@@ -72,58 +83,120 @@ public class GitHookTestCase extends StratosIntegrationTest {
                 restClient.getJsonStringFromFile(RESOURCES_PATH + "/" + gitHookFile));
 
         while (artifactUpdateEvents < 2) {
-            log.debug("Waiting till artifact updated comes in... ");
+            log.info("Waiting till artifact updated comes in... ");
             Thread.sleep(1000);
         }
+
+        log.info("Waiting for application status to become ACTIVE...");
+        TopologyHandler.getInstance().assertApplicationStatus(applicationId, ApplicationStatus.Active);
+
+        undeployArtifacts();
     }
 
     private void deployArtifacts() throws Exception {
-        String autoscalingPolicyFile = "autoscaling-policy-1";
-        boolean autoscalingPolicyAdded = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalingPolicyFile + ".json",
+        boolean autoscalePolicyAdded = restClient.addEntity(
+                RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + "/" + autoscalePolicyId + ".json",
                 RestConstants.AUTOSCALING_POLICIES,
                 RestConstants.AUTOSCALING_POLICIES_NAME);
-        assertTrue(autoscalingPolicyAdded);
+        assertTrue(autoscalePolicyAdded);
 
-        String cartridgeFile = "php";
         boolean cartridgeAdded = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeFile + ".json",
+                RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + cartridgeId + ".json",
                 RestConstants.CARTRIDGES,
                 RestConstants.CARTRIDGES_NAME);
         assertTrue(cartridgeAdded);
 
-        String networkPartitionFiile = "network-partition-1";
         boolean networkPartitionAdded = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + networkPartitionFiile + ".json",
+                RESOURCES_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" + networkPartitionId + ".json",
                 RestConstants.NETWORK_PARTITIONS,
                 RestConstants.NETWORK_PARTITIONS_NAME);
         assertTrue(networkPartitionAdded);
 
-        String depPolicyFile = "deployment-policy-1";
         boolean deploymentPolicyAdded = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + depPolicyFile + ".json",
+                RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + depPolicyId + ".json",
                 RestConstants.DEPLOYMENT_POLICIES,
                 RestConstants.DEPLOYMENT_POLICIES_NAME);
         assertTrue(deploymentPolicyAdded);
 
-        String applicationFile = "application";
         boolean applicationAdded = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + applicationFile + ".json",
+                RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + applicationId + ".json",
                 RestConstants.APPLICATIONS,
                 RestConstants.APPLICATIONS_NAME);
         assertTrue(applicationAdded);
 
-        String appPolicyFile = "application-policy-1";
+        ApplicationBean bean = (ApplicationBean) restClient
+                .getEntity(RestConstants.APPLICATIONS, applicationId, ApplicationBean.class,
+                        RestConstants.APPLICATIONS_NAME);
+        assertEquals(bean.getApplicationId(), applicationId);
+
         boolean appPolicyAdded = restClient.addEntity(
-                RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + appPolicyFile + ".json",
+                RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + appPolicyId + ".json",
                 RestConstants.APPLICATION_POLICIES,
                 RestConstants.APPLICATION_POLICIES_NAME);
         assertTrue(appPolicyAdded);
 
-
         boolean appDeployed = restClient.deployEntity(
-                RestConstants.APPLICATIONS + "/" + "single-cartridge-app" + RestConstants.APPLICATIONS_DEPLOY + "/" + appPolicyFile,
+                RestConstants.APPLICATIONS + "/" + applicationId + RestConstants.APPLICATIONS_DEPLOY + "/" + appPolicyId,
                 RestConstants.APPLICATIONS_NAME);
         assertTrue(appDeployed);
     }
+
+    private void undeployArtifacts() throws Exception{
+        log.info(String.format("Un-deploying the application [application id] %s", applicationId));
+        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + applicationId +
+                RestConstants.APPLICATIONS_UNDEPLOY;
+
+        boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy, RestConstants.APPLICATIONS_NAME);
+        assertTrue(unDeployed);
+
+        boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy(applicationId);
+        if (!undeploy) {
+            //Need to forcefully undeploy the application
+            log.info(String.format("Force undeployment is going to start for the [application] %s", applicationId));
+
+            restClient.undeployEntity(RestConstants.APPLICATIONS + applicationId +
+                    RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+            boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy(applicationId);
+            assertTrue(String.format("Forceful undeployment failed for the application %s", applicationId), forceUndeployed);
+        }
+
+        log.info("Removing the application [application id] sample-application-startup-test");
+        boolean removedApp = restClient.removeEntity(RestConstants.APPLICATIONS, applicationId,
+                RestConstants.APPLICATIONS_NAME);
+        assertTrue(removedApp);
+
+        ApplicationBean beanRemoved = (ApplicationBean) restClient
+                .getEntity(RestConstants.APPLICATIONS, applicationId, ApplicationBean.class,
+                        RestConstants.APPLICATIONS_NAME);
+        assertNull(beanRemoved);
+
+        log.info(String.format("Removing the application policy [application policy id] %s", appPolicyId));
+        boolean removeAppPolicy = restClient
+                .removeEntity(RestConstants.APPLICATION_POLICIES, appPolicyId,
+                        RestConstants.APPLICATION_POLICIES_NAME);
+        assertTrue(removeAppPolicy);
+
+        log.info(String.format("Removing the cartridge [cartridge type] %s", cartridgeId));
+        boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeId,
+                RestConstants.CARTRIDGES_NAME);
+        assertTrue(removedC1);
+
+        log.info(String.format("Removing the autoscaling policy [autoscaling policy id] %s", autoscalePolicyId));
+        boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES, autoscalePolicyId,
+                RestConstants.AUTOSCALING_POLICIES_NAME);
+        assertTrue(removedAuto);
+
+        log.info(String.format("Removing the deployment policy [deployment policy id] %s", depPolicyId));
+        boolean removedDep = restClient
+                .removeEntity(RestConstants.DEPLOYMENT_POLICIES, depPolicyId,
+                        RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertTrue(removedDep);
+
+        log.info(String.format("Removing the network partition [network partition id] %s", networkPartitionId));
+        boolean removedNet = restClient
+                .removeEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+                        RestConstants.NETWORK_PARTITIONS_NAME);
+        assertTrue(removedNet);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-1.json
deleted file mode 100644
index 417b94f..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-1.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-    "id": "application-policy-1",
-    "algorithm": "one-after-another",
-    "networkPartitions": [
-        "network-partition-1"
-    ],
-    "properties": [
-        {
-            "name": "key-1",
-            "value": "value-1"
-        },
-        {
-            "name": "key-2",
-            "value": "value-2"
-        }
-    ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-git-hook-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-git-hook-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-git-hook-test.json
new file mode 100644
index 0000000..1991b79
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/application-policies/application-policy-git-hook-test.json
@@ -0,0 +1,17 @@
+{
+    "id": "application-policy-git-hook-test",
+    "algorithm": "one-after-another",
+    "networkPartitions": [
+        "network-partition-git-hook-test"
+    ],
+    "properties": [
+        {
+            "name": "key-1",
+            "value": "value-1"
+        },
+        {
+            "name": "key-2",
+            "value": "value-2"
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/application.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/application.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/application.json
deleted file mode 100644
index 4043e4f..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/application.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-    "applicationId": "single-cartridge-app",
-    "alias": "single-cartridge-app",
-    "multiTenant": false,
-    "components": {
-        "cartridges": [
-            {
-                "type": "php",
-                "cartridgeMin": 1,
-                "cartridgeMax": 5,
-                "subscribableInfo": {
-                    "alias": "my-php",
-                    "autoscalingPolicy": "autoscaling-policy-1",
-                    "deploymentPolicy": "deployment-policy-1",
-                    "artifactRepository": {
-                        "privateRepo": false,
-                        "repoUrl": "https://github.com/lakwarus/single-cartridge.git",
-                        "repoUsername": "",
-                        "repoPassword": ""
-                    }
-                }
-            }
-        ]
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/git-hook-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/git-hook-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/git-hook-test.json
new file mode 100644
index 0000000..0905325
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/applications/git-hook-test.json
@@ -0,0 +1,25 @@
+{
+    "applicationId": "git-hook-test",
+    "alias": "git-hook-test",
+    "multiTenant": false,
+    "components": {
+        "cartridges": [
+            {
+                "type": "c1-git-hook-test",
+                "cartridgeMin": 1,
+                "cartridgeMax": 5,
+                "subscribableInfo": {
+                    "alias": "my-c1-git-hook-test",
+                    "autoscalingPolicy": "autoscaling-policy-git-hook-test",
+                    "deploymentPolicy": "deployment-policy-git-hook-test",
+                    "artifactRepository": {
+                        "privateRepo": false,
+                        "repoUrl": "https://github.com/lakwarus/single-cartridge.git",
+                        "repoUsername": "",
+                        "repoPassword": ""
+                    }
+                }
+            }
+        ]
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-1.json
deleted file mode 100644
index e5ac700..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-1.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "autoscaling-policy-1",
-    "loadThresholds": {
-        "requestsInFlight": {
-            "threshold": 20
-        },
-        "memoryConsumption": {
-            "threshold": 70
-        },
-        "loadAverage": {
-            "threshold": 70
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-git-hook-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-git-hook-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-git-hook-test.json
new file mode 100644
index 0000000..c32cd01
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/autoscaling-policies/autoscaling-policy-git-hook-test.json
@@ -0,0 +1,14 @@
+{
+    "id": "autoscaling-policy-git-hook-test",
+    "loadThresholds": {
+        "requestsInFlight": {
+            "threshold": 20
+        },
+        "memoryConsumption": {
+            "threshold": 70
+        },
+        "loadAverage": {
+            "threshold": 70
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/c1-git-hook-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/c1-git-hook-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/c1-git-hook-test.json
new file mode 100644
index 0000000..42337a9
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/c1-git-hook-test.json
@@ -0,0 +1,51 @@
+{
+    "type": "c1-git-hook-test",
+    "provider": "apache",
+    "category": "framework",
+    "host": "c1-git-hook-test.stratos.org",
+    "displayName": "c1-git-hook-test",
+    "description": "c1-git-hook-test cartridge",
+    "version": "7",
+    "multiTenant": "false",
+    "portMapping": [
+        {
+            "name": "http-80",
+            "protocol": "http",
+            "port": "8080",
+            "proxyPort": "8280"
+        },
+        {
+            "name": "http-22",
+            "protocol": "tcp",
+            "port": "22",
+            "proxyPort": "8222"
+        }
+    ],
+    "deployment": {
+    },
+    "iaasProvider": [
+        {
+            "type": "mock",
+            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+            "networkInterfaces": [
+                {
+                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+                }
+            ],
+            "property": [
+                {
+                    "name": "instanceType",
+                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+                },
+                {
+                    "name": "keyPair",
+                    "value": "reka"
+                },
+                {
+                    "name": "securityGroups",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/php.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/php.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/php.json
deleted file mode 100644
index 5d53e3a..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/cartridges/mock/php.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-    "type": "php",
-    "provider": "apache",
-    "category": "framework",
-    "host": "php.stratos.org",
-    "displayName": "php",
-    "description": "php Cartridge",
-    "version": "7",
-    "multiTenant": "false",
-    "portMapping": [
-        {
-            "name": "http-80",
-            "protocol": "http",
-            "port": "8080",
-            "proxyPort": "8280"
-        },
-        {
-            "name": "http-22",
-            "protocol": "tcp",
-            "port": "22",
-            "proxyPort": "8222"
-        }
-    ],
-    "deployment": {
-    },
-    "iaasProvider": [
-        {
-            "type": "mock",
-            "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
-            "networkInterfaces": [
-                {
-                    "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
-                }
-            ],
-            "property": [
-                {
-                    "name": "instanceType",
-                    "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
-                },
-                {
-                    "name": "keyPair",
-                    "value": "reka"
-                },
-                {
-                    "name": "securityGroups",
-                    "value": "default"
-                }
-            ]
-        }
-    ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-1.json
deleted file mode 100644
index a434226..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-    "id": "deployment-policy-1",
-    "networkPartitions": [
-        {
-            "id": "network-partition-1",
-            "partitionAlgo": "one-after-another",
-            "partitions": [
-                {
-                    "id": "partition-1",
-                    "partitionMax": 20
-                }
-            ]
-        }
-    ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-git-hook-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-git-hook-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-git-hook-test.json
new file mode 100644
index 0000000..53c25df
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/deployment-policies/deployment-policy-git-hook-test.json
@@ -0,0 +1,15 @@
+{
+    "id": "deployment-policy-git-hook-test",
+    "networkPartitions": [
+        {
+            "id": "network-partition-git-hook-test",
+            "partitionAlgo": "one-after-another",
+            "partitions": [
+                {
+                    "id": "partition-1",
+                    "partitionMax": 20
+                }
+            ]
+        }
+    ]
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-1.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-1.json
deleted file mode 100644
index 466da28..0000000
--- a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
-    "id": "network-partition-1",
-    "provider": "mock",
-    "partitions": [
-        {
-            "id": "partition-1",
-            "property": [
-                {
-                    "name": "region",
-                    "value": "default"
-                }
-            ]
-        }
-    ]
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a121351d/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-git-hook-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-git-hook-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-git-hook-test.json
new file mode 100644
index 0000000..0d6e15c
--- /dev/null
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/git-hook-test/network-partitions/mock/network-partition-git-hook-test.json
@@ -0,0 +1,15 @@
+{
+    "id": "network-partition-git-hook-test",
+    "provider": "mock",
+    "partitions": [
+        {
+            "id": "partition-1",
+            "property": [
+                {
+                    "name": "region",
+                    "value": "default"
+                }
+            ]
+        }
+    ]
+}


[2/9] stratos git commit: Rename eventReceiverInitiated to eventReceiverInitialized

Posted by is...@apache.org.
Rename eventReceiverInitiated to eventReceiverInitialized


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/64eadfb0
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/64eadfb0
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/64eadfb0

Branch: refs/heads/stratos-4.1.x
Commit: 64eadfb063c36f078a453f53b33f8bbef9fc9c6a
Parents: 074de0e
Author: Akila Perera <ra...@gmail.com>
Authored: Sat Nov 21 12:05:37 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../tests/ADCMTAppTenantUserTestCase.java       |   4 +-
 .../integration/tests/ADCMTAppTestCase.java     |   5 +-
 .../agent/integration/tests/ADCTestCase.java    |   2 +-
 .../integration/tests/AgentStartupTestCase.java |   2 +-
 .../tests/MessageBrokerHATestCase.java          | 210 +++++++++----------
 .../tests/PythonAgentIntegrationTest.java       |  89 ++++----
 6 files changed, 148 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/64eadfb0/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTenantUserTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTenantUserTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTenantUserTestCase.java
index 26c52d1..6e40dd6 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTenantUserTestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTenantUserTestCase.java
@@ -120,7 +120,7 @@ public class ADCMTAppTenantUserTestCase extends PythonAgentIntegrationTest {
         Thread startupTestThread = new Thread(new Runnable() {
             @Override
             public void run() {
-                while (!eventReceiverInitiated) {
+                while (!eventReceiverInitialized) {
                     sleep(1000);
                 }
                 List<String> outputLines = new ArrayList<String>();
@@ -214,4 +214,4 @@ public class ADCMTAppTenantUserTestCase extends PythonAgentIntegrationTest {
 
         return topology;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/64eadfb0/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTestCase.java
index f677629..6f0b070 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCMTAppTestCase.java
@@ -122,7 +122,7 @@ public class ADCMTAppTestCase extends PythonAgentIntegrationTest {
         Thread startupTestThread = new Thread(new Runnable() {
             @Override
             public void run() {
-                while (!eventReceiverInitiated) {
+                while (!eventReceiverInitialized) {
                     sleep(1000);
                 }
                 List<String> outputLines = new ArrayList<String>();
@@ -165,6 +165,7 @@ public class ADCMTAppTestCase extends PythonAgentIntegrationTest {
         while (!instanceStarted || !instanceActivated) {
             // wait until the instance activated event is received.
             // this will assert whether instance got activated within timeout period; no need for explicit assertions
+            log.info("Waiting for agent activation...");
             sleep(2000);
         }
     }
@@ -215,4 +216,4 @@ public class ADCMTAppTestCase extends PythonAgentIntegrationTest {
         cluster.addMember(member);
         return topology;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/64eadfb0/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCTestCase.java
index 14797e4..0dc92be 100755
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCTestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/ADCTestCase.java
@@ -179,7 +179,7 @@ public class ADCTestCase extends PythonAgentIntegrationTest {
         Thread startupTestThread = new Thread(new Runnable() {
             @Override
             public void run() {
-                while (!eventReceiverInitiated) {
+                while (!eventReceiverInitialized) {
                     sleep(1000);
                 }
                 List<String> outputLines = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/stratos/blob/64eadfb0/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentStartupTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentStartupTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentStartupTestCase.java
index f0a70d4..ea156b6 100755
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentStartupTestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentStartupTestCase.java
@@ -96,7 +96,7 @@ public class AgentStartupTestCase extends PythonAgentIntegrationTest {
         Thread startupTestThread = new Thread(new Runnable() {
             @Override
             public void run() {
-                while (!eventReceiverInitiated) {
+                while (!eventReceiverInitialized) {
                     sleep(2000);
                 }
                 List<String> outputLines = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/stratos/blob/64eadfb0/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/MessageBrokerHATestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/MessageBrokerHATestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/MessageBrokerHATestCase.java
index e6203a7..b1f4d8b 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/MessageBrokerHATestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/MessageBrokerHATestCase.java
@@ -23,61 +23,60 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.common.domain.LoadBalancingIPType;
 import org.apache.stratos.messaging.domain.topology.*;
-import org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent;
+import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupMemberEvent;
 import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
 import org.apache.stratos.messaging.event.topology.MemberInitializedEvent;
-import org.testng.annotations.Test;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
 /**
- * Test case to test the messsage broker connection resilience in the Python Cartridge Agent
+ * Test case to test the message broker connection resilience in the Python Cartridge Agent
  */
 public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
     public MessageBrokerHATestCase() throws IOException {
     }
 
     private static final Log log = LogFactory.getLog(MessageBrokerHATestCase.class);
-    private static final int ADC_TIMEOUT = 300000;
-    private static final String CLUSTER_ID = "tomcat.domain";
-    private static final String DEPLOYMENT_POLICY_NAME = "deployment-policy-6";
-    private static final String AUTOSCALING_POLICY_NAME = "autoscaling-policy-6";
-    private static final String APP_ID = "application-6";
-    private static final String MEMBER_ID = "tomcat.member-1";
+    private static final int HA_TEST_TIMEOUT = 300000;
+    private static final String CLUSTER_ID = "php.php.domain";
+    private static final String DEPLOYMENT_POLICY_NAME = "deployment-policy-1";
+    private static final String AUTOSCALING_POLICY_NAME = "autoscaling-policy-1";
+    private static final String APP_ID = "application-1";
+    private static final String MEMBER_ID = "php.member-1";
     private static final String INSTANCE_ID = "instance-1";
     private static final String CLUSTER_INSTANCE_ID = "cluster-1-instance-1";
     private static final String NETWORK_PARTITION_ID = "network-partition-1";
     private static final String PARTITION_ID = "partition-1";
-    private static final String TENANT_ID = "6";
-    private static final String SERVICE_NAME = "tomcat";
-
+    private static final String TENANT_ID = "-1234";
+    private static final String SERVICE_NAME = "php";
+    boolean pcaActivated = false;
 
     @BeforeMethod(alwaysRun = true)
     public void setup() throws Exception {
         System.setProperty("jndi.properties.dir", getTestCaseResourcesPath());
-//        integrationTestPropertiesPath = new FileInputStream(new File(getTestCaseResourcesPath() + PATH_SEP + "integration-test.properties"));
-
-        super.setup(ADC_TIMEOUT);
+        super.setup(HA_TEST_TIMEOUT);
         startServerSocket(8080);
     }
-    
+
     @AfterMethod(alwaysRun = true)
-    public void tearDownBrokerHATest(){
+    public void tearDownBrokerHATest() {
         tearDown();
     }
 
-    @Test(groups = {"test"})
-    public void testBrokerFailoverHeartbeat(){
+    @Test(timeOut = HA_TEST_TIMEOUT,
+          groups = { "ha" },
+          priority = 1)
+    public void testBrokerFailoverHeartbeat() {
+        log.info("Running MessageBrokerHATestCase subscriber failover test...");
         startCommunicatorThread();
+        assertAgentActivation();
         sleep(10000);
-//        assertAgentActivation();
 
         // take down the default broker
         log.info("Stopping subscribed message broker: DEFAULT");
@@ -89,12 +88,15 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
             List<String> newLines = getNewLines(outputLines, outputStream.toString());
             if (newLines.size() > 0) {
                 for (String line : newLines) {
-                    if (line.contains("Message broker localhost:" + mqttBindPorts[0] + " cannot be reached. Disconnecting client...")) {
-                        log.info("Message Broker Heartbeat checker has detected message broker node termination and is trying the next option.");
+                    if (line.contains("Message broker localhost:" + mqttBindPorts[0]
+                            + " cannot be reached. Disconnecting client...")) {
+                        log.info("Message Broker Heartbeat checker has detected message broker node termination and is"
+                                + " trying the next option.");
                         exit = true;
                     }
                 }
             }
+            log.info("Waiting for message broker subscriber failover detection for the 1st time.");
             sleep(1000);
         }
 
@@ -107,16 +109,18 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
             List<String> newLines = getNewLines(outputLines, outputStream.toString());
             if (newLines.size() > 0) {
                 for (String line : newLines) {
-                    if (line.contains("Message broker localhost:" + mqttBindPorts[1] + " cannot be reached. Disconnecting client...")) {
-                        log.info("Message Broker Heartbeat checker has detected message broker node termination and is trying the next option.");
+                    if (line.contains("Message broker localhost:" + mqttBindPorts[1]
+                            + " cannot be reached. Disconnecting client...")) {
+                        log.info("Message Broker Heartbeat checker has detected message broker node termination and is"
+                                + " trying the next option.");
                         exit = true;
                     }
                 }
             }
+            log.info("Waiting for message broker subscriber failover detection for the 2nd time.");
             sleep(1000);
         }
 
-        sleep(20000);
         log.info("Stopping subscribed message broker");
         stopActiveMQInstance("testBroker-" + amqpBindPorts[2] + "-" + mqttBindPorts[2]);
 
@@ -125,99 +129,100 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
             List<String> newLines = getNewLines(outputLines, outputStream.toString());
             if (newLines.size() > 0) {
                 for (String line : newLines) {
-                    if (line.contains("Message broker localhost:" + mqttBindPorts[2] + " cannot be reached. Disconnecting client...")) {
-                        log.info("Message Broker Heartbeat checker has detected message broker node termination and is trying the next option.");
+                    if (line.contains("Message broker localhost:" + mqttBindPorts[2]
+                            + " cannot be reached. Disconnecting client...")) {
+                        log.info("Message Broker Heartbeat checker has detected message broker node termination and is"
+                                + " trying the next option.");
                     }
-                    if (line.contains("Could not connect to any of the message brokers provided. Retrying in 2 seconds")) {
+                    if (line.contains(
+                            "Could not connect to any of the message brokers provided. Retrying in 2 seconds")) {
                         log.info("Failover went through all the options and will be retrying.");
                         exit = true;
                     }
                 }
             }
+            log.info("Waiting for message broker subscriber failover detection for the 3rd time.");
             sleep(1000);
         }
+        log.info("MessageBrokerHATestCase subscriber test completed successfully.");
     }
-    
-    @Test(groups = {"smoke"})
-    public void testBrokerFailoverForPublisher(){
-        startCommunicatorThread();
-
 
+    @Test(timeOut = HA_TEST_TIMEOUT,
+          groups = { "ha" },
+          priority = 2)
+    public void testBrokerFailoverForPublisher() {
+        log.info("Running MessageBrokerHATestCase publisher failover test...");
+        startCommunicatorThread();
+        assertAgentActivation();
         List<String> outputLines = new ArrayList<>();
         boolean exit = false;
+        boolean publishCleanupEvent = false;
         while (!exit) {
             List<String> newLines = getNewLines(outputLines, outputStream.toString());
             if (newLines.size() > 0) {
                 for (String line : newLines) {
-                    if (line.contains("Subscribed to 'topology/#'")) {
-                        // take down the default broker
-                        stopActiveMQInstance("testBroker-" + amqpBindPorts[0] + "-" + mqttBindPorts[0]);
-                    }
-
-                    if (line.contains("Waiting for complete topology event")) {
-
-                        sleep(4000);
-
-//                        stopActiveMQInstance("testBroker2");
-//                        stopActiveMQInstance("testBroker3");
-                        // Send complete topology event
-                        log.info("Publishing complete topology event...");
-                        Topology topology = createTestTopology();
-                        CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(topology);
-                        publishEvent(completeTopologyEvent);
-                        log.info("Complete topology event published");
-                    }
-
-                    if (line.contains("Waiting for cartridge agent to be initialized")) {
-                        // Publish member initialized event
-                        log.info("Publishing member initialized event...");
-                        MemberInitializedEvent memberInitializedEvent = new MemberInitializedEvent(
-                                SERVICE_NAME, CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID,
-                                PARTITION_ID, INSTANCE_ID
-                        );
-                        publishEvent(memberInitializedEvent);
-                        log.info("Member initialized event published");
-                    }
-
-
-                    // Send artifact updated event to activate the instance first
-                    if (line.contains("Artifact repository found")) {
-                        publishEvent(getArtifactUpdatedEventForPublicRepo());
-                        log.info("Artifact updated event published");
+                    if (!publishCleanupEvent) {
+                        log.info("Publishing instance cleanup member event and shutting down first MB instance...");
+
+                        // publish instance cleanup event to trigger an ready to shutdown event being published from PCA
+                        InstanceCleanupMemberEvent instanceCleanupMemberEvent = new InstanceCleanupMemberEvent(
+                                MEMBER_ID);
+                        publishEvent(instanceCleanupMemberEvent);
+                        publishCleanupEvent = true;
+                        waitUntilCleanupEventIsReceivedAndStopDefaultMB();
                     }
 
                     if (line.contains("Could not publish event to message broker localhost:1885.")) {
                         log.info("Event publishing to default message broker failed and the next option is tried.");
                         exit = true;
                     }
-
-//                    if (line.contains("The event will be dropped.")) {
-//                        log.info("Event publishing failed after timeout exceeded and the event was dropped.");
-//                        exit = true;
-//                    }
                 }
             }
+            log.info("Waiting for message broker publisher failover detection.");
             sleep(1000);
         }
 
-//        assertAgentActivation();
+        //        assertAgentActivation();
+        log.info("MessageBrokerHATestCase publisher test completed successfully.");
+    }
+
+    private void waitUntilCleanupEventIsReceivedAndStopDefaultMB() {
+        boolean eventReceived = false;
+        List<String> outputLines = new ArrayList<>();
+
+        while (!eventReceived) {
+            List<String> newLines = getNewLines(outputLines, outputStream.toString());
+            if (newLines.size() > 0) {
+                for (String line : newLines) {
+                    if (line.contains("Message received: instance/notifier/InstanceCleanupMemberEvent")) {
+                        // take down the default broker
+                        stopActiveMQInstance("testBroker-" + amqpBindPorts[0] + "-" + mqttBindPorts[0]);
+                        eventReceived = true;
+                    }
+                }
+            }
+            log.info("Waiting until cleanup event is received by PCA...");
+        }
+        log.info("Cleanup event is received by PCA.");
     }
 
     private void assertAgentActivation() {
+        pcaActivated = false;
+        instanceActivated = false;
+        instanceStarted = false;
         Thread startupTestThread = new Thread(new Runnable() {
             @Override
             public void run() {
-                while (!eventReceiverInitiated) {
+                while (!eventReceiverInitialized) {
+                    log.info("Waiting until event receiver is initialized...");
                     sleep(1000);
                 }
-                List<String> outputLines = new ArrayList<>();
-                boolean completeTopologyPublished = false;
-                boolean memberInitPublished = false;
-                while (!outputStream.isClosed()) {
+                List<String> outputLines = new ArrayList<String>();
+                while (!outputStream.isClosed() && !pcaActivated) {
                     List<String> newLines = getNewLines(outputLines, outputStream.toString());
                     if (newLines.size() > 0) {
                         for (String line : newLines) {
-                            if (line.contains("Waiting for complete topology event") && !completeTopologyPublished) {
+                            if (line.contains("Subscribed to 'topology/#'")) {
                                 sleep(2000);
                                 // Send complete topology event
                                 log.info("Publishing complete topology event...");
@@ -225,30 +230,21 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
                                 CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(topology);
                                 publishEvent(completeTopologyEvent);
                                 log.info("Complete topology event published");
-                                completeTopologyPublished = true;
-                            }
+                                sleep(2000);
 
-                            if (line.contains("Waiting for cartridge agent to be initialized") && !memberInitPublished) {
                                 // Publish member initialized event
                                 log.info("Publishing member initialized event...");
-                                MemberInitializedEvent memberInitializedEvent = new MemberInitializedEvent(
-                                        SERVICE_NAME, CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID,
-                                        PARTITION_ID, INSTANCE_ID
-                                );
+                                MemberInitializedEvent memberInitializedEvent = new MemberInitializedEvent(SERVICE_NAME,
+                                        CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID, PARTITION_ID,
+                                        INSTANCE_ID);
                                 publishEvent(memberInitializedEvent);
                                 log.info("Member initialized event published");
-                                memberInitPublished = true;
-                            }
-
-                            // Send artifact updated event to activate the instance first
-                            if (line.contains("Artifact repository found")) {
-                                publishEvent(getArtifactUpdatedEventForPublicRepo());
-                                log.info("Artifact updated event published");
                             }
                         }
                     }
                     sleep(1000);
                 }
+                log.info("Startup test thread finished.");
             }
         });
         startupTestThread.start();
@@ -256,21 +252,11 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
         while (!instanceStarted || !instanceActivated) {
             // wait until the instance activated event is received.
             // this will assert whether instance got activated within timeout period; no need for explicit assertions
+            log.info("Waiting for agent activation...");
             sleep(2000);
         }
-    }
-
-    private ArtifactUpdatedEvent getArtifactUpdatedEventForPublicRepo() {
-        ArtifactUpdatedEvent publicRepoEvent = createTestArtifactUpdatedEvent();
-        publicRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/opentestrepo1.git");
-        return publicRepoEvent;
-    }
-
-    private static ArtifactUpdatedEvent createTestArtifactUpdatedEvent() {
-        ArtifactUpdatedEvent artifactUpdatedEvent = new ArtifactUpdatedEvent();
-        artifactUpdatedEvent.setClusterId(CLUSTER_ID);
-        artifactUpdatedEvent.setTenantId(TENANT_ID);
-        return artifactUpdatedEvent;
+        pcaActivated = true;
+        log.info("PCA activation assertion passed.");
     }
 
     /**
@@ -287,9 +273,8 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
                 AUTOSCALING_POLICY_NAME, APP_ID);
         service.addCluster(cluster);
 
-        Member member = new Member(service.getServiceName(), cluster.getClusterId(), MEMBER_ID,
-                CLUSTER_INSTANCE_ID, NETWORK_PARTITION_ID, PARTITION_ID, LoadBalancingIPType.Private,
-                System.currentTimeMillis());
+        Member member = new Member(service.getServiceName(), cluster.getClusterId(), MEMBER_ID, CLUSTER_INSTANCE_ID,
+                NETWORK_PARTITION_ID, PARTITION_ID, LoadBalancingIPType.Private, System.currentTimeMillis());
 
         member.setDefaultPrivateIP("10.0.0.1");
         member.setDefaultPublicIP("20.0.0.1");
@@ -298,7 +283,6 @@ public class MessageBrokerHATestCase extends PythonAgentIntegrationTest {
         member.setProperties(properties);
         member.setStatus(MemberStatus.Created);
         cluster.addMember(member);
-
         return topology;
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/64eadfb0/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/PythonAgentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/PythonAgentIntegrationTest.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/PythonAgentIntegrationTest.java
index fb12db6..6e25b6b 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/PythonAgentIntegrationTest.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/PythonAgentIntegrationTest.java
@@ -24,6 +24,7 @@ import org.apache.activemq.security.AuthenticationUser;
 import org.apache.activemq.security.SimpleAuthenticationPlugin;
 import org.apache.commons.exec.*;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -38,7 +39,6 @@ import org.apache.stratos.messaging.message.receiver.instance.status.InstanceSta
 import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
 import org.apache.stratos.messaging.util.MessagingUtil;
 import org.apache.stratos.python.cartridge.agent.integration.common.ThriftTestServer;
-import org.apache.commons.io.IOUtils;
 
 import java.io.*;
 import java.net.ServerSocket;
@@ -63,7 +63,7 @@ public class PythonAgentIntegrationTest {
 
     public static final String TEST_THREAD_POOL_SIZE = "test.thread.pool.size";
     protected final UUID PYTHON_AGENT_DIR_NAME = UUID.randomUUID();
-//    protected final String defaultBrokerName = "testBrokerDefault";
+    //    protected final String defaultBrokerName = "testBrokerDefault";
     protected final Properties integrationProperties = new Properties();
 
     protected Map<Integer, ServerSocket> serverSocketMap = new HashMap<>();
@@ -76,7 +76,7 @@ public class PythonAgentIntegrationTest {
     protected String distributionName;
     protected int testThreadPoolSize;
 
-    protected boolean eventReceiverInitiated = false;
+    protected boolean eventReceiverInitialized = false;
     protected TopologyEventReceiver topologyEventReceiver;
     protected InstanceStatusEventReceiver instanceStatusEventReceiver;
     protected InitializerEventReceiver initializerEventReceiver;
@@ -87,7 +87,6 @@ public class PythonAgentIntegrationTest {
 
     private Map<String, BrokerService> messageBrokers;
 
-
     /**
      * Setup method for test method testPythonCartridgeAgent
      */
@@ -100,58 +99,58 @@ public class PythonAgentIntegrationTest {
         cepSSLPort = Integer.parseInt(integrationProperties.getProperty(CEP_SSL_PORT));
 
         Properties jndiProperties = new Properties();
-        jndiProperties.load(new FileInputStream(new File(System.getProperty("jndi.properties.dir") + PATH_SEP + "jndi.properties")));
-        if (!jndiProperties.containsKey(ACTIVEMQ_AMQP_BIND_PORTS) || !jndiProperties.containsKey(ACTIVEMQ_MQTT_BIND_PORTS)) {
+        jndiProperties.load(new FileInputStream(
+                new File(System.getProperty("jndi.properties.dir") + PATH_SEP + "jndi.properties")));
+        if (!jndiProperties.containsKey(ACTIVEMQ_AMQP_BIND_PORTS) || !jndiProperties
+                .containsKey(ACTIVEMQ_MQTT_BIND_PORTS)) {
             amqpBindPorts = integrationProperties.getProperty(ACTIVEMQ_AMQP_BIND_PORTS).split(",");
             mqttBindPorts = integrationProperties.getProperty(ACTIVEMQ_MQTT_BIND_PORTS).split(",");
-        }else{
+        } else {
             amqpBindPorts = jndiProperties.getProperty(ACTIVEMQ_AMQP_BIND_PORTS).split(",");
             mqttBindPorts = jndiProperties.getProperty(ACTIVEMQ_MQTT_BIND_PORTS).split(",");
         }
 
         if (amqpBindPorts.length != mqttBindPorts.length) {
-            throw new RuntimeException("The number of AMQP ports and MQTT ports should be equal in integration-test.properties.");
+            throw new RuntimeException(
+                    "The number of AMQP ports and MQTT ports should be equal in integration-test.properties.");
         }
 
         // start ActiveMQ test server
-        for (int i = 0; i < amqpBindPorts.length; i++){
+        for (int i = 0; i < amqpBindPorts.length; i++) {
+            log.info("Starting ActiveMQ instance with AMQP: " + amqpBindPorts[i] + ", MQTT: " + mqttBindPorts[i]);
             startActiveMQInstance(Integer.parseInt(amqpBindPorts[i]), Integer.parseInt(mqttBindPorts[i]), true);
         }
 
-        if (!this.eventReceiverInitiated) {
-            ExecutorService executorService = StratosThreadPool.getExecutorService("TEST_THREAD_POOL", testThreadPoolSize);
-            topologyEventReceiver = new TopologyEventReceiver();
-            topologyEventReceiver.setExecutorService(executorService);
-            topologyEventReceiver.execute();
+        ExecutorService executorService = StratosThreadPool.getExecutorService("TEST_THREAD_POOL", testThreadPoolSize);
+        topologyEventReceiver = new TopologyEventReceiver();
+        topologyEventReceiver.setExecutorService(executorService);
+        topologyEventReceiver.execute();
 
-            instanceStatusEventReceiver = new InstanceStatusEventReceiver();
-            instanceStatusEventReceiver.setExecutorService(executorService);
-            instanceStatusEventReceiver.execute();
+        instanceStatusEventReceiver = new InstanceStatusEventReceiver();
+        instanceStatusEventReceiver.setExecutorService(executorService);
+        instanceStatusEventReceiver.execute();
 
-            this.instanceStarted = false;
-            instanceStatusEventReceiver.addEventListener(new InstanceStartedEventListener() {
-                @Override
-                protected void onEvent(Event event) {
-                    log.info("Instance started event received");
-                    instanceStarted = true;
-                }
-            });
+        instanceStatusEventReceiver.addEventListener(new InstanceStartedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                log.info("Instance started event received");
+                instanceStarted = true;
+            }
+        });
 
-            this.instanceActivated = false;
-            instanceStatusEventReceiver.addEventListener(new InstanceActivatedEventListener() {
-                @Override
-                protected void onEvent(Event event) {
-                    log.info("Instance activated event received");
-                    instanceActivated = true;
-                }
-            });
+        instanceStatusEventReceiver.addEventListener(new InstanceActivatedEventListener() {
+            @Override
+            protected void onEvent(Event event) {
+                log.info("Instance activated event received");
+                instanceActivated = true;
+            }
+        });
 
-            initializerEventReceiver = new InitializerEventReceiver();
-            initializerEventReceiver.setExecutorService(executorService);
-            initializerEventReceiver.execute();
+        initializerEventReceiver = new InitializerEventReceiver();
+        initializerEventReceiver.setExecutorService(executorService);
+        initializerEventReceiver.execute();
 
-            this.eventReceiverInitiated = true;
-        }
+        this.eventReceiverInitialized = true;
 
         // Start CEP Thrift test server
         thriftTestServer = new ThriftTestServer();
@@ -226,7 +225,7 @@ public class PythonAgentIntegrationTest {
         // stop the broker services
         for (Map.Entry<String, BrokerService> entry : this.messageBrokers.entrySet()) {
             try {
-                    log.debug("Stopping broker service [" + entry.getKey() + "]");
+                log.debug("Stopping broker service [" + entry.getKey() + "]");
                 entry.getValue().stop();
             } catch (Exception ignore) {
             }
@@ -240,8 +239,8 @@ public class PythonAgentIntegrationTest {
     }
 
     public PythonAgentIntegrationTest() throws IOException {
-        integrationProperties.load(
-                PythonAgentIntegrationTest.class.getResourceAsStream(PATH_SEP + "integration-test.properties"));
+        integrationProperties
+                .load(PythonAgentIntegrationTest.class.getResourceAsStream(PATH_SEP + "integration-test.properties"));
         distributionName = integrationProperties.getProperty(DISTRIBUTION_NAME);
         cepPort = Integer.parseInt(integrationProperties.getProperty(CEP_PORT));
         cepSSLPort = Integer.parseInt(integrationProperties.getProperty(CEP_SSL_PORT));
@@ -279,7 +278,7 @@ public class PythonAgentIntegrationTest {
             AuthenticationUser authenticationUser = new AuthenticationUser("system", "manager", "users,admins");
             List<AuthenticationUser> authUserList = new ArrayList<>();
             authUserList.add(authenticationUser);
-            broker.setPlugins(new BrokerPlugin[]{new SimpleAuthenticationPlugin(authUserList)});
+            broker.setPlugins(new BrokerPlugin[] { new SimpleAuthenticationPlugin(authUserList) });
         }
 
         broker.setBrokerName(brokerName);
@@ -293,8 +292,8 @@ public class PythonAgentIntegrationTest {
         return brokerName;
     }
 
-    protected void stopActiveMQInstance(String brokerName){
-        if (this.messageBrokers.containsKey(brokerName)){
+    protected void stopActiveMQInstance(String brokerName) {
+        if (this.messageBrokers.containsKey(brokerName)) {
             log.debug("Stopping broker service [" + brokerName + "]");
             BrokerService broker = this.messageBrokers.get(brokerName);
             try {
@@ -320,7 +319,7 @@ public class PythonAgentIntegrationTest {
                                     log.error("ERROR found in PCA log", e);
                                 }
                             }
-                            log.info("[PCA] " + line);
+                            log.debug("[PCA] " + line);
                         }
                     }
                     sleep(100);


[7/9] stratos git commit: Refactor MessageBrokerHATestCase, include PCA activation assertion

Posted by is...@apache.org.
Refactor MessageBrokerHATestCase, include PCA activation assertion


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/074de0eb
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/074de0eb
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/074de0eb

Branch: refs/heads/stratos-4.1.x
Commit: 074de0ebf4781bc5536b041e8a69d6ae97edf62a
Parents: f42217e
Author: Akila Perera <ra...@gmail.com>
Authored: Sat Nov 21 12:05:03 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../agent/integration/tests/CEPHAModeTestCase.java        |  2 +-
 .../src/test/resources/MessageBrokerHATestCase/agent.conf | 10 +++++-----
 .../resources/MessageBrokerHATestCase/jndi.properties     |  4 ++--
 .../MessageBrokerHATestCase/payload/launch-params         |  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/074de0eb/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/CEPHAModeTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/CEPHAModeTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/CEPHAModeTestCase.java
index 18b8152..44d295b 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/CEPHAModeTestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/CEPHAModeTestCase.java
@@ -131,7 +131,7 @@ public class CEPHAModeTestCase extends PythonAgentIntegrationTest {
         Thread startupTestThread = new Thread(new Runnable() {
             @Override
             public void run() {
-                while (!eventReceiverInitiated) {
+                while (!eventReceiverInitialized) {
                     sleep(2000);
                 }
                 List<String> outputLines = new ArrayList<String>();

http://git-wip-us.apache.org/repos/asf/stratos/blob/074de0eb/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/agent.conf
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/agent.conf b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/agent.conf
index 8395bfd..c6c55f3 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/agent.conf
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/agent.conf
@@ -28,8 +28,8 @@ cep.stats.publisher.enabled           =true
 lb.private.ip                         =
 lb.public.ip                          =
 enable.artifact.update                =true
-auto.commit                           =true
-auto.checkout                         =true
+auto.commit                           =false
+auto.checkout                         =false
 artifact.update.interval              =15
 artifact.clone.retries                =5
 artifact.clone.interval               =10
@@ -40,7 +40,7 @@ monitoring.server.port                =7612
 monitoring.server.secure.port         =7712
 monitoring.server.admin.username      =admin
 monitoring.server.admin.password      =admin
-log.file.paths                        =/tmp/agent.screen-adc-test.log
+log.file.paths                        =/tmp/agent.screen-mb-ha-test.log
 metadata.service.url                  =https://localhost:9443
-super.tenant.repository.path          =/repository/deployment/server/
-tenant.repository.path                =/repository/tenants/
+super.tenant.repository.path          =
+tenant.repository.path                =

http://git-wip-us.apache.org/repos/asf/stratos/blob/074de0eb/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/jndi.properties
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/jndi.properties b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/jndi.properties
index 485fd75..5951f5d 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/jndi.properties
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/jndi.properties
@@ -18,9 +18,9 @@
 #
 
 connectionfactoryName=TopicConnectionFactory
-java.naming.provider.url=failover:(tcp://localhost:61617,tcp://localhost:61618,tcp://localhost:61619)?initialReconnectDelay=100
+java.naming.provider.url=failover:(tcp://localhost:61617)?initialReconnectDelay=100
 java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
 java.naming.security.principal=system
 java.naming.security.credentials=manager
 activemq.amqp.bind.ports=61617,61618,61619
-activemq.mqtt.bind.ports=1885,1886,1887
\ No newline at end of file
+activemq.mqtt.bind.ports=1885,1886,1887

http://git-wip-us.apache.org/repos/asf/stratos/blob/074de0eb/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/payload/launch-params
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/payload/launch-params b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/payload/launch-params
index 3498976..95cfd29 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/payload/launch-params
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/MessageBrokerHATestCase/payload/launch-params
@@ -1 +1 @@
-APPLICATION_ID=application1,SERVICE_NAME=tomcat,HOST_NAME=tomcat.stratos.org,MULTITENANT=false,TENANT_ID=-1234,TENANT_RANGE=*,CARTRIDGE_ALIAS=tomcat,CLUSTER_ID=tomcat.domain,CLUSTER_INSTANCE_ID=cluster-1-instance-1,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,DEPLOYMENT=default,PORTS=8080,PUPPET_IP=127.0.0.1,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_ENV=false,MEMBER_ID=tomcat.member-1,LB_CLUSTER_ID=null,NETWORK_PARTITION_ID=network-p1,PARTITION_ID=p1,APPLICATION_PATH=/tmp/ADCTestCase,MIN_COUNT=1,INTERNAL=false,CLUSTERING_PRIMARY_KEY=A,LOG_FILE_PATHS=/tmp/temp.log,PERSISTENCE_MAPPING=null
\ No newline at end of file
+APPLICATION_ID=application-1,APPLICATION_PATH=/tmp/MessageBrokerHATestCase,BASH=/bin/bash,BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath,BASH_ALIASES=(),BASH_ARGC=(),BASH_ARGV=(),BASH_CMDS=(),BASH_LINENO=([0]="0"),BASH_SOURCE=([0]="/usr/local/bin/populate-user-data.sh"),BASH_VERSINFO=([0]="4" [1]="3" [2]="30" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu"),BASH_VERSION='4.3.30(1)-release',CARTRIDGE_ALIAS=mytomcat,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,CATALINA_HOME=/opt/tomcat,CEP_IP=54.179.197.243,CEP_PORT=7711,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=cluster-1-instance-1,DEPENDENCY_CLUSTER_IDS=myphp.php.domain,DEPLOYMENT=default,DIRSTACK=(),EUID=0,GROUPS=(),GROUP_NAME=null,HOME=/root,HOSTNAME=mytomcat-tomcat-domain3bd3cd47-b95d-475a-aa11-3e3ddc089d49,HOSTTYPE=x86_64,HOST_NAME=mytomcat.tomcat.stratos.org,IFS=' 	,',INSTANCE_ID=null,INTERNAL=false,JAVA_HOME=/opt/jdk1.7.0_67,KUBERNETES_CLUSTER_ID=kubernetes-clu
 ster-1,KUBERNETES_PORT=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP_ADDR=10.100.0.2,KUBERNETES_PORT_443_TCP_PORT=443,KUBERNETES_PORT_443_TCP_PROTO=tcp,KUBERNETES_RO_PORT=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP_ADDR=10.100.0.1,KUBERNETES_RO_PORT_80_TCP_PORT=80,KUBERNETES_RO_PORT_80_TCP_PROTO=tcp,KUBERNETES_RO_SERVICE_HOST=10.100.0.1,KUBERNETES_RO_SERVICE_PORT=80,KUBERNETES_SERVICE_HOST=10.100.0.2,KUBERNETES_SERVICE_PORT=443,LB_CLUSTER_ID=null,LOG_LEVEL=DEBUG,MACHTYPE=x86_64-pc-linux-gnu,MB_IP=54.179.197.243,MB_PORT=1883,MEMBER_ID=php.member-1,MIN_COUNT=1,MULTITENANT=false,MYPHP_PHP_DOMAIN_1_PORT=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.171.218,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYPHP_PHP_DOMAIN_1_SERVICE_HOST=10.100.171.218,MYPHP_PHP_DOMAIN_1_SERVICE_
 PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_HOST=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_PORT=4500,NETWORK_PARTITION_ID=network-partition-1,OPTERR=1,OPTIND=1,OSTYPE=linux-gnu,PARTITION_ID=partition-1,PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PIPESTATUS=([0]="0"),PORTS=8080,POSIXLY_CORRECT=y,PPID=14,PRIMARY=false,PROVIDER=apache,PS4='+ ',PUPPET_DNS_AVAILABLE=null,PUPPET_ENV=false,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_IP=127.0.0.1,PWD=/opt,SERVICE_NAME=php,SHELL=/bin/bash,SHELLOPTS=braceexpand:hashall:interactive-comments:posix,SHLVL=2,TENANT_ID=-1234,TENANT_RANGE='*',TERM=dumb,TOKEN=eyJhbGciOiJSUzI1NiJ9.eyJleHAiOi04NzI0ODEyNDEsInN1YiI6ImFkbWluIiwiYXpwIjoid3I5SllVaDNtTXd6bVh
 HVllqWmVIWnhCV2xFYSIsImFwcElkIjoic2luZ2xlX2dyb3VwX3YxIiwiYXVkIjpbIndyOUpZVWgzbU13em1YR1ZZalplSFp4QldsRWEiXSwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5NDQzXC9vYXV0aDJlbmRwb2ludHNcL3Rva2VuIiwiaWF0IjotODcyNDgwMjQwfQ.OSa1gIXUT9amhk1YEU02Yc3JtUYqanzrXh5K1YyvRXcpSiY2Ccn2BfJO0hILF5UooRcGBihzfX3979NRcvGwcUDUvOUJ0eaGPmxFZYbu0nr3xD8lhAO3fa1QYsKAvMnMdwyu2uSgSp6R6EUdVleiwlabUoDsuEcKGkIAn_VQvG0,UID=0,_=posix,LVS_VIRTUAL_IP=192.168.0.40|255.255.255.0


[4/9] stratos git commit: adding a ServerLogClient class and using it to read BE logs

Posted by is...@apache.org.
adding a ServerLogClient class and using it to read BE logs


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/22ac8e25
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/22ac8e25
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/22ac8e25

Branch: refs/heads/stratos-4.1.x
Commit: 22ac8e2585348f1b1293e3dfd474a1c266a93c36
Parents: 28e65f2
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Fri Nov 20 17:06:35 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:12 2015 +0530

----------------------------------------------------------------------
 .../integration/common/ServerLogClient.java     | 101 ++++++++++++++++
 .../common/StratosTestServerManager.java        |  16 ---
 .../tests/StratosIntegrationTest.java           |   2 -
 .../tests/other/IaasProviderAttributeTest.java  | 116 ++++++++++---------
 .../cartridge-iaasprovider-attribute-test.json  |   4 -
 .../src/test/resources/common/log4j.properties  |  19 ++-
 6 files changed, 176 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/22ac8e25/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
new file mode 100644
index 0000000..2ac6ce9
--- /dev/null
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/ServerLogClient.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.common;
+
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.automation.engine.context.AutomationContext;
+import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
+import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
+
+import javax.xml.xpath.XPathExpressionException;
+
+public class ServerLogClient {
+
+    private static final Log log = LogFactory.getLog(ServerLogClient.class);
+    private LogViewerClient logViewerClient;
+    private AutomationContext automationContext;
+
+    public ServerLogClient () throws AutomationUtilException {
+        createAutomationContext();
+        createlogViewerClient(getBackEndUrl(), getUsername(), getPassword());
+    }
+
+    public ServerLogClient (String backEndUrl, String username, String password) throws
+            AutomationUtilException {
+        createlogViewerClient(backEndUrl, username, password);
+    }
+
+    private void createlogViewerClient(String backEndUrl, String username, String password) throws AutomationUtilException {
+        try {
+            logViewerClient = new LogViewerClient(backEndUrl, username, password);
+        } catch (AxisFault e) {
+            String errorMsg = "Error in creating LogViewerClient";
+            log.error(errorMsg, e);
+            throw new AutomationUtilException(errorMsg, e);
+        }
+    }
+
+    private void createAutomationContext() throws AutomationUtilException {
+        try {
+            automationContext = new AutomationContext();
+        } catch (XPathExpressionException e) {
+            String errorMsg = "Error in creating AutomationContext";
+            log.error(errorMsg, e);
+            throw new AutomationUtilException(errorMsg, e);
+        }
+    }
+
+    private String getBackEndUrl () throws AutomationUtilException {
+        try {
+            return automationContext.getContextUrls().getBackEndUrl();
+        } catch (XPathExpressionException e) {
+            String errorMsg = "Error in getting beck end URL";
+            log.error(errorMsg, e);
+            throw new AutomationUtilException(errorMsg, e);
+        }
+    }
+
+    private String getUsername () throws AutomationUtilException {
+        try {
+            return automationContext.getSuperTenant().getTenantAdmin().getUserName();
+        } catch (XPathExpressionException e) {
+            String errorMsg = "Error in getting super tenant username";
+            log.error(errorMsg, e);
+            throw new AutomationUtilException(errorMsg, e);
+        }
+    }
+
+    private String getPassword () throws AutomationUtilException {
+        try {
+            return automationContext.getSuperTenant().getTenantAdmin().getPassword();
+        } catch (XPathExpressionException e) {
+            String errorMsg = "Error in getting super tenant password";
+            log.error(errorMsg, e);
+            throw new AutomationUtilException(errorMsg, e);
+        }
+    }
+
+
+    public LogViewerClient getLogViewerClient () {
+        return logViewerClient;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/22ac8e25/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
index e5bb7f8..d2db900 100644
--- a/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
+++ b/products/stratos/modules/integration/test-common/src/main/java/org/apache/stratos/integration/common/StratosTestServerManager.java
@@ -263,14 +263,6 @@ public class StratosTestServerManager extends TestServerManager {
     public void setWebAppURLHttps(String webAppURLHttps) {
         this.webAppURLHttps = webAppURLHttps;
     }
-
-    public ServerLogReader getLogReader () {
-        return ((StratosServerManager)carbonServer).getInputLogStreamReader();
-    }
-
-    public ServerLogReader getErrorLogReader () {
-        return ((StratosServerManager)carbonServer).getErrorStreamReader();
-    }
 }
 
 // TODO: get rid of this class once startup script issue is fixed in automation engine
@@ -628,12 +620,4 @@ class StratosServerManager extends CarbonServerManager {
         }
 
     }
-
-    public ServerLogReader getInputLogStreamReader () {
-        return inputStreamHandler;
-    }
-
-    public ServerLogReader getErrorStreamReader () {
-        return errorStreamHandler;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/22ac8e25/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
index 3983835..5b397ab 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/StratosIntegrationTest.java
@@ -39,7 +39,6 @@ public class StratosIntegrationTest {
     protected MockIaasApiClient mockIaasApiClient;
     public static final int GLOBAL_TEST_TIMEOUT = 5 * 60 * 1000; // 5 mins
     public static final int APPLICATION_TEST_TIMEOUT = 20 * 60 * 1000; // 20 mins
-    protected StratosTestServerManager stratosTestServerManager;
 
     public StratosIntegrationTest() {
         try {
@@ -54,7 +53,6 @@ public class StratosIntegrationTest {
             stratosSecuredBackendURL = StratosServerExtension.getStratosTestServerManager().getWebAppURLHttps();
             restClient = new RestClient(stratosBackendURL, stratosSecuredBackendURL, adminUsername, adminPassword);
             mockIaasApiClient = new MockIaasApiClient(stratosBackendURL + "/mock-iaas/api");
-            stratosTestServerManager = StratosServerExtension.getStratosTestServerManager();
             // initialize topology handler before running the tests
             TopologyHandler.getInstance();
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/22ac8e25/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
index 70b089b..1f7b042 100644
--- a/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
+++ b/products/stratos/modules/integration/test-integration/src/test/java/org/apache/stratos/integration/tests/other/IaasProviderAttributeTest.java
@@ -25,10 +25,12 @@ import org.apache.stratos.common.beans.application.ApplicationBean;
 import org.apache.stratos.common.beans.cartridge.CartridgeBean;
 import org.apache.stratos.common.beans.cartridge.IaasProviderBean;
 import org.apache.stratos.integration.common.RestConstants;
+import org.apache.stratos.integration.common.ServerLogClient;
 import org.apache.stratos.integration.common.TopologyHandler;
 import org.apache.stratos.integration.tests.StratosIntegrationTest;
 import org.apache.stratos.messaging.domain.application.ApplicationStatus;
 import org.testng.annotations.Test;
+import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
 
 import java.util.List;
 
@@ -50,7 +52,7 @@ public class IaasProviderAttributeTest extends StratosIntegrationTest {
     private static final String APPLICATION = "app-iaasprovider-attribute-test";
 
     @Test(timeOut = GLOBAL_TEST_TIMEOUT, groups = {"stratos.cartridge.iaas.attributes", "all"})
-    public void testIaasProviderAttributesForDefaultCartridge () throws Exception {
+    public void testIaasProviderAttributes () throws Exception {
 
         // add autoscaling policy
         log.info("Adding autoscaling policy [autoscale policy id] " + AUTOSCALING_POLICY);
@@ -118,66 +120,70 @@ public class IaasProviderAttributeTest extends StratosIntegrationTest {
 
         TopologyHandler topologyHandler = TopologyHandler.getInstance();
 
-        long time = System.currentTimeMillis() + 300000L;
+        log.info("Waiting for application status to become ACTIVE...");
+        topologyHandler.assertApplicationStatus(applicationBean.getApplicationId(), ApplicationStatus.Active);
 
+        // create a ServerLogClientInstance and get logs
         boolean found = false;
-        while (System.currentTimeMillis() < time) {
-            if (!stratosTestServerManager.getLogReader().getOutput().contains("cc_property_value_1")
-                    && stratosTestServerManager.getLogReader().getOutput().contains("cartridge_property_value_1")) {
-                found = true;
-                break;
+        ServerLogClient serverLogClient = new ServerLogClient(stratosSecuredBackendURL + "/services/",
+                adminUsername,
+                adminPassword);
+        LogEvent [] logEvents = serverLogClient.getLogViewerClient().getAllRemoteSystemLogs();
+        if (logEvents.length > 0) {
+            for (int i = 0; i < logEvents.length; i++) {
+                if (!logEvents[i].getMessage().contains("cartridge_property_value_1") &&
+                logEvents[i].getMessage().contains("cc_property_value_1")) {
+                    found = true;
+                    break;
+                }
             }
         }
 
-        assertTrue("Property 'property1' not found | value not equal to 'cartridge_property_value_1'", found);
+        assertTrue("Property 'property1' not found | value not equal to 'cc_property_value_1'", found);
+
+        // undeploy application
+        log.info("Un-deploying the application [application id] app-iaasprovider-attribute-test");
+        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+                RestConstants.APPLICATIONS_UNDEPLOY;
+
+        boolean undeployedApp = restClient.undeployEntity(resourcePathUndeploy, RestConstants
+                .APPLICATIONS_NAME);
+        assertTrue(undeployedApp);
+        log.info("Undeployed application 'app-iaasprovider-attribute-test'");
+
+        // force undeploy to make sure its undeployed
+        log.info("Force undeployment is going to start for the [application] app-iaasprovider-attribute-test");
+        restClient.undeployEntity(RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+                RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+        boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("app-iaasprovider-attribute-test");
+        assertTrue(String.format("Forceful undeployment failed for the application %s",
+                "app-iaasprovider-attribute-test"), forceUndeployed);
 
-//        log.info("Waiting for application status to become ACTIVE...");
-//        topologyHandler.assertApplicationStatus(applicationBean.getApplicationId(),
-//                ApplicationStatus.Active);
-//
-//        // undeploy application
-//        log.info("Un-deploying the application [application id] app-iaasprovider-attribute-test");
-//        String resourcePathUndeploy = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
-//                RestConstants.APPLICATIONS_UNDEPLOY;
-//
-//        boolean undeployedApp = restClient.undeployEntity(resourcePathUndeploy, RestConstants
-//                .APPLICATIONS_NAME);
-//        assertTrue(undeployedApp);
-//        log.info("Undeployed application 'app-iaasprovider-attribute-test'");
-//
-//        // force undeploy to make sure its undeployed
-//        log.info("Force undeployment is going to start for the [application] app-iaasprovider-attribute-test");
-//        restClient.undeployEntity(RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
-//                RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
-//
-//        boolean forceUndeployed = topologyHandler.assertApplicationUndeploy("app-iaasprovider-attribute-test");
-//        assertTrue(String.format("Forceful undeployment failed for the application %s",
-//                "app-iaasprovider-attribute-test"), forceUndeployed);
-//
-//        // update cartridge
-//        boolean updated = restClient.updateEntity(RESOURCES_PATH + "/cartridges/" + UPDATED_CARTRIDGE + ".json",
-//                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
-//        assertTrue(updated);
-//        log.info("Updated cartridge 'cartridge-iaasprovider-attribute-test'");
-//
-//        // re-deplpoy the application
-//        resourcePath = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
-//                RestConstants.APPLICATIONS_DEPLOY + "/" + APPLICATION_POLICY;
-//        appDeployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
-//        assertTrue(appDeployed);
-//        log.info("Re-deployed application 'app-iaasprovider-attribute-test'");
-//
-//        time = System.currentTimeMillis() + 300000L;
-//
-//        found = false;
-//        while (System.currentTimeMillis() < time) {
-//            if (stratosTestServerManager.getLogReader().getOutput().contains("cartridge_property_value_1")) {
-//                found = true;
-//                break;
-//            }
-//        }
-//
-//        assertTrue("Property 'property1' not found | value not equal to 'cartridge_property_value_1'", found);
+        // update cartridge
+        boolean updated = restClient.updateEntity(RESOURCES_PATH + "/cartridges/" + UPDATED_CARTRIDGE + ".json",
+                RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+        assertTrue(updated);
+        log.info("Updated cartridge 'cartridge-iaasprovider-attribute-test'");
+
+        // re-deplpoy the application
+        resourcePath = RestConstants.APPLICATIONS + "/app-iaasprovider-attribute-test" +
+                RestConstants.APPLICATIONS_DEPLOY + "/" + APPLICATION_POLICY;
+        appDeployed = restClient.deployEntity(resourcePath, RestConstants.APPLICATIONS_NAME);
+        assertTrue(appDeployed);
+        log.info("Re-deployed application 'app-iaasprovider-attribute-test'");
+
+        logEvents = serverLogClient.getLogViewerClient().getAllRemoteSystemLogs();
+        if (logEvents.length > 0) {
+            for (int i = 0; i < logEvents.length; i++) {
+                if (logEvents[i].getMessage().contains("cartridge_property_value_1")) {
+                    found = true;
+                    break;
+                }
+            }
+        }
+
+        assertTrue("Property 'property1' not found | value not equal to 'cartridge_property_value_1'", found);
 
         terminateAndRemoveAllArtifacts();
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/22ac8e25/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
index f9f883b..f819974 100644
--- a/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/cartridge-iaas-attribute-test/cartridges/cartridge-iaasprovider-attribute-test.json
@@ -23,10 +23,6 @@
         {
           "name":"tag:Name",
           "value":"WSO2 PPaaS Default Server"
-        },
-        {
-          "name":"property1",
-          "value":"cartridge_property_value_1"
         }
       ]
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/22ac8e25/products/stratos/modules/integration/test-integration/src/test/resources/common/log4j.properties
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/test-integration/src/test/resources/common/log4j.properties b/products/stratos/modules/integration/test-integration/src/test/resources/common/log4j.properties
index b99dd63..2d49c47 100644
--- a/products/stratos/modules/integration/test-integration/src/test/resources/common/log4j.properties
+++ b/products/stratos/modules/integration/test-integration/src/test/resources/common/log4j.properties
@@ -115,14 +115,23 @@ log4j.appender.CARBON_CONSOLE.layout.TenantPattern=%U%@%D[%T]
 log4j.appender.CARBON_CONSOLE.threshold=DEBUG
 
 # CARBON_MEMORY is set to be a MemoryAppender using a PatternLayout.
-log4j.appender.CARBON_MEMORY=org.wso2.carbon.logging.appenders.MemoryAppender
-log4j.appender.CARBON_MEMORY.layout=org.apache.log4j.PatternLayout
-log4j.appender.CARBON_MEMORY.bufferSize=200
+#log4j.appender.CARBON_MEMORY=org.wso2.carbon.logging.appenders.MemoryAppender
+#log4j.appender.CARBON_MEMORY.layout=org.apache.log4j.PatternLayout
+#log4j.appender.CARBON_MEMORY.bufferSize=200
 # ConversionPattern will be overridden by the configuration setting in the DB
 #log4j.appender.CARBON_MEMORY.layout.ConversionPattern=[%d] %5p - %x %m {%c}%n
-log4j.appender.CARBON_MEMORY.layout.ConversionPattern=[%d] %5p {%c} - %x %m%n
-log4j.appender.CARBON_MEMORY.threshold=DEBUG
+#log4j.appender.CARBON_MEMORY.layout.ConversionPattern=[%d] %5p {%c} - %x %m%n
+#log4j.appender.CARBON_MEMORY.threshold=DEBUG
 
+# CARBON_MEMORY is set to be a MemoryAppender using a PatternLayout.
+log4j.appender.CARBON_MEMORY=org.wso2.carbon.logging.appender.CarbonMemoryAppender
+log4j.appender.CARBON_MEMORY.bufferSize=2000
+log4j.appender.CARBON_MEMORY.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
+# ConversionPattern will be overridden by the configuration setting in the DB
+log4j.appender.CARBON_MEMORY.layout.ConversionPattern=TID: [%T] [%S] [%d] %P%5p {%c} - %x %m {%c}%n
+log4j.appender.CARBON_MEMORY.layout.TenantPattern=%U%@%D [%T] [%S]
+log4j.appender.CARBON_MEMORY.columnList=%T,%S,%A,%d,%c,%p,%m,%H,%I,%Stacktrace
+log4j.appender.CARBON_MEMORY.threshold=DEBUG
 
 # CARBON_LOGFILE is set to be a DailyRollingFileAppender using a PatternLayout.
 log4j.appender.CARBON_LOGFILE=org.apache.log4j.RollingFileAppender


[9/9] stratos git commit: Merge branch 'stratos-4.1.x' of https://git-wip-us.apache.org/repos/asf/stratos into stratos-4.1.x

Posted by is...@apache.org.
Merge branch 'stratos-4.1.x' of https://git-wip-us.apache.org/repos/asf/stratos into stratos-4.1.x


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/999f0f25
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/999f0f25
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/999f0f25

Branch: refs/heads/stratos-4.1.x
Commit: 999f0f25f63cff543a50837dbcdbcd941b34c7b3
Parents: a121351 196ffcc
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Sat Nov 21 15:58:50 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 15:58:50 2015 +0530

----------------------------------------------------------------------

----------------------------------------------------------------------