stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raviha...@apache.org
Subject [1/2] stratos git commit: Fixed Python agent live tests with embedded mqtt, improved agent test cases
Date Wed, 05 Aug 2015 07:13:58 GMT
Repository: stratos
Updated Branches:
  refs/heads/master 1c7f63581 -> 67a439253


Fixed Python agent live tests with embedded mqtt, improved agent test cases


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7f8fb760
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7f8fb760
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7f8fb760

Branch: refs/heads/master
Commit: 7f8fb760687cd6332c2de363ae73097a93cc3f91
Parents: 1c7f635
Author: Akila Perera <ravihansa3000@gmail.com>
Authored: Wed Aug 5 12:42:49 2015 +0530
Committer: Akila Perera <ravihansa3000@gmail.com>
Committed: Wed Aug 5 12:42:49 2015 +0530

----------------------------------------------------------------------
 .../pom.xml                                     | 28 ++----
 .../bash/ApplicationSignUpRemovedEvent.sh       |  4 +-
 .../extensions/bash/ArtifactUpdatedEvent.sh     |  4 +-
 .../extensions/bash/CompleteTenantEvent.sh      |  6 +-
 .../extensions/bash/CompleteTopologyEvent.sh    | 10 +-
 .../extensions/bash/CopyArtifacts.sh            |  8 +-
 .../extensions/bash/CreateLVSDummyInterface.sh  | 31 -------
 .../extensions/bash/DomainMappingAddedEvent.sh  | 17 +---
 .../bash/DomainMappingRemovedEvent.sh           | 17 +---
 .../extensions/bash/InstanceActivatedEvent.sh   |  8 +-
 .../extensions/bash/InstanceStartedEvent.sh     |  7 +-
 .../extensions/bash/MemberActivatedEvent.sh     | 23 +----
 .../extensions/bash/MemberStartedEvent.sh       | 23 +----
 .../extensions/bash/MemberSuspendedEvent.sh     | 23 +----
 .../extensions/bash/MemberTerminatedEvent.sh    | 23 +----
 .../extensions/bash/StartServers.sh             | 19 +---
 .../extensions/bash/TenantSubscribedEvent.sh    | 28 ------
 .../cartridge.agent/extensions/bash/clean.sh    |  4 +-
 .../test/PythonCartridgeAgentTest.java          | 97 ++++++++++++++------
 .../src/test/resources/jndi.properties          |  2 +-
 20 files changed, 106 insertions(+), 276 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/pom.xml b/components/org.apache.stratos.python.cartridge.agent/pom.xml
index 7299328..e1226b9 100644
--- a/components/org.apache.stratos.python.cartridge.agent/pom.xml
+++ b/components/org.apache.stratos.python.cartridge.agent/pom.xml
@@ -27,7 +27,7 @@
 
     <modelVersion>4.0.0</modelVersion>
     <artifactId>org.apache.stratos.python.cartridge.agent</artifactId>
-    <packaging>bundle</packaging>
+    <packaging>jar</packaging>
     <name>Apache Stratos - Python Cartridge Agent</name>
 
     <profiles>
@@ -68,23 +68,6 @@
         </profile>
     </profiles>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <DynamicImport-Package>*</DynamicImport-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
     <dependencies>
         <dependency>
             <groupId>junit</groupId>
@@ -120,13 +103,16 @@
             <groupId>org.apache.activemq</groupId>
             <artifactId>activemq-all</artifactId>
             <version>5.10.0</version>
-            <scope>test</scope>
+        </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>
-            <scope>test</scope>
         </dependency>
     </dependencies>
-</project>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
index 651015d..04d15c3 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ApplicationSignUpRemovedEvent.sh
@@ -23,6 +23,4 @@
 # event is received and they are copied to the given path.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Tenant UnSubscribed Event" | tee -a $log
+echo `date`": Application signup removed event shell extension executed"

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
index 16d1a6f..0a84528 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/ArtifactUpdatedEvent.sh
@@ -23,9 +23,7 @@
 # event is received and they are copied to the given path.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Artifacts Updated Event" | tee -a $log
+echo `date`": Artifacts updated event shell extension executed"
 
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
index 2586474..d82f154 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTenantEvent.sh
@@ -23,8 +23,4 @@
 # event is received.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Complete Tenant Event: " | tee -a $log
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Tenant List: ${STRATOS_TENANT_LIST_JSON}" | tee -a $log
+echo `date`": Complete tenant event shell extension executed"

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
index ea2e941..c3d5659 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CompleteTopologyEvent.sh
@@ -23,12 +23,4 @@
 # event is received.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Complete Topology Event: " | tee -a $log
