You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/02/05 17:28:44 UTC
stratos git commit: Updating resource folder path used for finding
sample applications path and adding timeouts
Repository: stratos
Updated Branches:
refs/heads/master 16260d393 -> eafea5218
Updating resource folder path used for finding sample applications path and adding timeouts
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/eafea521
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/eafea521
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/eafea521
Branch: refs/heads/master
Commit: eafea52180a51725b0da067e7d7e76cebe9935cf
Parents: 16260d3
Author: Imesh Gunaratne <im...@apache.org>
Authored: Thu Feb 5 21:57:54 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Thu Feb 5 21:58:36 2015 +0530
----------------------------------------------------------------------
products/stratos/modules/integration/pom.xml | 4 -
.../tests/SampleApplicationTests.java | 127 ------------------
.../tests/SampleApplicationsTest.java | 132 +++++++++++++++++++
.../tests/StratosTestServerManager.java | 12 +-
.../src/test/resources/instrumentation.txt | 2 -
.../integration/src/test/resources/testing.xml | 39 ------
6 files changed, 138 insertions(+), 178 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/eafea521/products/stratos/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/pom.xml b/products/stratos/modules/integration/pom.xml
index 549dd9b..12112e6 100755
--- a/products/stratos/modules/integration/pom.xml
+++ b/products/stratos/modules/integration/pom.xml
@@ -113,10 +113,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<inherited>false</inherited>
<configuration>
- <includes>
- <include>**/*TestServerManager.java</include>
- <include>**/SampleApplicationTests.java</include>
- </includes>
<systemProperties>
<maven.test.haltafterfailure>false</maven.test.haltafterfailure>
<sec.verifier.dir>${basedir}/target/security-verifier/</sec.verifier.dir>
http://git-wip-us.apache.org/repos/asf/stratos/blob/eafea521/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationTests.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationTests.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationTests.java
deleted file mode 100644
index 0feecc3..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationTests.java
+++ /dev/null
@@ -1,127 +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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.threading.StratosThreadPool;
-import org.apache.stratos.messaging.domain.application.Application;
-import org.apache.stratos.messaging.domain.application.ApplicationStatus;
-import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
-import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.util.concurrent.ExecutorService;
-
-import static junit.framework.Assert.*;
-
-/**
- * Sample application tests.
- */
-public class SampleApplicationTests extends StratosTestServerManager {
-
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
-
- private final static String SAMPLES_FOLDER_PATH = SampleApplicationTests.class.getResource("/").getPath() +
- "./../../../../../../samples";
- public static final int APPLICATION_ACTIVATION_TIMEOUT = 240000;
-
- private ApplicationsEventReceiver applicationsEventReceiver;
-
- @BeforeClass
- public void setUp(){
- // Set jndi.properties.dir system property for initializing event receivers
- String path = getClass().getResource("/").getPath();
- path = StringUtils.removeEnd(path, File.separator);
- System.setProperty("jndi.properties.dir", path);
- }
-
- @Test
- public void testSingleCartridgeApplication() {
- try {
- initializeApplicationEventReceiver();
-
- String scriptPath = SAMPLES_FOLDER_PATH + "/applications/single-cartridge/scripts/mock/deploy.sh";
- executeCommand(scriptPath);
-
- assertApplicationActivation("single-cartridge-app");
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred", false);
- }
- }
-
- /**
- * Initialize application event receiver
- */
- private void initializeApplicationEventReceiver() {
- if(applicationsEventReceiver == null) {
- applicationsEventReceiver = new ApplicationsEventReceiver();
- ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER", 1);
- applicationsEventReceiver.setExecutorService(executorService);
- applicationsEventReceiver.execute();
- }
- }
-
- /**
- * Execute shell command
- * @param commandText
- */
- private void executeCommand(String commandText) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try {
- CommandLine commandline = CommandLine.parse(commandText);
- DefaultExecutor exec = new DefaultExecutor();
- PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
- exec.setStreamHandler(streamHandler);
- exec.execute(commandline);
- log.info(outputStream.toString());
- } catch (Exception e) {
- log.error(outputStream.toString(), e);
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Assert application activation
- * @param applicationName
- */
- private void assertApplicationActivation(String applicationName) {
- long startTime = System.currentTimeMillis();
- Application application = ApplicationManager.getApplications().getApplication(applicationName);
- while(!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
- application = ApplicationManager.getApplications().getApplication(applicationName);
- if((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
- break;
- }
- }
-
- assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
- assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
- ApplicationStatus.Active, application.getStatus());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/eafea521/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
new file mode 100644
index 0000000..c520c89
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.integration.tests;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.messaging.domain.application.Application;
+import org.apache.stratos.messaging.domain.application.ApplicationStatus;
+import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
+import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.util.concurrent.ExecutorService;
+
+import static junit.framework.Assert.*;
+
+/**
+ * Sample application tests.
+ */
+public class SampleApplicationsTest extends StratosTestServerManager {
+
+ private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
+
+ public static final int APPLICATION_ACTIVATION_TIMEOUT = 240000;
+ private ApplicationsEventReceiver applicationsEventReceiver;
+
+ @BeforeClass
+ public void setUp(){
+ // Set jndi.properties.dir system property for initializing event receivers
+ System.setProperty("jndi.properties.dir", getResourcesFolderPath());
+ }
+
+ @Test
+ public void testSingleCartridgeApplication() {
+ try {
+ initializeApplicationEventReceiver();
+
+ String scriptPath = getResourcesFolderPath() + "/../../../../../../" +
+ "samples/applications/single-cartridge/scripts/mock/deploy.sh";
+ executeCommand(scriptPath);
+
+ assertApplicationActivation("single-cartridge-app");
+ } catch (Exception e) {
+ log.error(e);
+ assertTrue("An error occurred", false);
+ }
+ }
+
+ /**
+ * Initialize application event receiver
+ */
+ private void initializeApplicationEventReceiver() {
+ if(applicationsEventReceiver == null) {
+ applicationsEventReceiver = new ApplicationsEventReceiver();
+ ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER", 1);
+ applicationsEventReceiver.setExecutorService(executorService);
+ applicationsEventReceiver.execute();
+ }
+ }
+
+ /**
+ * Execute shell command
+ * @param commandText
+ */
+ private void executeCommand(String commandText) {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ try {
+ CommandLine commandline = CommandLine.parse(commandText);
+ DefaultExecutor exec = new DefaultExecutor();
+ PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
+ exec.setStreamHandler(streamHandler);
+ exec.execute(commandline);
+ log.info(outputStream.toString());
+ } catch (Exception e) {
+ log.error(outputStream.toString(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Assert application activation
+ * @param applicationName
+ */
+ private void assertApplicationActivation(String applicationName) {
+ long startTime = System.currentTimeMillis();
+ Application application = ApplicationManager.getApplications().getApplication(applicationName);
+ while(!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
+ application = ApplicationManager.getApplications().getApplication(applicationName);
+ if((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+ break;
+ }
+ }
+
+ assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
+ assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
+ ApplicationStatus.Active, application.getStatus());
+ }
+
+ /**
+ * Get resources folder path
+ * @return
+ */
+ private String getResourcesFolderPath() {
+ String path = getClass().getResource("/").getPath();
+ return StringUtils.removeEnd(path, File.separator);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/eafea521/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 589d27f..2a8a664 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
@@ -46,10 +46,10 @@ public class StratosTestServerManager extends TestServerManager {
private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- private final static String CARBON_ZIP = SampleApplicationTests.class.getResource("/").getPath() +
+ private final static String CARBON_ZIP = SampleApplicationsTest.class.getResource("/").getPath() +
"/../../../distribution/target/apache-stratos-4.1.0-SNAPSHOT.zip";
private final static int PORT_OFFSET = 0;
- private static final String ACTIVEMQ_BIND_ADDRESS1 = "tcp://localhost:61616";
+ private static final String ACTIVEMQ_BIND_ADDRESS = "tcp://localhost:61616";
private static final String MOCK_IAAS_XML = "mock-iaas.xml";
private ServerUtils serverUtils;
@@ -61,7 +61,7 @@ public class StratosTestServerManager extends TestServerManager {
}
@Override
- @BeforeSuite
+ @BeforeSuite(timeOut = 300000)
public String startServer() throws IOException {
TestLogAppender testLogAppender = new TestLogAppender();
@@ -74,7 +74,7 @@ public class StratosTestServerManager extends TestServerManager {
log.info("Starting ActiveMQ...");
BrokerService broker = new BrokerService();
broker.setBrokerName("testBroker");
- broker.addConnector(ACTIVEMQ_BIND_ADDRESS1);
+ broker.addConnector(ACTIVEMQ_BIND_ADDRESS);
broker.start();
long time2 = System.currentTimeMillis();
log.info(String.format("ActiveMQ started in %d sec", (time2 - time1)/1000));
@@ -104,7 +104,7 @@ public class StratosTestServerManager extends TestServerManager {
while (!serverStarted(testLogAppender)) {
log.info("Waiting for topology to be initialized...");
- Thread.sleep(2000);
+ Thread.sleep(5000);
}
long time4 = System.currentTimeMillis();
@@ -117,7 +117,7 @@ public class StratosTestServerManager extends TestServerManager {
}
@Override
- @AfterSuite
+ @AfterSuite(timeOut = 300000)
public void stopServer() throws Exception {
super.stopServer();
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/eafea521/products/stratos/modules/integration/src/test/resources/instrumentation.txt
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/instrumentation.txt b/products/stratos/modules/integration/src/test/resources/instrumentation.txt
deleted file mode 100755
index 3ebd80a..0000000
--- a/products/stratos/modules/integration/src/test/resources/instrumentation.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-org.apache.stratos.tenant.mgt_
-org.apache.stratos.tenant.mgt.core_
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/eafea521/products/stratos/modules/integration/src/test/resources/testing.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/testing.xml b/products/stratos/modules/integration/src/test/resources/testing.xml
deleted file mode 100644
index 6160b11..0000000
--- a/products/stratos/modules/integration/src/test/resources/testing.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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 Test Suite">
- <test name="testing" preserve-order="true">
- <classes>
- <class name="org.apache.stratos.integration.tests.SampleApplicationTests"/>
- <!-- class name="org.apache.stratos.manager.integration.tests.LoginLogoutTestCase"/>
- <class name="org.apache.stratos.manager.integration.tests.SecurityVerificationTestCase"/>
- <class name="org.apache.stratos.manager.integration.tests.TenantMgtTestCase">
- <methods>
- <include name="init"/>
- <include name="addTenantTest"/>
- <include name="activateTenantTest"/>
- </methods>
- </class-->
- </classes>
- </test>
-</suite>