Updated Branches: refs/heads/master 6b4a9c251 -> 143619358
Adding initial implementation of autoscaler test-suite Signed-off-by: Lahiru Sandaruwan <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/18a16924 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/18a16924 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/18a16924 Branch: refs/heads/master Commit: 18a169248f4f751a221fd816ebece2e345b869d7 Parents: c74290a Author: Melan Nimesh <[email protected]> Authored: Sun Dec 22 19:36:54 2013 +0530 Committer: Lahiru Sandaruwan <[email protected]> Committed: Sun Dec 22 20:25:11 2013 +0530 ---------------------------------------------------------------------- products/autoscaler/modules/integration/pom.xml | 212 +++++++++++++++++++ .../autoscaler/integration/TopicPublisher.java | 101 +++++++++ .../tests/AutoscalerTestServerManager.java | 100 +++++++++ .../integration/tests/LoginLogoutTestCase.java | 49 +++++ .../tests/SecurityVerificationTestCase.java | 27 +++ .../tests/TopologyEventsPublisherTestCase.java | 122 +++++++++++ .../src/test/resources/automation.properties | 116 ++++++++++ .../src/test/resources/jndi.properties | 5 + .../src/test/resources/keys/wso2carbon.jks | Bin 0 -> 33260 bytes .../integration/src/test/resources/testng.xml | 33 +++ 10 files changed, 765 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/pom.xml ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/pom.xml b/products/autoscaler/modules/integration/pom.xml new file mode 100644 index 0000000..c98b056 --- /dev/null +++ b/products/autoscaler/modules/integration/pom.xml @@ -0,0 +1,212 @@ +<?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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.apache.stratos.autoscaler</groupId> + <artifactId>autoscaler-parent</artifactId> + <version>4.0.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>integration</artifactId> + <name>Apache Stratos - Autoscaler- Integration Tests</name> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <executions> + <execution> + <id>auto-clean</id> + <phase>initialize</phase> + <goals> + <goal>clean</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <inherited>false</inherited> + <configuration> + <suiteXmlFiles> + <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> + </suiteXmlFiles> + <systemProperties> + <maven.test.haltafterfailure>false</maven.test.haltafterfailure> + <carbon.zip> + ${basedir}/../distribution/target/apache-stratos-autoscaler-${project.version}.zip + </carbon.zip> + <sec.verifier.dir>${basedir}/target/security-verifier/</sec.verifier.dir> + <extracted.dir>autoscaler-parent-${project.version}</extracted.dir> + <property> + <name>framework.resource.location</name> + <value> + ${basedir}/src/test/resources/ + </value> + </property> + <property> + <name>server.list</name> + <value> + AS + </value> + </property> + </systemProperties> + <workingDirectory>${basedir}/target</workingDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-secVerifier</id> + <phase>compile</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${basedir}/target/security-verifier</outputDirectory> + <includeTypes>aar</includeTypes> + <includeArtifactIds>SecVerifier</includeArtifactIds> + <stripVersion>true</stripVersion> + </configuration> + </execution> + <execution> + <id>copy-jar-dependencies</id> + <phase>compile</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${basedir}/src/test/resources/artifacts/jar + </outputDirectory> + <includeTypes>jar</includeTypes> + <includeArtifactIds> + activemq-core,geronimo-j2ee-management_1.1_spec,geronimo-jms_1.1_spec + </includeArtifactIds> + <excludeTransitive>true</excludeTransitive> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.integration.framework</artifactId> + <version>${carbon.kernel.version}</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon.automation</groupId> + <artifactId>org.wso2.carbon.automation.api</artifactId> + <version>${clarity.version}</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon.automation</groupId> + <artifactId>org.wso2.carbon.automation.core</artifactId> + <version>${clarity.version}</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon.automation</groupId> + <artifactId>org.wso2.carbon.automation.utils</artifactId> + <version>${clarity.version}</version> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.1.1</version> + </dependency> + <dependency> + <groupId>org.apache.axis2.wso2</groupId> + <artifactId>axis2-client</artifactId> + <version>${axis2.osgi.version}</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.addressing</artifactId> + <version>${carbon.version}</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.integration.core</artifactId> + <version>${carbon.kernel.version}</version> + <classifier>tests</classifier> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>SecVerifier</artifactId> + <version>${carbon.version}</version> + <type>aar</type> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-core</artifactId> + <version>5.2.0</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-j2ee-management_1.1_spec</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.2.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>org.apache.stratos.messaging</artifactId> + <version>4.0.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <properties> + <clarity.version>4.1.3</clarity.version> + <carbon.kernel.version>4.1.0.stratos</carbon.kernel.version> + </properties> + +</project> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/TopicPublisher.java ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/TopicPublisher.java b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/TopicPublisher.java new file mode 100644 index 0000000..e803091 --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/TopicPublisher.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.autoscaler.integration; + +import com.google.gson.Gson; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.util.Constants; + +import javax.jms.*; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import java.io.IOException; +import java.io.Serializable; +import java.util.Properties; + +public class TopicPublisher { + private static final Log log = LogFactory.getLog(TopicPublisher.class); + private TopicConnection topicConnection; + private TopicSession topicSession; + private Topic topic; + private String topicName; + + public TopicPublisher(String topicName) { + this.topicName = topicName; + } + + public void connect() throws NamingException, JMSException, IOException { + // Prepare JNDI properties + Properties properties = new Properties(); + properties.put("java.naming.provider.url", "tcp://localhost:61616"); + properties.put("java.naming.factory.initial","org.apache.activemq.jndi.ActiveMQInitialContextFactory"); + properties.put("connectionfactoryName", "ConnectionFactory"); + properties.put("java.naming.security.principal", "admin"); + properties.put("java.naming.security.credentials", "admin"); + InitialContext ctx = new InitialContext(properties); + + // Lookup connection factory + String connectionFactoryName = properties.get("connectionfactoryName").toString(); + TopicConnectionFactory connectionFactory = (TopicConnectionFactory) ctx.lookup(connectionFactoryName); + topicConnection = connectionFactory.createTopicConnection(); + topicConnection.start(); + topicSession = topicConnection.createTopicSession(false,QueueSession.AUTO_ACKNOWLEDGE); + + // Create topic + topic = topicSession.createTopic(topicName); + } + + public void publish(Event event) throws NamingException, JMSException,IOException { + Gson gson = new Gson(); + String json = gson.toJson(event); + publish(json, event.getClass().getName()); + } + + private void publish(Object message, String eventClassName) + throws NamingException, JMSException, IOException { + // Send message + if (message instanceof String) { + TextMessage textMessage = topicSession.createTextMessage((String) message); + textMessage.setStringProperty(Constants.EVENT_CLASS_NAME,eventClassName); + javax.jms.TopicPublisher topicPublisher = topicSession.createPublisher(topic); + topicPublisher.publish(textMessage); + log.info("Text message sent: " + (String) message); + } else if (message instanceof Serializable) { + ObjectMessage objectMessage = topicSession.createObjectMessage((Serializable) message); + javax.jms.TopicPublisher topicPublisher = topicSession.createPublisher(topic); + topicPublisher.publish(objectMessage); + log.info("Object message sent: "+ ((Serializable) message).toString()); + } else { + throw new RuntimeException("Unknown message type"); + } + } + + public void close() throws JMSException { + // Clean up resources + if (topicSession != null) + topicSession.close(); + if (topicConnection != null) + topicConnection.close(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/AutoscalerTestServerManager.java ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/AutoscalerTestServerManager.java b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/AutoscalerTestServerManager.java new file mode 100644 index 0000000..b69a84a --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/AutoscalerTestServerManager.java @@ -0,0 +1,100 @@ +/* + * 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.integration.tests; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.wso2.carbon.automation.core.utils.environmentutils.EnvironmentBuilder; +import org.wso2.carbon.automation.core.utils.jmsbrokerutils.controller.JMSBrokerController; +import org.wso2.carbon.automation.core.utils.jmsbrokerutils.controller.config.JMSBrokerConfiguration; +import org.wso2.carbon.automation.core.utils.jmsbrokerutils.controller.config.JMSBrokerConfigurationProvider; +import org.wso2.carbon.integration.framework.TestServerManager; + +import java.io.File; +import java.io.IOException; + + +/** + * Prepares the Autoscaler for test runs, starts JMS Broker, starts the server, and stops the + * server after test runs + */ +public class AutoscalerTestServerManager extends TestServerManager { + private static final Log log = LogFactory.getLog(AutoscalerTestServerManager.class); + + private EnvironmentBuilder builder = null; + private JMSBrokerController activeMqBroker = null; + + @Override + @BeforeSuite(timeOut = 300000) + public String startServer() throws IOException { + + builder = new EnvironmentBuilder(); + + if (builder.getFrameworkSettings().getEnvironmentSettings().is_builderEnabled()) { + // starting jms broker + activeMqBroker = new JMSBrokerController("localhost",getJMSBrokerConfiguration()); + if (!JMSBrokerController.isBrokerStarted()) { + Assert.assertTrue(activeMqBroker.start(),"JMS Broker stating failed"); + } + } + + String carbonHome = super.startServer(); + System.setProperty("carbon.home", carbonHome); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + throw new IOException(e); + } + return carbonHome; + } + + @Override + @AfterSuite(timeOut = 60000) + public void stopServer() throws Exception { + super.stopServer(); + if (builder.getFrameworkSettings().getEnvironmentSettings().is_builderEnabled()) { + if (activeMqBroker != null) { + Assert.assertTrue(activeMqBroker.stop(), "JMS Broker Stopping failed"); + } + } + } + + protected void copyArtifacts(String carbonHome) throws IOException { + Assert.assertNotNull(carbonHome, "carbon home cannot be null"); + String resourceLocation = System.getProperty("framework.resource.location", + System.getProperty("basedir") + "src" + File.separator + "test" + File.separator + "resources" + File.separator ); + String libDir = carbonHome + File.separator + "repository"+ File.separator + "components"+ File.separator + "lib"; + String confDir = carbonHome + File.separator + "repository"+ File.separator + "conf"; + log.info("Copying jndi.properties file...."); + FileUtils.copyFile(new File(resourceLocation,"jndi.properties"),new File(confDir,"jndi.properties")); + log.info("Copying ActiveMQ dependencies...."); + FileUtils.copyDirectory(new File(resourceLocation + File.separator + "artifacts"+ File.separator + "jar"), new File(libDir)); + } + + private JMSBrokerConfiguration getJMSBrokerConfiguration() { + return JMSBrokerConfigurationProvider.getInstance() + .getBrokerConfiguration(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/LoginLogoutTestCase.java ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/LoginLogoutTestCase.java b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/LoginLogoutTestCase.java new file mode 100644 index 0000000..e3b0e92 --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/LoginLogoutTestCase.java @@ -0,0 +1,49 @@ +/* + * 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.integration.tests; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.Test; +import org.wso2.carbon.integration.framework.ClientConnectionUtil; +import org.wso2.carbon.integration.framework.LoginLogoutUtil; + +/** + * A test case which tests logging in & logging out of a Carbon core server + */ +public class LoginLogoutTestCase { + + private LoginLogoutUtil util = new LoginLogoutUtil(); + public static final Log log = LogFactory.getLog(LoginLogoutTestCase.class); + + @Test(groups = {"stratos.autoscaler"}) + public void login() throws Exception { + log.info("****************************** LoginLogoutTestCase Start ******************************"); + ClientConnectionUtil.waitForPort(9763); + util.login(); + } + + @Test(groups = {"stratos.autoscaler"}) + public void logout() throws Exception { + ClientConnectionUtil.waitForPort(9763); + util.logout(); + log.info("****************************** LoginLogoutTestCase End ******************************"); + } +} + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/SecurityVerificationTestCase.java ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/SecurityVerificationTestCase.java b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/SecurityVerificationTestCase.java new file mode 100644 index 0000000..92d7708 --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/SecurityVerificationTestCase.java @@ -0,0 +1,27 @@ +/* + * 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.integration.tests; + +import org.wso2.carbon.integration.framework.SecurityVerificationTest; + +/** + * Test to ensure that the Stratos Autoscaler is properly secured + */ +public class SecurityVerificationTestCase extends SecurityVerificationTest { +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/TopologyEventsPublisherTestCase.java ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/TopologyEventsPublisherTestCase.java b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/TopologyEventsPublisherTestCase.java new file mode 100644 index 0000000..84a6258 --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/java/org/apache/stratos/autoscaler/integration/tests/TopologyEventsPublisherTestCase.java @@ -0,0 +1,122 @@ +/* + * 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.integration.tests; + +import java.io.IOException; + +import javax.jms.JMSException; +import javax.naming.NamingException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.integration.TopicPublisher; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.MemberStatus; +import org.apache.stratos.messaging.domain.topology.Port; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; +import org.apache.stratos.messaging.event.topology.InstanceSpawnedEvent; +import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; +import org.apache.stratos.messaging.event.topology.MemberStartedEvent; +import org.apache.stratos.messaging.event.topology.ServiceCreatedEvent; +import org.testng.annotations.Test; +import org.apache.stratos.messaging.domain.topology.ServiceType; +import org.apache.stratos.messaging.domain.topology.Member; + +public class TopologyEventsPublisherTestCase { + + public static final Log log = LogFactory.getLog(LoginLogoutTestCase.class); + private static String TOPIC_NAME = "topology"; + private static long TIME_INTERVAL = 4000; + + @Test(groups = {"stratos.autoscaler"}) + public void publish() throws Exception { + TopicPublisher publisher = new TopicPublisher(TOPIC_NAME); + publisher.connect(); + sendTopologyEvents(publisher); + } + + private static void sendTopologyEvents(TopicPublisher publisher) throws JMSException, NamingException, IOException, InterruptedException { + Topology topology = new Topology(); + + // Application server service + Service service1 = new Service("AppServer",ServiceType.SingleTenant); + service1.addPort(new Port("https", 9764, 90)); + topology.addService(service1); + + // Application server cluster 1 + Cluster cluster1 = new Cluster(service1.getServiceName(), "appserver-cluster", "p1", ""); + cluster1.addHostName("appserver.foo.org"); + cluster1.setTenantRange("1-*"); + service1.addCluster(cluster1); + + // Application server cluster 1 members + Member member1 = new Member(cluster1.getServiceName(), cluster1.getClusterId(), "m1", "", ""); + member1.setMemberIp("10.0.0.1"); + member1.setStatus(MemberStatus.Activated); + cluster1.addMember(member1); + + Member member2 = new Member(cluster1.getServiceName(), cluster1.getClusterId(), "m2", "", ""); + member2.setMemberIp("10.0.0.1"); + member2.setStatus(MemberStatus.Activated); + cluster1.addMember(member2); + + Member member3 = new Member(cluster1.getServiceName(), cluster1.getClusterId(), "m3", "", ""); + member3.setMemberIp("10.0.0.1"); + member3.setStatus(MemberStatus.Activated); + cluster1.addMember(member3); + + // Send complete topology event + CompleteTopologyEvent event = new CompleteTopologyEvent(topology); + publisher.publish(event); + Thread.sleep(TIME_INTERVAL); + + // Send ESB service created event + ServiceCreatedEvent event1 = new ServiceCreatedEvent("ESB", ServiceType.MultiTenant); + event1.addPort(new Port("https", 9764, 90)); + publisher.publish(event1); + Thread.sleep(TIME_INTERVAL); + + // Send ESB cluster c1 created event + ClusterCreatedEvent event2 = new ClusterCreatedEvent("ESB", "esb-cluster", cluster1); + publisher.publish(event2); + Thread.sleep(TIME_INTERVAL); + + // Send ESB cluster c1 member m1 spawned event + InstanceSpawnedEvent event3 = new InstanceSpawnedEvent(event2.getServiceName(), event2.getClusterId(), "m1", "p1", ""); + publisher.publish(event3); + Thread.sleep(TIME_INTERVAL); + + // Send ESB cluster c1 member m1 started event + MemberStartedEvent event4 = new MemberStartedEvent(event2.getServiceName(), event2.getClusterId(), "m1", "", ""); + publisher.publish(event4); + Thread.sleep(TIME_INTERVAL); + + // Send ESB cluster c1 member m1 activated event + MemberActivatedEvent event5 = new MemberActivatedEvent(event2.getServiceName(), event2.getClusterId(), "m1", "", ""); + event5.setMemberIp("10.0.0.1"); + event5.addPort(new Port("http", 9764, 90)); + publisher.publish(event5); + Thread.sleep(TIME_INTERVAL); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/resources/automation.properties ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/resources/automation.properties b/products/autoscaler/modules/integration/src/test/resources/automation.properties new file mode 100644 index 0000000..3f651a1 --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/resources/automation.properties @@ -0,0 +1,116 @@ +# Testing server details +#--------------------------------------------------------------------------------------------------- +stratos.test=false +execution.environment=integration +execution.mode=user +port.enable=true +carbon.web.context.enable=false +service.deployment.delay=30000 +cluster.enable=false +product.list=AS +deployment.framework.enable=false +builder.enable=true +coverage.enable=true + +as.host.name=localhost +as.http.port=9767 +as.https.port=9447 + +axis2.host.name=localhost +axis2.http.port=9000 +axis2.https.port=9001 + +manager.host.name=localhost +manager.http.port=9764 +manager.https.port=9444 + +dss.host.name=localhost +dss.http.port=9763 +dss.https.port=9443 + +greg.host.name=localhost +greg.http.port=9763 +greg.https.port=9443 + +is.host.name=localhost +is.http.port=9767 +is.https.port=9447 + +mb.host.name=localhost +mb.http.port=9770 +mb.https.port=9450 +mb.qpid.port=5675 + +bam.host.name=localhost +bam.http.port=9765 +bam.https.port=9445 + +esb.host.name=localhost +esb.http.port=9763 +esb.https.port=9443 +esb.nhttp.port=8280 +esb.nhttps.port=8243 + +cep.host.name=localhost +cep.http.port=9772 +cep.https.port=9452 +cep.qpid.port=5672 + +gs.host.name=localhost +gs.http.port=9771 +gs.https.port=9453 + +bps.host.name=localhost +bps.http.port=9763 +bps.https.port=9443 + +ms.host.name=localhost +ms.http.port=9769 +ms.https.port=9449 + +brs.host.name=localhost +brs.http.port=9775 +brs.https.port=9455 + +ravana.framework.path=/opt/ravana/ravana2 +ravana.test=true + +#(chrome|firefox|opera|ie|htmlUnit) +browser.name=firefox +path.to.chrome.driver="/opt/ravana/chromedriver" + +#run selenium test on remote browser or not. (true|false) +remote.selenium.web.driver.start=false +remote.webdirver.url=http://10.100.2.51:4444/wd/hub/ + +#this database configuration is used for data service test in product testing. configuration used as a data source in dbs files +#database.driver.name=com.mysql.jdbc.Driver +#jdbc.url=jdbc:mysql://127.0.0.1:3306 +database.driver.name=org.h2.Driver +jdbc.url=jdbc:h2: +db.user=root +db.password=root123 +db.name=testDb + +#RSS Data Source configuration in Stratos. this user name and password are used to create a user on RSS Manager in stratos and used in .dbs file as well +#user name should be limited to 7 characters +rss.database.user = tstusr1 +rss.database.password =test123 + +ravana.jdbc.url=jdbc:mysql://127.0.0.1:3306 +ravana.db.user=root +ravana.db.password=root + + +#this database configuration is used for test result dashboard. +dashboard.enable=false +dashboard.database.driver.name=com.mysql.jdbc.Driver +dashboard.jdbc.url=jdbc:mysql://127.0.0.1:3306 +dashboard.db.user=root +dashboard.db.password=root +dashboard.db.name=FRAMEWORK_DB + +#keystore name and passward, you need to put this put the keystore files to src/test/resources/keystores +truststore.name=wso2carbon.jks +truststore.password=wso2carbon + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/resources/jndi.properties b/products/autoscaler/modules/integration/src/test/resources/jndi.properties new file mode 100644 index 0000000..449d93f --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/resources/jndi.properties @@ -0,0 +1,5 @@ +java.naming.provider.url=tcp://localhost:61616 +java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory +connectionfactoryName=ConnectionFactory +java.naming.security.principal=admin +java.naming.security.credentials=admin \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/resources/keys/wso2carbon.jks ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/resources/keys/wso2carbon.jks b/products/autoscaler/modules/integration/src/test/resources/keys/wso2carbon.jks new file mode 100644 index 0000000..7942c53 Binary files /dev/null and b/products/autoscaler/modules/integration/src/test/resources/keys/wso2carbon.jks differ http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/18a16924/products/autoscaler/modules/integration/src/test/resources/testng.xml ---------------------------------------------------------------------- diff --git a/products/autoscaler/modules/integration/src/test/resources/testng.xml b/products/autoscaler/modules/integration/src/test/resources/testng.xml new file mode 100644 index 0000000..29d8751 --- /dev/null +++ b/products/autoscaler/modules/integration/src/test/resources/testng.xml @@ -0,0 +1,33 @@ +<?xml version='1.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. + +--> + +<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" > +<suite name="Apache Stratos Autoscaler Test Suite"> + <test name="testing" preserve-order="true"> + <classes> + <class name="org.apache.stratos.autoscaler.integration.tests.AutoscalerTestServerManager"/> + <class name="org.apache.stratos.autoscaler.integration.tests.LoginLogoutTestCase"/> + <class name="org.apache.stratos.autoscaler.integration.tests.SecurityVerificationTestCase"/> + <class name="org.apache.stratos.autoscaler.integration.tests.TopologyEventsPublisherTestCase"></class> + </classes> + </test> +</suite>