-echo "LB IP: ${STRATOS_LB_IP}" | tee -a $log
-echo "LB PUBLIC IP: $STRATOS_LB_PUBLIC_IP}" | tee -a $log
-echo "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
-echo "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
+echo `date`": Complete topology event shell extension executed"

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
index baa0aeb..dcb4b1b 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CopyArtifacts.sh
@@ -23,10 +23,4 @@
 # event is received and they are copied to the given path.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-if [[ ! -d $2 ]]; then
-   mkdir -p $2
-fi
-cp -rf $1* $2
-echo "Artifacts Copied" | tee -a $log
+echo `date`": Artifacts updated event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
deleted file mode 100755
index f734db3..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-# --------------------------------------------------------------
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# --------------------------------------------------------------
-# This extension script will be executed once the update artifacts
-# event is received and they are copied to the given path.
-# --------------------------------------------------------------
-#
-
-
-sudo modprobe dummy numdummies=1
-sudo ifconfig dummy0 ${STRATOS_LVS_DUMMY_VIRTUAL_IP} netmask ${STRATOS_LVS_SUBNET_MASK}
-
-echo "update the dummy interface with ${STRATOS_LVS_DUMMY_VIRTUAL_IP} and ${STRATOS_LVS_SUBNET_MASK}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
index 7f39472..7e5417f 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingAddedEvent.sh
@@ -23,19 +23,4 @@
 # event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-
-echo "Domain mapping added: [tenant-id] $1 [tenant-domain] $2 [domain-name] $3 [application-context] $4" | tee -a $log
-OUTPUT=`date`": Subscription Domain Added Event"
-OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CONTEXT_PATH: ${SUBSCRIPTION_CONTEXT_PATH}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:addWebAppToHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:addWebAppToHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName><xs:uri xmlns:xs=\"http://mapper.url.carbon.wso2.org\">/t/$STRATOS_SUBSCRIPTION_TENANT_DOMAIN/webapps/$SUBSCRIPTION_CONTEXT_PATH/</xs:uri><xs:appType xmlns:xs=\"http://mapper.url.carbon.wso2.org\">webapp</xs:appType></p:addWebAppToHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
+echo `date`": Domain mapping added event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
index 3911ec6..b6775a0 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/DomainMappingRemovedEvent.sh
@@ -19,21 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed when a subscription domain removed
+# This extension script will be executed when a subscription domain added
 # event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Domain Mapping Removed Event"
