diff --git a/README.md b/README.md index 078fad9..1ee2a3a 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,17 @@ -## Sample artifact resources for AWS Pipeline +## Sample test cases for AWS Pipeline WSO2EI -Sample product artifacts and and sample test cases for WSO2 products. This repository is used as the sample for artifacts repository in WSO2 AWS pipeline.. +Sample product artifacts and and sample test cases for WSO2 Enterprise Integrator. This repository is used as the sample for artifacts repository in WSO2 AWS pipeline for WSO2EI.. -#### Add new artifacts -* Place the car file in `artifacts/deployment/server/carbonapps/` directory. Follow below naming convention when for artifacts. (c-apps). - - * Different endpoint c-apps need to included for different environments. For, - production environment endpoint c-app: should contain "_production" in the name. - eg: helloworld_production_1.0.car - - staging environment endpoint c-app: should contain "_staging" in the name. - eg: helloworld_staging_1.0.car - - dev environment endpoint c-app: should contain "_dev" in the name. - eg: helloworld_dev_1.0.car - - * Common c-app for all the environments. - should contain "_common" in the name - eg: helloworld_common_1.0.car +* A sample scenario test suite implemented using Testng is in `tests/wso2ei/` directory. This run a simple test to validate response code of a rest endpoint. + +#### Add new test +* Place the tests in `test/wso2ei/` directory. Update the testng.xml file to include your test class. -* A sample scenario test suite implemented using Testng is in `test/{product}/sample-test-suite{product}` directory. This run a -simple test to validate response code of a rest endpoint. Use following command to run the test, +#### Run test suites +* Use following command to run the tests, ``` mvn test -Dendpoint= ``` + +#### Add new artifacts +* Place the artifact source code in the repository. Update `buildArtifact.sh` file with correct paths to artifact code. diff --git a/artifacts/repository/deployment/server/carbonapps/helloworld_common_1.0.0.car b/artifacts/repository/deployment/server/carbonapps/helloworld_common_1.0.0.car deleted file mode 100644 index 7cb2c38..0000000 Binary files a/artifacts/repository/deployment/server/carbonapps/helloworld_common_1.0.0.car and /dev/null differ diff --git a/artifacts/repository/deployment/server/carbonapps/helloworld_dev_1.0.0.car b/artifacts/repository/deployment/server/carbonapps/helloworld_dev_1.0.0.car deleted file mode 100644 index 89a6631..0000000 Binary files a/artifacts/repository/deployment/server/carbonapps/helloworld_dev_1.0.0.car and /dev/null differ diff --git a/artifacts/repository/deployment/server/carbonapps/helloworld_production_1.0.0.car b/artifacts/repository/deployment/server/carbonapps/helloworld_production_1.0.0.car deleted file mode 100644 index d598e42..0000000 Binary files a/artifacts/repository/deployment/server/carbonapps/helloworld_production_1.0.0.car and /dev/null differ diff --git a/artifacts/repository/deployment/server/carbonapps/helloworld_staging_1.0.0.car b/artifacts/repository/deployment/server/carbonapps/helloworld_staging_1.0.0.car deleted file mode 100644 index 8fd0c82..0000000 Binary files a/artifacts/repository/deployment/server/carbonapps/helloworld_staging_1.0.0.car and /dev/null differ diff --git a/buildArtifact.sh b/buildArtifact.sh new file mode 100755 index 0000000..fbd77a6 --- /dev/null +++ b/buildArtifact.sh @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------ +# Copyright 2019 WSO2, Inc. (http://wso2.com) +# +# 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 +# ------------------------------------------------------------------------ + +#!/bin/bash + +ARTIFACT_LOCATION=${ARTIFACT_LOC} +IMAGE_RESOURCES=${IMAGE_RESOURCES} + +cd $ARTIFACT_LOCATION/helloworld/ + +if [ -d "artifacts" ]; then + rm -rf $ARTIFACT_LOCATION/helloworld/artifacts/* +else + mkdir artifacts +fi + +cd $ARTIFACT_LOCATION/helloworld/helloworld +mvn clean install >> $ARTIFACT_LOCATION/helloworld/artifact.log +cd ../helloworld_common +mvn clean install >> $ARTIFACT_LOCATION/helloworld/artifact.log +cp -r target/* $ARTIFACT_LOCATION/helloworld/artifacts/ + +cp -r $ARTIFACT_LOCATION/helloworld/artifacts/* $IMAGE_RESOURCES +rm -rf $ARTIFACT_LOCATION/helloworld/artifacts \ No newline at end of file diff --git a/helloworld/helloworld/artifact.xml b/helloworld/helloworld/artifact.xml new file mode 100755 index 0000000..c639148 --- /dev/null +++ b/helloworld/helloworld/artifact.xml @@ -0,0 +1,8 @@ + + + src/main/synapse-config/api/helloworld.xml + + + src/main/synapse-config/endpoints/development.xml + + diff --git a/helloworld/helloworld/pom.xml b/helloworld/helloworld/pom.xml new file mode 100755 index 0000000..f0ae561 --- /dev/null +++ b/helloworld/helloworld/pom.xml @@ -0,0 +1,148 @@ + + + 4.0.0 + com.example.helloworld + helloworld + 1.0.0 + pom + helloworld + helloworld + + false + bpel/workflow=zip,lib/registry/filter=jar,webapp/jaxws=war,lib/library/bundle=jar,service/dataservice=dbs,synapse/local-entry=xml,synapse/proxy-service=xml,carbon/application=car,registry/resource=zip,lib/dataservice/validator=jar,synapse/endpoint=xml,web/application=war,lib/carbon/ui=jar,service/axis2=aar,synapse/sequence=xml,synapse/configuration=xml,wso2/gadget=dar,lib/registry/handlers=jar,lib/synapse/mediator=jar,synapse/task=xml,synapse/api=xml,synapse/template=xml,synapse/message-store=xml,synapse/message-processors=xml,synapse/inbound-endpoint=xml + + + + + true + daily + ignore + + wso2-nexus + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + + + + + true + daily + ignore + + wso2-nexus + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + + + target/capp + + + org.codehaus.mojo + exec-maven-plugin + 1.4.0 + true + + + package + package + + exec + + + mvn + ${project.build.directory} + + clean + package + -Dmaven.test.skip=${maven.test.skip} + + + + + install + install + + exec + + + mvn + ${project.build.directory} + + clean + install + -Dmaven.test.skip=${maven.test.skip} + + + + + deploy + deploy + + exec + + + mvn + ${project.build.directory} + + deploy + -Dmaven.test.skip=${maven.test.skip} + + + + + + + + maven-eclipse-plugin + 2.9 + + + + org.wso2.developerstudio.eclipse.esb.project.nature + + + + + org.wso2.maven + wso2-esb-api-plugin + 2.1.0 + true + + + api + process-resources + + pom-gen + + + . + ${artifact.types} + + + + + + + org.wso2.maven + wso2-esb-endpoint-plugin + 2.1.0 + true + + + endpoint + process-resources + + pom-gen + + + . + ${artifact.types} + + + + + + + + diff --git a/helloworld/helloworld/src/main/synapse-config/api/helloworld.xml b/helloworld/helloworld/src/main/synapse-config/api/helloworld.xml new file mode 100755 index 0000000..5ea39b2 --- /dev/null +++ b/helloworld/helloworld/src/main/synapse-config/api/helloworld.xml @@ -0,0 +1,20 @@ + + + + + + + + + + {name: "WSO2 Enterprise Integrator" , message: "You have successfully deployed helloworld artifact"} + + + + + + + + + + diff --git a/helloworld/helloworld/src/main/synapse-config/endpoints/development.xml b/helloworld/helloworld/src/main/synapse-config/endpoints/development.xml new file mode 100755 index 0000000..0bf254c --- /dev/null +++ b/helloworld/helloworld/src/main/synapse-config/endpoints/development.xml @@ -0,0 +1,4 @@ + + +
+ diff --git a/helloworld/helloworld_common/pom.xml b/helloworld/helloworld_common/pom.xml new file mode 100755 index 0000000..b621a29 --- /dev/null +++ b/helloworld/helloworld_common/pom.xml @@ -0,0 +1,117 @@ + + + 4.0.0 + com.example.helloworld_common + helloworld_common + 1.0.0 + carbon/application + helloworld_common + helloworld_common + + capp/EnterpriseServiceBus + capp/EnterpriseServiceBus + jaggery/app=zip,lib/library/bundle=jar,service/rule=aar,event/receiver=xml,synapse/message-processors=xml,synapse/endpointTemplate=xml,synapse/message-store=xml,synapse/proxy-service=xml,event/execution-plan=siddhiql,carbon/application=car,registry/resource=zip,lib/dataservice/validator=jar,synapse/endpoint=xml,web/application=war,synapse/inbound-endpoint=xml,synapse/sequence=xml,synapse/configuration=xml,synapse/task=xml,synapse/api=xml,webapp/jaxws=war,service/meta=xml,bpel/workflow=zip,synapse/lib=zip,service/dataservice=dbs,event/publisher=xml,synapse/local-entry=xml,synapse/priority-executor=xml,synapse/template=xml,synapse/event-source=xml,event/stream=json,lib/carbon/ui=jar,service/axis2=aar,synapse/sequenceTemplate=xml,wso2/gadget=dar,lib/synapse/mediator=jar + + + + com.example.helloworld.api + helloworld + 1.0.0 + xml + + + com.example.helloworld.endpoint + development + 1.0.0 + xml + + + + + + true + daily + ignore + + wso2-nexus + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + + wso2-maven2-repository-1 + http://dist.wso2.org/maven2 + + + wso2-nexus-repository-1 + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + + + + + true + daily + ignore + + wso2-nexus + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + + wso2-maven2-repository-1 + http://dist.wso2.org/maven2 + + + wso2-nexus-repository-1 + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + + + + + maven-eclipse-plugin + 2.9 + + + + org.wso2.developerstudio.eclipse.distribution.project.nature + + + + + org.wso2.maven + maven-car-plugin + 2.1.1 + true + + + car + package + + car + + + + + + + org.wso2.maven + maven-car-deploy-plugin + 1.1.1 + true + + + + ${basedir}/src/main/resources/security/wso2carbon.jks + wso2carbon + JKS + https://localhost:9443 + admin + admin + deploy + + + + + + + diff --git a/tests/wso2am/pom.xml b/tests/wso2am/pom.xml deleted file mode 100644 index 5809278..0000000 --- a/tests/wso2am/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - 4.0.0 - - org.wso2 - wso2am - 1.0-SNAPSHOT - - - 6.9.8 - 3.1 - - - - - org.testng - testng - ${testng.version} - test - - - commons-httpclient - commons-httpclient - ${commons-httpclient.version} - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.1 - - - src/test/resources/testng.xml - - - - endpoint - - - - - - - diff --git a/tests/wso2am/src/test/java/org/wso2/apimTest.java b/tests/wso2am/src/test/java/org/wso2/apimTest.java deleted file mode 100644 index f56123e..0000000 --- a/tests/wso2am/src/test/java/org/wso2/apimTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * 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 - * - * 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; - -/********** Test class for APIM ***********/ - -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.util.concurrent.TimeUnit; - -public class apimTest { - - @Test public static void main(String[] args) { - int exitCode=1; - try { - String uri = System.getProperty("endpoint"); - String publisherUri = "https:"+ uri.split(":")[1] + "/publisher"; - System.out.println(publisherUri); - String command = "curl -k -X GET " + publisherUri; - ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); - Process process = processBuilder.start(); - TimeUnit.SECONDS.sleep(5); - exitCode = process.exitValue(); - System.out.print(exitCode); - process.destroy(); - } catch (Exception e) { - e.printStackTrace(); - } - Assert.assertEquals(exitCode, 0); - } -} \ No newline at end of file diff --git a/tests/wso2am/src/test/resources/testng.xml b/tests/wso2am/src/test/resources/testng.xml deleted file mode 100644 index ced8241..0000000 --- a/tests/wso2am/src/test/resources/testng.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - diff --git a/tests/wso2ei/src/test/java/org/wso2/eiTest.java b/tests/wso2ei/src/test/java/org/wso2/eiTest.java index b0538ee..a8aa501 100644 --- a/tests/wso2ei/src/test/java/org/wso2/eiTest.java +++ b/tests/wso2ei/src/test/java/org/wso2/eiTest.java @@ -37,25 +37,21 @@ // */ // public class eiTest { - @Test public void testEndpoint() throws InterruptedException { - HttpClient client = new HttpClient(); - String deployedAPI = "/helloworld"; - int statusCode = -1; - String uri = System.getProperty("endpoint") + deployedAPI; - System.out.println(uri); - TimeUnit.MINUTES.sleep(5); - HttpMethod method = new GetMethod(uri); + @Test public static void main(String[] args) { + int exitCode=1; try { - statusCode = client.executeMethod(method); - } catch (HttpException e) { - System.err.println("Fatal protocol violation: " + e.getMessage()); + String uri = System.getProperty("endpoint"); + String carbonUri = "https:"+ uri.split(":")[1] + "/carbon"; + String command = "curl -k -X GET " + carbonUri; + ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); + Process process = processBuilder.start(); + TimeUnit.SECONDS.sleep(5); + exitCode = process.exitValue(); + System.out.print(exitCode); + process.destroy(); + } catch (Exception e) { e.printStackTrace(); - } catch (IOException e){ - System.err.println("Fatal transport error: " + e.getMessage()); - e.printStackTrace(); - } finally { - method.releaseConnection(); } - Assert.assertEquals(statusCode, HttpStatus.SC_OK); + Assert.assertEquals(exitCode, 0); } } \ No newline at end of file diff --git a/tests/wso2is/pom.xml b/tests/wso2is/pom.xml deleted file mode 100644 index c565132..0000000 --- a/tests/wso2is/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - 4.0.0 - - org.wso2 - wso2is - 1.0-SNAPSHOT - - - 6.9.8 - 3.1 - - - - - org.testng - testng - ${testng.version} - test - - - commons-httpclient - commons-httpclient - ${commons-httpclient.version} - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.1 - - - src/test/resources/testng.xml - - - - endpoint - - - - - - - diff --git a/tests/wso2is/src/test/java/org/wso2/isTest.java b/tests/wso2is/src/test/java/org/wso2/isTest.java deleted file mode 100644 index f0b4407..0000000 --- a/tests/wso2is/src/test/java/org/wso2/isTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * 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 - * - * 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; - -/********** Test class for IS ***********/ - -import org.testng.Assert; -import org.testng.annotations.Test; -import java.util.concurrent.TimeUnit; - -/** - * This class tests whether IS node is up and running - */ - -public class isTest { - @Test public static void main(String[] args) { - int exitCode=1; - try { - String uri = System.getProperty("endpoint"); - String carbonUri = "https:"+ uri.split(":")[1] + "/carbon"; - String command = "curl -k -X GET " + carbonUri; - ProcessBuilder processBuilder = new ProcessBuilder(command.split(" ")); - Process process = processBuilder.start(); - TimeUnit.SECONDS.sleep(5); - exitCode = process.exitValue(); - System.out.print(exitCode); - process.destroy(); - } catch (Exception e) { - e.printStackTrace(); - } - Assert.assertEquals(exitCode, 0); - } -} diff --git a/tests/wso2is/src/test/resources/testng.xml b/tests/wso2is/src/test/resources/testng.xml deleted file mode 100644 index 4b77667..0000000 --- a/tests/wso2is/src/test/resources/testng.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - -