From 1aa8c58043f17a3c47e38d2bbee098d47f29a084 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Wed, 21 Sep 2022 12:18:55 +0530 Subject: [PATCH 01/10] resolved conflicts --- adapter/scripts/build.sh | 2 +- enforcer-parent/commons/pom.xml | 60 +++++++++++++++++++ enforcer-parent/enforcer/pom.xml | 88 +++++++++++++++++++++++++++- integration/test-integration/pom.xml | 73 ++++++++++++++++++++++- 4 files changed, 217 insertions(+), 6 deletions(-) diff --git a/adapter/scripts/build.sh b/adapter/scripts/build.sh index 7d2667de2c..d68df6a40a 100755 --- a/adapter/scripts/build.sh +++ b/adapter/scripts/build.sh @@ -45,7 +45,7 @@ export cc_test_test_uintarray2=-50 export CC_Adapter_Server_Enabled=string go clean -testcache -go test -race -coverprofile=./target/coverage.txt -covermode=atomic ./... +go test -race -coverprofile=./target/coverage.out -covermode=atomic ./... if [ $? -ne 0 ]; then echo "FAILED: Unit tests failure" exit 1 diff --git a/enforcer-parent/commons/pom.xml b/enforcer-parent/commons/pom.xml index 452539d614..736f85054a 100644 --- a/enforcer-parent/commons/pom.xml +++ b/enforcer-parent/commons/pom.xml @@ -107,6 +107,66 @@ + + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + surefireArgLine + + + + default-prepare-agent-integration + + prepare-agent-integration + + + failsafeArgLine + + + + default-report + + report + + + + default-report-integration + + report-integration + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + @{surefireArgLine} + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven.failsafe.plugin.version} + + + integration-tests + + integration-test + verify + + + @{failsafeArgLine} + + + + diff --git a/enforcer-parent/enforcer/pom.xml b/enforcer-parent/enforcer/pom.xml index fbaf649c9b..4fb951d8a0 100644 --- a/enforcer-parent/enforcer/pom.xml +++ b/enforcer-parent/enforcer/pom.xml @@ -189,10 +189,10 @@ ${project.build.directory}/ - org.apache.logging.log4j, org.json.wso2 + org.apache.logging.log4j, org.json.wso2, org.jacoco - log4j-api, log4j-core, log4j-jcl, json, log4j-slf4j-impl + log4j-api, log4j-core, log4j-jcl, json, log4j-slf4j-impl, org.jacoco.agent @@ -262,6 +262,84 @@ + + org.jacoco + jacoco-maven-plugin + + + default-prepare-agent + + prepare-agent + + + surefireArgLine + + + + default-prepare-agent-integration + + prepare-agent-integration + + + failsafeArgLine + + + + default-report + + report + + + + default-report-integration + + report-integration + + + + merge-results + verify + + merge + + + + + ${session.executionRootDirectory} + + **/*.exec + + + + ${project.build.directory}/coverage-aggregate-reports/aggregate.exec + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + @{surefireArgLine} + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven.failsafe.plugin.version} + + + integration-tests + + integration-test + verify + + + @{failsafeArgLine} + + + + @@ -499,6 +577,12 @@ javax.validation validation-api + + org.jacoco + org.jacoco.agent + ${jacoco.version} + runtime + javax.xml.soap javax.xml.soap-api diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index b23bf6405f..2540ae84f3 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -42,6 +42,7 @@ ${apictl.version} true + **/jacoco.exec src/test/resources/testng-cc-standalone.xml @@ -55,9 +56,6 @@ - - org.wso2.choreo.connect:org.wso2.choreo.connect.enforcer - @@ -102,6 +100,75 @@ + + io.fabric8 + docker-maven-plugin + + + + choreo-connect-backend + testcontainers/ryuk:${ryuk.image.version} + + + + + + docker-test-container-pull + generate-resources + + start + + + + docker-test-container-remove + post-integration-test + + stop + + + + + + org.jacoco + jacoco-maven-plugin + + + + prepare-agent + + + + report-aggregate + verify + + report-aggregate + + + + **/choreo-connect-temp/docker-compose/resources/enforcer/dropins/aggregate.exec + + ${project.reporting.outputDirectory}/jacoco-aggregate + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.15 + + + integration-tests + + integration-test + verify + + + @{failsafeArgLine} + + + + com.googlecode.maven-download-plugin download-maven-plugin From 869b7930fda0a3dfebc908efc594480c9ff4d392 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Tue, 18 Oct 2022 22:42:08 +0530 Subject: [PATCH 02/10] resolved conflicts --- .github/workflows/main.yml | 7 +++- .../prepare-files-after-int-tests.sh | 24 +++++++++++++ .../prepare-files-before-int-tests.sh | 22 ++++++++++++ enforcer-parent/commons/pom.xml | 3 ++ enforcer-parent/enforcer/pom.xml | 30 ++++++++++++++-- integration/test-integration/pom.xml | 30 ++++++++++++++++ pom.xml | 34 +++++++++++++++++++ 7 files changed, 147 insertions(+), 3 deletions(-) create mode 100755 dev-scripts/code-coverage/prepare-files-after-int-tests.sh create mode 100755 dev-scripts/code-coverage/prepare-files-before-int-tests.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c098148da4..e0f2216cfe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,8 +53,13 @@ jobs: -pl '!:integration' -pl '!:mock-backend-server' -pl '!:test-integration' - name: Run integration tests run: | - mvn clean install -PRelease -pl ':integration' -amd -s .maven/settings.xml + mvn clean install -Dskip.code.coverage=false -PRelease -pl ':integration' -amd -s .maven/settings.xml - name: Build multi platform Ubuntu images run: | ./build-ubuntu-multi-platform-images.sh all docker images + - name: Change working directory + run: | + cd ./covReports + - name: Upload coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v3 diff --git a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh new file mode 100755 index 0000000000..25ef7d6d37 --- /dev/null +++ b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# -------------------------------------------------------------------- +# Copyright (c) 2022, WSO2 Inc. (http://wso2.com) 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. +# ----------------------------------------------------------------------- + +# Sets the Choreo Connect version +echo "Preparing code coverage files after integration tests...." +rm -f ../../resources/enforcer/dropins/aggregate.exec +mkdir ../../covReports +cp ../../adapter/target/coverage.out ../../covReports +cp ../../integration/test-integration/target/site/jacoco-aggregate/jacoco.xml ../../covReports +echo "Preparing code coverage files after integration tests completed successfully...." diff --git a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh new file mode 100755 index 0000000000..6c6864e768 --- /dev/null +++ b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# -------------------------------------------------------------------- +# Copyright (c) 2022, WSO2 Inc. (http://wso2.com) 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. +# ----------------------------------------------------------------------- + +# Sets the Choreo Connect version +echo "Preparing code coverage files before integration tests..." +cp ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec ../../resources/enforcer/dropins/ +JAVA_OPTS=-javaagent:/home/wso2/lib/org.jacoco.agent-0.8.8-runtime.jar=destfile=/home/wso2/lib/dropins/aggregate.exec,append=true +echo "Preparing code coverage files before integration tests completed successfully..." diff --git a/enforcer-parent/commons/pom.xml b/enforcer-parent/commons/pom.xml index 736f85054a..598347acaf 100644 --- a/enforcer-parent/commons/pom.xml +++ b/enforcer-parent/commons/pom.xml @@ -110,6 +110,9 @@ org.jacoco jacoco-maven-plugin + + ${skip.code.coverage} + default-prepare-agent diff --git a/enforcer-parent/enforcer/pom.xml b/enforcer-parent/enforcer/pom.xml index 4fb951d8a0..bcda25dd9d 100644 --- a/enforcer-parent/enforcer/pom.xml +++ b/enforcer-parent/enforcer/pom.xml @@ -34,6 +34,11 @@ https://wso2.org/ + + + + + @@ -189,10 +194,27 @@ ${project.build.directory}/ - org.apache.logging.log4j, org.json.wso2, org.jacoco + org.apache.logging.log4j, org.json.wso2 - log4j-api, log4j-core, log4j-jcl, json, log4j-slf4j-impl, org.jacoco.agent + log4j-api, log4j-core, log4j-jcl, json, log4j-slf4j-impl + + + + + copy-dependencies-for-code-coverage + generate-resources + + copy-dependencies + + + ${skip.code.coverage} + ${project.build.directory}/ + + org.jacoco + + + org.jacoco.agent @@ -265,6 +287,9 @@ org.jacoco jacoco-maven-plugin + + ${skip.code.coverage} + default-prepare-agent @@ -596,4 +621,5 @@ graphQL + diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index 2540ae84f3..31b6759bfe 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -131,6 +131,9 @@ org.jacoco jacoco-maven-plugin + + ${skip.code.coverage} + @@ -187,6 +190,33 @@ + + org.codehaus.mojo + exec-maven-plugin + + + compile + + exec + + + ${skip.code.coverage} + ${ccBaseDir}/dev-scripts/code-coverage/prepare-files-before-int-tests.sh + + + + after-integration-tests + verify + + exec + + + ${skip.code.coverage} + ${ccBaseDir}/dev-scripts/code-coverage/prepare-files-after-int-tests.sh + + + + org.apache.maven.plugins maven-deploy-plugin diff --git a/pom.xml b/pom.xml index e4b0320249..c392b4645d 100644 --- a/pom.xml +++ b/pom.xml @@ -174,6 +174,28 @@ + + org.commonjava.maven.plugins + directory-maven-plugin + ${directory.maven.plugin.version} + + + directories + + highest-basedir + + initialize + + ccBaseDir + + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + maven-antrun-plugin false @@ -588,6 +610,12 @@ slf4j-api ${slf4j.api.version} + + org.jacoco + org.jacoco.agent + ${jacoco.version} + test + com.github.tomakehurst wiremock-jre8 @@ -618,6 +646,7 @@ UTF-8 + UTF-8 3.3.23 5.6.0 @@ -680,6 +709,7 @@ 17.3.wso2v1 1.6.0 3.21.7 + 1.0 2.14.0-rc1 @@ -689,5 +719,9 @@ 7.1.1 4 + + 2.15 + 0.8.8 + true From 026cf96bffbc3a86958c3be5ebf6306d7c7d90c7 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Thu, 8 Sep 2022 12:47:43 +0530 Subject: [PATCH 03/10] minor flow correction --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0f2216cfe..62a7b82b3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,11 +49,7 @@ jobs: - name: Build with Maven run: | export GOFLAGS=-mod=mod - mvn clean install -PRelease -s .maven/settings.xml \ - -pl '!:integration' -pl '!:mock-backend-server' -pl '!:test-integration' - - name: Run integration tests - run: | - mvn clean install -Dskip.code.coverage=false -PRelease -pl ':integration' -amd -s .maven/settings.xml + mvn clean install -Dskip.code.coverage=false -PRelease -s .maven/settings.xml - name: Build multi platform Ubuntu images run: | ./build-ubuntu-multi-platform-images.sh all From 52de0d3f23bd498fbc4e9516d0496454c79dd104 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Tue, 18 Oct 2022 22:48:56 +0530 Subject: [PATCH 04/10] resolved conflicts --- dev-scripts/code-coverage/prepare-files-before-int-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh index 6c6864e768..bef4dea437 100755 --- a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh @@ -18,5 +18,5 @@ # Sets the Choreo Connect version echo "Preparing code coverage files before integration tests..." cp ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec ../../resources/enforcer/dropins/ -JAVA_OPTS=-javaagent:/home/wso2/lib/org.jacoco.agent-0.8.8-runtime.jar=destfile=/home/wso2/lib/dropins/aggregate.exec,append=true +#JAVA_OPTS=-javaagent:/home/wso2/lib/org.jacoco.agent-0.8.8-runtime.jar=destfile=/home/wso2/lib/dropins/aggregate.exec,append=true echo "Preparing code coverage files before integration tests completed successfully..." From b3640126062fe7356c235444a29445316961fbd5 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Tue, 18 Oct 2022 22:51:26 +0530 Subject: [PATCH 05/10] resolved conflicts change to trigger jenkins job --- .../prepare-files-before-int-tests.sh | 6 ++- enforcer-parent/enforcer/pom.xml | 21 +++++++- integration/test-integration/pom.xml | 23 +++++---- .../connect/tests/context/CcInstance.java | 9 ++-- .../tests/context/ChoreoConnectImpl.java | 21 +++++++- ...cWithBackendTlsAndCorsDisabledWithOPA.java | 2 +- .../CcWithClientCertEncodeDisabled.java | 2 +- .../CcWithClientCertEncodeEnabled.java | 2 +- .../setup/standalone/CcWithDefaultConf.java | 2 +- .../setup/standalone/CcWithJwtConfig.java | 2 +- .../CcWithJwtConfigAndTransformer.java | 2 +- .../setup/standalone/CcWithMtlsDefault.java | 2 +- .../setup/standalone/CcWithMultipleEnv.java | 2 +- .../setup/standalone/CcWithSourceControl.java | 2 +- .../setup/withapim/CcStartupExecutor.java | 2 +- .../setup/withapim/CcStartupExecutorTwo.java | 2 +- .../wso2/choreo/connect/tests/util/Utils.java | 15 ++++++ .../test/resources/testng-cc-standalone.xml | 2 + .../test/resources/testng-cc-with-apim.xml | 49 ++++++++++--------- 19 files changed, 115 insertions(+), 53 deletions(-) diff --git a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh index bef4dea437..b4509a8d87 100755 --- a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh @@ -17,6 +17,10 @@ # Sets the Choreo Connect version echo "Preparing code coverage files before integration tests..." -cp ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec ../../resources/enforcer/dropins/ +pwd +mkdir ../../resources/enforcer/dropins/ +#cp ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec ../../resources/enforcer/dropins/ +#chmod 777 ../../resources/enforcer/dropins/aggregate.exec +chmod 777 ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec #JAVA_OPTS=-javaagent:/home/wso2/lib/org.jacoco.agent-0.8.8-runtime.jar=destfile=/home/wso2/lib/dropins/aggregate.exec,append=true echo "Preparing code coverage files before integration tests completed successfully..." diff --git a/enforcer-parent/enforcer/pom.xml b/enforcer-parent/enforcer/pom.xml index bcda25dd9d..c5394971ec 100644 --- a/enforcer-parent/enforcer/pom.xml +++ b/enforcer-parent/enforcer/pom.xml @@ -220,6 +220,23 @@ + + org.codehaus.mojo + exec-maven-plugin + + + package + + exec + + + ${skip.code.coverage} + ${ccBaseDir}/dev-scripts/code-coverage/prepare-files-before-int-tests.sh + + + + + io.fabric8 docker-maven-plugin @@ -249,7 +266,7 @@ docker-build - package + install build @@ -323,7 +340,7 @@ merge-results - verify + test merge diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index 31b6759bfe..9ba75b965d 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -40,6 +40,9 @@ ${basedir}/target/test-integration-${project.version}.jar ${apictl.version} + + + true **/jacoco.exec @@ -194,16 +197,16 @@ org.codehaus.mojo exec-maven-plugin - - compile - - exec - - - ${skip.code.coverage} - ${ccBaseDir}/dev-scripts/code-coverage/prepare-files-before-int-tests.sh - - + + + + + + + + + + after-integration-tests verify diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java index 3da095fbd9..7bfc6ef8b5 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java @@ -49,16 +49,17 @@ public class CcInstance extends ChoreoConnectImpl { private CcInstance(String dockerComposeFile, String confFileName, String backendServiceFile, String gitServiceFile, boolean withCustomJwtTransformer, boolean withAnalyticsMetricImpl, List startupAPIs, boolean isInterceptorCertRequired, String enforcerTrustCertsDir, String volumeMountDir, - boolean isClientCertValidationRequired + boolean isClientCertValidationRequired, boolean isInitialStartup ) throws IOException, CCTestException { - createTmpMgwSetup(); + createTmpMgwSetup(isInitialStartup); String targetDir = Utils.getTargetDirPath(); if (!StringUtils.isEmpty(confFileName)) { Utils.copyFile(targetDir + TestConstant.TEST_RESOURCES_PATH + TestConstant.CONFIGS_DIR + File.separator + confFileName, ccTempPath + TestConstant.DOCKER_COMPOSE_CC_DIR + TestConstant.CONFIG_TOML_PATH); } + addCodeCovExec(); if (withCustomJwtTransformer && withAnalyticsMetricImpl) { addCustomJwtTransformer(); } @@ -179,11 +180,11 @@ public Builder withClientCertValidation() { return this; } - public CcInstance build() throws IOException, CCTestException { + public CcInstance build(boolean isInitialStartUp) throws IOException, CCTestException { instance = new CcInstance(this.dockerComposeFile, this.confFileName, this.backendServiceFile, this.gitServiceFile, this.withCustomJwtTransformer, this.withAnalyticsMetricImpl, this.startupAPIProjectFiles, this.isInterceptorCertRequired, this.enforcerTrustCertsDir, - this.volumeMountDir, this.isClientCertValidationRequired + this.volumeMountDir, this.isClientCertValidationRequired, isInitialStartUp ); return instance; } diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java index 1fe73c2a75..b98c157713 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java @@ -155,7 +155,20 @@ private Boolean checkForBackendAvailability() throws IOException { * * @throws CCTestException if an error occurs while file copy operation */ - void createTmpMgwSetup() throws CCTestException { + void createTmpMgwSetup(boolean isInitialStartup) throws CCTestException { + + log.info(">>>>>>> ############# Creating a new CC startup...."); + if (!isInitialStartup) { + log.info(">>>>>>> ############# Creating a new CC startup after initialization...."); + File myObj = new File("/home/ubuntu/lahiru/pmgNew/product-microgateway/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + if (myObj.delete()) { + System.out.println("Deleted the file: " + myObj.getName()); + } else { + System.out.println("Failed to delete the file."); + } + Utils.copyFile2(Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec", + "/home/ubuntu/lahiru/pmgNew/product-microgateway/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + } Utils.deleteQuietly(ccTempPath); Utils.copyDirectory(ccExtractedPath, ccTempPath); } @@ -182,6 +195,12 @@ public static void addCustomJwtTransformer() throws CCTestException { + File.separator + "jwt-transformer.jar"); } + public static void addCodeCovExec() throws CCTestException { + Utils.copyFile2("/home/ubuntu/lahiru/pmgNew/product-microgateway/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec", + Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + + File.separator + "aggregate.exec"); + } + public static void addInterceptorCertToRouterTruststore() throws IOException { String routerTruststore = ChoreoConnectImpl.class.getClassLoader() .getResource("certs/" + TestConstant.CA_CERTS_FILE).getPath(); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java index 33601ccf7a..a10dd9e944 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java @@ -36,7 +36,7 @@ void start() throws Exception { .withEnforcerTrustCertsDir("enforcer-truststore-opa-certs") .withVolumeMountDir("opa-volume") .withAllCustomImpls() // for custom OPA request generator - .build(); + .build(false); ccInstance.start(); Awaitility.await().pollDelay(5, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java index 89d45812ea..8cc9787c7b 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java @@ -31,7 +31,7 @@ public class CcWithClientCertEncodeDisabled { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("client-cert-not-encode-config.toml").build(); + ccInstance = new CcInstance.Builder().withNewConfig("client-cert-not-encode-config.toml").build(false); ccInstance.start(); ApictlUtils.addEnv("test"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java index 55063acc06..dca6f385c7 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java @@ -31,7 +31,7 @@ public class CcWithClientCertEncodeEnabled { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("client-cert-encode-config.toml").build(); + ccInstance = new CcInstance.Builder().withNewConfig("client-cert-encode-config.toml").build(false); ccInstance.start(); ApictlUtils.addEnv("test"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java index 2a74d4e45b..baf895a647 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java @@ -49,7 +49,7 @@ void start() throws Exception { .withStartupAPI(Utils.getTargetDirPath() + ApictlUtils.API_PROJECTS_PATH + "openAPI_startup_zipped.zip") .withStartupAPI(Utils.getTargetDirPath() + ApictlUtils.API_PROJECTS_PATH + "openAPI_startup") - .build(); + .build(true); ccInstance.start(); Awaitility.await().pollDelay(5, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java index e32db66e67..b21e95a7a7 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java @@ -35,7 +35,7 @@ void start() throws Exception { ApictlUtils.createProject( "timeout_endpoint_openAPI.yaml", "timeout_endpoint"); ccInstance = new CcInstance.Builder().withBackendServiceFile("backend-service-gql.yaml") - .withNewConfig("jwt-generator-config.toml").build(); + .withNewConfig("jwt-generator-config.toml").build(false); ccInstance.start(); ApictlUtils.addEnv("test"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java index 936af87c24..a789420d85 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java @@ -30,7 +30,7 @@ public class CcWithJwtConfigAndTransformer { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("jwt-generator-config.toml").withAllCustomImpls().build(); + ccInstance = new CcInstance.Builder().withNewConfig("jwt-generator-config.toml").withAllCustomImpls().build(false); ccInstance.start(); //TODO: (SuKSW) Check why this fails // Awaitility.await().pollDelay(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java index a7c8955ed2..a83478535e 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java @@ -34,7 +34,7 @@ public class CcWithMtlsDefault { void start() throws Exception { ccInstance = new CcInstance.Builder().withNewConfig("mtls-enabled-config.toml"). - withNewDockerCompose("cc-cacert-mounted-mtls.yaml").withClientCertValidation().build(); + withNewDockerCompose("cc-cacert-mounted-mtls.yaml").withClientCertValidation().build(false); ccInstance.start(); ApictlUtils.createProject("mutual_ssl_openAPI.yaml", "MutualSSL", null, null, null, "mutual_ssl_api.yaml", false, "client_certificate.crt", "client_certificates.yaml"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java index d1b3ee2d15..1d653a13ff 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java @@ -43,7 +43,7 @@ public class CcWithMultipleEnv { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("multiple-env-config.toml").build(); + ccInstance = new CcInstance.Builder().withNewConfig("multiple-env-config.toml").build(false); ccInstance.start(); Awaitility.await().pollDelay(5, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java index 58b6dcb5f9..3395f7076c 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java @@ -40,7 +40,7 @@ void start() throws Exception { .withGitServiceFile("git-service.yaml") .withNewConfig("cc-with-source-control.toml") .withVolumeMountDir("gitea") - .build(); + .build(false); ccInstance.start(); Awaitility.await().pollDelay(10, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java index 66fe7d1d8d..336c666072 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java @@ -35,7 +35,7 @@ public void startChoreoConnect() throws Exception { ccInstance = new CcInstance.Builder().withNewDockerCompose("cc-in-common-network-docker-compose.yaml") .withNewConfig("controlplane-enabled-config.toml") .withBackendServiceFile("backend-service-with-tls-and-network.yaml") - .withAllCustomImpls().build(); + .withAllCustomImpls().build(false); ccInstance.start(); Awaitility.await().pollDelay(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java index e846caab61..90cd50bb36 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java @@ -43,7 +43,7 @@ public void startChoreoConnect() throws Exception { .withNewConfig("cc-special-scenarios-with-apim.toml") .withBackendServiceFile("backend-service-with-tls-and-network.yaml") .withInterceptorCertInRouterTruststore() - .withAllCustomImpls().build(); + .withAllCustomImpls().build(false); ccInstance.start(); Awaitility.await().pollDelay(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java index 480e94729f..d26543e146 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java @@ -61,6 +61,10 @@ import java.net.URL; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; @@ -509,6 +513,17 @@ public static void copyFile(String sourceLocation, String destLocation) throws C } } + public static void copyFile2(String sourceLocation, String destLocation) throws CCTestException { + try { + Path sourcePath = Paths.get(sourceLocation); + Path destPath = Paths.get(destLocation); + Files.copy(sourcePath,destPath,StandardCopyOption.COPY_ATTRIBUTES); + } catch (IOException e) { + throw new CCTestException("error while copying file. ", e); + } + } + + /** * Delay the program for a given time period * diff --git a/integration/test-integration/src/test/resources/testng-cc-standalone.xml b/integration/test-integration/src/test/resources/testng-cc-standalone.xml index 3a3592382d..98b2b8ff93 100644 --- a/integration/test-integration/src/test/resources/testng-cc-standalone.xml +++ b/integration/test-integration/src/test/resources/testng-cc-standalone.xml @@ -137,4 +137,6 @@ + + diff --git a/integration/test-integration/src/test/resources/testng-cc-with-apim.xml b/integration/test-integration/src/test/resources/testng-cc-with-apim.xml index 35507727f5..6ae259b335 100644 --- a/integration/test-integration/src/test/resources/testng-cc-with-apim.xml +++ b/integration/test-integration/src/test/resources/testng-cc-with-apim.xml @@ -69,29 +69,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -106,7 +106,7 @@ - + @@ -155,3 +155,4 @@ + From 2322c627ebaa7ab0b32dfb7c5612a2c1a2fb9f5e Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Wed, 21 Sep 2022 14:06:55 +0530 Subject: [PATCH 06/10] path fix codecov possible file change --- .github/workflows/main.yml | 3 --- .../code-coverage/prepare-files-after-int-tests.sh | 8 +++++--- integration/test-integration/pom.xml | 1 + .../choreo/connect/tests/context/ChoreoConnectImpl.java | 9 +++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 62a7b82b3d..d35e950c68 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,8 +54,5 @@ jobs: run: | ./build-ubuntu-multi-platform-images.sh all docker images - - name: Change working directory - run: | - cd ./covReports - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v3 diff --git a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh index 25ef7d6d37..6b7d9bf563 100755 --- a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh @@ -18,7 +18,9 @@ # Sets the Choreo Connect version echo "Preparing code coverage files after integration tests...." rm -f ../../resources/enforcer/dropins/aggregate.exec -mkdir ../../covReports -cp ../../adapter/target/coverage.out ../../covReports -cp ../../integration/test-integration/target/site/jacoco-aggregate/jacoco.xml ../../covReports + +rm ../../.github/workflows/coverage.yml +rm ../../enforcer-parent/commons/target/site/jacoco/jacoco.xml +rm ../../enforcer-parent/enforcer/target/site/jacoco/jacoco.xml +rm ../../router/target/mgw-wasm/.cache/bazel/_bazel_envoybuild/ac6b95f765ecc3e5ca8ed36bf09bfca3/external/emscripten_bin_linux/emscripten/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_coverage_interface.inc echo "Preparing code coverage files after integration tests completed successfully...." diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index 9ba75b965d..c4a89f35ce 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -39,6 +39,7 @@ ${basedir}/target/test-integration-${project.version}.jar + ${ccBaseDir} ${apictl.version} diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java index b98c157713..91c0d3d46d 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java @@ -156,21 +156,21 @@ private Boolean checkForBackendAvailability() throws IOException { * @throws CCTestException if an error occurs while file copy operation */ void createTmpMgwSetup(boolean isInitialStartup) throws CCTestException { - log.info(">>>>>>> ############# Creating a new CC startup...."); if (!isInitialStartup) { log.info(">>>>>>> ############# Creating a new CC startup after initialization...."); - File myObj = new File("/home/ubuntu/lahiru/pmgNew/product-microgateway/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + File myObj = new File(System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); if (myObj.delete()) { System.out.println("Deleted the file: " + myObj.getName()); } else { System.out.println("Failed to delete the file."); } Utils.copyFile2(Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec", - "/home/ubuntu/lahiru/pmgNew/product-microgateway/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); } Utils.deleteQuietly(ccTempPath); Utils.copyDirectory(ccExtractedPath, ccTempPath); + log.info(">>" + System.getProperty("root_pom_path")); } public void addCcLoggersToEnv() { @@ -196,7 +196,8 @@ public static void addCustomJwtTransformer() throws CCTestException { } public static void addCodeCovExec() throws CCTestException { - Utils.copyFile2("/home/ubuntu/lahiru/pmgNew/product-microgateway/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec", + log.info(">>>>>>>> |||||||||||| "+ System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + Utils.copyFile2(System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec", Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec"); } From 684b9668cd730bae4f28ffc908a494ceaa024612 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Wed, 21 Sep 2022 23:46:55 +0530 Subject: [PATCH 07/10] codecov precentage addition --- .github/workflows/codecov.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000000..045842d238 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: 100% + threshold: 1% From 0f4ccee569182dfb2379e29e01cf5404dfe7b1ad Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Tue, 18 Oct 2022 22:54:24 +0530 Subject: [PATCH 08/10] resolved conflicts java agent change --- .github/workflows/codecov.yml | 2 +- .../prepare-files-after-int-tests.sh | 3 +-- .../prepare-files-before-int-tests.sh | 8 ++++---- integration/test-integration/pom.xml | 3 ++- .../connect/tests/context/CcInstance.java | 14 ++++++++++---- .../tests/context/ChoreoConnectImpl.java | 19 ++++++++----------- .../wso2/choreo/connect/tests/util/Utils.java | 2 +- .../test/resources/testng-cc-standalone.xml | 2 -- .../test/resources/testng-cc-with-apim.xml | 1 - 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 045842d238..2646456593 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -2,5 +2,5 @@ coverage: status: project: default: - target: 100% + target: 27% threshold: 1% diff --git a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh index 6b7d9bf563..032589a92d 100755 --- a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh @@ -18,9 +18,8 @@ # Sets the Choreo Connect version echo "Preparing code coverage files after integration tests...." rm -f ../../resources/enforcer/dropins/aggregate.exec - rm ../../.github/workflows/coverage.yml rm ../../enforcer-parent/commons/target/site/jacoco/jacoco.xml rm ../../enforcer-parent/enforcer/target/site/jacoco/jacoco.xml -rm ../../router/target/mgw-wasm/.cache/bazel/_bazel_envoybuild/ac6b95f765ecc3e5ca8ed36bf09bfca3/external/emscripten_bin_linux/emscripten/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_coverage_interface.inc +rm -rf ../../router/target/mgw-wasm/.cache/bazel/ echo "Preparing code coverage files after integration tests completed successfully...." diff --git a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh index b4509a8d87..92badd9a7d 100755 --- a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh @@ -17,10 +17,10 @@ # Sets the Choreo Connect version echo "Preparing code coverage files before integration tests..." -pwd mkdir ../../resources/enforcer/dropins/ -#cp ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec ../../resources/enforcer/dropins/ -#chmod 777 ../../resources/enforcer/dropins/aggregate.exec chmod 777 ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec -#JAVA_OPTS=-javaagent:/home/wso2/lib/org.jacoco.agent-0.8.8-runtime.jar=destfile=/home/wso2/lib/dropins/aggregate.exec,append=true +sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../resources/docker-compose/docker-compose.yaml +sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true \t -Dhttpclient.hostnameVerifier=AllowAll/g' ../../resources/docker-compose/apim/docker-compose.yaml +sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-cacert-mounted-mtls.yaml +sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true \t -Dhttpclient.hostnameVerifier=AllowAll/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-in-common-network-docker-compose.yaml echo "Preparing code coverage files before integration tests completed successfully..." diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index c4a89f35ce..cc278ee5c0 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -39,7 +39,8 @@ ${basedir}/target/test-integration-${project.version}.jar - ${ccBaseDir} + ${ccBaseDir} + ${skip.code.coverage} ${apictl.version} diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java index 7bfc6ef8b5..0b2fa46789 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java @@ -50,16 +50,22 @@ private CcInstance(String dockerComposeFile, String confFileName, String backend boolean withCustomJwtTransformer, boolean withAnalyticsMetricImpl, List startupAPIs, boolean isInterceptorCertRequired, String enforcerTrustCertsDir, String volumeMountDir, boolean isClientCertValidationRequired, boolean isInitialStartup - ) - throws IOException, CCTestException { - createTmpMgwSetup(isInitialStartup); + ) throws IOException, CCTestException { + boolean isCodeCovAllowedToSkip = true; + if (System.getProperty("is_code_coverage_enabled") != null) { + String codeCovProperty = System.getProperty("is_code_coverage_enabled"); + isCodeCovAllowedToSkip = Boolean.valueOf(codeCovProperty); + } + createTmpMgwSetup(isInitialStartup, isCodeCovAllowedToSkip); String targetDir = Utils.getTargetDirPath(); if (!StringUtils.isEmpty(confFileName)) { Utils.copyFile(targetDir + TestConstant.TEST_RESOURCES_PATH + TestConstant.CONFIGS_DIR + File.separator + confFileName, ccTempPath + TestConstant.DOCKER_COMPOSE_CC_DIR + TestConstant.CONFIG_TOML_PATH); } - addCodeCovExec(); + if(!isCodeCovAllowedToSkip) { + addCodeCovExec(); + } if (withCustomJwtTransformer && withAnalyticsMetricImpl) { addCustomJwtTransformer(); } diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java index 91c0d3d46d..cb535eb6d5 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java @@ -155,22 +155,19 @@ private Boolean checkForBackendAvailability() throws IOException { * * @throws CCTestException if an error occurs while file copy operation */ - void createTmpMgwSetup(boolean isInitialStartup) throws CCTestException { - log.info(">>>>>>> ############# Creating a new CC startup...."); - if (!isInitialStartup) { - log.info(">>>>>>> ############# Creating a new CC startup after initialization...."); - File myObj = new File(System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + void createTmpMgwSetup(boolean isInitialStartup, boolean isCodeCovAllowedToSkip) throws CCTestException { + if (!isCodeCovAllowedToSkip && !isInitialStartup) { + File myObj = new File(System.getProperty("root_pom_path") + "/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); if (myObj.delete()) { - System.out.println("Deleted the file: " + myObj.getName()); + log.debug("Deleted the aggregate.exec file"); } else { - System.out.println("Failed to delete the file."); + log.debug("Failed to delete aggregate.exec file"); } - Utils.copyFile2(Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec", + Utils.copyFileWithAttributes(Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec", System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); } Utils.deleteQuietly(ccTempPath); Utils.copyDirectory(ccExtractedPath, ccTempPath); - log.info(">>" + System.getProperty("root_pom_path")); } public void addCcLoggersToEnv() { @@ -195,9 +192,9 @@ public static void addCustomJwtTransformer() throws CCTestException { + File.separator + "jwt-transformer.jar"); } + // adds aggregated jacoco exec (relevant to the enforcer) into the cc-temp dropins directory public static void addCodeCovExec() throws CCTestException { - log.info(">>>>>>>> |||||||||||| "+ System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); - Utils.copyFile2(System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec", + Utils.copyFileWithAttributes(System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec", Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec"); } diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java index d26543e146..5caa469c7a 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java @@ -513,7 +513,7 @@ public static void copyFile(String sourceLocation, String destLocation) throws C } } - public static void copyFile2(String sourceLocation, String destLocation) throws CCTestException { + public static void copyFileWithAttributes(String sourceLocation, String destLocation) throws CCTestException { try { Path sourcePath = Paths.get(sourceLocation); Path destPath = Paths.get(destLocation); diff --git a/integration/test-integration/src/test/resources/testng-cc-standalone.xml b/integration/test-integration/src/test/resources/testng-cc-standalone.xml index 98b2b8ff93..3a3592382d 100644 --- a/integration/test-integration/src/test/resources/testng-cc-standalone.xml +++ b/integration/test-integration/src/test/resources/testng-cc-standalone.xml @@ -137,6 +137,4 @@ - - diff --git a/integration/test-integration/src/test/resources/testng-cc-with-apim.xml b/integration/test-integration/src/test/resources/testng-cc-with-apim.xml index 6ae259b335..f99b714987 100644 --- a/integration/test-integration/src/test/resources/testng-cc-with-apim.xml +++ b/integration/test-integration/src/test/resources/testng-cc-with-apim.xml @@ -155,4 +155,3 @@ - From 7f35947dbf01d916511cc6b89afa143256fbb879 Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Thu, 22 Sep 2022 17:55:57 +0530 Subject: [PATCH 09/10] java agent pram fix minor format change in testng file resolved conflicts resolved conflicts --- .../prepare-files-before-int-tests.sh | 8 ++-- enforcer-parent/enforcer/pom.xml | 5 -- integration/test-integration/pom.xml | 28 ----------- .../wso2/choreo/connect/tests/util/Utils.java | 7 +++ .../test/resources/testng-cc-with-apim.xml | 48 +++++++++---------- 5 files changed, 35 insertions(+), 61 deletions(-) diff --git a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh index 92badd9a7d..57df4b9191 100755 --- a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh @@ -19,8 +19,8 @@ echo "Preparing code coverage files before integration tests..." mkdir ../../resources/enforcer/dropins/ chmod 777 ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec -sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../resources/docker-compose/docker-compose.yaml -sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true \t -Dhttpclient.hostnameVerifier=AllowAll/g' ../../resources/docker-compose/apim/docker-compose.yaml -sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-cacert-mounted-mtls.yaml -sed -i '' 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} \t -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true \t -Dhttpclient.hostnameVerifier=AllowAll/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-in-common-network-docker-compose.yaml +sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../resources/docker-compose/docker-compose.yaml +sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true -Dhttpclient.hostnameVerifier=AllowAll/g' ../../resources/docker-compose/apim/docker-compose.yaml +sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-cacert-mounted-mtls.yaml +sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true -Dhttpclient.hostnameVerifier=AllowAll/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-in-common-network-docker-compose.yaml echo "Preparing code coverage files before integration tests completed successfully..." diff --git a/enforcer-parent/enforcer/pom.xml b/enforcer-parent/enforcer/pom.xml index c5394971ec..69bfd1cd93 100644 --- a/enforcer-parent/enforcer/pom.xml +++ b/enforcer-parent/enforcer/pom.xml @@ -34,11 +34,6 @@ https://wso2.org/ - - - - - diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index cc278ee5c0..7790a976a2 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -105,34 +105,6 @@ - - io.fabric8 - docker-maven-plugin - - - - choreo-connect-backend - testcontainers/ryuk:${ryuk.image.version} - - - - - - docker-test-container-pull - generate-resources - - start - - - - docker-test-container-remove - post-integration-test - - stop - - - - org.jacoco jacoco-maven-plugin diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java index 5caa469c7a..0b9ff881f4 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java @@ -513,6 +513,13 @@ public static void copyFile(String sourceLocation, String destLocation) throws C } } + /** + * Copies a file with existing attribute values + * + * @param sourceLocation current location of the file + * @param destLocation destination location path of the file + * @throws CCTestException if error happens while copying the file + */ public static void copyFileWithAttributes(String sourceLocation, String destLocation) throws CCTestException { try { Path sourcePath = Paths.get(sourceLocation); diff --git a/integration/test-integration/src/test/resources/testng-cc-with-apim.xml b/integration/test-integration/src/test/resources/testng-cc-with-apim.xml index f99b714987..35507727f5 100644 --- a/integration/test-integration/src/test/resources/testng-cc-with-apim.xml +++ b/integration/test-integration/src/test/resources/testng-cc-with-apim.xml @@ -69,29 +69,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -106,7 +106,7 @@ - + From fde1644c49df6190456df16efd7aad529352c88f Mon Sep 17 00:00:00 2001 From: slahirucd7 Date: Wed, 19 Oct 2022 20:05:59 +0530 Subject: [PATCH 10/10] changes for reiview suggestions before int test script change before int test script change for commas remove commented lines remove a comment in the scripts --- .../prepare-files-after-int-tests.sh | 1 - .../prepare-files-before-int-tests.sh | 10 +++++----- integration/test-integration/pom.xml | 13 ------------- .../connect/tests/context/CcInstance.java | 17 ++++++++++++----- .../tests/context/ChoreoConnectImpl.java | 10 +++++----- .../CcWithBackendTlsAndCorsDisabledWithOPA.java | 2 +- .../CcWithClientCertEncodeDisabled.java | 2 +- .../CcWithClientCertEncodeEnabled.java | 2 +- .../setup/standalone/CcWithDefaultConf.java | 3 ++- .../tests/setup/standalone/CcWithJwtConfig.java | 2 +- .../CcWithJwtConfigAndTransformer.java | 2 +- .../setup/standalone/CcWithMtlsDefault.java | 2 +- .../setup/standalone/CcWithMultipleEnv.java | 2 +- .../setup/standalone/CcWithSourceControl.java | 2 +- .../tests/setup/withapim/CcStartupExecutor.java | 2 +- .../setup/withapim/CcStartupExecutorTwo.java | 2 +- .../choreo/connect/tests/util/TestConstant.java | 11 +++++++++-- .../wso2/choreo/connect/tests/util/Utils.java | 12 +++++++++++- 18 files changed, 54 insertions(+), 43 deletions(-) diff --git a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh index 032589a92d..d5d4150b06 100755 --- a/dev-scripts/code-coverage/prepare-files-after-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-after-int-tests.sh @@ -15,7 +15,6 @@ # limitations under the License. # ----------------------------------------------------------------------- -# Sets the Choreo Connect version echo "Preparing code coverage files after integration tests...." rm -f ../../resources/enforcer/dropins/aggregate.exec rm ../../.github/workflows/coverage.yml diff --git a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh index 57df4b9191..cadd81827b 100755 --- a/dev-scripts/code-coverage/prepare-files-before-int-tests.sh +++ b/dev-scripts/code-coverage/prepare-files-before-int-tests.sh @@ -15,12 +15,12 @@ # limitations under the License. # ----------------------------------------------------------------------- -# Sets the Choreo Connect version echo "Preparing code coverage files before integration tests..." mkdir ../../resources/enforcer/dropins/ chmod 777 ../../enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec -sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../resources/docker-compose/docker-compose.yaml -sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true -Dhttpclient.hostnameVerifier=AllowAll/g' ../../resources/docker-compose/apim/docker-compose.yaml -sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-cacert-mounted-mtls.yaml -sed -i 's/JAVA_OPTS.*/JAVA_OPTS=${JAVA_OPTS} -javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true -Dhttpclient.hostnameVerifier=AllowAll/g' ../../integration/test-integration/src/test/resources/dockerCompose/cc-in-common-network-docker-compose.yaml +export JAVA_AGENT_ARG="-javaagent:\/home\/wso2\/lib\/org.jacoco.agent-0.8.8-runtime.jar=destfile=\/home\/wso2\/lib\/dropins\/aggregate.exec,append=true" +sed -i "s/JAVA_OPTS.*/JAVA_OPTS=\${JAVA_OPTS} ${JAVA_AGENT_ARG}/g" ../../resources/docker-compose/docker-compose.yaml +sed -i "s/JAVA_OPTS.*/JAVA_OPTS=\${JAVA_OPTS} ${JAVA_AGENT_ARG} -Dhttpclient.hostnameVerifier=AllowAll/g" ../../resources/docker-compose/apim/docker-compose.yaml +sed -i "s/JAVA_OPTS.*/JAVA_OPTS=\${JAVA_OPTS} ${JAVA_AGENT_ARG}/g" ../../integration/test-integration/src/test/resources/dockerCompose/cc-cacert-mounted-mtls.yaml +sed -i "s/JAVA_OPTS.*/JAVA_OPTS=\${JAVA_OPTS} ${JAVA_AGENT_ARG} -Dhttpclient.hostnameVerifier=AllowAll/g" ../../integration/test-integration/src/test/resources/dockerCompose/cc-in-common-network-docker-compose.yaml echo "Preparing code coverage files before integration tests completed successfully..." diff --git a/integration/test-integration/pom.xml b/integration/test-integration/pom.xml index 7790a976a2..3609a9cd63 100644 --- a/integration/test-integration/pom.xml +++ b/integration/test-integration/pom.xml @@ -42,9 +42,6 @@ ${ccBaseDir} ${skip.code.coverage} ${apictl.version} - - - true **/jacoco.exec @@ -171,16 +168,6 @@ org.codehaus.mojo exec-maven-plugin - - - - - - - - - - after-integration-tests verify diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java index 0b2fa46789..e0bf288da6 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/CcInstance.java @@ -52,8 +52,9 @@ private CcInstance(String dockerComposeFile, String confFileName, String backend boolean isClientCertValidationRequired, boolean isInitialStartup ) throws IOException, CCTestException { boolean isCodeCovAllowedToSkip = true; - if (System.getProperty("is_code_coverage_enabled") != null) { - String codeCovProperty = System.getProperty("is_code_coverage_enabled"); + String codeCoverageEnabled = System.getProperty("is_code_coverage_enabled"); + if (codeCoverageEnabled != null) { + String codeCovProperty = codeCoverageEnabled; isCodeCovAllowedToSkip = Boolean.valueOf(codeCovProperty); } createTmpMgwSetup(isInitialStartup, isCodeCovAllowedToSkip); @@ -133,6 +134,7 @@ public static class Builder { boolean withAnalyticsMetricImpl = false; boolean isInterceptorCertRequired = false; boolean isClientCertValidationRequired = false; + boolean isInitialStartUp = false; public Builder withNewDockerCompose(String dockerComposeFile) { this.dockerComposeFile = dockerComposeFile; @@ -186,12 +188,17 @@ public Builder withClientCertValidation() { return this; } - public CcInstance build(boolean isInitialStartUp) throws IOException, CCTestException { + // to indicate Choreo-Connect initial startup during the integration tests + public Builder markInitialCCStartup(boolean isInitialStartUp) { + this.isInitialStartUp = isInitialStartUp; + return this; + } + + public CcInstance build() throws IOException, CCTestException { instance = new CcInstance(this.dockerComposeFile, this.confFileName, this.backendServiceFile, this.gitServiceFile, this.withCustomJwtTransformer, this.withAnalyticsMetricImpl, this.startupAPIProjectFiles, this.isInterceptorCertRequired, this.enforcerTrustCertsDir, - this.volumeMountDir, this.isClientCertValidationRequired, isInitialStartUp - ); + this.volumeMountDir, this.isClientCertValidationRequired, this.isInitialStartUp); return instance; } } diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java index cb535eb6d5..f89d4fec82 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/context/ChoreoConnectImpl.java @@ -157,14 +157,14 @@ private Boolean checkForBackendAvailability() throws IOException { */ void createTmpMgwSetup(boolean isInitialStartup, boolean isCodeCovAllowedToSkip) throws CCTestException { if (!isCodeCovAllowedToSkip && !isInitialStartup) { - File myObj = new File(System.getProperty("root_pom_path") + "/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + File myObj = new File(System.getProperty("root_pom_path") + Utils.getEnforcerCodeCovExecPath()); if (myObj.delete()) { log.debug("Deleted the aggregate.exec file"); } else { log.debug("Failed to delete aggregate.exec file"); } - Utils.copyFileWithAttributes(Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + "aggregate.exec", - System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec"); + Utils.copyFileWithAttributes(Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH + File.separator + TestConstant.JACOCO_EXEC_NAME, + System.getProperty("root_pom_path")+ Utils.getEnforcerCodeCovExecPath()); } Utils.deleteQuietly(ccTempPath); Utils.copyDirectory(ccExtractedPath, ccTempPath); @@ -194,9 +194,9 @@ public static void addCustomJwtTransformer() throws CCTestException { // adds aggregated jacoco exec (relevant to the enforcer) into the cc-temp dropins directory public static void addCodeCovExec() throws CCTestException { - Utils.copyFileWithAttributes(System.getProperty("root_pom_path")+"/enforcer-parent/enforcer/target/coverage-aggregate-reports/aggregate.exec", + Utils.copyFileWithAttributes(System.getProperty("root_pom_path")+ Utils.getEnforcerCodeCovExecPath(), Utils.getTargetDirPath() + TestConstant.CC_TEMP_PATH + TestConstant.DROPINS_FOLDER_PATH - + File.separator + "aggregate.exec"); + + File.separator + TestConstant.JACOCO_EXEC_NAME); } public static void addInterceptorCertToRouterTruststore() throws IOException { diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java index a10dd9e944..33601ccf7a 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithBackendTlsAndCorsDisabledWithOPA.java @@ -36,7 +36,7 @@ void start() throws Exception { .withEnforcerTrustCertsDir("enforcer-truststore-opa-certs") .withVolumeMountDir("opa-volume") .withAllCustomImpls() // for custom OPA request generator - .build(false); + .build(); ccInstance.start(); Awaitility.await().pollDelay(5, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java index 8cc9787c7b..89d45812ea 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeDisabled.java @@ -31,7 +31,7 @@ public class CcWithClientCertEncodeDisabled { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("client-cert-not-encode-config.toml").build(false); + ccInstance = new CcInstance.Builder().withNewConfig("client-cert-not-encode-config.toml").build(); ccInstance.start(); ApictlUtils.addEnv("test"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java index dca6f385c7..55063acc06 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithClientCertEncodeEnabled.java @@ -31,7 +31,7 @@ public class CcWithClientCertEncodeEnabled { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("client-cert-encode-config.toml").build(false); + ccInstance = new CcInstance.Builder().withNewConfig("client-cert-encode-config.toml").build(); ccInstance.start(); ApictlUtils.addEnv("test"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java index baf895a647..7a9623e5e1 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithDefaultConf.java @@ -49,7 +49,8 @@ void start() throws Exception { .withStartupAPI(Utils.getTargetDirPath() + ApictlUtils.API_PROJECTS_PATH + "openAPI_startup_zipped.zip") .withStartupAPI(Utils.getTargetDirPath() + ApictlUtils.API_PROJECTS_PATH + "openAPI_startup") - .build(true); + .markInitialCCStartup(true) + .build(); ccInstance.start(); Awaitility.await().pollDelay(5, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java index b21e95a7a7..e32db66e67 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfig.java @@ -35,7 +35,7 @@ void start() throws Exception { ApictlUtils.createProject( "timeout_endpoint_openAPI.yaml", "timeout_endpoint"); ccInstance = new CcInstance.Builder().withBackendServiceFile("backend-service-gql.yaml") - .withNewConfig("jwt-generator-config.toml").build(false); + .withNewConfig("jwt-generator-config.toml").build(); ccInstance.start(); ApictlUtils.addEnv("test"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java index a789420d85..936af87c24 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithJwtConfigAndTransformer.java @@ -30,7 +30,7 @@ public class CcWithJwtConfigAndTransformer { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("jwt-generator-config.toml").withAllCustomImpls().build(false); + ccInstance = new CcInstance.Builder().withNewConfig("jwt-generator-config.toml").withAllCustomImpls().build(); ccInstance.start(); //TODO: (SuKSW) Check why this fails // Awaitility.await().pollDelay(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java index a83478535e..a7c8955ed2 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMtlsDefault.java @@ -34,7 +34,7 @@ public class CcWithMtlsDefault { void start() throws Exception { ccInstance = new CcInstance.Builder().withNewConfig("mtls-enabled-config.toml"). - withNewDockerCompose("cc-cacert-mounted-mtls.yaml").withClientCertValidation().build(false); + withNewDockerCompose("cc-cacert-mounted-mtls.yaml").withClientCertValidation().build(); ccInstance.start(); ApictlUtils.createProject("mutual_ssl_openAPI.yaml", "MutualSSL", null, null, null, "mutual_ssl_api.yaml", false, "client_certificate.crt", "client_certificates.yaml"); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java index 1d653a13ff..d1b3ee2d15 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithMultipleEnv.java @@ -43,7 +43,7 @@ public class CcWithMultipleEnv { @BeforeTest(description = "initialise the setup") void start() throws Exception { - ccInstance = new CcInstance.Builder().withNewConfig("multiple-env-config.toml").build(false); + ccInstance = new CcInstance.Builder().withNewConfig("multiple-env-config.toml").build(); ccInstance.start(); Awaitility.await().pollDelay(5, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java index 3395f7076c..58b6dcb5f9 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/standalone/CcWithSourceControl.java @@ -40,7 +40,7 @@ void start() throws Exception { .withGitServiceFile("git-service.yaml") .withNewConfig("cc-with-source-control.toml") .withVolumeMountDir("gitea") - .build(false); + .build(); ccInstance.start(); Awaitility.await().pollDelay(10, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java index 336c666072..66fe7d1d8d 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutor.java @@ -35,7 +35,7 @@ public void startChoreoConnect() throws Exception { ccInstance = new CcInstance.Builder().withNewDockerCompose("cc-in-common-network-docker-compose.yaml") .withNewConfig("controlplane-enabled-config.toml") .withBackendServiceFile("backend-service-with-tls-and-network.yaml") - .withAllCustomImpls().build(false); + .withAllCustomImpls().build(); ccInstance.start(); Awaitility.await().pollDelay(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java index 90cd50bb36..e846caab61 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/setup/withapim/CcStartupExecutorTwo.java @@ -43,7 +43,7 @@ public void startChoreoConnect() throws Exception { .withNewConfig("cc-special-scenarios-with-apim.toml") .withBackendServiceFile("backend-service-with-tls-and-network.yaml") .withInterceptorCertInRouterTruststore() - .withAllCustomImpls().build(false); + .withAllCustomImpls().build(); ccInstance.start(); Awaitility.await().pollDelay(20, TimeUnit.SECONDS).pollInterval(5, TimeUnit.SECONDS) .atMost(2, TimeUnit.MINUTES).until(ccInstance.isHealthy()); diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/TestConstant.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/TestConstant.java index 08cd68cd89..c32c8bdb73 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/TestConstant.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/TestConstant.java @@ -228,15 +228,22 @@ public class TestConstant { public static final String DOCKER_COMPOSE_YAML_PATH = File.separator + "docker-compose.yaml"; public static final String CA_CERTS_FILE = File.separator + "ca-certificates.crt"; + public static final String ENFORCER_DIR_NAME = "enforcer"; public static final String ROUTER_TRUSTSTORE_DIR = RESOURCES_DIR + File.separator + "router" + SECURITY_DIR + File.separator + "truststore"; - public static final String ENFORCER_TRUSTSTORE_DIR = RESOURCES_DIR + File.separator + "enforcer" + public static final String ENFORCER_TRUSTSTORE_DIR = RESOURCES_DIR + File.separator + ENFORCER_DIR_NAME + SECURITY_DIR + File.separator + "truststore"; public static final String DOCKER_COMPOSE_CC_DIR = DOCKER_COMPOSE_DIR + File.separator + "choreo-connect"; public static final String DROPINS_FOLDER_PATH = DOCKER_COMPOSE_DIR + RESOURCES_DIR - + File.separator + "enforcer" + File.separator + "dropins"; + + File.separator + ENFORCER_DIR_NAME + File.separator + "dropins"; public static final String STARTUP_APIS_DIR = RESOURCES_DIR + File.separator + "adapter" + File.separator + "artifacts" + File.separator + "apis"; + public static final String JACOCO_EXEC_NAME = "aggregate.exec"; + public static final String ENFORCER_PARENT_DIR_NAME = "enforcer-parent"; + public static final String TARGET_DIR_NAME = "target"; + public static final String CODECOV_AGGREGATE_REPORT_DIR_NAME = "coverage-aggregate-reports"; + + public static final String HEALTH_ENDPOINT_RESPONSE = "{\"status\": \"healthy\"}"; diff --git a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java index 0b9ff881f4..1de056a028 100644 --- a/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java +++ b/integration/test-integration/src/test/java/org/wso2/choreo/connect/tests/util/Utils.java @@ -530,7 +530,6 @@ public static void copyFileWithAttributes(String sourceLocation, String destLoca } } - /** * Delay the program for a given time period * @@ -658,6 +657,17 @@ public static JSONObject changeHeadersToLowerCase(JSONObject headers) { return headersCaseInsensitive; } + /** + * Gives jacoco aggregate.exec file containing path relevant to the Enforcer + * + * @return jacoco aggregate.exec file path + */ + public static String getEnforcerCodeCovExecPath() { + return File.separator + TestConstant.ENFORCER_PARENT_DIR_NAME + File.separator + TestConstant.ENFORCER_DIR_NAME + + File.separator + TestConstant.TARGET_DIR_NAME + File.separator + + TestConstant.CODECOV_AGGREGATE_REPORT_DIR_NAME + File.separator + TestConstant.JACOCO_EXEC_NAME; + } + public static String getTargetDirPath() { File targetClassesDir = new File(Utils.class.getProtectionDomain().getCodeSource(). getLocation().getPath());