Fixing Stratos hanging at integration tests issue
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c9de1b2b Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c9de1b2b Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c9de1b2b Branch: refs/heads/master Commit: c9de1b2b084ebba700b51afa1863b9f9b2612df7 Parents: 93960ed Author: Akila Perera <[email protected]> Authored: Wed Sep 2 00:18:16 2015 +0530 Committer: Akila Perera <[email protected]> Committed: Wed Sep 2 11:30:23 2015 +0530 ---------------------------------------------------------------------- .../modules/distribution/src/assembly/bin.xml | 2 +- products/stratos/modules/integration/pom.xml | 13 +- .../tests/StratosTestServerManager.java | 134 +++++--- .../application/ApplicationBurstingTest.java | 72 +++-- .../src/test/resources/JMSOutputAdaptor.xml | 30 -- .../test/resources/common/JMSOutputAdaptor.xml | 30 ++ .../src/test/resources/common/jndi.properties | 22 ++ .../src/test/resources/common/log4j.properties | 206 ++++++++++++ .../src/test/resources/common/mock-iaas.xml | 123 ++++++++ .../src/test/resources/common/scaling.drl | 311 +++++++++++++++++++ .../src/test/resources/jndi.properties | 22 -- .../src/test/resources/mock-iaas.xml | 123 -------- .../integration/src/test/resources/scaling.drl | 311 ------------------- .../test-conf/integration-test.properties | 6 +- 14 files changed, 841 insertions(+), 564 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/distribution/src/assembly/bin.xml ---------------------------------------------------------------------- diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml index 8349917..64c5b3e 100755 --- a/products/stratos/modules/distribution/src/assembly/bin.xml +++ b/products/stratos/modules/distribution/src/assembly/bin.xml @@ -435,7 +435,7 @@ <!-- cep --> <!--creating an empty input event adaptors directory--> <fileSet> - <directory>../../../../extensions/modules/cep/artifacts/inputeventadaptors</directory> + <directory>../../../../extensions/cep/modules/artifacts/inputeventadaptors</directory> <outputDirectory>${stratos.distribution.name}-${project.version}/repository/deployment/server/inputeventadaptors </outputDirectory> </fileSet> http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/pom.xml ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/pom.xml b/products/stratos/modules/integration/pom.xml index 5475846..7020370 100755 --- a/products/stratos/modules/integration/pom.xml +++ b/products/stratos/modules/integration/pom.xml @@ -117,6 +117,17 @@ <filtering>true</filtering> </resource> </resources> + <testResources> + <testResource> + <directory>src/test/resources/common</directory> + <includes> + <include>**/jndi.properties</include> + </includes> + </testResource> + <testResource> + <directory>src/test/resources</directory> + </testResource> + </testResources> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> @@ -178,4 +189,4 @@ </plugin> </plugins> </build> -</project> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java index a03cc54..84ef2c3 100755 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java @@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.stratos.common.test.TestLogAppender; -import org.apache.stratos.integration.tests.application.SampleApplicationsTest; import org.apache.stratos.integration.tests.rest.IntegrationMockClient; import org.apache.stratos.integration.tests.rest.RestClient; import org.apache.stratos.messaging.domain.tenant.Tenant; @@ -41,6 +40,7 @@ import org.wso2.carbon.integration.framework.utils.TestUtil; import java.io.File; import java.io.IOException; import java.net.URL; +import java.util.Properties; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -49,44 +49,80 @@ import static org.testng.Assert.assertNotNull; * Prepare activemq, Stratos server for tests, enables mock iaas, starts servers and stop them after the tests. */ public class StratosTestServerManager extends TestServerManager { - private static final Log log = LogFactory.getLog(StratosTestServerManager.class); + private static Properties integrationProperties; + public static final String BASE_PATH = StratosTestServerManager.class.getResource("/").getPath(); + public static final String STRATOS_DISTRIBUTION_NAME = "distribution.path"; + public final static String PORT_OFFSET = "carbon.port.offset"; + public static final String ACTIVEMQ_BIND_ADDRESS = "activemq.bind.address"; + public static final String STRATOS_ENDPOINT = "stratos.endpoint"; + public static final String ADMIN_USERNAME = "stratos.admin.username"; + public static final String ADMIN_PASSWORD = "stratos.admin.password"; + private static final String TENANT1_USER_NAME = "stratos.tenant1.username"; + private static final String TENANT1_PASSWD = "stratos.tenant1.password"; + private static final String TENANT2_USER_NAME = "stratos.tenant2.username"; + private static final String TENANT2_PASSWD = "stratos.tenant2.password"; + public static final String MOCK_IAAS_XML_FILE = "mock-iaas.xml"; + public static final String SCALING_DROOL_FILE = "scaling.drl"; + public static final String JNDI_PROPERTIES_FILE = "jndi.properties"; + public static final String JMS_OUTPUT_ADAPTER_FILE = "JMSOutputAdaptor.xml"; - private final static String CARBON_ZIP = SampleApplicationsTest.class.getResource("/").getPath() + - "/../../../distribution/target/apache-stratos-4.2.0-SNAPSHOT.zip"; - private final static int PORT_OFFSET = 0; - private static final String ACTIVEMQ_BIND_ADDRESS = "tcp://localhost:61617"; - private static final String MOCK_IAAS_XML_FILE = "mock-iaas.xml"; - private static final String JNDI_PROPERTIES_FILE = "jndi.properties"; - private static final String JMS_OUTPUT_ADAPTER_FILE = "JMSOutputAdaptor.xml"; - private static final String SUPER_ADMIN_USERNAME = "admin"; - private static final String SUPER_ADMIN_PASSWD = "admin"; - private static final String TENANT1_USER_NAME = "[email protected]"; - private static final String TENANT1_PASSWD = "admin123"; - private static final String TENANT2_USER_NAME = "[email protected]"; - private static final String TENANT2_PASSWD = "admin123"; - + protected String distributionName; + protected int portOffset; + protected String adminUsername; + protected String adminPassword; + protected String tenant1UserName; + protected String tenant1Password; + protected String tenant2UserName; + protected String tenant2Password; + protected String stratosEndpoint; + protected String activemqBindAddress; protected RestClient restClientAdmin; - protected RestClient restClientTenant1; - protected RestClient restClientTenant2; - private String endpoint = "http://localhost:9763"; - private BrokerService broker = new BrokerService(); private TestLogAppender testLogAppender = new TestLogAppender(); private ServerUtils serverUtils; private String carbonHome; protected IntegrationMockClient mockIaasApiClient; + protected RestClient restClientTenant1; + protected RestClient restClientTenant2; protected int tenant1Id; protected int tenant2Id; public StratosTestServerManager() { - super(CARBON_ZIP, PORT_OFFSET); + super(BASE_PATH + getIntegrationTestProperty(STRATOS_DISTRIBUTION_NAME), + Integer.parseInt(getIntegrationTestProperty(PORT_OFFSET))); + + distributionName = integrationProperties.getProperty(STRATOS_DISTRIBUTION_NAME); + portOffset = Integer.parseInt(integrationProperties.getProperty(PORT_OFFSET)); + adminUsername = integrationProperties.getProperty(ADMIN_USERNAME); + adminPassword = integrationProperties.getProperty(ADMIN_PASSWORD); + tenant1UserName = integrationProperties.getProperty(TENANT1_USER_NAME); + tenant1Password = integrationProperties.getProperty(TENANT1_PASSWD); + tenant2UserName = integrationProperties.getProperty(TENANT2_USER_NAME); + tenant2Password = integrationProperties.getProperty(TENANT2_PASSWD); + stratosEndpoint = integrationProperties.getProperty(STRATOS_ENDPOINT); + activemqBindAddress = integrationProperties.getProperty(ACTIVEMQ_BIND_ADDRESS); serverUtils = new ServerUtils(); - restClientAdmin=new RestClient(endpoint, SUPER_ADMIN_USERNAME, SUPER_ADMIN_PASSWD); - restClientTenant1 = new RestClient(endpoint, TENANT1_USER_NAME, TENANT1_PASSWD); - restClientTenant2 = new RestClient(endpoint, TENANT2_USER_NAME, TENANT2_PASSWD); - mockIaasApiClient = new IntegrationMockClient(endpoint + "/mock-iaas/api"); + mockIaasApiClient = new IntegrationMockClient(stratosEndpoint + "/mock-iaas/api"); + restClientAdmin = new RestClient(stratosEndpoint, adminUsername, adminPassword); + restClientTenant1 = new RestClient(stratosEndpoint, tenant1UserName, tenant1Password); + restClientTenant2 = new RestClient(stratosEndpoint, tenant2UserName, tenant2Password); + } + private static String getIntegrationTestProperty(String key) { + if (integrationProperties == null) { + integrationProperties = new Properties(); + try { + integrationProperties + .load(StratosTestServerManager.class.getResourceAsStream("/integration-test.properties")); + log.info("Stratos integration properties: " + integrationProperties.toString()); + } + catch (IOException e) { + log.error("Error loading integration-test.properties file from classpath. Please make sure that file " + + "exists in classpath.", e); + } + } + return integrationProperties.getProperty(key); } @Override @@ -102,7 +138,7 @@ public class StratosTestServerManager extends TestServerManager { broker.setDataDirectory(StratosTestServerManager.class.getResource("/").getPath() + File.separator + ".." + File.separator + "activemq-data"); broker.setBrokerName("testBroker"); - broker.addConnector(ACTIVEMQ_BIND_ADDRESS); + broker.addConnector(activemqBindAddress); broker.start(); long time2 = System.currentTimeMillis(); log.info(String.format("ActiveMQ started in %d sec", (time2 - time1) / 1000)); @@ -128,7 +164,7 @@ public class StratosTestServerManager extends TestServerManager { log.info("Stratos server setup completed"); log.info("Starting Stratos server..."); - this.serverUtils.startServerUsingCarbonHome(carbonHome, carbonHome, "stratos", PORT_OFFSET, null); + this.serverUtils.startServerUsingCarbonHome(carbonHome, carbonHome, "stratos", portOffset, null); FrameworkSettings.init(); while (!serverStarted()) { @@ -143,7 +179,7 @@ public class StratosTestServerManager extends TestServerManager { long time4 = System.currentTimeMillis(); log.info(String.format("Stratos server started in %d sec", (time4 - time3) / 1000)); - tenantCreation(); + createTenants(); return carbonHome; } } @@ -152,6 +188,29 @@ public class StratosTestServerManager extends TestServerManager { } } + private void createTenants() { + log.info("Added tenants to the testing suit"); + boolean addedTenant1 = restClientAdmin + .addEntity(RestConstants.TENANT1_RESOURCE, RestConstants.TENANT_API, RestConstants.TENANTS_NAME); + assertEquals(addedTenant1, true); + boolean addedTenant2 = restClientAdmin + .addEntity(RestConstants.TENANT2_RESOURCE, RestConstants.TENANT_API, RestConstants.TENANTS_NAME); + assertEquals(addedTenant2, true); + } + + + @BeforeClass + public void getTenantDetails() { + Tenant tenant1 = (Tenant) restClientAdmin + .getEntity(RestConstants.TENANT_API, RestConstants.TENANT1_GET_RESOURCE, Tenant.class, + RestConstants.TENANTS_NAME); + tenant1Id = tenant1.getTenantId(); + Tenant tenant2 = (Tenant) restClientAdmin + .getEntity(RestConstants.TENANT_API, RestConstants.TENANT2_GET_RESOURCE, Tenant.class, + RestConstants.TENANTS_NAME); + tenant2Id = tenant2.getTenantId(); + } + private boolean mockServiceStarted() { for (String message : testLogAppender.getMessages()) { if (message.contains("Mock IaaS service component activated")) { @@ -179,6 +238,7 @@ public class StratosTestServerManager extends TestServerManager { protected void copyArtifacts(String carbonHome) throws IOException { copyConfigFile(carbonHome, MOCK_IAAS_XML_FILE); copyConfigFile(carbonHome, JNDI_PROPERTIES_FILE); + copyConfigFile(carbonHome, SCALING_DROOL_FILE, "repository/conf/drools"); copyConfigFile(carbonHome, JMS_OUTPUT_ADAPTER_FILE, "repository/deployment/server/outputeventadaptors"); } @@ -214,22 +274,4 @@ public class StratosTestServerManager extends TestServerManager { } return false; } - - - private void tenantCreation(){ - log.info("Added tenants to the testing suit"); - boolean addedTenant1=restClientAdmin.addEntity(RestConstants.TENANT1_RESOURCE,RestConstants.TENANT_API,RestConstants.TENANTS_NAME); - assertEquals(addedTenant1,true); - boolean addedTenant2=restClientAdmin.addEntity(RestConstants.TENANT2_RESOURCE,RestConstants.TENANT_API,RestConstants.TENANTS_NAME); - assertEquals(addedTenant2,true); - - } - - @BeforeClass - public void getTenantDetails(){ - Tenant tenant1=(Tenant)restClientAdmin.getEntity(RestConstants.TENANT_API,RestConstants.TENANT1_GET_RESOURCE,Tenant.class,RestConstants.TENANTS_NAME); - tenant1Id=tenant1.getTenantId(); - Tenant tenant2=(Tenant)restClientAdmin.getEntity(RestConstants.TENANT_API,RestConstants.TENANT2_GET_RESOURCE,Tenant.class,RestConstants.TENANTS_NAME); - tenant2Id=tenant2.getTenantId(); - } } http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java index 4ff15ba..f210b12 100644 --- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java +++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java @@ -43,24 +43,28 @@ public class ApplicationBurstingTest extends StratosTestServerManager { @Test public void testApplicationBusting() { try { - log.info("-------------------------------Started application Bursting test case-------------------------------"); + log.info("----------------------------Started application Bursting test case----------------------------"); String autoscalingPolicyId = "autoscaling-policy-application-bursting-test"; - boolean addedScalingPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH - + "/" + autoscalingPolicyId + ".json", - RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); + boolean addedScalingPolicy = + restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.AUTOSCALING_POLICIES_PATH + + "/" + autoscalingPolicyId + ".json", + RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME); assertEquals(addedScalingPolicy, true); - boolean addedC1 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb-application-bursting-test.json", + boolean addedC1 = restClientTenant1.addEntity( + RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb-application-bursting-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertEquals(addedC1, true); - boolean addedC2 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json", + boolean addedC2 = restClientTenant1.addEntity( + RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php-application-bursting-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertEquals(addedC2, true); - boolean addedC3 = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json", + boolean addedC3 = restClientTenant1.addEntity( + RESOURCES_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat-application-bursting-test.json", RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME); assertEquals(addedC3, true); @@ -84,9 +88,10 @@ public class ApplicationBurstingTest extends StratosTestServerManager { RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME); assertEquals(addedN2, true); - boolean addedDep = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + - "deployment-policy-application-bursting-test.json", - RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); + boolean addedDep = + restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" + + "deployment-policy-application-bursting-test.json", + RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME); assertEquals(addedDep, true); boolean added = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATIONS_PATH + "/" + @@ -98,9 +103,11 @@ public class ApplicationBurstingTest extends StratosTestServerManager { "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); assertEquals(bean.getApplicationId(), "application-bursting-test"); - boolean addAppPolicy = restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + - "application-policy-application-bursting-test.json", RestConstants.APPLICATION_POLICIES, - RestConstants.APPLICATION_POLICIES_NAME); + boolean addAppPolicy = + restClientTenant1.addEntity(RESOURCES_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" + + "application-policy-application-bursting-test.json", + RestConstants.APPLICATION_POLICIES, + RestConstants.APPLICATION_POLICIES_NAME); assertEquals(addAppPolicy, true); ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClientTenant1.getEntity( @@ -125,8 +132,9 @@ public class ApplicationBurstingTest extends StratosTestServerManager { //Cluster active handling TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), tenant1Id); - boolean removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - RestConstants.CARTRIDGE_GROUPS_NAME); + boolean removedGroup = restClientTenant1 + .removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", + RestConstants.CARTRIDGE_GROUPS_NAME); assertEquals(removedGroup, false); boolean removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, @@ -151,7 +159,8 @@ public class ApplicationBurstingTest extends StratosTestServerManager { RestConstants.APPLICATIONS_NAME); assertEquals(unDeployed, true); - boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", tenant1Id); + boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", + tenant1Id); if (!undeploy) { //Need to forcefully undeploy the application log.info("Force undeployment is going to start for the [application] " + "application-bursting-test"); @@ -159,7 +168,8 @@ public class ApplicationBurstingTest extends StratosTestServerManager { restClientTenant1.undeployEntity(RestConstants.APPLICATIONS + "/" + "application-bursting-test" + RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS); - boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("application-bursting-test", tenant1Id); + boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy( + "application-bursting-test", tenant1Id); assertEquals(String.format("Forceful undeployment failed for the application %s", "application-bursting-test"), forceUndeployed, true); @@ -173,20 +183,24 @@ public class ApplicationBurstingTest extends StratosTestServerManager { "application-bursting-test", ApplicationBean.class, RestConstants.APPLICATIONS_NAME); assertEquals(beanRemoved, null); - removedGroup = restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", - RestConstants.CARTRIDGE_GROUPS_NAME); + removedGroup = restClientTenant1 + .removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group-application-bursting-test", + RestConstants.CARTRIDGE_GROUPS_NAME); assertEquals(removedGroup, true); - boolean removedC1 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test", - RestConstants.CARTRIDGES_NAME); + boolean removedC1 = + restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "esb-application-bursting-test", + RestConstants.CARTRIDGES_NAME); assertEquals(removedC1, true); - boolean removedC2 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test", - RestConstants.CARTRIDGES_NAME); + boolean removedC2 = + restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "php-application-bursting-test", + RestConstants.CARTRIDGES_NAME); assertEquals(removedC2, true); - boolean removedC3 = restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test", - RestConstants.CARTRIDGES_NAME); + boolean removedC3 = + restClientTenant1.removeEntity(RestConstants.CARTRIDGES, "tomcat-application-bursting-test", + RestConstants.CARTRIDGES_NAME); assertEquals(removedC3, true); removedAuto = restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES, @@ -217,12 +231,12 @@ public class ApplicationBurstingTest extends StratosTestServerManager { "network-partition-application-bursting-test-2", RestConstants.NETWORK_PARTITIONS_NAME); assertEquals(removedN2, true); - log.info("-------------------------------Ended application bursting test case-------------------------------"); + log.info("----------------------------Ended application bursting test case----------------------------"); - } catch (Exception e) { + } + catch (Exception e) { log.error("An error occurred while handling application bursting", e); assertTrue("An error occurred while handling application bursting", false); } } -} - +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml b/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml deleted file mode 100755 index a6a2cff..0000000 --- a/products/stratos/modules/integration/src/test/resources/JMSOutputAdaptor.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. - ---> - -<outputEventAdaptor name="JMSOutputAdaptor" statistics="disable" - trace="enable" type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager"> - <!--property name="java.naming.provider.url">CEP_HOME/repository/conf/jndi.properties</property--> - <property name="java.naming.provider.url">tcp://localhost:61617</property> - <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property> - <property name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</property> - <property name="transport.jms.DestinationType">topic</property> -</outputEventAdaptor> http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/common/JMSOutputAdaptor.xml ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/common/JMSOutputAdaptor.xml b/products/stratos/modules/integration/src/test/resources/common/JMSOutputAdaptor.xml new file mode 100755 index 0000000..a6a2cff --- /dev/null +++ b/products/stratos/modules/integration/src/test/resources/common/JMSOutputAdaptor.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> + +<outputEventAdaptor name="JMSOutputAdaptor" statistics="disable" + trace="enable" type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager"> + <!--property name="java.naming.provider.url">CEP_HOME/repository/conf/jndi.properties</property--> + <property name="java.naming.provider.url">tcp://localhost:61617</property> + <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property> + <property name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</property> + <property name="transport.jms.DestinationType">topic</property> +</outputEventAdaptor> http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/common/jndi.properties ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/common/jndi.properties b/products/stratos/modules/integration/src/test/resources/common/jndi.properties new file mode 100644 index 0000000..beefe3c --- /dev/null +++ b/products/stratos/modules/integration/src/test/resources/common/jndi.properties @@ -0,0 +1,22 @@ +# +# 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. +# + +connectionfactoryName=TopicConnectionFactory +java.naming.provider.url=tcp://localhost:61617 +java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/common/log4j.properties ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/common/log4j.properties b/products/stratos/modules/integration/src/test/resources/common/log4j.properties new file mode 100644 index 0000000..72ad1c4 --- /dev/null +++ b/products/stratos/modules/integration/src/test/resources/common/log4j.properties @@ -0,0 +1,206 @@ +# +# 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 +# + +log4j.rootLogger=INFO, CARBON_CONSOLE, CARBON_LOGFILE, CARBON_MEMORY, CARBON_SYS_LOG + +log4j.logger.AUDIT_LOG=INFO, AUDIT_LOGFILE +log4j.logger.org.apache.axis2.wsdl.codegen.writer.PrettyPrinter=ERROR, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.axis2.clustering=INFO +log4j.logger.org.apache=INFO +log4j.logger.org.apache.catalina=WARN +log4j.logger.org.apache.tomcat=WARN +log4j.logger.org.wso2.carbon.apacheds=WARN +log4j.logger.org.apache.directory.server.ldap=WARN +log4j.logger.org.apache.directory.server.core.event=WARN +log4j.logger.com.atomikos=INFO,ATOMIKOS +log4j.logger.org.quartz=WARN +log4j.logger.org.apache.jackrabbit.webdav=WARN +log4j.logger.org.apache.juddi=ERROR +log4j.logger.org.apache.commons.digester.Digester=WARN +log4j.logger.org.apache.jasper.compiler.TldLocationsCache=WARN +log4j.logger.org.apache.qpid=WARN +log4j.logger.org.apache.qpid.server.Main=INFO +log4j.logger.qpid.message=WARN +log4j.logger.qpid.message.broker.listening=INFO +log4j.logger.org.apache.tiles=WARN +log4j.logger.org.apache.commons.httpclient=ERROR +log4j.logger.org.apache.coyote=WARN +log4j.logger.org.apache.solr=ERROR +log4j.logger.org.infinispan=WARN +log4j.logger.org.jgroups=ERROR +log4j.logger.me.prettyprint.cassandra.hector.TimingLogger=ERROR +log4j.logger.org.wso2=INFO + +# Apache Stratos logging configuration +log4j.logger.org.apache.stratos.manager=INFO +log4j.logger.org.apache.stratos.autoscaler=INFO +log4j.logger.org.apache.stratos.messaging=INFO +log4j.logger.org.apache.stratos.cloud.controller=INFO +log4j.logger.org.wso2.andes.client=ERROR +# Autoscaler rule logs +log4j.logger.org.apache.stratos.autoscaler.rule.RuleLog=INFO + +# Apache jclouds +#log4j.logger.jclouds.wire=DEBUG +#log4j.logger.jclouds.headers=DEBUG +#log4j.logger.org.jclouds=DEBUG + +# CEP Window processors +#log4j.logger.org.apache.stratos.cep.extension.FaultHandlingWindowProcessor=DEBUG + +log4j.logger.org.apache.axis2.enterprise=FATAL, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.opensaml.xml=WARN, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.directory.shared.ldap=WARN, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.directory.server.ldap.handlers=WARN, CARBON_LOGFILE, CARBON_MEMORY + +# Following are to remove false error messages from startup (IS) +log4j.logger.org.apache.directory.shared.ldap.entry.DefaultServerAttribute=FATAL, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.directory.server.core.DefaultDirectoryService=ERROR, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.directory.shared.ldap.ldif.LdifReader=ERROR, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.directory.server.ldap.LdapProtocolHandler=ERROR, CARBON_LOGFILE, CARBON_MEMORY +log4j.logger.org.apache.directory.server.core=ERROR, CARBON_LOGFILE, CARBON_MEMORY + +# Hive logging configuration +log4j.logger.DataNucleus=ERROR +log4j.logger.Datastore=ERROR +log4j.logger.Datastore.Schema=ERROR +log4j.logger.JPOX.Datastore=ERROR +log4j.logger.JPOX.Plugin=ERROR +log4j.logger.JPOX.MetaData=ERROR +log4j.logger.JPOX.Query=ERROR +log4j.logger.JPOX.General=ERROR +log4j.logger.JPOX.Enhancer=ERROR +log4j.logger.org.apache.hadoop.hive=WARN +log4j.logger.hive=WARN +log4j.logger.ExecMapper=WARN +log4j.logger.ExecReducer=WARN +log4j.logger.net.sf.ehcache.config.ConfigurationFactory=ERROR +log4j.logger.org.apache.axis2.clustering.tribes.Axis2GroupChannel=FATAL + +log4j.logger.trace.messages=TRACE,CARBON_TRACE_LOGFILE + +log4j.additivity.org.apache.axis2.clustering=false +log4j.additivity.com.atomikos=false + +# CARBON_CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CARBON_CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CARBON_CONSOLE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout +# ConversionPattern will be overridden by the configuration setting in the DB +log4j.appender.CARBON_CONSOLE.layout.ConversionPattern=[%d] %P%5p {%c} - %x %m%n +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 +# 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 + + +# CARBON_LOGFILE is set to be a DailyRollingFileAppender using a PatternLayout. +log4j.appender.CARBON_LOGFILE=org.apache.log4j.RollingFileAppender +log4j.appender.CARBON_LOGFILE.MaxFileSize=10000KB +log4j.appender.CARBON_LOGFILE.MaxBackupIndex=10 +# Log file will be overridden by the configuration setting in the DB +# This path should be relative to WSO2 Carbon Home +log4j.appender.CARBON_LOGFILE.File=${carbon.home}/repository/logs/${instance.log}/wso2carbon${instance.log}.log +log4j.appender.CARBON_LOGFILE.Append=true +log4j.appender.CARBON_LOGFILE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout +# ConversionPattern will be overridden by the configuration setting in the DB +log4j.appender.CARBON_LOGFILE.layout.ConversionPattern=TID: [%T] [%S] [%d] %P%5p {%c} - %x %m%n +log4j.appender.CARBON_LOGFILE.layout.TenantPattern=%U%@%D [%T] [%S] +log4j.appender.CARBON_LOGFILE.threshold=DEBUG + +log4j.appender.CARBON_SYS_LOG = org.apache.log4j.net.SyslogAppender +log4j.appender.CARBON_SYS_LOG.layout=org.apache.log4j.PatternLayout +log4j.appender.CARBON_SYS_LOG.layout.ConversionPattern=[%d] %5p {%c} - %x %m%n +log4j.appender.CARBON_SYS_LOG.SyslogHost=localhost +log4j.appender.CARBON_SYS_LOG.Facility=USER +log4j.appender.CARBON_SYS_LOG.threshold=DEBUG + +# LOGEVENT is set to be a LogEventAppender using a PatternLayout to send logs to LOGEVENT +log4j.appender.LOGEVENT=org.wso2.carbon.logging.appender.LogEventAppender +log4j.appender.LOGEVENT.url=tcp://10.100.3.103:7611 +log4j.appender.LOGEVENT.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout +log4j.appender.LOGEVENT.columnList=%T,%S,%A,%d,%c,%p,%m,%H,%I,%Stacktrace +log4j.appender.LOGEVENT.userName=admin +log4j.appender.LOGEVENT.password=admin + +# Appender config to CARBON_TRACE_LOGFILE +log4j.appender.CARBON_TRACE_LOGFILE=org.apache.log4j.DailyRollingFileAppender +log4j.appender.CARBON_TRACE_LOGFILE.File=${carbon.home}/repository/logs/${instance.log}/wso2carbon-trace-messages${instance.log}.log +log4j.appender.CARBON_TRACE_LOGFILE.Append=true +log4j.appender.CARBON_TRACE_LOGFILE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout +log4j.appender.CARBON_TRACE_LOGFILE.layout.ConversionPattern=[%d] %P%5p {%c} - %x %m%n +log4j.appender.CARBON_TRACE_LOGFILE.layout.TenantPattern=%U%@%D [%T] [%S] +log4j.appender.CARBON_TRACE_LOGFILE.threshold=TRACE +log4j.additivity.trace.messages=false + +# Appender config to AUDIT_LOGFILE +log4j.appender.AUDIT_LOGFILE=org.apache.log4j.DailyRollingFileAppender +log4j.appender.AUDIT_LOGFILE.File=${carbon.home}/repository/logs/audit.log +log4j.appender.AUDIT_LOGFILE.Append=true +log4j.appender.AUDIT_LOGFILE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout +log4j.appender.AUDIT_LOGFILE.layout.ConversionPattern=[%d] %P%5p - %x %m %n +log4j.appender.AUDIT_LOGFILE.layout.TenantPattern=%U%@%D [%T] [%S] +log4j.appender.AUDIT_LOGFILE.threshold=INFO +log4j.additivity.AUDIT_LOG=false + +# The event trace logger dumps enough information @INFO level. +# Writes events received by DataBridge +log4j.category.LOG_AGGREGATOR_LOGGER=INFO, LOG_AGGREGATOR_FILE_APPENDER +log4j.additivity.LOG_AGGREGATOR_LOGGER=false +log4j.appender.LOG_AGGREGATOR_FILE_APPENDER=org.apache.log4j.DailyRollingFileAppender +log4j.appender.LOG_AGGREGATOR_FILE_APPENDER.File=${carbon.home}/repository/logs/${instance.log}/aggregate${instance.log}.log +log4j.appender.LOG_AGGREGATOR_FILE_APPENDER.Append=true +log4j.appender.LOG_AGGREGATOR_FILE_APPENDER.layout=org.apache.log4j.PatternLayout +log4j.appender.LOG_AGGREGATOR_FILE_APPENDER.layout.ConversionPattern=%m%n + +# The event trace logger dumps enough information @INFO level, but maybe pushed upto TRACE. +# Writes only run-time/event processing time tracing/debug messages for event passing through trace +# enabled transport adapters event formatters, builders and processors. Enabling event tracing on these has a performance impact +log4j.category.EVENT_TRACE_LOGGER=INFO, EVENT_TRACE_APPENDER +log4j.additivity.EVENT_TRACE_LOGGER=false +log4j.appender.EVENT_TRACE_APPENDER=org.apache.log4j.DailyRollingFileAppender +log4j.appender.EVENT_TRACE_APPENDER.File=${carbon.home}/repository/logs/${instance.log}/wso2-cep-trace${instance.log}.log +log4j.appender.EVENT_TRACE_APPENDER.Append=true +log4j.appender.EVENT_TRACE_APPENDER.layout=org.apache.log4j.PatternLayout +log4j.appender.EVENT_TRACE_APPENDER.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n + +# Appender config to send Atomikos transaction logs to new log file tm.out. +log4j.appender.ATOMIKOS = org.apache.log4j.RollingFileAppender +log4j.appender.ATOMIKOS.File = repository/logs/tm.out +log4j.appender.ATOMIKOS.Append = true +log4j.appender.ATOMIKOS.layout = org.apache.log4j.PatternLayout +log4j.appender.ATOMIKOS.layout.ConversionPattern=%p %t %c - %m%n + +# 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 http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/common/mock-iaas.xml ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/common/mock-iaas.xml b/products/stratos/modules/integration/src/test/resources/common/mock-iaas.xml new file mode 100644 index 0000000..0f6b206 --- /dev/null +++ b/products/stratos/modules/integration/src/test/resources/common/mock-iaas.xml @@ -0,0 +1,123 @@ +<!-- + ~ 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. + --> + +<mock-iaas enabled="true"> + <health-statistics> + <cartridge type="tomcat"> + <!-- factor:memory-consumption|load-average|requests-in-flight--> + <!-- mode:loop|continue|stop --> + <!-- Mode defines the action needs to be taken after the last sample value: + loop: start from beginning + continue: continue the last sample value + stop: stop publishing statistics --> + <pattern factor="memory-consumption" mode="continue"> + <!-- Sample values --> + <sampleValues>20,30,40,50,60,70,50,40,30,20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + <pattern factor="load-average" mode="continue"> + <!-- Sample values --> + <sampleValues>20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + </cartridge> + <cartridge type="c7-single-cluster-scaling-test"> + <!-- factor:memory-consumption|load-average|requests-in-flight--> + <!-- mode:loop|continue|stop --> + <!-- Mode defines the action needs to be taken after the last sample value: + loop: start from beginning + continue: continue the last sample value + stop: stop publishing statistics --> + <pattern factor="memory-consumption" mode="continue"> + <!-- Sample values --> + <sampleValues>60,70,80,90,90,90,40,60,50,60</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + <pattern factor="load-average" mode="continue"> + <!-- Sample values --> + <sampleValues>70,70,70</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + </cartridge> + <cartridge type="c7-partition-round-robin-test"> + <!-- factor:memory-consumption|load-average|requests-in-flight--> + <!-- mode:loop|continue|stop --> + <!-- Mode defines the action needs to be taken after the last sample value: + loop: start from beginning + continue: continue the last sample value + stop: stop publishing statistics --> + <pattern factor="memory-consumption" mode="stop"> + <!-- Sample values --> + <sampleValues>20,20,20,20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>30</sampleDuration> + </pattern> + <pattern factor="load-average" mode="stop"> + <!-- Sample values --> + <sampleValues>20,20,20,20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>30</sampleDuration> + </pattern> + </cartridge> + <cartridge type="c3-group-termination-behavior-test"> + <!-- factor:memory-consumption|load-average|requests-in-flight--> + <!-- mode:loop|continue|stop --> + <!-- Mode defines the action needs to be taken after the last sample value: + loop: start from beginning + continue: continue the last sample value + stop: stop publishing statistics --> + <pattern factor="memory-consumption" mode="stop"> + <!-- Sample values --> + <sampleValues>20,20,20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + <pattern factor="load-average" mode="stop"> + <!-- Sample values --> + <sampleValues>20,20,20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + </cartridge> + <cartridge type="php"> + <!-- factor:memory-consumption|load-average|requests-in-flight--> + <!-- mode:loop|continue|stop --> + <!-- Mode defines the action needs to be taken after the last sample value: + loop: start from beginning + continue: continue the last sample value + stop: stop publishing statistics --> + <pattern factor="memory-consumption" mode="continue"> + <!-- Sample values --> + <sampleValues>20,30,40,50,60,70,50,40,30,20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + <pattern factor="load-average" mode="continue"> + <!-- Sample values --> + <sampleValues>20</sampleValues> + <!-- Duration of each sample value in seconds --> + <sampleDuration>60</sampleDuration> + </pattern> + </cartridge> + </health-statistics> +</mock-iaas> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/common/scaling.drl ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/common/scaling.drl b/products/stratos/modules/integration/src/test/resources/common/scaling.drl new file mode 100644 index 0000000..69d9111 --- /dev/null +++ b/products/stratos/modules/integration/src/test/resources/common/scaling.drl @@ -0,0 +1,311 @@ +/* + * 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.autoscaler + +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.autoscaler.context.AutoscalerContext; +import org.apache.stratos.autoscaler.context.member.MemberStatsContext; +import org.apache.stratos.autoscaler.util.AutoscalerConstants; +import org.apache.stratos.autoscaler.context.partition.network.NetworkPartitionContext; +import org.apache.stratos.autoscaler.pojo.policy.PolicyManager; +import org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy; +import org.apache.stratos.autoscaler.pojo.policy.autoscale.RequestsInFlight; +import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadThresholds; +import org.apache.stratos.autoscaler.pojo.policy.autoscale.MemoryConsumption; +import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadAverage; +import org.apache.stratos.autoscaler.algorithms.PartitionAlgorithm; +import org.apache.stratos.autoscaler.algorithms.partition.OneAfterAnother; +import org.apache.stratos.autoscaler.algorithms.partition.RoundRobin; +import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext; +import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; +import org.apache.stratos.cloud.controller.stub.domain.Partition; +import org.apache.stratos.cloud.controller.stub.domain.MemberContext; +import org.apache.stratos.autoscaler.context.cluster.ClusterInstanceContext; + +import org.apache.stratos.autoscaler.pojo.policy.autoscale.LoadAverage +import org.apache.stratos.autoscaler.pojo.policy.autoscale.MemoryConsumption + +global org.apache.stratos.autoscaler.rule.RuleLog log; +global org.apache.stratos.autoscaler.rule.RuleTasksDelegator delegator; +global org.apache.stratos.autoscaler.pojo.policy.autoscale.AutoscalePolicy autoscalePolicy; +global java.lang.String applicationId; +global java.lang.String clusterId; +global java.lang.Boolean rifReset; +global java.lang.Boolean mcReset; +global java.lang.Boolean laReset; +global java.lang.Boolean arspiReset; +global java.lang.String algorithmName; + +rule "Scaling Rule" +dialect "mvel" + when + clusterInstanceContext : ClusterInstanceContext () + + loadThresholds : LoadThresholds() from autoscalePolicy.getLoadThresholds() + partitionAlgorithm : PartitionAlgorithm() from delegator.getPartitionAlgorithm(algorithmName) + + eval(log.debug("Running scale up rule: [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + + " [cluster] " + clusterId)) + eval(log.debug("[scaling] [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + " [cluster] " + + clusterId + " Algorithm name: " + algorithmName)) + + + rifThreshold : Float() from loadThresholds.getRequestsInFlightThreshold() + + rifAverage : Float() from clusterInstanceContext.getAverageRequestsInFlight() + rifGradient : Float() from clusterInstanceContext.getRequestsInFlightGradient() + rifSecondDerivative : Float() from clusterInstanceContext.getRequestsInFlightSecondDerivative() + rifPredictedValue : Double() from delegator.getPredictedValueForNextMinute(rifAverage, rifGradient, rifSecondDerivative, 1) + + mcThreshold : Float() from loadThresholds.getMemoryConsumptionThreshold() + + mcPredictedValue : Double() from delegator.getMemoryConsumptionPredictedValue(clusterInstanceContext) + + laThreshold : Float() from loadThresholds.getLoadAverageThreshold() + + laPredictedValue : Double() from delegator.getLoadAveragePredictedValue(clusterInstanceContext) + + activeInstancesCount : Integer() from clusterInstanceContext.getActiveMemberCount() + maxInstancesCount : Integer() from clusterInstanceContext.getMaxInstanceCount() + minInstancesCount : Integer() from clusterInstanceContext.getMinInstanceCount() + requestsServedPerInstance : Float() from clusterInstanceContext.getRequestsServedPerInstance() + averageRequestsServedPerInstance : Float() from clusterInstanceContext.getAverageRequestsServedPerInstance() + + numberOfInstancesReuquiredBasedOnRif : Integer() from delegator.getNumberOfInstancesRequiredBasedOnRif( + rifPredictedValue, rifThreshold) + numberOfInstancesReuquiredBasedOnMemoryConsumption : Integer() from + delegator.getNumberOfInstancesRequiredBasedOnMemoryConsumption(mcThreshold, mcPredictedValue, minInstancesCount, + maxInstancesCount) + numberOfInstancesReuquiredBasedOnLoadAverage : Integer() from + delegator.getNumberOfInstancesRequiredBasedOnLoadAverage(laThreshold, laPredictedValue, minInstancesCount) + + numberOfRequiredInstances : Integer() from delegator.getMaxNumberOfInstancesRequired( + numberOfInstancesReuquiredBasedOnRif, numberOfInstancesReuquiredBasedOnMemoryConsumption, mcReset, + numberOfInstancesReuquiredBasedOnLoadAverage, laReset) + + + + scaleUp : Boolean() from (activeInstancesCount < numberOfRequiredInstances) + scaleDown : Boolean() from (activeInstancesCount > numberOfRequiredInstances || (numberOfRequiredInstances == 1 && activeInstancesCount == 1)) + + + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " RIF Resetted?: " + rifReset)) + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " RIF predicted value: " + rifPredictedValue)) + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " RIF threshold: " + rifThreshold)) + + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " MC predicted value: " + mcPredictedValue)) + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " MC threshold: " + mcThreshold)) + + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " LA predicted value: " + laPredictedValue)) + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " LA threshold: " + laThreshold)) + + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " Scale-up action: " + scaleUp)) + eval(log.debug("[scaling] " + "[cluster] " + clusterId + " Scale-down action: " + scaleDown)) + + then + + log.debug("[scaling] Number of required instances based on stats: " + numberOfRequiredInstances + " " + + "[active instances count] " + activeInstancesCount + " [network-partition] " + + clusterInstanceContext.getNetworkPartitionId() + " [cluster] " + clusterId); + + int nonTerminatedMembers = clusterInstanceContext.getNonTerminatedMemberCount(); + if(scaleUp){ + + int clusterMaxMembers = clusterInstanceContext.getMaxInstanceCount(); + if (nonTerminatedMembers < clusterMaxMembers) { + + int additionalInstances = 0; + if(clusterMaxMembers < numberOfRequiredInstances){ + + additionalInstances = clusterMaxMembers - nonTerminatedMembers; + log.info("[scale-up] Required member count based on stat based scaling is higher than max, hence" + + " notifying to parent for possible group scaling or app bursting. [cluster] " + clusterId + + " [instance id]" + clusterInstanceContext.getId() + " [max] " + clusterMaxMembers + + " [number of required instances] " + numberOfRequiredInstances + + " [additional instances to be created] " + additionalInstances); + delegator.delegateScalingOverMaxNotification(clusterId, clusterInstanceContext.getNetworkPartitionId(), + clusterInstanceContext.getId()); + } else { + + additionalInstances = numberOfRequiredInstances - nonTerminatedMembers; + } + + clusterInstanceContext.resetScaleDownRequestsCount(); + + log.debug("[scale-up] " + " [has scaling dependents] " + clusterInstanceContext.hasScalingDependants() + + " [cluster] " + clusterId ); + if(clusterInstanceContext.hasScalingDependants()) { + + log.debug("[scale-up] Notifying dependencies [cluster] " + clusterId); + delegator.delegateScalingDependencyNotification(clusterId, clusterInstanceContext.getNetworkPartitionId(), + clusterInstanceContext.getId(), numberOfRequiredInstances, clusterInstanceContext.getMinInstanceCount()); + } else { + + boolean partitionsAvailable = true; + int count = 0; + + while(count != additionalInstances && partitionsAvailable){ + + ClusterLevelPartitionContext partitionContext = (ClusterLevelPartitionContext) partitionAlgorithm.getNextScaleUpPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray()); + if(partitionContext != null){ + + log.info("[scale-up] Partition available, hence trying to spawn an instance to scale up! " + + " [application id] " + applicationId + + " [cluster] " + clusterId + " [instance id] " + clusterInstanceContext.getId() + + " [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + + " [partition] " + partitionContext.getPartitionId() + + " scaleup due to RIF: " + (rifReset && (rifPredictedValue > rifThreshold)) + + " [rifPredictedValue] " + rifPredictedValue + " [rifThreshold] " + rifThreshold + + " scaleup due to MC: " + (mcReset && (mcPredictedValue > mcThreshold)) + + " [mcPredictedValue] " + mcPredictedValue + " [mcThreshold] " + mcThreshold + + " scaleup due to LA: " + (laReset && (laPredictedValue > laThreshold)) + + " [laPredictedValue] " + laPredictedValue + " [laThreshold] " + laThreshold); + + log.debug("[scale-up] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + clusterId ); + delegator.delegateSpawn(partitionContext, clusterId, clusterInstanceContext.getId()); + count++; + } else { + + log.warn("[scale-up] No more partition available even though " + + "cartridge-max is not reached!, [cluster] " + clusterId + + " Please update deployment-policy with new partitions or with higher " + + "partition-max"); + partitionsAvailable = false; + } + } + } + } else { + log.info("[scale-up] Trying to scale up over max, hence not scaling up cluster itself and + notifying to parent for possible group scaling or app bursting. + [cluster] " + clusterId + " [instance id]" + clusterInstanceContext.getId() + + " [max] " + clusterMaxMembers); + delegator.delegateScalingOverMaxNotification(clusterId, clusterInstanceContext.getNetworkPartitionId(), + clusterInstanceContext.getId()); + } + } else if(scaleDown){ + + if(nonTerminatedMembers > clusterInstanceContext.getMinInstanceCount){ + + log.debug("[scale-down] Decided to Scale down [cluster] " + clusterId); + if(clusterInstanceContext.getScaleDownRequestsCount() >= 0 ){ + + log.debug("[scale-down] Reached scale down requests threshold [cluster] " + clusterId + " Count " + + clusterInstanceContext.getScaleDownRequestsCount()); + + if(clusterInstanceContext.hasScalingDependants()) { + + log.debug("[scale-up] Notifying dependencies [cluster] " + clusterId); + delegator.delegateScalingDependencyNotification(clusterId, clusterInstanceContext.getNetworkPartitionId(), + clusterInstanceContext.getId(), numberOfRequiredInstances, clusterInstanceContext.getMinInstanceCount()); + } else{ + + MemberStatsContext selectedMemberStatsContext = null; + double lowestOverallLoad = 0.0; + boolean foundAValue = false; + ClusterLevelPartitionContext partitionContext = (ClusterLevelPartitionContext) partitionAlgorithm.getNextScaleDownPartitionContext(clusterInstanceContext.getPartitionCtxtsAsAnArray()); + if(partitionContext != null) { + log.info("[scale-down] Partition available to scale down " + + " [application id] " + applicationId + + " [cluster] " + clusterId + " [instance id] " + clusterInstanceContext.getId() + + " [network-partition] " + clusterInstanceContext.getNetworkPartitionId() + + " [partition] " + partitionContext.getPartitionId() + + " scaledown due to RIF: " + (rifReset && (rifPredictedValue < rifThreshold)) + + " [rifPredictedValue] " + rifPredictedValue + " [rifThreshold] " + rifThreshold + + " scaledown due to MC: " + (mcReset && (mcPredictedValue < mcThreshold)) + + " [mcPredictedValue] " + mcPredictedValue + " [mcThreshold] " + mcThreshold + + " scaledown due to LA: " + (laReset && (laPredictedValue < laThreshold)) + + " [laPredictedValue] " + laPredictedValue + " [laThreshold] " + laThreshold + ); + + + for(MemberStatsContext memberStatsContext: partitionContext.getMemberStatsContexts().values()){ + + LoadAverage loadAverage = memberStatsContext.getLoadAverage(); + log.debug("[scale-down] " + " [cluster] " + + clusterId + " [member] " + memberStatsContext.getMemberId() + " Load average: " + loadAverage); + + MemoryConsumption memoryConsumption = memberStatsContext.getMemoryConsumption(); + log.debug("[scale-down] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + + clusterId + " [member] " + memberStatsContext.getMemberId() + " Memory consumption: " + + memoryConsumption); + + double predictedCpu = delegator.getPredictedValueForNextMinute(loadAverage.getAverage(), + loadAverage.getGradient(),loadAverage.getSecondDerivative(), 1); + log.debug("[scale-down] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + + clusterId + " [member] " + memberStatsContext.getMemberId() + " Predicted CPU: " + predictedCpu); + + double predictedMemoryConsumption = delegator.getPredictedValueForNextMinute( + memoryConsumption.getAverage(),memoryConsumption.getGradient(),memoryConsumption.getSecondDerivative(), 1); + log.debug("[scale-down] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + + clusterId + " [member] " + memberStatsContext.getMemberId() + " Predicted memory consumption: " + + predictedMemoryConsumption); + + double overallLoad = (predictedCpu + predictedMemoryConsumption) / 2; + log.debug("[scale-down] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + + clusterId + " [member] " + memberStatsContext.getMemberId() + " Overall load: " + overallLoad); + + if(!foundAValue){ + foundAValue = true; + selectedMemberStatsContext = memberStatsContext; + lowestOverallLoad = overallLoad; + } else if(overallLoad < lowestOverallLoad){ + selectedMemberStatsContext = memberStatsContext; + lowestOverallLoad = overallLoad; + } + + } + if(selectedMemberStatsContext != null) { + log.info("[scale-down] Trying to terminating an instace to scale down!" ); + log.debug("[scale-down] " + " [partition] " + partitionContext.getPartitionId() + " [cluster] " + + clusterId + " Member with lowest overall load: " + selectedMemberStatsContext.getMemberId()); + + delegator.delegateTerminate(partitionContext, selectedMemberStatsContext.getMemberId()); + } + } else { + log.warn("Partition is not available to scale-down..!!!!"); + } + } + } else{ + log.debug("[scale-down] Not reached scale down requests threshold. " + clusterId + " Count " + + clusterInstanceContext.getScaleDownRequestsCount()); + clusterInstanceContext.increaseScaleDownRequestsCount(); + + } + } else { + log.debug("[scale-down] Min is reached, hence not scaling down [cluster] " + clusterId + " [instance id]" + + clusterInstanceContext.getId()); + //if(clusterInstanceContext.isInGroupScalingEnabledSubtree()){ + + delegator.delegateScalingDownBeyondMinNotification(clusterId, clusterInstanceContext.getNetworkPartitionId(), + clusterInstanceContext.getId()); + //} + } + } else{ + log.debug("[scaling] No decision made to either scale up or scale down ... [cluster] " + clusterId + " [instance id]" + + clusterInstanceContext.getId()); + + } + +end + + + + http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/jndi.properties b/products/stratos/modules/integration/src/test/resources/jndi.properties deleted file mode 100644 index beefe3c..0000000 --- a/products/stratos/modules/integration/src/test/resources/jndi.properties +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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. -# - -connectionfactoryName=TopicConnectionFactory -java.naming.provider.url=tcp://localhost:61617 -java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory http://git-wip-us.apache.org/repos/asf/stratos/blob/c9de1b2b/products/stratos/modules/integration/src/test/resources/mock-iaas.xml ---------------------------------------------------------------------- diff --git a/products/stratos/modules/integration/src/test/resources/mock-iaas.xml b/products/stratos/modules/integration/src/test/resources/mock-iaas.xml deleted file mode 100644 index 37051b6..0000000 --- a/products/stratos/modules/integration/src/test/resources/mock-iaas.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - ~ 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. - --> - -<mock-iaas enabled="true"> - <health-statistics> - <cartridge type="tomcat"> - <!-- factor:memory-consumption|load-average|requests-in-flight--> - <!-- mode:loop|continue|stop --> - <!-- Mode defines the action needs to be taken after the last sample value: - loop: start from beginning - continue: continue the last sample value - stop: stop publishing statistics --> - <pattern factor="memory-consumption" mode="continue"> - <!-- Sample values --> - <sampleValues>20,30,40,50,60,70,50,40,30,20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - <pattern factor="load-average" mode="continue"> - <!-- Sample values --> - <sampleValues>20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - </cartridge> - <cartridge type="c7-single-cluster-scaling-test"> - <!-- factor:memory-consumption|load-average|requests-in-flight--> - <!-- mode:loop|continue|stop --> - <!-- Mode defines the action needs to be taken after the last sample value: - loop: start from beginning - continue: continue the last sample value - stop: stop publishing statistics --> - <pattern factor="memory-consumption" mode="continue"> - <!-- Sample values --> - <sampleValues>60,70,80,90,90,90,40,60,50,60</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - <pattern factor="load-average" mode="continue"> - <!-- Sample values --> - <sampleValues>70,70,70</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - </cartridge> - <cartridge type="c7-partition-round-robin-test"> - <!-- factor:memory-consumption|load-average|requests-in-flight--> - <!-- mode:loop|continue|stop --> - <!-- Mode defines the action needs to be taken after the last sample value: - loop: start from beginning - continue: continue the last sample value - stop: stop publishing statistics --> - <pattern factor="memory-consumption" mode="stop"> - <!-- Sample values --> - <sampleValues>20,20,20,20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>30</sampleDuration> - </pattern> - <pattern factor="load-average" mode="stop"> - <!-- Sample values --> - <sampleValues>20,20,20,20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>30</sampleDuration> - </pattern> - </cartridge> - <cartridge type="c3-group-termination-behavior-test"> - <!-- factor:memory-consumption|load-average|requests-in-flight--> - <!-- mode:loop|continue|stop --> - <!-- Mode defines the action needs to be taken after the last sample value: - loop: start from beginning - continue: continue the last sample value - stop: stop publishing statistics --> - <pattern factor="memory-consumption" mode="stop"> - <!-- Sample values --> - <sampleValues>20,20,20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - <pattern factor="load-average" mode="stop"> - <!-- Sample values --> - <sampleValues>20,20,20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - </cartridge> - <cartridge type="php"> - <!-- factor:memory-consumption|load-average|requests-in-flight--> - <!-- mode:loop|continue|stop --> - <!-- Mode defines the action needs to be taken after the last sample value: - loop: start from beginning - continue: continue the last sample value - stop: stop publishing statistics --> - <pattern factor="memory-consumption" mode="continue"> - <!-- Sample values --> - <sampleValues>20,30,40,50,60,70,50,40,30,20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - <pattern factor="load-average" mode="continue"> - <!-- Sample values --> - <sampleValues>20</sampleValues> - <!-- Duration of each sample value in seconds --> - <sampleDuration>60</sampleDuration> - </pattern> - </cartridge> - </health-statistics> -</mock-iaas>
