From 1343d7e69da236e6e83cf508d2215871c3f634e7 Mon Sep 17 00:00:00 2001 From: ksdperera Date: Tue, 15 Dec 2015 12:15:38 +0530 Subject: [PATCH 1/7] Adding HA Cluster Integration Test Automation --- .../integration/test/ha/HATestCase.java | 144 ++++ .../CEP/haTestCase/activeNodeConfig/axis2.xml | 729 ++++++++++++++++++ .../activeNodeConfig/event-processor.xml | 161 ++++ .../activeNodeConfig/master-datasources.xml | 106 +++ .../haTestCase/passiveNodeConfig/axis2.xml | 729 ++++++++++++++++++ .../haTestCase/passiveNodeConfig/carbon.xml | 681 ++++++++++++++++ .../passiveNodeConfig/event-processor.xml | 161 ++++ .../passiveNodeConfig/master-datasources.xml | 106 +++ 8 files changed, 2817 insertions(+) create mode 100644 modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml diff --git a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java new file mode 100644 index 00000000..397916f3 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.wso2.carbon.integration.test.ha; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; +import org.wso2.carbon.automation.engine.annotations.SetEnvironment; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; +import org.wso2.carbon.automation.extensions.servers.carbonserver.MultipleServersManager; +import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider; +import org.wso2.carbon.event.simulator.stub.types.EventDto; +import org.wso2.carbon.integration.common.tests.CarbonTestServerManager; +import org.wso2.carbon.integration.common.utils.LoginLogoutClient; +import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; +import org.wso2.carbon.integration.test.client.WireMonitorServer; +import org.wso2.cep.integration.common.utils.CEPIntegrationTest; +import org.wso2.cep.integration.common.utils.CEPIntegrationTestConstants; + +import java.io.File; + + +public class HATestCase{ + + private static final Log log = LogFactory.getLog(HATestCase.class); + private MultipleServersManager manager = new MultipleServersManager(); + private static final String EVENT_PROCESSING_FILE = "event-processor.xml"; + private static final String AXIS2_XML_FILE = "axis2.xml"; + private static final String MASTER_DATASOURCES = "master-datasources.xml"; + private static final String CARBON = "carbon.xml"; + private static final String RESOURCE_LOCATION1 = TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "CEP" + + File.separator + "haTestCase"+ File.separator + "activeNodeConfig"; + private static final String RESOURCE_LOCATION2 = TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "CEP" + + File.separator + "haTestCase"+ File.separator + "passiveNodeConfig"; + private static String CARBON_HOME1; + private static String CARBON_HOME2; + private ServerConfigurationManager serverConfigManager1; + private ServerConfigurationManager serverConfigManager2; + private AutomationContext cepServer1; + private AutomationContext cepServer2; + + + @BeforeClass(alwaysRun = true) + public void init() throws Exception { + log.info("--------Initialization Start--------"); + cepServer1 = new AutomationContext("CEP",TestUserMode.SUPER_TENANT_ADMIN); + cepServer2 = new AutomationContext("CEP",TestUserMode.SUPER_TENANT_ADMIN); + + CarbonTestServerManager server1 = new CarbonTestServerManager(cepServer1,0); + CarbonTestServerManager server2 = new CarbonTestServerManager(cepServer2,1); + + serverConfigManager1 = new ServerConfigurationManager(cepServer1); + serverConfigManager2 = new ServerConfigurationManager(cepServer2); + + manager.startServers(server1,server2); + + CARBON_HOME1 = server1.getCarbonHome(); + CARBON_HOME2 = server2.getCarbonHome(); + + log.info("Server 1 Replacing " + EVENT_PROCESSING_FILE); + String eventProcessingFileLocation = RESOURCE_LOCATION1 + File.separator + EVENT_PROCESSING_FILE; + String cepEventProcessorFileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + + "conf" + File.separator + EVENT_PROCESSING_FILE; + serverConfigManager1.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation), new File(cepEventProcessorFileLocation), true); + + log.info("Server 1 Replacing " + AXIS2_XML_FILE); + String axis2FileLocation = RESOURCE_LOCATION1 + File.separator + AXIS2_XML_FILE; + String cepAxis2FileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" + + File.separator + "axis2" + File.separator + AXIS2_XML_FILE; + serverConfigManager1.applyConfigurationWithoutRestart(new File(axis2FileLocation), new File(cepAxis2FileLocation), true); + + log.info("Server 1 Replacing " + MASTER_DATASOURCES); + String msDataFileLocation = RESOURCE_LOCATION1 + File.separator + MASTER_DATASOURCES; + String cepMsFileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" + + File.separator + "datasources" + File.separator + MASTER_DATASOURCES; + serverConfigManager1.applyConfigurationWithoutRestart(new File(msDataFileLocation), new File(cepMsFileLocation), true); + + log.info("Restarting CEP server1"); + serverConfigManager1.restartGracefully(); + + log.info("Server 2 Replacing " + EVENT_PROCESSING_FILE); + String eventProcessingFileLocation2 = RESOURCE_LOCATION2 + File.separator + EVENT_PROCESSING_FILE; + String cepEventProcessorFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + + "conf" + File.separator + EVENT_PROCESSING_FILE; + serverConfigManager2.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation2), new File(cepEventProcessorFileLocation2), true); + + log.info("Server 2 Replacing " + AXIS2_XML_FILE); + String axis2FileLocation2 = RESOURCE_LOCATION2 + File.separator + AXIS2_XML_FILE; + String cepAxis2FileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + + File.separator + "axis2" + File.separator + AXIS2_XML_FILE; + serverConfigManager2.applyConfigurationWithoutRestart(new File(axis2FileLocation2), new File(cepAxis2FileLocation2), true); + + log.info("Server 2 Replacing " + MASTER_DATASOURCES); + String msDataFileLocation2 = RESOURCE_LOCATION2 + File.separator + MASTER_DATASOURCES; + String cepMsFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + + File.separator + "datasources" + File.separator + MASTER_DATASOURCES; + serverConfigManager2.applyConfigurationWithoutRestart(new File(msDataFileLocation2), new File(cepMsFileLocation2), true); + + log.info("Server 2 Replacing " + CARBON); + String carbonDataFileLocation2 = RESOURCE_LOCATION2 + File.separator + CARBON; + String cepCarbonFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + + File.separator + CARBON; + serverConfigManager2.applyConfigurationWithoutRestart(new File(carbonDataFileLocation2), new File(cepCarbonFileLocation2), true); + + + log.info("Restarting CEP server2"); + serverConfigManager2.restartGracefully(); + Thread.sleep(5000); + log.info("--------Initialization End--------"); + } + + @Test + public void test() { + log.info("Test server startup with system properties"); + } + + + @AfterClass(alwaysRun = true) + public void clean() throws Exception { + cepServer1 = null; + cepServer2 = null; + manager.stopAllServers(); + } +} diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml new file mode 100644 index 00000000..bb2e749f --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml @@ -0,0 +1,729 @@ + + + + + + + + + + + + + ${hotdeployment} + ${hotupdate} + optional + true + work/mtom + 4000 + + ${childfirstCL} + + + true + + + true + + + + false + + inmemory + + + + + + + services + + + axis2services + + + axis2modules + + + @product.name@-@product.version@ + + + @product.name@-@product.version@ + + + + + + + false + + + + + + false + + + true + + + + ./repository/deployment/server/synapse-configs + + + + . + + + . + + + WSO2 Carbon Server + + + + + + + ${jaxwsparam} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9763 + + + + + + + + + + + + 9443 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 + chunked + + true + + + HTTP/1.1 + chunked + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + wka + + + + + wso2.carbon.domain + + + + + + 45564 + + 100 + + 60 + + + + + + 10.100.4.11 + + + + + + 4000 + + + + + + + + + + + + + + + + + + 10.100.4.11 + 4000 + + + 10.100.4.11 + 4001 + + + + + + + + + \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml new file mode 100644 index 00000000..e3c3ed8d --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml @@ -0,0 +1,161 @@ + + + + + + + 15 + 10 + + cep_persistence + + + + + + + + + + + + 10000 + + 10.100.4.11 + 11224 + 20000 + 20000 + + 5242880 + + UTF-8 + 1024 + 30000 + + 1000000 + + 10 + + 1000000 + + 10 + + + 10.100.4.11 + 10005 + 15000 + 10000 + + + 0.0.0.0 + 11000 + + 5242880 + + UTF-8 + 1024 + 30000 + + + + + + + + + + + 0.0.0.0 + 8904 + + + 0.0.0.0 + 11000 + + + + + + + localhost + 8904 + + + localhost + 8905 + + + + 20000 + + 5000 + + 10000 + + + + + + 15000 + 15100 + + + 20000 + + 8192 + + 8192 + + 5242880 + + UTF-8 + + 10000 + + 20000 + + + + 1024 + + 5242880 + + UTF-8 + + 20000 + + + + 60000 + 60000 + + + org.wso2.cep.storm.dependencies.jar + + + + 20000 + + + + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml new file mode 100644 index 00000000..44d179f9 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml @@ -0,0 +1,106 @@ + + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + + WSO2_CARBON_DB + The datasource used for registry and user manager + + jdbc/WSO2CarbonDB + + + + jdbc:h2:repository/database/WSO2CARBON_DB;AUTO_SERVER=TRUE + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + false + + + + + + WSO2_GEO_DB + The datasource used for geo dashboard + + jdbc/WSO2GeoDB + + + + jdbc:h2:repository/database/WSO2_GEO;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000 + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + false + + + + + + + + + + \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml new file mode 100644 index 00000000..33265cbf --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml @@ -0,0 +1,729 @@ + + + + + + + + + + + + + ${hotdeployment} + ${hotupdate} + optional + true + work/mtom + 4000 + + ${childfirstCL} + + + true + + + true + + + + false + + inmemory + + + + + + + services + + + axis2services + + + axis2modules + + + @product.name@-@product.version@ + + + @product.name@-@product.version@ + + + + + + + false + + + + + + false + + + true + + + + ./repository/deployment/server/synapse-configs + + + + . + + + . + + + WSO2 Carbon Server + + + + + + + ${jaxwsparam} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9763 + + + + + + + + + + + + 9443 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 + chunked + + true + + + HTTP/1.1 + chunked + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + wka + + + + + wso2.carbon.domain + + + + + + 45564 + + 100 + + 60 + + + + + + 10.100.4.11 + + + + + + 4001 + + + + + + + + + + + + + + + + + + 10.100.4.11 + 4000 + + + 10.100.4.11 + 4001 + + + + + + + + + \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml new file mode 100644 index 00000000..41d52f98 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml @@ -0,0 +1,681 @@ + + + + + + + + + WSO2 Complex Event Processor + + + CEP + + + 4.0.0 + + + + + + + + + local:/${carbon.context}/services/ + + + + + + + ComplexEventProcessor + + + + + + + org.wso2.carbon + + + / + + + + + + + + + 15 + + + + + + + + + 1 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 10500 + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + + + + + + + + 30 + + + + + + + + + 15 + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + true + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + + + + + true + allow + + + + + + + + + + + false + + (.*)(/images|/css|/js|/docs)(.*) + + + + + + + true + + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + http://product-dist.wso2.com/p2/carbon/releases/wilkes/ + + + + + + + + true + + + + + + true + + \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml new file mode 100644 index 00000000..2cb3932f --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml @@ -0,0 +1,161 @@ + + + + + + + 15 + 10 + + cep_persistence + + + + + + + + + + + + 10000 + + 10.100.4.11 + 11225 + 20000 + 20000 + + 5242880 + + UTF-8 + 1024 + 30000 + + 1000000 + + 10 + + 1000000 + + 10 + + + 10.100.4.11 + 10006 + 15000 + 10000 + + + 0.0.0.0 + 11000 + + 5242880 + + UTF-8 + 1024 + 30000 + + + + + + + + + + + 0.0.0.0 + 8904 + + + 0.0.0.0 + 11000 + + + + + + + localhost + 8904 + + + localhost + 8905 + + + + 20000 + + 5000 + + 10000 + + + + + + 15000 + 15100 + + + 20000 + + 8192 + + 8192 + + 5242880 + + UTF-8 + + 10000 + + 20000 + + + + 1024 + + 5242880 + + UTF-8 + + 20000 + + + + 60000 + 60000 + + + org.wso2.cep.storm.dependencies.jar + + + + 20000 + + + + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml new file mode 100644 index 00000000..a5e76588 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml @@ -0,0 +1,106 @@ + + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + + WSO2_CARBON_DB + The datasource used for registry and user manager + + jdbc/WSO2CarbonDB + + + + jdbc:h2:repository/database/WSO2CARBON_DB;AUTO_SERVER=TRUE + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + false + + + + + + WSO2_GEO_DB + The datasource used for geo dashboard + + jdbc/WSO2GeoDB + + + + jdbc:h2:repository/database/WSO2_GEO;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000 + wso2carbon + wso2carbon + org.h2.Driver + 50 + 60000 + true + SELECT 1 + 30000 + false + + + + + + + + + + \ No newline at end of file From 95af117048999e51133f07fab4069a944cbfb862 Mon Sep 17 00:00:00 2001 From: ksdperera Date: Mon, 4 Jan 2016 10:07:28 +0530 Subject: [PATCH 2/7] Modify HATestCase for multiple server handling in HA cluster mode and adding server configuration files and test sample files --- .../integration/test/ha/HATestCase.java | 263 +++++-- .../HATestCase/HAArtifacts/httpReceiver.txt | 56 ++ .../HATestCase/HAArtifacts/httpReceiver.xml | 26 + .../org.wso2.event.sensor.stream_1.0.0.json | 44 ++ .../HAArtifacts/wso2EventPublisher.xml | 29 + .../HAArtifacts/wso2EventPublisher2.xml | 29 + .../activeNodeConfigs}/axis2.xml | 6 +- .../activeNodeConfigs}/event-processor.xml | 20 +- .../passiveNodeConfigs}/axis2.xml | 14 +- .../passiveNodeConfigs}/event-processor.xml | 5 +- .../activeNodeConfig/master-datasources.xml | 106 --- .../haTestCase/passiveNodeConfig/carbon.xml | 681 ------------------ .../passiveNodeConfig/master-datasources.xml | 106 --- 13 files changed, 425 insertions(+), 960 deletions(-) create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.txt create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/org.wso2.event.sensor.stream_1.0.0.json create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher.xml create mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher2.xml rename modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/{haTestCase/activeNodeConfig => HATestCase/activeNodeConfigs}/axis2.xml (99%) rename modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/{haTestCase/activeNodeConfig => HATestCase/activeNodeConfigs}/event-processor.xml (95%) rename modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/{haTestCase/passiveNodeConfig => HATestCase/passiveNodeConfigs}/axis2.xml (99%) rename modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/{haTestCase/passiveNodeConfig => HATestCase/passiveNodeConfigs}/event-processor.xml (98%) delete mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml delete mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml delete mode 100644 modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml diff --git a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java index 397916f3..9a9ccff7 100644 --- a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java +++ b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java @@ -22,57 +22,95 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; -import org.wso2.carbon.automation.engine.annotations.SetEnvironment; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.wso2.appserver.integration.common.clients.*; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; import org.wso2.carbon.automation.extensions.servers.carbonserver.MultipleServersManager; import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider; -import org.wso2.carbon.event.simulator.stub.types.EventDto; import org.wso2.carbon.integration.common.tests.CarbonTestServerManager; import org.wso2.carbon.integration.common.utils.LoginLogoutClient; import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager; -import org.wso2.carbon.integration.test.client.WireMonitorServer; +import org.wso2.carbon.integration.test.client.HttpEventPublisherClient; +import org.wso2.carbon.integration.test.client.Wso2EventServer; import org.wso2.cep.integration.common.utils.CEPIntegrationTest; -import org.wso2.cep.integration.common.utils.CEPIntegrationTestConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.xpath.*; import java.io.File; +import java.io.IOException; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.Enumeration; +import org.xml.sax.SAXException; - -public class HATestCase{ - +public class HATestCase extends CEPIntegrationTest { private static final Log log = LogFactory.getLog(HATestCase.class); private MultipleServersManager manager = new MultipleServersManager(); private static final String EVENT_PROCESSING_FILE = "event-processor.xml"; private static final String AXIS2_XML_FILE = "axis2.xml"; - private static final String MASTER_DATASOURCES = "master-datasources.xml"; - private static final String CARBON = "carbon.xml"; - private static final String RESOURCE_LOCATION1 = TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "CEP" - + File.separator + "haTestCase"+ File.separator + "activeNodeConfig"; - private static final String RESOURCE_LOCATION2 = TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" + File.separator + "CEP" - + File.separator + "haTestCase"+ File.separator + "passiveNodeConfig"; + + private static final String RESOURCE_LOCATION1 = TestConfigurationProvider.getResourceLocation() + "artifacts" + File.separator + "CEP" + + File.separator + "HATestCase" + File.separator + "activeNodeConfigs"; + private static final String RESOURCE_LOCATION2 = TestConfigurationProvider.getResourceLocation() + "artifacts" + File.separator + "CEP" + + File.separator + "HATestCase" + File.separator + "passiveNodeConfigs"; + private static String CARBON_HOME1; private static String CARBON_HOME2; + private ServerConfigurationManager serverConfigManager1; private ServerConfigurationManager serverConfigManager2; + private AutomationContext cepServer1; private AutomationContext cepServer2; + private CarbonTestServerManager server1; + private CarbonTestServerManager server2; + private EventStreamManagerAdminServiceClient eventStreamManagerAdminServiceClient1; + private EventReceiverAdminServiceClient eventReceiverAdminServiceClient1; + private EventPublisherAdminServiceClient eventPublisherAdminServiceClient1; + private static String backendURL1; + + private EventStreamManagerAdminServiceClient eventStreamManagerAdminServiceClient2; + private EventReceiverAdminServiceClient eventReceiverAdminServiceClient2; + private EventPublisherAdminServiceClient eventPublisherAdminServiceClient2; + private static String backendURL2; + + private static String machineIP; + + /* + + */ @BeforeClass(alwaysRun = true) public void init() throws Exception { log.info("--------Initialization Start--------"); - cepServer1 = new AutomationContext("CEP",TestUserMode.SUPER_TENANT_ADMIN); - cepServer2 = new AutomationContext("CEP",TestUserMode.SUPER_TENANT_ADMIN); + super.init(TestUserMode.SUPER_TENANT_ADMIN); + + machineIP = findAddress("localhost"); + + cepServer1 = new AutomationContext("CEP", "cep002", TestUserMode.SUPER_TENANT_ADMIN); + cepServer2 = new AutomationContext("CEP", "cep003", TestUserMode.SUPER_TENANT_ADMIN); - CarbonTestServerManager server1 = new CarbonTestServerManager(cepServer1,0); - CarbonTestServerManager server2 = new CarbonTestServerManager(cepServer2,1); + log.info("Sever1 https Port : "+cepServer1.getInstance().getPorts().get("https")); + log.info("Sever2 https Port : "+cepServer2.getInstance().getPorts().get("https")); + + server1 = new CarbonTestServerManager(cepServer1, 801); + server2 = new CarbonTestServerManager(cepServer2, 802); serverConfigManager1 = new ServerConfigurationManager(cepServer1); serverConfigManager2 = new ServerConfigurationManager(cepServer2); - manager.startServers(server1,server2); + manager.startServers(server1, server2); CARBON_HOME1 = server1.getCarbonHome(); CARBON_HOME2 = server2.getCarbonHome(); @@ -82,63 +120,200 @@ public void init() throws Exception { String cepEventProcessorFileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" + File.separator + EVENT_PROCESSING_FILE; serverConfigManager1.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation), new File(cepEventProcessorFileLocation), true); + replaceIP(cepEventProcessorFileLocation); log.info("Server 1 Replacing " + AXIS2_XML_FILE); String axis2FileLocation = RESOURCE_LOCATION1 + File.separator + AXIS2_XML_FILE; String cepAxis2FileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + AXIS2_XML_FILE; serverConfigManager1.applyConfigurationWithoutRestart(new File(axis2FileLocation), new File(cepAxis2FileLocation), true); - - log.info("Server 1 Replacing " + MASTER_DATASOURCES); - String msDataFileLocation = RESOURCE_LOCATION1 + File.separator + MASTER_DATASOURCES; - String cepMsFileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" - + File.separator + "datasources" + File.separator + MASTER_DATASOURCES; - serverConfigManager1.applyConfigurationWithoutRestart(new File(msDataFileLocation), new File(cepMsFileLocation), true); + replaceIP(cepAxis2FileLocation); log.info("Restarting CEP server1"); serverConfigManager1.restartGracefully(); + // Waiting for the server to restart + Thread.sleep(5000); log.info("Server 2 Replacing " + EVENT_PROCESSING_FILE); String eventProcessingFileLocation2 = RESOURCE_LOCATION2 + File.separator + EVENT_PROCESSING_FILE; String cepEventProcessorFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + File.separator + EVENT_PROCESSING_FILE; serverConfigManager2.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation2), new File(cepEventProcessorFileLocation2), true); + replaceIP(cepEventProcessorFileLocation2); log.info("Server 2 Replacing " + AXIS2_XML_FILE); String axis2FileLocation2 = RESOURCE_LOCATION2 + File.separator + AXIS2_XML_FILE; String cepAxis2FileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + AXIS2_XML_FILE; serverConfigManager2.applyConfigurationWithoutRestart(new File(axis2FileLocation2), new File(cepAxis2FileLocation2), true); - - log.info("Server 2 Replacing " + MASTER_DATASOURCES); - String msDataFileLocation2 = RESOURCE_LOCATION2 + File.separator + MASTER_DATASOURCES; - String cepMsFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" - + File.separator + "datasources" + File.separator + MASTER_DATASOURCES; - serverConfigManager2.applyConfigurationWithoutRestart(new File(msDataFileLocation2), new File(cepMsFileLocation2), true); - - log.info("Server 2 Replacing " + CARBON); - String carbonDataFileLocation2 = RESOURCE_LOCATION2 + File.separator + CARBON; - String cepCarbonFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" - + File.separator + CARBON; - serverConfigManager2.applyConfigurationWithoutRestart(new File(carbonDataFileLocation2), new File(cepCarbonFileLocation2), true); - + replaceIP(cepAxis2FileLocation2); log.info("Restarting CEP server2"); serverConfigManager2.restartGracefully(); + // Waiting for the server to restart Thread.sleep(5000); + + backendURL1 = cepServer1.getContextUrls().getBackEndUrl(); + String loggedInSessionCookie = getSessionCookie(cepServer1); + eventReceiverAdminServiceClient1 = configurationUtil.getEventReceiverAdminServiceClient(backendURL1, loggedInSessionCookie); + eventStreamManagerAdminServiceClient1 = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL1, loggedInSessionCookie); + eventPublisherAdminServiceClient1 = configurationUtil.getEventPublisherAdminServiceClient(backendURL1, loggedInSessionCookie); + + backendURL2 = cepServer2.getContextUrls().getBackEndUrl(); + String loggedInSessionCookie2 = getSessionCookie(cepServer2); + eventReceiverAdminServiceClient2 = configurationUtil.getEventReceiverAdminServiceClient(backendURL2, loggedInSessionCookie2); + eventStreamManagerAdminServiceClient2 = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL2, loggedInSessionCookie2); + eventPublisherAdminServiceClient2 = configurationUtil.getEventPublisherAdminServiceClient(backendURL2, loggedInSessionCookie2); + log.info("--------Initialization End--------"); } - @Test - public void test() { - log.info("Test server startup with system properties"); - } + @Test(groups = {"wso2.cep"}, description = "Testing CEP HA for two cluster nodes") + public void test1() throws Exception { + + String samplePath = "HATestCase" + File.separator + "HAArtifacts"; + int startESCount1 = eventStreamManagerAdminServiceClient1.getEventStreamCount(); + int startERCount1 = eventReceiverAdminServiceClient1.getActiveEventReceiverCount(); + int startEPCount1 = eventPublisherAdminServiceClient1.getActiveEventPublisherCount(); + + int startESCount2 = eventStreamManagerAdminServiceClient2.getEventStreamCount(); + int startERCount2 = eventReceiverAdminServiceClient2.getActiveEventReceiverCount(); + int startEPCount2 = eventPublisherAdminServiceClient2.getActiveEventPublisherCount(); + + int activeMsgCount = 9; + int passiveMsgCount = 9; + + //Add StreamDefinition + String streamDefinitionAsString = getJSONArtifactConfiguration(samplePath, "org.wso2.event.sensor.stream_1.0.0.json"); + eventStreamManagerAdminServiceClient1.addEventStreamAsString(streamDefinitionAsString); + Assert.assertEquals(eventStreamManagerAdminServiceClient1.getEventStreamCount(), startESCount1 + 1); + eventStreamManagerAdminServiceClient2.addEventStreamAsString(streamDefinitionAsString); + Assert.assertEquals(eventStreamManagerAdminServiceClient2.getEventStreamCount(), startESCount2 + 1); + + //Add Http JSON EventReceiver without mapping + String eventReceiverConfig = getXMLArtifactConfiguration(samplePath, "httpReceiver.xml"); + eventReceiverAdminServiceClient1.addEventReceiverConfiguration(eventReceiverConfig); + Assert.assertEquals(eventReceiverAdminServiceClient1.getActiveEventReceiverCount(), startERCount1 + 1); + eventReceiverAdminServiceClient2.addEventReceiverConfiguration(eventReceiverConfig); + Assert.assertEquals(eventReceiverAdminServiceClient2.getActiveEventReceiverCount(), startERCount2 + 1); + + //Add Wso2event EventPublisher + String eventPublisherConfig = getXMLArtifactConfiguration(samplePath, "wso2EventPublisher.xml"); + eventPublisherAdminServiceClient1.addEventPublisherConfiguration(eventPublisherConfig); + Assert.assertEquals(eventPublisherAdminServiceClient1.getActiveEventPublisherCount(), startEPCount1 + 1); + eventPublisherConfig = getXMLArtifactConfiguration(samplePath, "wso2EventPublisher2.xml"); + eventPublisherAdminServiceClient2.addEventPublisherConfiguration(eventPublisherConfig); + Assert.assertEquals(eventPublisherAdminServiceClient2.getActiveEventPublisherCount(), startEPCount2 + 1); + + // The data-bridge receiver + Wso2EventServer agentServer1 = new Wso2EventServer(samplePath, Integer.parseInt(cepServer1.getInstance().getPorts().get("thrift_publisher")), false); + Thread agentServerThread = new Thread(agentServer1); + agentServerThread.start(); + // Let the server start + Thread.sleep(10000); + + // The data-bridge receiver + Wso2EventServer agentServer2 = new Wso2EventServer(samplePath, Integer.parseInt(cepServer2.getInstance().getPorts().get("thrift_publisher")), false); + Thread agentServerThread2 = new Thread(agentServer2); + agentServerThread2.start(); + // Let the server start + Thread.sleep(10000); + + for (int i = 0; i < 3; i++) { + if (i == 1) { + log.info("Shutdown Active Server"); + server1.stopServer(); + } + log.info("Event No : " + i); + HttpEventPublisherClient.publish("http://localhost:" + cepServer2.getInstance().getPorts().get("http") + + "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(30000); + } + log.info("Start Active Server Again"); + server1.startServer(); + for (int i = 0; i < 3; i++) { + if (i == 1) { + log.info("Shutdown Passive Server"); + server2.stopServer(); + } + log.info("Event No : " + i); + HttpEventPublisherClient.publish("http://localhost:" + cepServer1.getInstance().getPorts().get("http") + + "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(30000); + } + + log.info("Total Event Send Count : "+(activeMsgCount+passiveMsgCount)); + log.info("Test Run Active Event Count : " + agentServer1.getMsgCount()); + log.info("Test Run Passive Event Count : " + agentServer2.getMsgCount()); + + try { + Assert.assertEquals(agentServer1.getMsgCount(), activeMsgCount, "Incorrect number of messages consumed by Active Node!"); + Assert.assertEquals(agentServer2.getMsgCount(), passiveMsgCount, "Incorrect number of messages consumed by Passive Node!"); + } catch (Throwable e) { + log.error("Exception thrown: " + e.getMessage(), e); + Assert.fail("Exception: " + e.getMessage()); + } finally { + agentServer1.stop(); + agentServer2.stop(); + } + + } @AfterClass(alwaysRun = true) public void clean() throws Exception { + super.cleanup(); cepServer1 = null; cepServer2 = null; manager.stopAllServers(); } -} + + + protected String getSessionCookie(AutomationContext serverContext) throws Exception { + LoginLogoutClient loginLogoutClient = new LoginLogoutClient(serverContext); + return loginLogoutClient.login(); + } + + public static String findAddress(String hostname) throws SocketException { + if (hostname.trim().equals("localhost") || hostname.trim().equals("127.0.0.1") || hostname.trim().equals("::1")) { + Enumeration ifaces = + NetworkInterface.getNetworkInterfaces(); + while (ifaces.hasMoreElements()) { + NetworkInterface iface = ifaces.nextElement(); + Enumeration addresses = iface.getInetAddresses(); + + while (addresses.hasMoreElements()) { + InetAddress addr = addresses.nextElement(); + if (addr instanceof Inet4Address && !addr.isLoopbackAddress()) { + return addr.getHostAddress(); + } + } + } + return "127.0.0.1"; + } else { + return hostname; + } + } + + public void replaceIP(String inputFilePath) throws ParserConfigurationException, XPathExpressionException, TransformerException, IOException, SAXException { + String exp = "//*[text()='host-ip-address']"; + try { + Document xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(inputFilePath)); + + XPath xPath = XPathFactory.newInstance().newXPath(); + XPathExpression xPathExpression = xPath.compile(exp); + NodeList nodes = (NodeList) xPathExpression. + evaluate(xmlDocument, XPathConstants.NODESET); + for (int i = 0; i < nodes.getLength(); i++) { + nodes.item(i).setTextContent(machineIP); + } + + //Save the result to a new XML doc + Transformer xformer = TransformerFactory.newInstance().newTransformer(); + xformer.transform(new DOMSource(xmlDocument), new StreamResult(new File(inputFilePath))); + } catch (Exception ex) { + log.info("Error while replacing IP address"); + } + } + +} \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.txt b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.txt new file mode 100644 index 00000000..f55fd390 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.txt @@ -0,0 +1,56 @@ +{ + "event": { + "metaData": { + "timestamp": 4354643, + "isPowerSaverEnabled": false, + "sensorId": 701, + "sensorName": temperature + }, + "correlationData": { + "longitude": 4.504343, + "latitude": 20.44345 + }, + "payloadData": { + "humidity": 2.3, + "sensorValue": 4.504343 + } + } +} +***** +{ + "event": { + "metaData": { + "timestamp": 4354643, + "isPowerSaverEnabled": false, + "sensorId": 702, + "sensorName": temperature + }, + "correlationData": { + "longitude": 4.504343, + "latitude": 20.44345 + }, + "payloadData": { + "humidity": 2.3, + "sensorValue": 4.504343 + } + } +} +***** +{ + "event": { + "metaData": { + "timestamp": 4354643, + "isPowerSaverEnabled": false, + "sensorId": 703, + "sensorName": temperature + }, + "correlationData": { + "longitude": 4.504343, + "latitude": 20.44345 + }, + "payloadData": { + "humidity": 2.3, + "sensorValue": 4.504343 + } + } +} \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.xml new file mode 100644 index 00000000..23df6aad --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/httpReceiver.xml @@ -0,0 +1,26 @@ + + + + + + all + + + + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/org.wso2.event.sensor.stream_1.0.0.json b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/org.wso2.event.sensor.stream_1.0.0.json new file mode 100644 index 00000000..7f2096b8 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/org.wso2.event.sensor.stream_1.0.0.json @@ -0,0 +1,44 @@ +{ + "name": "org.wso2.event.sensor.stream", + "version": "1.0.0", + "nickName": "", + "description": "", + "metaData": [ + { + "name": "timestamp", + "type": "LONG" + }, + { + "name": "isPowerSaverEnabled", + "type": "BOOL" + }, + { + "name": "sensorId", + "type": "INT" + }, + { + "name": "sensorName", + "type": "STRING" + } + ], + "correlationData": [ + { + "name": "longitude", + "type": "DOUBLE" + }, + { + "name": "latitude", + "type": "DOUBLE" + } + ], + "payloadData": [ + { + "name": "humidity", + "type": "FLOAT" + }, + { + "name": "sensorValue", + "type": "DOUBLE" + } + ] +} \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher.xml new file mode 100644 index 00000000..09f6f599 --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher.xml @@ -0,0 +1,29 @@ + + + + + + + + admin + thrift + blocking + tcp://localhost:8462 + kuv2MubUUveMyv6GeHrXr9il59ajJIqUI4eoYHcgGKf/BBFOWn96NTjJQI+wYbWjKW6r79S7L7ZzgYeWx7DlGbff5X3pBN2Gh9yV0BHP1E93QtFqR7uTWi141Tr7V7ZwScwNqJbiNoV+vyLbsqKJE7T3nP8Ih9Y6omygbcLcHzg= + + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher2.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher2.xml new file mode 100644 index 00000000..3c16582c --- /dev/null +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/HAArtifacts/wso2EventPublisher2.xml @@ -0,0 +1,29 @@ + + + + + + + + admin + thrift + blocking + tcp://localhost:8463 + kuv2MubUUveMyv6GeHrXr9il59ajJIqUI4eoYHcgGKf/BBFOWn96NTjJQI+wYbWjKW6r79S7L7ZzgYeWx7DlGbff5X3pBN2Gh9yV0BHP1E93QtFqR7uTWi141Tr7V7ZwScwNqJbiNoV+vyLbsqKJE7T3nP8Ih9Y6omygbcLcHzg= + + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/activeNodeConfigs/axis2.xml similarity index 99% rename from modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml rename to modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/activeNodeConfigs/axis2.xml index bb2e749f..c5680c3a 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/axis2.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/activeNodeConfigs/axis2.xml @@ -652,7 +652,7 @@ --> - 10.100.4.11 + host-ip-address - 10.100.4.11 + host-ip-address 4000 - 10.100.4.11 + host-ip-address 4001 diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/activeNodeConfigs/event-processor.xml similarity index 95% rename from modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml rename to modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/activeNodeConfigs/event-processor.xml index e3c3ed8d..2fa12da8 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/event-processor.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/activeNodeConfigs/event-processor.xml @@ -1,4 +1,4 @@ - + --> - - - + 15 10 @@ -30,14 +28,14 @@ - + 10000 - 10.100.4.11 + host-ip-address 11224 20000 20000 @@ -57,7 +55,7 @@ 10 - 10.100.4.11 + host-ip-address 10005 15000 10000 @@ -77,7 +75,7 @@ - + @@ -152,10 +150,10 @@ org.wso2.cep.storm.dependencies.jar - + 20000 - + \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/passiveNodeConfigs/axis2.xml similarity index 99% rename from modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml rename to modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/passiveNodeConfigs/axis2.xml index 33265cbf..5f48ba61 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/axis2.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/passiveNodeConfigs/axis2.xml @@ -245,13 +245,13 @@ - - - 10.100.4.11 + host-ip-address - 10.100.4.11 + host-ip-address 4000 - 10.100.4.11 + host-ip-address 4001 @@ -726,4 +726,4 @@ port="2222"/> - \ No newline at end of file + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/passiveNodeConfigs/event-processor.xml similarity index 98% rename from modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml rename to modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/passiveNodeConfigs/event-processor.xml index 2cb3932f..069dd056 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/event-processor.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/HATestCase/passiveNodeConfigs/event-processor.xml @@ -37,7 +37,7 @@ 10000 - 10.100.4.11 + host-ip-address 11225 20000 20000 @@ -57,7 +57,7 @@ 10 - 10.100.4.11 + host-ip-address 10006 15000 10000 @@ -159,3 +159,4 @@ + diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml deleted file mode 100644 index 44d179f9..00000000 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/activeNodeConfig/master-datasources.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader - - - - - - WSO2_CARBON_DB - The datasource used for registry and user manager - - jdbc/WSO2CarbonDB - - - - jdbc:h2:repository/database/WSO2CARBON_DB;AUTO_SERVER=TRUE - wso2carbon - wso2carbon - org.h2.Driver - 50 - 60000 - true - SELECT 1 - 30000 - false - - - - - - WSO2_GEO_DB - The datasource used for geo dashboard - - jdbc/WSO2GeoDB - - - - jdbc:h2:repository/database/WSO2_GEO;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000 - wso2carbon - wso2carbon - org.h2.Driver - 50 - 60000 - true - SELECT 1 - 30000 - false - - - - - - - - - - \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml deleted file mode 100644 index 41d52f98..00000000 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/carbon.xml +++ /dev/null @@ -1,681 +0,0 @@ - - - - - - - - - WSO2 Complex Event Processor - - - CEP - - - 4.0.0 - - - - - - - - - local:/${carbon.context}/services/ - - - - - - - ComplexEventProcessor - - - - - - - org.wso2.carbon - - - / - - - - - - - - - 15 - - - - - - - - - 1 - - - - - 9999 - - 11111 - - - - - - 10389 - - 8000 - - - - - - 10500 - - - - - - - org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory - - - - - - - - - java - - - - - - - - - - false - - - false - - - 600 - - - - false - - - - - - - - 30 - - - - - - - - - 15 - - - - - - ${carbon.home}/repository/deployment/server/ - - - 15 - - - ${carbon.home}/repository/conf/axis2/axis2.xml - - - 30000 - - - ${carbon.home}/repository/deployment/client/ - - ${carbon.home}/repository/conf/axis2/axis2_client.xml - - true - - - - - - - - - - admin - Default Administrator Role - - - user - Default User Role - - - - - - - - - - - - ${carbon.home}/repository/resources/security/wso2carbon.jks - - JKS - - wso2carbon - - wso2carbon - - wso2carbon - - - - - - ${carbon.home}/repository/resources/security/client-truststore.jks - - JKS - - wso2carbon - - - - - - - - - - - - - - - - - - - UserManager - - - false - - - - - - true - allow - - - - - - - - - - - false - - (.*)(/images|/css|/js|/docs)(.*) - - - - - - - true - - - - - ${carbon.home}/tmp/work - - - - - - true - - - 10 - - - 30 - - - - - - 100 - - - - keystore - certificate - * - - org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor - - - - - jarZip - - org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor - - - - dbs - - org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor - - - - tools - - org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor - - - - toolsAny - - org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor - - - - - - - info - org.wso2.carbon.core.transports.util.InfoProcessor - - - wsdl - org.wso2.carbon.core.transports.util.Wsdl11Processor - - - wsdl2 - org.wso2.carbon.core.transports.util.Wsdl20Processor - - - xsd - org.wso2.carbon.core.transports.util.XsdProcessor - - - - - - false - false - true - svn - http://svnrepo.example.com/repos/ - username - password - true - - - - - - - - - - - - - - - ${require.carbon.servlet} - - - - - true - - - - - - - default repository - http://product-dist.wso2.com/p2/carbon/releases/wilkes/ - - - - - - - - true - - - - - - true - - \ No newline at end of file diff --git a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml b/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml deleted file mode 100644 index a5e76588..00000000 --- a/modules/integration/tests-integration/tests/src/test/resources/artifacts/CEP/haTestCase/passiveNodeConfig/master-datasources.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader - - - - - - WSO2_CARBON_DB - The datasource used for registry and user manager - - jdbc/WSO2CarbonDB - - - - jdbc:h2:repository/database/WSO2CARBON_DB;AUTO_SERVER=TRUE - wso2carbon - wso2carbon - org.h2.Driver - 50 - 60000 - true - SELECT 1 - 30000 - false - - - - - - WSO2_GEO_DB - The datasource used for geo dashboard - - jdbc/WSO2GeoDB - - - - jdbc:h2:repository/database/WSO2_GEO;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000 - wso2carbon - wso2carbon - org.h2.Driver - 50 - 60000 - true - SELECT 1 - 30000 - false - - - - - - - - - - \ No newline at end of file From 020ec2605d446483957a882a511519764369fa56 Mon Sep 17 00:00:00 2001 From: ksdperera Date: Tue, 12 Jan 2016 16:19:09 +0530 Subject: [PATCH 3/7] Adding port offset to the thrift_publisher --- .../integration/test/ha/HATestCase.java | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java index 9a9ccff7..fd9a6f54 100644 --- a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java +++ b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java @@ -89,7 +89,18 @@ public class HATestCase extends CEPIntegrationTest { private static String machineIP; /* - + 1. Start Server1 as an Active Member and Server2 as a Passive Member + 2. Publish 3 events to Server2(Passive node) -> 3 events were received by Server1(Active Node) + 3. Shutdown Server1(Active Node) -> Server2(Passive node) became Active Member + 4. Publish another 6 events to Server2(Active node) -> 6 events were received by Server2(Active node) + 5. Start Server1 again -> Server1 became Passive Member + 6. Publish another 3 events to Server1(Passive node) -> 3 events were received by Server2(Active node) + 7. Publish 3 events to Server2(Active node) -> 3 events were received by Server2(Active Node) + 8. Shutdown Server2(Active Node) -> Server1(Passive node) became Active Member + 9. Publish another 6 events to Server1(Active node) -> 6 events were received by Server1(Active node) + 10. Start Server2 again -> Server2 became Passive Member + 11. Publish another 3 events to Server2(Passive node) -> 3 events were received by Server1(Active node) + 12. Shutdown Server1 and Server2 */ @BeforeClass(alwaysRun = true) public void init() throws Exception { @@ -101,8 +112,8 @@ public void init() throws Exception { cepServer1 = new AutomationContext("CEP", "cep002", TestUserMode.SUPER_TENANT_ADMIN); cepServer2 = new AutomationContext("CEP", "cep003", TestUserMode.SUPER_TENANT_ADMIN); - log.info("Sever1 https Port : "+cepServer1.getInstance().getPorts().get("https")); - log.info("Sever2 https Port : "+cepServer2.getInstance().getPorts().get("https")); + log.info("Sever1 https Port : " + cepServer1.getInstance().getPorts().get("https")); + log.info("Sever2 https Port : " + cepServer2.getInstance().getPorts().get("https")); server1 = new CarbonTestServerManager(cepServer1, 801); server2 = new CarbonTestServerManager(cepServer2, 802); @@ -181,8 +192,8 @@ public void test1() throws Exception { int startERCount2 = eventReceiverAdminServiceClient2.getActiveEventReceiverCount(); int startEPCount2 = eventPublisherAdminServiceClient2.getActiveEventPublisherCount(); - int activeMsgCount = 9; - int passiveMsgCount = 9; + int server1MsgCount = 12; + int server2MsgCount = 12; //Add StreamDefinition String streamDefinitionAsString = getJSONArtifactConfiguration(samplePath, "org.wso2.event.sensor.stream_1.0.0.json"); @@ -207,14 +218,14 @@ public void test1() throws Exception { Assert.assertEquals(eventPublisherAdminServiceClient2.getActiveEventPublisherCount(), startEPCount2 + 1); // The data-bridge receiver - Wso2EventServer agentServer1 = new Wso2EventServer(samplePath, Integer.parseInt(cepServer1.getInstance().getPorts().get("thrift_publisher")), false); + Wso2EventServer agentServer1 = new Wso2EventServer(samplePath, Integer.parseInt(cepServer1.getInstance().getPorts().get("thrift_publisher"))+1, false); Thread agentServerThread = new Thread(agentServer1); agentServerThread.start(); // Let the server start Thread.sleep(10000); // The data-bridge receiver - Wso2EventServer agentServer2 = new Wso2EventServer(samplePath, Integer.parseInt(cepServer2.getInstance().getPorts().get("thrift_publisher")), false); + Wso2EventServer agentServer2 = new Wso2EventServer(samplePath, Integer.parseInt(cepServer2.getInstance().getPorts().get("thrift_publisher"))+2, false); Thread agentServerThread2 = new Thread(agentServer2); agentServerThread2.start(); // Let the server start @@ -222,34 +233,40 @@ public void test1() throws Exception { for (int i = 0; i < 3; i++) { if (i == 1) { - log.info("Shutdown Active Server"); + log.info("Shutdown Server1(Active Node)"); server1.stopServer(); } - log.info("Event No : " + i); HttpEventPublisherClient.publish("http://localhost:" + cepServer2.getInstance().getPorts().get("http") + "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); Thread.sleep(30000); } - log.info("Start Active Server Again"); + log.info("Start Server1 Again"); server1.startServer(); + HttpEventPublisherClient.publish("http://localhost:" + cepServer1.getInstance().getPorts().get("http") + + "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(30000); for (int i = 0; i < 3; i++) { if (i == 1) { - log.info("Shutdown Passive Server"); + log.info("Shutdown Server2(Active Node)"); server2.stopServer(); } - log.info("Event No : " + i); HttpEventPublisherClient.publish("http://localhost:" + cepServer1.getInstance().getPorts().get("http") + "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); Thread.sleep(30000); } + log.info("Start Server2 Again"); + server2.startServer(); + HttpEventPublisherClient.publish("http://localhost:" + cepServer2.getInstance().getPorts().get("http") + + "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(30000); - log.info("Total Event Send Count : "+(activeMsgCount+passiveMsgCount)); - log.info("Test Run Active Event Count : " + agentServer1.getMsgCount()); - log.info("Test Run Passive Event Count : " + agentServer2.getMsgCount()); + log.info("Total Event Send Count : " + (server1MsgCount + server2MsgCount)); + log.info("Test Run Server1 Event Count : " + agentServer1.getMsgCount()); + log.info("Test Run Server2 Event Count : " + agentServer2.getMsgCount()); try { - Assert.assertEquals(agentServer1.getMsgCount(), activeMsgCount, "Incorrect number of messages consumed by Active Node!"); - Assert.assertEquals(agentServer2.getMsgCount(), passiveMsgCount, "Incorrect number of messages consumed by Passive Node!"); + Assert.assertEquals(agentServer1.getMsgCount(), server1MsgCount, "Incorrect number of messages consumed by Server1!"); + Assert.assertEquals(agentServer2.getMsgCount(), server2MsgCount, "Incorrect number of messages consumed by server2!"); } catch (Throwable e) { log.error("Exception thrown: " + e.getMessage(), e); Assert.fail("Exception: " + e.getMessage()); From 513e6f2ada25efec6aa18626808c1a1d7e4af8f2 Mon Sep 17 00:00:00 2001 From: ksdperera Date: Tue, 12 Jan 2016 16:26:05 +0530 Subject: [PATCH 4/7] Adding HATestCase to testng.xml --- .../tests-integration/tests/src/test/resources/testng.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/integration/tests-integration/tests/src/test/resources/testng.xml b/modules/integration/tests-integration/tests/src/test/resources/testng.xml index 62b90021..c11b91dd 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/testng.xml @@ -26,6 +26,7 @@ + From 36eee41c4594aab0d07da8183042567cd53ab85a Mon Sep 17 00:00:00 2001 From: ksdperera Date: Wed, 13 Jan 2016 18:11:50 +0530 Subject: [PATCH 5/7] Adding code formatting --- .../integration/test/ha/HATestCase.java | 84 +++++-------------- .../tests/src/test/resources/testng.xml | 2 +- 2 files changed, 22 insertions(+), 64 deletions(-) diff --git a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java index fd9a6f54..fa210f8a 100644 --- a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java +++ b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,34 +58,20 @@ public class HATestCase extends CEPIntegrationTest { private MultipleServersManager manager = new MultipleServersManager(); private static final String EVENT_PROCESSING_FILE = "event-processor.xml"; private static final String AXIS2_XML_FILE = "axis2.xml"; - private static final String RESOURCE_LOCATION1 = TestConfigurationProvider.getResourceLocation() + "artifacts" + File.separator + "CEP" + File.separator + "HATestCase" + File.separator + "activeNodeConfigs"; private static final String RESOURCE_LOCATION2 = TestConfigurationProvider.getResourceLocation() + "artifacts" + File.separator + "CEP" + File.separator + "HATestCase" + File.separator + "passiveNodeConfigs"; - - private static String CARBON_HOME1; - private static String CARBON_HOME2; - - private ServerConfigurationManager serverConfigManager1; - private ServerConfigurationManager serverConfigManager2; - private AutomationContext cepServer1; private AutomationContext cepServer2; - private CarbonTestServerManager server1; private CarbonTestServerManager server2; - private EventStreamManagerAdminServiceClient eventStreamManagerAdminServiceClient1; private EventReceiverAdminServiceClient eventReceiverAdminServiceClient1; private EventPublisherAdminServiceClient eventPublisherAdminServiceClient1; - private static String backendURL1; - private EventStreamManagerAdminServiceClient eventStreamManagerAdminServiceClient2; private EventReceiverAdminServiceClient eventReceiverAdminServiceClient2; private EventPublisherAdminServiceClient eventPublisherAdminServiceClient2; - private static String backendURL2; - private static String machineIP; /* @@ -104,36 +90,23 @@ public class HATestCase extends CEPIntegrationTest { */ @BeforeClass(alwaysRun = true) public void init() throws Exception { - log.info("--------Initialization Start--------"); super.init(TestUserMode.SUPER_TENANT_ADMIN); - machineIP = findAddress("localhost"); - cepServer1 = new AutomationContext("CEP", "cep002", TestUserMode.SUPER_TENANT_ADMIN); cepServer2 = new AutomationContext("CEP", "cep003", TestUserMode.SUPER_TENANT_ADMIN); - - log.info("Sever1 https Port : " + cepServer1.getInstance().getPorts().get("https")); - log.info("Sever2 https Port : " + cepServer2.getInstance().getPorts().get("https")); - server1 = new CarbonTestServerManager(cepServer1, 801); server2 = new CarbonTestServerManager(cepServer2, 802); - - serverConfigManager1 = new ServerConfigurationManager(cepServer1); - serverConfigManager2 = new ServerConfigurationManager(cepServer2); - + ServerConfigurationManager serverConfigManager1 = new ServerConfigurationManager(cepServer1); + ServerConfigurationManager serverConfigManager2 = new ServerConfigurationManager(cepServer2); manager.startServers(server1, server2); + String CARBON_HOME1 = server1.getCarbonHome(); + String CARBON_HOME2 = server2.getCarbonHome(); - CARBON_HOME1 = server1.getCarbonHome(); - CARBON_HOME2 = server2.getCarbonHome(); - - log.info("Server 1 Replacing " + EVENT_PROCESSING_FILE); String eventProcessingFileLocation = RESOURCE_LOCATION1 + File.separator + EVENT_PROCESSING_FILE; String cepEventProcessorFileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" + File.separator + EVENT_PROCESSING_FILE; serverConfigManager1.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation), new File(cepEventProcessorFileLocation), true); replaceIP(cepEventProcessorFileLocation); - - log.info("Server 1 Replacing " + AXIS2_XML_FILE); String axis2FileLocation = RESOURCE_LOCATION1 + File.separator + AXIS2_XML_FILE; String cepAxis2FileLocation = CARBON_HOME1 + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + AXIS2_XML_FILE; @@ -145,53 +118,42 @@ public void init() throws Exception { // Waiting for the server to restart Thread.sleep(5000); - log.info("Server 2 Replacing " + EVENT_PROCESSING_FILE); String eventProcessingFileLocation2 = RESOURCE_LOCATION2 + File.separator + EVENT_PROCESSING_FILE; String cepEventProcessorFileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + File.separator + EVENT_PROCESSING_FILE; serverConfigManager2.applyConfigurationWithoutRestart(new File(eventProcessingFileLocation2), new File(cepEventProcessorFileLocation2), true); replaceIP(cepEventProcessorFileLocation2); - - log.info("Server 2 Replacing " + AXIS2_XML_FILE); String axis2FileLocation2 = RESOURCE_LOCATION2 + File.separator + AXIS2_XML_FILE; String cepAxis2FileLocation2 = CARBON_HOME2 + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + AXIS2_XML_FILE; serverConfigManager2.applyConfigurationWithoutRestart(new File(axis2FileLocation2), new File(cepAxis2FileLocation2), true); replaceIP(cepAxis2FileLocation2); - log.info("Restarting CEP server2"); serverConfigManager2.restartGracefully(); // Waiting for the server to restart Thread.sleep(5000); - backendURL1 = cepServer1.getContextUrls().getBackEndUrl(); + String backendURL1 = cepServer1.getContextUrls().getBackEndUrl(); String loggedInSessionCookie = getSessionCookie(cepServer1); eventReceiverAdminServiceClient1 = configurationUtil.getEventReceiverAdminServiceClient(backendURL1, loggedInSessionCookie); eventStreamManagerAdminServiceClient1 = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL1, loggedInSessionCookie); eventPublisherAdminServiceClient1 = configurationUtil.getEventPublisherAdminServiceClient(backendURL1, loggedInSessionCookie); - - backendURL2 = cepServer2.getContextUrls().getBackEndUrl(); + String backendURL2 = cepServer2.getContextUrls().getBackEndUrl(); String loggedInSessionCookie2 = getSessionCookie(cepServer2); eventReceiverAdminServiceClient2 = configurationUtil.getEventReceiverAdminServiceClient(backendURL2, loggedInSessionCookie2); eventStreamManagerAdminServiceClient2 = configurationUtil.getEventStreamManagerAdminServiceClient(backendURL2, loggedInSessionCookie2); eventPublisherAdminServiceClient2 = configurationUtil.getEventPublisherAdminServiceClient(backendURL2, loggedInSessionCookie2); - - log.info("--------Initialization End--------"); } @Test(groups = {"wso2.cep"}, description = "Testing CEP HA for two cluster nodes") public void test1() throws Exception { - String samplePath = "HATestCase" + File.separator + "HAArtifacts"; - int startESCount1 = eventStreamManagerAdminServiceClient1.getEventStreamCount(); int startERCount1 = eventReceiverAdminServiceClient1.getActiveEventReceiverCount(); int startEPCount1 = eventPublisherAdminServiceClient1.getActiveEventPublisherCount(); - int startESCount2 = eventStreamManagerAdminServiceClient2.getEventStreamCount(); int startERCount2 = eventReceiverAdminServiceClient2.getActiveEventReceiverCount(); int startEPCount2 = eventPublisherAdminServiceClient2.getActiveEventPublisherCount(); - int server1MsgCount = 12; int server2MsgCount = 12; @@ -233,40 +195,36 @@ public void test1() throws Exception { for (int i = 0; i < 3; i++) { if (i == 1) { - log.info("Shutdown Server1(Active Node)"); + log.info("Shutting down CEP Server1(Active Node)"); server1.stopServer(); } HttpEventPublisherClient.publish("http://localhost:" + cepServer2.getInstance().getPorts().get("http") + - "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); - Thread.sleep(30000); + File.separator+"endpoints"+File.separator+"httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(5000); } - log.info("Start Server1 Again"); + log.info("Starting CEP Server1"); server1.startServer(); HttpEventPublisherClient.publish("http://localhost:" + cepServer1.getInstance().getPorts().get("http") + - "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); - Thread.sleep(30000); + File.separator + "endpoints" + File.separator + "httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(5000); for (int i = 0; i < 3; i++) { if (i == 1) { - log.info("Shutdown Server2(Active Node)"); + log.info("Shutting down CEP Server2(Active Node)"); server2.stopServer(); } HttpEventPublisherClient.publish("http://localhost:" + cepServer1.getInstance().getPorts().get("http") + - "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); - Thread.sleep(30000); + File.separator+"endpoints"+File.separator+"httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(5000); } - log.info("Start Server2 Again"); + log.info("Starting CEP Server2"); server2.startServer(); HttpEventPublisherClient.publish("http://localhost:" + cepServer2.getInstance().getPorts().get("http") + - "/endpoints/httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); - Thread.sleep(30000); - - log.info("Total Event Send Count : " + (server1MsgCount + server2MsgCount)); - log.info("Test Run Server1 Event Count : " + agentServer1.getMsgCount()); - log.info("Test Run Server2 Event Count : " + agentServer2.getMsgCount()); + File.separator + "endpoints" + File.separator + "httpReceiver", "admin", "admin", samplePath, "httpReceiver.txt"); + Thread.sleep(5000); try { - Assert.assertEquals(agentServer1.getMsgCount(), server1MsgCount, "Incorrect number of messages consumed by Server1!"); - Assert.assertEquals(agentServer2.getMsgCount(), server2MsgCount, "Incorrect number of messages consumed by server2!"); + Assert.assertEquals(agentServer1.getMsgCount(), server1MsgCount, "Incorrect number of messages consumed by CEP Server1!"); + Assert.assertEquals(agentServer2.getMsgCount(), server2MsgCount, "Incorrect number of messages consumed by CEP server2!"); } catch (Throwable e) { log.error("Exception thrown: " + e.getMessage(), e); Assert.fail("Exception: " + e.getMessage()); diff --git a/modules/integration/tests-integration/tests/src/test/resources/testng.xml b/modules/integration/tests-integration/tests/src/test/resources/testng.xml index c11b91dd..131052e6 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/testng.xml @@ -1,5 +1,5 @@ - @@ -80,6 +79,9 @@ + + + From 1e5b9d69c222ed0b1d88b60779d1e3609962c016 Mon Sep 17 00:00:00 2001 From: ksdperera Date: Thu, 14 Jan 2016 12:03:52 +0530 Subject: [PATCH 7/7] Updating License Headers --- .../integration/test/ha/HATestCase.java | 22 ++++++++++--------- .../tests/src/test/resources/testng.xml | 22 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java index fa210f8a..d20fb54b 100644 --- a/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java +++ b/modules/integration/tests-integration/tests/src/test/java/org/wso2/carbon/integration/test/ha/HATestCase.java @@ -1,17 +1,19 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed 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 + * WSO2 Inc. 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 + * 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. + * 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.wso2.carbon.integration.test.ha; diff --git a/modules/integration/tests-integration/tests/src/test/resources/testng.xml b/modules/integration/tests-integration/tests/src/test/resources/testng.xml index fab19ac6..5e92f491 100644 --- a/modules/integration/tests-integration/tests/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests/src/test/resources/testng.xml @@ -1,17 +1,19 @@