-OUTPUT="$OUTPUT SUBSCRIPTION_APPLICATION_ID: ${SUBSCRIPTION_APPLICATION_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_SERVICE_NAME: ${STRATOS_SUBSCRIPTION_SERVICE_NAME},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_DOMAIN_NAME: ${STRATOS_SUBSCRIPTION_DOMAIN_NAME},"
-OUTPUT="$OUTPUT SUBSCRIPTION_CLUSTER_ID: ${SUBSCRIPTION_CLUSTER_ID},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_ID: ${STRATOS_SUBSCRIPTION_TENANT_ID},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_SUBSCRIPTION_TENANT_DOMAIN: $STRATOS_SUBSCRIPTION_TENANT_DOMAIN}"
-echo $OUTPUT | tee -a $log
-
-curl -k -v -X POST -H "Content-Type:application/soap+xml;charset=UTF-8;action=urn:deleteHost" -d "<?xml version=\"1.0\" encoding=\"UTF-8\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"><s:Body><p:deleteHost xmlns:p=\"http://mapper.url.carbon.wso2.org\"><xs:hostName xmlns:xs=\"http://mapper.url.carbon.wso2.org\">$STRATOS_SUBSCRIPTION_DOMAIN_NAME</xs:hostName></p:deleteHost></s:Body></s:Envelope>" https://localhost:9443/services/UrlMapperAdminService -u admin:admin
-
+echo `date`": Domain mapping removed event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
index f5d60e8..29d9bab 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceActivatedEvent.sh
@@ -19,10 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed once the instance is
-# activated and ready to serve incoming requests.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance activated" | tee -a $log
+echo `date`": Instance activated event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
index 7b5aa6a..e7cd0a1 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/InstanceStartedEvent.sh
@@ -19,9 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed once the instance is started.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Instance Started Event: " | tee -a $log
+echo `date`": Instance started event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
index e59b41e..1a84459 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberActivatedEvent.sh
@@ -19,25 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed when member activated
-# event is received.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Activated Event: "
-OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
-OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
-OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
-OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
-OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
-OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
-OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
-OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
-OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
-echo $OUTPUT | tee -a $log
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
-echo "---------------" | tee -a $log
+echo `date`": Member activated event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
index b750fd0..0ce73ce 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberStartedEvent.sh
@@ -19,25 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed when member suspended
-# event is received.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Started Event: "
-OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
-OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
-OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
-OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
-OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
-OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
-OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
-OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
-OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
-echo $OUTPUT | tee -a $log
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
-echo "---------------" | tee -a $log
+echo `date`": Member started event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
index 103e8dd..5e058ba 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberSuspendedEvent.sh
@@ -19,25 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed when member suspended
-# event is received.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Suspended Event: "
-OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
-OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
-OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
-OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
-OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
-OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
-OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
-OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
-OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
-echo $OUTPUT | tee -a $log
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
-echo "---------------" | tee -a $log
+echo `date`": Member suspend event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
index 37bbd84..637b06e 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/MemberTerminatedEvent.sh
@@ -19,25 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed when member terminated
-# event is received.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-OUTPUT=`date`": Member Terminated Event: "
-OUTPUT="$OUTPUT MEMBER_ID: ${STRATOS_MEMBER_ID}, "
-OUTPUT="$OUTPUT MEMBER_IP: ${STRATOS_MEMBER_IP}, "
-OUTPUT="$OUTPUT CLUSTER_ID: ${STRATOS_CLUSTER_ID}, "
-OUTPUT="$OUTPUT LB_CLUSTER_ID: ${STRATOS_LB_CLUSTER_ID}, "
-OUTPUT="$OUTPUT NETWORK_PARTITION_ID: ${STRATOS_NETWORK_PARTITION_ID}, "
-OUTPUT="$OUTPUT SERVICE_NAME: ${STRATOS_SERVICE_NAME}, "
-OUTPUT="$OUTPUT PORTS: ${STRATOS_PORTS},"
-OUTPUT="$OUTPUT STRATOS_LB_IP: ${STRATOS_LB_IP},"
-OUTPUT="$OUTPUT STRATOS_LB_PUBLIC_IP: ${STRATOS_LB_PUBLIC_IP},"
-OUTPUT="$OUTPUT APPLICATION_PATH: ${APPLICATION_PATH},"
-OUTPUT="$OUTPUT STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
-echo $OUTPUT | tee -a $log
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
-echo "---------------" | tee -a $log
+echo `date`": Member terminated event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
index 31ce66c..5cc74a5 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/StartServers.sh
@@ -19,21 +19,8 @@
 # under the License.
 #
 # --------------------------------------------------------------
-# This extension script will be executed to start the servers.
+# This extension script will be executed when a subscription domain added
+# event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-if [[ -z $STRATOS_CLUSTERING ]]; then
-   echo `date`": Starting servers..." | tee -a $log
-else
-   echo `date`": Starting servers in clustering mode..." | tee -a $log
-fi
-
-echo "LB IP: ${STRATOS_LB_IP}" | tee -a $log
-echo "LB PUBLIC IP: $STRATOS_LB_PUBLIC_IP}" | tee -a $log
-echo "STRATOS_PARAM_FILE_PATH: ${STRATOS_PARAM_FILE_PATH}"
-echo "Member List: ${STRATOS_MEMBER_LIST_JSON}" | tee -a $log
-echo "Complete Topology: ${STRATOS_TOPOLOGY_JSON}" | tee -a $log
-echo "Members in LB: ${STRATOS_MEMBERS_IN_LB_JSON}" | tee -a $log
-echo "APPLICATION_PATH: ${APPLICATION_PATH}" | tee -a $log
\ No newline at end of file
+echo `date`": Start servers event shell extension executed"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh
deleted file mode 100755
index 66f004c..0000000
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/TenantSubscribedEvent.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# --------------------------------------------------------------
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# --------------------------------------------------------------
-# This extension script will be executed once the update artifacts
-# event is received and they are copied to the given path.
-# --------------------------------------------------------------
-#
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Tenant Subscribed Event" | tee -a $log

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
index c62ad35..6f15529 100755
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/clean.sh
@@ -23,6 +23,4 @@
 # to clean up the instance before terminating it.
 # --------------------------------------------------------------
 #
-
-log=/var/log/apache-stratos/cartridge-agent-extensions.log
-echo `date`": Cleaning the cartridge" | tee -a $log
+echo `date`": Cleaning the cartridge"

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java b/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
index bb116ce..ea62d97 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
+++ b/components/org.apache.stratos.python.cartridge.agent/src/test/java/org/apache/stratos/python.cartridge.agent/test/PythonCartridgeAgentTest.java
@@ -19,8 +19,10 @@
 
 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;
