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 10:58:52 UTC
[1/5] stratos git commit: integration test for TFLDEV-41
Repository: stratos
Updated Branches:
refs/heads/stratos-4.1.x 540111794 -> 196ffcc10
integration test for TFLDEV-41
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/8b21208d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/8b21208d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/8b21208d
Branch: refs/heads/stratos-4.1.x
Commit: 8b21208de60c6b45dde6d7cbcc54c658b9c4c52d
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 10:34:09 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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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/8b21208d/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
[5/5] 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/196ffcc1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/196ffcc1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/196ffcc1
Branch: refs/heads/stratos-4.1.x
Commit: 196ffcc10c2101a0c7475ec3a836873bcc8fffda
Parents: 4a25072 5401117
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Sat Nov 21 14:52:28 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 14:52:28 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(-)
----------------------------------------------------------------------
[3/5] stratos git commit: changes for integration tests - TFLDEV-41
Posted by is...@apache.org.
changes for integration tests - TFLDEV-41
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/f2830962
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/f2830962
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/f2830962
Branch: refs/heads/stratos-4.1.x
Commit: f2830962cb6b9277a22941b7faacbe410d9d0cdd
Parents: 932ec49
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 10:35:28 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/f2830962/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/f2830962/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();
}
[2/5] 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/932ec493
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/932ec493
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/932ec493
Branch: refs/heads/stratos-4.1.x
Commit: 932ec493851f5751f4d7f62eba6ec55977c39a90
Parents: 8b21208
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 10:35:11 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/932ec493/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/932ec493/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/932ec493/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/932ec493/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/932ec493/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/932ec493/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
[4/5] 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/4a250721
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4a250721
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4a250721
Branch: refs/heads/stratos-4.1.x
Commit: 4a250721b8a06e703e545a6322416c4eb53193fb
Parents: f283096 1ed041d
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Sat Nov 21 12:38:45 2015 +0530
Committer: Isuru Haththotuwa <is...@apache.org>
Committed: Sat Nov 21 12:38:45 2015 +0530
----------------------------------------------------------------------
.../modules/event/eventhandler.py | 18 +-
.../cartridge.agent/publisher.py | 17 +-
.../tests/ADCMTAppTenantUserTestCase.java | 4 +-
.../integration/tests/ADCMTAppTestCase.java | 5 +-
.../agent/integration/tests/ADCTestCase.java | 2 +-
.../integration/tests/AgentStartupTestCase.java | 2 +-
.../integration/tests/CEPHAModeTestCase.java | 2 +-
.../tests/MessageBrokerHATestCase.java | 210 +++++++++----------
.../tests/PythonAgentIntegrationTest.java | 89 ++++----
.../MessageBrokerHATestCase/agent.conf | 10 +-
.../MessageBrokerHATestCase/jndi.properties | 4 +-
.../payload/launch-params | 2 +-
.../src/test/resources/log4j.properties | 55 +++++
13 files changed, 225 insertions(+), 195 deletions(-)
----------------------------------------------------------------------