Repository: stratos Updated Branches: refs/heads/master a4745eb9d -> bf76be91f
Adding Merge conflicts Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e19bfe73 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e19bfe73 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e19bfe73 Branch: refs/heads/master Commit: e19bfe73f4c9ec05ffd0b965a614c46216339144 Parents: a4745eb Author: Akila Perera <[email protected]> Authored: Thu Aug 27 10:48:59 2015 +0530 Committer: gayangunarathne <[email protected]> Committed: Tue Sep 1 19:45:04 2015 +0530 ---------------------------------------------------------------------- .../python-cartridge-agent/integration/pom.xml | 161 ++++++ .../python.cartridge.agent/test/ADCTest.java | 21 + .../test/PythonCartridgeAgentTest.java | 578 +++++++++++++++++++ .../src/test/resources/log4j.properties | 41 ++ .../src/test/resources/pca-testing1.xml | 29 + .../src/test/resources/pca-testing2.xml | 29 + .../src/test/resources/suite-1/agent.conf | 46 ++ .../src/test/resources/suite-1/jndi.properties | 22 + .../src/test/resources/suite-1/logging.ini | 52 ++ .../resources/suite-1/payload/launch-params | 1 + .../src/test/resources/suite-2/agent.conf | 46 ++ .../src/test/resources/suite-2/jndi.properties | 22 + .../src/test/resources/suite-2/logging.ini | 52 ++ .../resources/suite-2/payload/launch-params | 18 + .../test-conf/integration-test.properties | 26 + .../src/test/resources/suite-1/agent.conf | 45 -- .../src/test/resources/suite-1/jndi.properties | 22 - .../src/test/resources/suite-1/logging.ini | 52 -- products/python-cartridge-agent/pom.xml | 2 +- 19 files changed, 1145 insertions(+), 120 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/pom.xml ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/pom.xml b/products/python-cartridge-agent/integration/pom.xml new file mode 100755 index 0000000..e92bbb4 --- /dev/null +++ b/products/python-cartridge-agent/integration/pom.xml @@ -0,0 +1,161 @@ +<!-- + ~ 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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.stratos</groupId> + <artifactId>python-cartridge-agent-parent</artifactId> + <version>4.1.2</version> + </parent> + + <artifactId>python-agent-integration</artifactId> + <packaging>jar</packaging> + <name>Python Cartridge Agent - Integration Tests</name> + + <build> + <resources> + <resource> + <directory>src/test/resources/test-conf</directory> + <filtering>true</filtering> + </resource> + </resources> + </build> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>**/*</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>live</id> + <build> + <resources> + <resource> + <directory>src/test/resources/test-conf</directory> + <filtering>true</filtering> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <inherited>false</inherited> + <configuration> + <suiteXmlFiles> + <suiteXmlFile>src/test/resources/pca-testing1.xml</suiteXmlFile> + </suiteXmlFiles> + <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> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + <dependencies> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-exec</artifactId> + <version>1.0.1</version> + </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>org.apache.stratos.common</artifactId> + <version>${project.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.wso2.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents.wso2</groupId> + <artifactId>httpcore</artifactId> + <version>4.3.0.wso2v1</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents.wso2</groupId> + <artifactId>httpclient</artifactId> + <version>4.2.5.wso2v1</version> + </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>org.apache.stratos.mock.iaas.client</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.wso2.andes.wso2</groupId> + <artifactId>andes-client</artifactId> + <version>0.13.wso2v8</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-all</artifactId> + <version>5.10.0</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-mqtt</artifactId> + <version>5.10.0</version> + </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>org.apache.stratos.messaging</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/ADCTest.java ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/ADCTest.java b/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/ADCTest.java new file mode 100755 index 0000000..86fc7c3 --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/ADCTest.java @@ -0,0 +1,21 @@ +package org.apache.stratos.python.cartridge.agent.test;/* + * 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. + */ + +public class ADCTest { +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java b/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java new file mode 100755 index 0000000..93f4c1e --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java @@ -0,0 +1,578 @@ +/* + * 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.python.cartridge.agent.test; + +import org.apache.activemq.broker.BrokerService; +import org.apache.commons.exec.*; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.domain.LoadBalancingIPType; +import org.apache.stratos.common.threading.StratosThreadPool; +import org.apache.stratos.messaging.broker.publish.EventPublisher; +import org.apache.stratos.messaging.broker.publish.EventPublisherPool; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent; +import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; +import org.apache.stratos.messaging.event.topology.MemberInitializedEvent; +import org.apache.stratos.messaging.listener.instance.status.InstanceActivatedEventListener; +import org.apache.stratos.messaging.listener.instance.status.InstanceStartedEventListener; +import org.apache.stratos.messaging.message.receiver.instance.status.InstanceStatusEventReceiver; +import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; +import org.apache.stratos.messaging.util.MessagingUtil; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +import java.io.*; +import java.net.ServerSocket; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import static junit.framework.Assert.assertTrue; + +public class PythonCartridgeAgentTest { + + private static final Log log = LogFactory.getLog(PythonCartridgeAgentTest.class); + private static final String RESOURCES_PATH = "/suite-1"; + private static final String NEW_LINE = System.getProperty("line.separator"); + // private static final long TIMEOUT = 1440000; + private static final long TIMEOUT = 120000; + private static final String CLUSTER_ID = "php.php.domain"; + private static final String DEPLOYMENT_POLICY_NAME = "deployment-policy-1"; + private static final String AUTOSCALING_POLICY_NAME = "autoscaling-policy-1"; + private static final String APP_ID = "application-1"; + private static final String MEMBER_ID = "php.member-1"; + private static final String CLUSTER_INSTANCE_ID = "cluster-1-instance-1"; + private static final String NETWORK_PARTITION_ID = "network-partition-1"; + private static final String PARTITION_ID = "partition-1"; + private static final String TENANT_ID = "-1234"; + private static final String SERVICE_NAME = "php"; + public static final String SOURCE_PATH = "/tmp/stratos-pca-test-app-path/"; + + private static List<ServerSocket> serverSocketList; + private static Map<String, Executor> executorList; + + private boolean instanceStarted; + private boolean instanceActivated; + private ByteArrayOutputStreamLocal outputStream; + private boolean eventReceiverInitiated = false; + private TopologyEventReceiver topologyEventReceiver; + private InstanceStatusEventReceiver instanceStatusEventReceiver; + private BrokerService broker = new BrokerService(); + private static final UUID PYTHON_AGENT_DIR_NAME = UUID.randomUUID(); + + private static final String ACTIVEMQ_AMQP_BIND_ADDRESS = "activemq.amqp.bind.address"; + private static final String ACTIVEMQ_MQTT_BIND_ADDRESS = "activemq.mqtt.bind.address"; + private static final String CEP_PORT = "cep.port"; + private static final String DISTRIBUTION_NAME = "distribution.name"; + + private int cepPort; + private String amqpBindAddress; + private String mqttBindAddress; + private String distributionName; + private Properties integrationProperties; + + public PythonCartridgeAgentTest() { + if (integrationProperties == null) { + integrationProperties = new Properties(); + try { + integrationProperties + .load(PythonCartridgeAgentTest.class.getResourceAsStream("/integration-test.properties")); + distributionName = integrationProperties.getProperty(DISTRIBUTION_NAME); + amqpBindAddress = integrationProperties.getProperty(ACTIVEMQ_AMQP_BIND_ADDRESS); + mqttBindAddress = integrationProperties.getProperty(ACTIVEMQ_MQTT_BIND_ADDRESS); + cepPort = Integer.parseInt(integrationProperties.getProperty(CEP_PORT)); + log.info("PCA 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); + } + } + } + + /** + * Setup method for test class + */ + @BeforeSuite + public static void oneTimeSetUp() { + // Set jndi.properties.dir system property for initializing event publishers and receivers + System.setProperty("jndi.properties.dir", getResourcesPath()); + } + + /** + * Setup method for test method testPythonCartridgeAgent + */ + @BeforeSuite + public void setup() { + serverSocketList = new ArrayList<ServerSocket>(); + executorList = new HashMap<String, Executor>(); + try { + broker.addConnector(amqpBindAddress); + broker.addConnector(mqttBindAddress); + broker.setBrokerName("testBroker"); + broker.setDataDirectory( + PythonCartridgeAgentTest.class.getResource("/").getPath() + "/../" + PYTHON_AGENT_DIR_NAME + + "/activemq-data"); + broker.start(); + log.info("Broker service started!"); + } + catch (Exception e) { + log.error("Error while setting up broker service", e); + } + if (!this.eventReceiverInitiated) { + ExecutorService executorService = StratosThreadPool.getExecutorService("TEST_THREAD_POOL", 15); + topologyEventReceiver = new TopologyEventReceiver(); + topologyEventReceiver.setExecutorService(executorService); + topologyEventReceiver.execute(); + + instanceStatusEventReceiver = new InstanceStatusEventReceiver(); + instanceStatusEventReceiver.setExecutorService(executorService); + instanceStatusEventReceiver.execute(); + + this.instanceStarted = false; + instanceStatusEventReceiver.addEventListener(new InstanceStartedEventListener() { + @Override + protected void onEvent(Event event) { + log.info("Instance started event received"); + instanceStarted = true; + } + }); + + this.instanceActivated = false; + instanceStatusEventReceiver.addEventListener(new InstanceActivatedEventListener() { + @Override + protected void onEvent(Event event) { + log.info("Instance activated event received"); + instanceActivated = true; + } + }); + + this.eventReceiverInitiated = true; + } + // Simulate CEP server socket + startServerSocket(cepPort); + String agentPath = setupPythonAgent(); + log.info("Python agent working directory name: " + PYTHON_AGENT_DIR_NAME); + log.info("Starting python cartridge agent..."); + this.outputStream = executeCommand("python " + agentPath + "/agent.py > " + + PythonCartridgeAgentTest.class.getResource(File.separator).getPath() + "/../" + PYTHON_AGENT_DIR_NAME + + "/cartridge-agent.log"); + } + + /** + * TearDown method for test method testPythonCartridgeAgent + */ + @AfterSuite + public void tearDown() { + for (Map.Entry<String, Executor> entry : executorList.entrySet()) { + try { + String commandText = entry.getKey(); + Executor executor = entry.getValue(); + ExecuteWatchdog watchdog = executor.getWatchdog(); + if (watchdog != null) { + log.info("Terminating process: " + commandText); + watchdog.destroyProcess(); + } + } + catch (Exception ignore) { + } + } + for (ServerSocket serverSocket : serverSocketList) { + try { + log.info("Stopping socket server: " + serverSocket.getLocalSocketAddress()); + serverSocket.close(); + } + catch (IOException ignore) { + } + } + + try { + log.info("Deleting source checkout folder..."); + FileUtils.deleteDirectory(new File(SOURCE_PATH)); + } + catch (Exception ignore) { + + } + + this.instanceStatusEventReceiver.terminate(); + this.topologyEventReceiver.terminate(); + + this.instanceActivated = false; + this.instanceStarted = false; + try { + broker.stop(); + } + catch (Exception e) { + log.error("Error while stopping the broker service", e); + } + } + + + /** + * This method returns a collection of {@link org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent} + * objects as parameters to the test + * + * @return + */ + + public static ArrayList<ArtifactUpdatedEvent> getArtifactUpdatedEventsAsParams() { + ArtifactUpdatedEvent publicRepoEvent = createTestArtifactUpdatedEvent(); + + ArtifactUpdatedEvent privateRepoEvent = createTestArtifactUpdatedEvent(); + privateRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/testrepo.git"); + privateRepoEvent.setRepoUserName("testapache2211"); + privateRepoEvent.setRepoPassword("RExPDGa4GkPJj4kJDzSROQ=="); + + ArtifactUpdatedEvent privateRepoEvent2 = createTestArtifactUpdatedEvent(); + privateRepoEvent2.setRepoURL("https://[email protected]/testapache2211/testrepo.git"); + privateRepoEvent2.setRepoUserName("testapache2211"); + privateRepoEvent2.setRepoPassword("iF7qT+BKKPE3PGV1TeDsJA=="); + + ArrayList<ArtifactUpdatedEvent> list = new ArrayList<ArtifactUpdatedEvent>(); + list.add(privateRepoEvent); + list.add(privateRepoEvent2); + list.add(publicRepoEvent); + return list; + } + + /** + * Creates an {@link org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent} object with a public + * repository URL + * + * @return + */ + private static ArtifactUpdatedEvent createTestArtifactUpdatedEvent() { + ArtifactUpdatedEvent publicRepoEvent = new ArtifactUpdatedEvent(); + publicRepoEvent.setClusterId(CLUSTER_ID); + publicRepoEvent.setTenantId(TENANT_ID); + publicRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/opentestrepo1.git"); + publicRepoEvent.setCommitEnabled(true); + return publicRepoEvent; + } + + @Test(timeOut = TIMEOUT) + public void testPythonCartridgeAgent() { + Thread communicatorThread = new Thread(new Runnable() { + @Override + public void run() { + List<String> outputLines = new ArrayList<String>(); + while (!outputStream.isClosed()) { + List<String> newLines = getNewLines(outputLines, outputStream.toString()); + if (newLines.size() > 0) { + for (String line : newLines) { + if (line.contains("Subscribed to 'topology/#'")) { + sleep(1000); + // Send complete topology event + log.info("Publishing complete topology event..."); + Topology topology = createTestTopology(); + CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(topology); + publishEvent(completeTopologyEvent); + log.info("Complete topology event published"); + + sleep(3000); + // Publish member initialized event + log.info("Publishing member initialized event..."); + MemberInitializedEvent memberInitializedEvent = new MemberInitializedEvent( + SERVICE_NAME, CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID, + PARTITION_ID + ); + publishEvent(memberInitializedEvent); + log.info("Member initialized event published"); + + // Simulate server socket + startServerSocket(8080); + } + if (line.contains("Artifact repository found")) { + // Send artifact updated event + ArrayList<ArtifactUpdatedEvent> list = getArtifactUpdatedEventsAsParams(); + for (ArtifactUpdatedEvent artifactUpdatedEvent : list) { + publishEvent(artifactUpdatedEvent); + } + } + + if (line.contains("Exception in thread") || line.contains("ERROR")) { + //throw new RuntimeException(line); + } + log.info(line); + } + } + sleep(100); + } + } + }); + + communicatorThread.start(); + + while (!instanceActivated) { + // wait until the instance activated event is received. + sleep(2000); + } + + assertTrue("Instance started event was not received", instanceStarted); + assertTrue("Instance activated event was not received", instanceActivated); + } + + /** + * Publish messaging event + * + * @param event + */ + private void publishEvent(Event event) { + String topicName = MessagingUtil.getMessageTopicName(event); + EventPublisher eventPublisher = EventPublisherPool.getPublisher(topicName); + eventPublisher.publish(event); + } + + /** + * Start server socket + * + * @param port + */ + private void startServerSocket(final int port) { + Thread socketThread = new Thread(new Runnable() { + @Override + public void run() { + try { + ServerSocket serverSocket = new ServerSocket(port); + serverSocketList.add(serverSocket); + log.info("Server socket started on port: " + port); + serverSocket.accept(); + } + catch (IOException e) { + String message = "Could not start server socket: [port] " + port; + log.error(message, e); + throw new RuntimeException(message, e); + } + } + }); + socketThread.start(); + } + + /** + * Create test topology + * + * @return + */ + private Topology createTestTopology() { + Topology topology = new Topology(); + Service service = new Service(SERVICE_NAME, ServiceType.SingleTenant); + topology.addService(service); + + Cluster cluster = new Cluster(service.getServiceName(), CLUSTER_ID, DEPLOYMENT_POLICY_NAME, + AUTOSCALING_POLICY_NAME, APP_ID); + service.addCluster(cluster); + + Member member = new Member(service.getServiceName(), cluster.getClusterId(), MEMBER_ID, + CLUSTER_INSTANCE_ID, NETWORK_PARTITION_ID, PARTITION_ID, LoadBalancingIPType.Private, + System.currentTimeMillis()); + + member.setDefaultPrivateIP("10.0.0.1"); + member.setDefaultPublicIP("20.0.0.1"); + Properties properties = new Properties(); + properties.setProperty("prop1", "value1"); + member.setProperties(properties); + member.setStatus(MemberStatus.Created); + cluster.addMember(member); + + return topology; + } + + /** + * Return new lines found in the output + * + * @param currentOutputLines current output lines + * @param output output + * @return + */ + private List<String> getNewLines(List<String> currentOutputLines, String output) { + List<String> newLines = new ArrayList<String>(); + + if (StringUtils.isNotBlank(output)) { + String[] lines = output.split(NEW_LINE); + for (String line : lines) { + if (!currentOutputLines.contains(line)) { + currentOutputLines.add(line); + newLines.add(line); + } + } + } + return newLines; + } + + public static String getResourcesPath() { + return PythonCartridgeAgentTest.class.getResource("/").getPath() + "/../../src/test/resources" + RESOURCES_PATH; + } + + /** + * Sleep current thread + * + * @param time + */ + private void sleep(long time) { + try { + Thread.sleep(time); + } + catch (InterruptedException ignore) { + } + } + + /** + * Copy python agent distribution to a new folder, extract it and copy sample configuration files + * + * @return + */ + private String setupPythonAgent() { + try { + log.info("Setting up python cartridge agent..."); + + + String srcAgentPath = PythonCartridgeAgentTest.class.getResource("/").getPath() + + "/../../../distribution/target/" + distributionName + ".zip"; + String unzipDestPath = + PythonCartridgeAgentTest.class.getResource("/").getPath() + "/../" + PYTHON_AGENT_DIR_NAME + "/"; + //FileUtils.copyFile(new File(srcAgentPath), new File(destAgentPath)); + unzip(srcAgentPath, unzipDestPath); + String destAgentPath = PythonCartridgeAgentTest.class.getResource("/").getPath() + "/../" + + PYTHON_AGENT_DIR_NAME + "/" + distributionName; + + String srcAgentConfPath = getResourcesPath() + "/agent.conf"; + String destAgentConfPath = destAgentPath + "/agent.conf"; + FileUtils.copyFile(new File(srcAgentConfPath), new File(destAgentConfPath)); + + String srcLoggingIniPath = getResourcesPath() + "/logging.ini"; + String destLoggingIniPath = destAgentPath + "/logging.ini"; + FileUtils.copyFile(new File(srcLoggingIniPath), new File(destLoggingIniPath)); + + String srcPayloadPath = getResourcesPath() + "/payload"; + String destPayloadPath = destAgentPath + "/payload"; + FileUtils.copyDirectory(new File(srcPayloadPath), new File(destPayloadPath)); + + log.info("Changing extension scripts permissions"); + File extensionsPath = new File(destAgentPath + "/extensions/bash"); + File[] extensions = extensionsPath.listFiles(); + for (File extension : extensions) { + extension.setExecutable(true); + } + + log.info("Python cartridge agent setup completed"); + + return destAgentPath; + } + catch (Exception e) { + String message = "Could not copy cartridge agent distribution"; + log.error(message, e); + throw new RuntimeException(message, e); + } + } + + public void unzip(String zipFilePath, String destDirectory) throws IOException { + File destDir = new File(destDirectory); + if (!destDir.exists()) { + destDir.mkdir(); + } + ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath)); + ZipEntry entry = zipIn.getNextEntry(); + // iterates over entries in the zip file + while (entry != null) { + String filePath = destDirectory + File.separator + entry.getName(); + if (!entry.isDirectory()) { + // if the entry is a file, extracts it + extractFile(zipIn, filePath); + } else { + // if the entry is a directory, make the directory + File dir = new File(filePath); + dir.mkdir(); + } + zipIn.closeEntry(); + entry = zipIn.getNextEntry(); + } + zipIn.close(); + } + + private void extractFile(ZipInputStream zipIn, String filePath) throws IOException { + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath)); + byte[] bytesIn = new byte[4096]; + int read = 0; + while ((read = zipIn.read(bytesIn)) != -1) { + bos.write(bytesIn, 0, read); + } + bos.close(); + } + + /** + * Execute shell command + * + * @param commandText + */ + private ByteArrayOutputStreamLocal executeCommand(final String commandText) { + final ByteArrayOutputStreamLocal outputStream = new ByteArrayOutputStreamLocal(); + try { + CommandLine commandline = CommandLine.parse(commandText); + DefaultExecutor exec = new DefaultExecutor(); + PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); + exec.setWorkingDirectory(new File( + PythonCartridgeAgentTest.class.getResource("/").getPath() + "/../" + PYTHON_AGENT_DIR_NAME)); + exec.setStreamHandler(streamHandler); + ExecuteWatchdog watchdog = new ExecuteWatchdog(TIMEOUT); + exec.setWatchdog(watchdog); + exec.execute(commandline, new ExecuteResultHandler() { + @Override + public void onProcessComplete(int i) { + log.info(commandText + " process completed"); + } + + @Override + public void onProcessFailed(ExecuteException e) { + log.error(commandText + " process failed", e); + } + }); + executorList.put(commandText, exec); + return outputStream; + } + catch (Exception e) { + log.error(outputStream.toString(), e); + throw new RuntimeException(e); + } + } + + /** + * Implements ByteArrayOutputStream.isClosed() method + */ + private class ByteArrayOutputStreamLocal extends ByteArrayOutputStream { + private boolean closed; + + @Override + public void close() throws IOException { + super.close(); + closed = true; + } + + public boolean isClosed() { + return closed; + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/log4j.properties b/products/python-cartridge-agent/integration/src/test/resources/log4j.properties new file mode 100755 index 0000000..c0c6e78 --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/log4j.properties @@ -0,0 +1,41 @@ +# +# 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. +# + +# Set root logger level and appenders +log4j.rootLogger=INFO, CONSOLE_APPENDER, FILE_APPENDER + +# CONSOLE_APPENDER is set to be a ConsoleAppender. +log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender + +# The standard error log where all the warnings, errors and fatal errors will be logged +log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender +log4j.appender.FILE_APPENDER.File=cartridge-agent.log +log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout +log4j.appender.FILE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n +log4j.appender.FILE_APPENDER.threshold=DEBUG + +# CONSOLE_APPENDER uses PatternLayout. +log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=[%d{ISO8601}] %5p - [%c{1}] %m%n + +log4j.logger.org.apache.stratos.cartridge.agent=INFO +log4j.logger.org.apache.stratos.messaging=INFO +log4j.logger.org.apache.stratos.common.util=DEBUG +log4j.logger.org.wso2.andes.client=ERROR +log4j.logger.org.apache.activemq.jndi.ActiveMQInitialContextFactory=ERROR \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/pca-testing1.xml ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/pca-testing1.xml b/products/python-cartridge-agent/integration/src/test/resources/pca-testing1.xml new file mode 100755 index 0000000..a13f950 --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/pca-testing1.xml @@ -0,0 +1,29 @@ +<?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. + --> + +<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > + +<suite name="PythonCartridgeAgentIntegrationSuite1"> + <test name="PCATest"> + <classes> + <class name="org.apache.stratos.python.cartridge.agent.test.PythonCartridgeAgentTest"/> + </classes> + </test> +</suite> http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/pca-testing2.xml ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/pca-testing2.xml b/products/python-cartridge-agent/integration/src/test/resources/pca-testing2.xml new file mode 100755 index 0000000..c292953 --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/pca-testing2.xml @@ -0,0 +1,29 @@ +<?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. + --> + +<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > + +<suite name="PythonCartridgeAgentIntegrationSuite2"> + <test name="PCATest"> + <classes> + <class name="org.apache.stratos.python.cartridge.agent.test.ADCTest"/> + </classes> + </test> +</suite> http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-1/agent.conf ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-1/agent.conf b/products/python-cartridge-agent/integration/src/test/resources/suite-1/agent.conf new file mode 100755 index 0000000..136433d --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-1/agent.conf @@ -0,0 +1,46 @@ +# 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. + +[agent] +mb.ip =localhost +mb.port =1885 +listen.address =localhost +thrift.receiver.ip =localhost +thrift.receiver.port =7712 +thrift.server.admin.username =admin +thrift.server.admin.password =admin +cep.stats.publisher.enabled =true +lb.private.ip = +lb.public.ip = +enable.artifact.update =true +auto.commit =false +auto.checkout =true +artifact.update.interval =15 +artifact.clone.retries =5 +artifact.clone.interval =10 +port.check.timeout =600000 +enable.data.publisher =false +monitoring.server.ip =localhost +monitoring.server.port =7612 +monitoring.server.secure.port =7712 +monitoring.server.admin.username =admin +monitoring.server.admin.password =admin +#log.file.paths =/home/chamilad/dev/wso2esb-4.8.1/repository/logs/wso2carbon.log +log.file.paths =/tmp/agent.screen.log +metadata.service.url =https://localhost:9443 +super.tenant.repository.path =/repository/deployment/server/ +tenant.repository.path =/repository/tenants/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-1/jndi.properties ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-1/jndi.properties b/products/python-cartridge-agent/integration/src/test/resources/suite-1/jndi.properties new file mode 100755 index 0000000..beefe3c --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-1/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/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-1/logging.ini ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-1/logging.ini b/products/python-cartridge-agent/integration/src/test/resources/suite-1/logging.ini new file mode 100755 index 0000000..15cad9b --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-1/logging.ini @@ -0,0 +1,52 @@ +# 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. + + +[formatters] +keys=default + +[formatter_default] +format=[%(asctime)s] %(levelname)s {%(filename)s:%(funcName)s} - %(message)s +class=logging.Formatter + +[handlers] +keys=console, error_file, log_file + +[handler_console] +class=logging.StreamHandler +formatter=default +args=tuple() + +[handler_log_file] +class=logging.FileHandler +level=DEBUG +formatter=default +args=("agent.log", "w") + +[handler_error_file] +class=logging.FileHandler +level=ERROR +formatter=default +args=("error.log", "w") + +[loggers] +keys=root + +[logger_root] +level=DEBUG +formatter=default +handlers=console,error_file,log_file \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-1/payload/launch-params ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-1/payload/launch-params b/products/python-cartridge-agent/integration/src/test/resources/suite-1/payload/launch-params new file mode 100755 index 0000000..165508e --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-1/payload/launch-params @@ -0,0 +1 @@ +APPLICATION_ID=single_group_v1,APPLICATION_PATH=/tmp/tomcat/webapps,BASH=/bin/bash,BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath,BASH_ALIASES=(),BASH_ARGC=(),BASH_ARGV=(),BASH_CMDS=(),BASH_LINENO=([0]="0"),BASH_SOURCE=([0]="/usr/local/bin/populate-user-data.sh"),BASH_VERSINFO=([0]="4" [1]="3" [2]="30" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu"),BASH_VERSION='4.3.30(1)-release',CARTRIDGE_ALIAS=mytomcat,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,CATALINA_HOME=/opt/tomcat,CEP_IP=54.179.197.243,CEP_PORT=7711,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=single_group_v1-1,DEPENDENCY_CLUSTER_IDS=myphp.php.domain,DEPLOYMENT=default,DIRSTACK=(),EUID=0,GROUPS=(),GROUP_NAME=null,HOME=/root,HOSTNAME=mytomcat-tomcat-domain3bd3cd47-b95d-475a-aa11-3e3ddc089d49,HOSTTYPE=x86_64,HOST_NAME=mytomcat.tomcat.stratos.org,IFS=' ,',INSTANCE_ID=null,INTERNAL=false,JAVA_HOME=/opt/jdk1.7.0_67,KUBERNETES_CLUSTER_ID=kubernetes-cluster-1,KUB ERNETES_PORT=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP_ADDR=10.100.0.2,KUBERNETES_PORT_443_TCP_PORT=443,KUBERNETES_PORT_443_TCP_PROTO=tcp,KUBERNETES_RO_PORT=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP_ADDR=10.100.0.1,KUBERNETES_RO_PORT_80_TCP_PORT=80,KUBERNETES_RO_PORT_80_TCP_PROTO=tcp,KUBERNETES_RO_SERVICE_HOST=10.100.0.1,KUBERNETES_RO_SERVICE_PORT=80,KUBERNETES_SERVICE_HOST=10.100.0.2,KUBERNETES_SERVICE_PORT=443,LB_CLUSTER_ID=null,LOG_LEVEL=DEBUG,MACHTYPE=x86_64-pc-linux-gnu,MB_IP=54.179.197.243,MB_PORT=1883,MEMBER_ID=php.member-1,MIN_COUNT=1,MULTITENANT=false,MYPHP_PHP_DOMAIN_1_PORT=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.171.218,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYPHP_PHP_DOMAIN_1_SERVICE_HOST=10.100.171.218,MYPHP_PHP_DOMAIN_1_SERVICE_PORT=4500, MYTOMCAT_TOMCAT_DOMAIN_1_PORT=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_HOST=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_PORT=4500,NETWORK_PARTITION_ID=network-partition-1,OPTERR=1,OPTIND=1,OSTYPE=linux-gnu,PARTITION_ID=partition-1,PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PIPESTATUS=([0]="0"),PORTS=8080,POSIXLY_CORRECT=y,PPID=14,PRIMARY=false,PROVIDER=apache,PS4='+ ',PUPPET_DNS_AVAILABLE=null,PUPPET_ENV=false,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_IP=127.0.0.1,PWD=/opt,REPO_URL=https://github.com/imesh/stratos-tomcat-applications.git,SERVICE_NAME=php,SHELL=/bin/bash,SHELLOPTS=braceexpand:hashall:interactive-comments:posix,SHLVL=2,TENANT_ID=-1234,TENANT_RANGE='*',TERM=dumb,TOKEN=eyJhbGciOiJSUzI1NiJ9.eyJleHAiOi04NzI 0ODEyNDEsInN1YiI6ImFkbWluIiwiYXpwIjoid3I5SllVaDNtTXd6bVhHVllqWmVIWnhCV2xFYSIsImFwcElkIjoic2luZ2xlX2dyb3VwX3YxIiwiYXVkIjpbIndyOUpZVWgzbU13em1YR1ZZalplSFp4QldsRWEiXSwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5NDQzXC9vYXV0aDJlbmRwb2ludHNcL3Rva2VuIiwiaWF0IjotODcyNDgwMjQwfQ.OSa1gIXUT9amhk1YEU02Yc3JtUYqanzrXh5K1YyvRXcpSiY2Ccn2BfJO0hILF5UooRcGBihzfX3979NRcvGwcUDUvOUJ0eaGPmxFZYbu0nr3xD8lhAO3fa1QYsKAvMnMdwyu2uSgSp6R6EUdVleiwlabUoDsuEcKGkIAn_VQvG0,UID=0,_=posix,LVS_VIRTUAL_IP=192.168.0.40|255.255.255.0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-2/agent.conf ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-2/agent.conf b/products/python-cartridge-agent/integration/src/test/resources/suite-2/agent.conf new file mode 100755 index 0000000..136433d --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-2/agent.conf @@ -0,0 +1,46 @@ +# 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. + +[agent] +mb.ip =localhost +mb.port =1885 +listen.address =localhost +thrift.receiver.ip =localhost +thrift.receiver.port =7712 +thrift.server.admin.username =admin +thrift.server.admin.password =admin +cep.stats.publisher.enabled =true +lb.private.ip = +lb.public.ip = +enable.artifact.update =true +auto.commit =false +auto.checkout =true +artifact.update.interval =15 +artifact.clone.retries =5 +artifact.clone.interval =10 +port.check.timeout =600000 +enable.data.publisher =false +monitoring.server.ip =localhost +monitoring.server.port =7612 +monitoring.server.secure.port =7712 +monitoring.server.admin.username =admin +monitoring.server.admin.password =admin +#log.file.paths =/home/chamilad/dev/wso2esb-4.8.1/repository/logs/wso2carbon.log +log.file.paths =/tmp/agent.screen.log +metadata.service.url =https://localhost:9443 +super.tenant.repository.path =/repository/deployment/server/ +tenant.repository.path =/repository/tenants/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-2/jndi.properties ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-2/jndi.properties b/products/python-cartridge-agent/integration/src/test/resources/suite-2/jndi.properties new file mode 100755 index 0000000..beefe3c --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-2/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/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-2/logging.ini ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-2/logging.ini b/products/python-cartridge-agent/integration/src/test/resources/suite-2/logging.ini new file mode 100755 index 0000000..15cad9b --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-2/logging.ini @@ -0,0 +1,52 @@ +# 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. + + +[formatters] +keys=default + +[formatter_default] +format=[%(asctime)s] %(levelname)s {%(filename)s:%(funcName)s} - %(message)s +class=logging.Formatter + +[handlers] +keys=console, error_file, log_file + +[handler_console] +class=logging.StreamHandler +formatter=default +args=tuple() + +[handler_log_file] +class=logging.FileHandler +level=DEBUG +formatter=default +args=("agent.log", "w") + +[handler_error_file] +class=logging.FileHandler +level=ERROR +formatter=default +args=("error.log", "w") + +[loggers] +keys=root + +[logger_root] +level=DEBUG +formatter=default +handlers=console,error_file,log_file \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/suite-2/payload/launch-params ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/suite-2/payload/launch-params b/products/python-cartridge-agent/integration/src/test/resources/suite-2/payload/launch-params new file mode 100755 index 0000000..0d29753 --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/suite-2/payload/launch-params @@ -0,0 +1,18 @@ +# 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. + +APPLICATION_ID=application1,SERVICE_NAME=php,HOST_NAME=php.php.stratos.org,MULTITENANT=false,TENANT_ID=-1234,TENANT_RANGE=*,CARTRIDGE_ALIAS=php,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=single-cartridge-app-1,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,DEPLOYMENT=default,REPO_URL=https://github.com/imesh/stratos-php-applications.git,PORTS=9080,PUPPET_IP=127.0.0.1,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_ENV=false,MEMBER_ID=php.member-1,LB_CLUSTER_ID=null,NETWORK_PARTITION_ID=network-p1,PARTITION_ID=p1,APPLICATION_PATH=/tmp/stratos-pca-test-app-path/,MIN_COUNT=1,INTERNAL=false,CLUSTERING_PRIMARY_KEY=A,LOG_FILE_PATHS=/tmp/temp.log,PERSISTENCE_MAPPING=null,MP_IP=192.168.1.4,MB_PORT=1883,LVS_VIRTUAL_IP=192.168.0.40|255.255.255.0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/integration/src/test/resources/test-conf/integration-test.properties ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/integration/src/test/resources/test-conf/integration-test.properties b/products/python-cartridge-agent/integration/src/test/resources/test-conf/integration-test.properties new file mode 100755 index 0000000..1242841 --- /dev/null +++ b/products/python-cartridge-agent/integration/src/test/resources/test-conf/integration-test.properties @@ -0,0 +1,26 @@ +# 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. + +# Stratos distribution properties added via filters during the build +distribution.version=${project.version} +distribution.name=${python.cartridge.agent.distribution.name}-${project.version} +activemq.amqp.bind.address=tcp://localhost:61617 +activemq.mqtt.bind.address=mqtt://localhost:1885 +cep.port=7712 +stratos.endpoint=http://localhost:9763 +stratos.admin.username=admin +stratos.admin.password=admin \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/agent.conf ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/agent.conf b/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/agent.conf deleted file mode 100755 index eae5003..0000000 --- a/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/agent.conf +++ /dev/null @@ -1,45 +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. - -[agent] -mb.ip =localhost -mb.port =1885 -listen.address =localhost -thrift.receiver.ip =localhost -thrift.receiver.port =7712 -thrift.server.admin.username =admin -thrift.server.admin.password =admin -cep.stats.publisher.enabled =true -lb.private.ip = -lb.public.ip = -enable.artifact.update =true -auto.commit =false -auto.checkout =true -artifact.update.interval =15 -artifact.clone.retries =5 -artifact.clone.interval =10 -port.check.timeout =600000 -enable.data.publisher =false -monitoring.server.ip =localhost -monitoring.server.port =7612 -monitoring.server.secure.port =7712 -monitoring.server.admin.username =admin -monitoring.server.admin.password =admin -log.file.paths =/tmp/agent.screen-startup-test.log -metadata.service.url =https://localhost:9443 -super.tenant.repository.path =/repository/deployment/server/ -tenant.repository.path =/repository/tenants/ http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/jndi.properties ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/jndi.properties b/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/jndi.properties deleted file mode 100755 index beefe3c..0000000 --- a/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/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/e19bfe73/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/logging.ini ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/logging.ini b/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/logging.ini deleted file mode 100755 index 15cad9b..0000000 --- a/products/python-cartridge-agent/modules/integration/src/test/resources/suite-1/logging.ini +++ /dev/null @@ -1,52 +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. - - -[formatters] -keys=default - -[formatter_default] -format=[%(asctime)s] %(levelname)s {%(filename)s:%(funcName)s} - %(message)s -class=logging.Formatter - -[handlers] -keys=console, error_file, log_file - -[handler_console] -class=logging.StreamHandler -formatter=default -args=tuple() - -[handler_log_file] -class=logging.FileHandler -level=DEBUG -formatter=default -args=("agent.log", "w") - -[handler_error_file] -class=logging.FileHandler -level=ERROR -formatter=default -args=("error.log", "w") - -[loggers] -keys=root - -[logger_root] -level=DEBUG -formatter=default -handlers=console,error_file,log_file \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/e19bfe73/products/python-cartridge-agent/pom.xml ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/pom.xml b/products/python-cartridge-agent/pom.xml index 2e72823..9579cef 100755 --- a/products/python-cartridge-agent/pom.xml +++ b/products/python-cartridge-agent/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.stratos</groupId> <artifactId>stratos-products-parent</artifactId> - <version>4.2.0-SNAPSHOT</version> + <version>4.1.2</version> </parent> <artifactId>python-cartridge-agent-parent</artifactId>