@@ -38,11 +40,13 @@ import org.apache.stratos.messaging.listener.instance.status.InstanceStartedEven
 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.junit.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.net.ServerSocket;
@@ -57,7 +61,7 @@ public class PythonCartridgeAgentTest {
     private static final Log log = LogFactory.getLog(PythonCartridgeAgentTest.class);
 
     private static final String NEW_LINE = System.getProperty("line.separator");
-//    private static final long TIMEOUT = 1440000;
+    //    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";
@@ -82,6 +86,10 @@ public class PythonCartridgeAgentTest {
     private TopologyEventReceiver topologyEventReceiver;
     private InstanceStatusEventReceiver instanceStatusEventReceiver;
     private int cepPort = 7711;
+    private BrokerService broker = new BrokerService();
+    private static final String ACTIVEMQ_AMQP_BIND_ADDRESS = "tcp://localhost:61617";
+    private static final String ACTIVEMQ_MQTT_BIND_ADDRESS = "mqtt://localhost:1883";
+    private static final UUID PYTHON_AGENT_DIR_NAME = UUID.randomUUID();
 
     public PythonCartridgeAgentTest(ArtifactUpdatedEvent artifactUpdatedEvent, Boolean expectedResult) {
         this.artifactUpdatedEvent = artifactUpdatedEvent;
@@ -101,10 +109,21 @@ public class PythonCartridgeAgentTest {
      * Setup method for test method testPythonCartridgeAgent
      */
     @Before
-    public void setup(){
+    public void setup() {
         serverSocketList = new ArrayList<ServerSocket>();
         executorList = new HashMap<String, Executor>();
-
+        try {
+            broker.addConnector(ACTIVEMQ_AMQP_BIND_ADDRESS);
+            broker.addConnector(ACTIVEMQ_MQTT_BIND_ADDRESS);
+            broker.setBrokerName("testBroker");
+            broker.setDataDirectory(PythonCartridgeAgentTest.class.getResource("/").getPath() +
+                    File.separator + ".." + File.separator + PYTHON_AGENT_DIR_NAME + File.separator + "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();
@@ -135,13 +154,14 @@ public class PythonCartridgeAgentTest {
 
             this.eventReceiverInitiated = true;
         }
-
-        String agentPath = setupPythonAgent();
-        log.info("Starting python cartridge agent...");
-        this.outputStream = executeCommand("python " + agentPath + "/agent.py");
-
         // 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 > " + getResourcesFolderPath() + File.separator + ".." +
+                        File.separator + PYTHON_AGENT_DIR_NAME + File.separator + "cartridge-agent-ttttt.log");
     }
 
     /**
@@ -158,26 +178,24 @@ public class PythonCartridgeAgentTest {
                     log.info("Terminating process: " + commandText);
                     watchdog.destroyProcess();
                 }
-                File workingDirectory = executor.getWorkingDirectory();
-                if (workingDirectory != null) {
-                    log.info("Cleaning working directory: " + workingDirectory.getAbsolutePath());
-                    FileUtils.deleteDirectory(workingDirectory);
-                }
-            } catch (Exception ignore) {
+            }
+            catch (Exception ignore) {
             }
         }
         for (ServerSocket serverSocket : serverSocketList) {
             try {
                 log.info("Stopping socket server: " + serverSocket.getLocalSocketAddress());
                 serverSocket.close();
-            } catch (IOException ignore) {
+            }
+            catch (IOException ignore) {
             }
         }
 
         try {
             log.info("Deleting source checkout folder...");
             FileUtils.deleteDirectory(new File(SOURCE_PATH));
-        } catch (Exception ignore){
+        }
+        catch (Exception ignore) {
 
         }
 
@@ -186,16 +204,23 @@ public class PythonCartridgeAgentTest {
 
         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
      */
     @Parameterized.Parameters
-    public static Collection getArtifactUpdatedEventsAsParams(){
+    public static Collection getArtifactUpdatedEventsAsParams() {
         ArtifactUpdatedEvent publicRepoEvent = createTestArtifactUpdatedEvent();
 
         ArtifactUpdatedEvent privateRepoEvent = createTestArtifactUpdatedEvent();
@@ -223,6 +248,7 @@ public class PythonCartridgeAgentTest {
     /**
      * Creates an {@link org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent} object with a public
      * repository URL
+     *
      * @return
      */
     private static ArtifactUpdatedEvent createTestArtifactUpdatedEvent() {
@@ -256,7 +282,8 @@ public class PythonCartridgeAgentTest {
                                 // 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
+                                        SERVICE_NAME, CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID,
+                                        PARTITION_ID
                                 );
                                 publishEvent(memberInitializedEvent);
                                 log.info("Member initialized event published");
@@ -282,7 +309,7 @@ public class PythonCartridgeAgentTest {
 
         communicatorThread.start();
 
-        while (!instanceActivated){
+        while (!instanceActivated) {
             // wait until the instance activated event is received.
             sleep(2000);
         }
@@ -293,6 +320,7 @@ public class PythonCartridgeAgentTest {
 
     /**
      * Publish messaging event
+     *
      * @param event
      */
     private void publishEvent(Event event) {
@@ -303,6 +331,7 @@ public class PythonCartridgeAgentTest {
 
     /**
      * Start server socket
+     *
      * @param port
      */
     private void startServerSocket(final int port) {
@@ -311,9 +340,11 @@ public class PythonCartridgeAgentTest {
             public void run() {
                 try {
                     ServerSocket serverSocket = new ServerSocket(port);
-                    serverSocket.accept();
                     serverSocketList.add(serverSocket);
-                } catch (IOException e) {
+                    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);
@@ -384,7 +415,8 @@ public class PythonCartridgeAgentTest {
     private void sleep(long time) {
         try {
             Thread.sleep(time);
-        } catch (InterruptedException ignore) {
+        }
+        catch (InterruptedException ignore) {
         }
     }
 
@@ -397,7 +429,9 @@ public class PythonCartridgeAgentTest {
         try {
             log.info("Setting up python cartridge agent...");
             String srcAgentPath = getResourcesFolderPath() + "/../../src/main/python/cartridge.agent/cartridge.agent";
-            String destAgentPath = getResourcesFolderPath() + "/../" + UUID.randomUUID() + "/cartridge.agent";
+            String destAgentPath =
+                    getResourcesFolderPath() + File.separator + ".." + File.separator + PYTHON_AGENT_DIR_NAME +
+                            "/cartridge.agent";
             FileUtils.copyDirectory(new File(srcAgentPath), new File(destAgentPath));
 
             String srcAgentConfPath = getResourcesFolderPath() + "/agent.conf";
@@ -415,14 +449,15 @@ public class PythonCartridgeAgentTest {
             log.info("Changing extension scripts permissions");
             File extensionsPath = new File(destAgentPath + "/extensions/bash");
             File[] extensions = extensionsPath.listFiles();
-            for (File extension:extensions){
+            for (File extension : extensions) {
                 extension.setExecutable(true);
             }
 
             log.info("Python cartridge agent setup completed");
 
             return destAgentPath;
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             String message = "Could not copy cartridge agent distribution";
             log.error(message, e);
             throw new RuntimeException(message, e);
@@ -440,6 +475,8 @@ public class PythonCartridgeAgentTest {
             CommandLine commandline = CommandLine.parse(commandText);
             DefaultExecutor exec = new DefaultExecutor();
             PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
+            exec.setWorkingDirectory(new File(
+                    getResourcesFolderPath() + File.separator + ".." + File.separator + PYTHON_AGENT_DIR_NAME));
             exec.setStreamHandler(streamHandler);
             ExecuteWatchdog watchdog = new ExecuteWatchdog(TIMEOUT);
             exec.setWatchdog(watchdog);
@@ -456,7 +493,8 @@ public class PythonCartridgeAgentTest {
             });
             executorList.put(commandText, exec);
             return outputStream;
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             log.error(outputStream.toString(), e);
             throw new RuntimeException(e);
         }
@@ -464,10 +502,11 @@ public class PythonCartridgeAgentTest {
 
     /**
      * Get resources folder path
+     *
      * @return
      */
     private static String getResourcesFolderPath() {
-        String path = PythonCartridgeAgentTest.class.getResource("/").getPath();
+        String path = PythonCartridgeAgentTest.class.getResource(File.separator).getPath();
         return StringUtils.removeEnd(path, File.separator);
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/7f8fb760/components/org.apache.stratos.python.cartridge.agent/src/test/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/jndi.properties b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/jndi.properties
index 21d7420..beefe3c 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/test/resources/jndi.properties
+++ b/components/org.apache.stratos.python.cartridge.agent/src/test/resources/jndi.properties
@@ -18,5 +18,5 @@
 #
 
 connectionfactoryName=TopicConnectionFactory
-java.naming.provider.url=tcp://localhost:61616
+java.naming.provider.url=tcp://localhost:61617
 java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory


Mime
View raw message