diff --git a/.github/workflows/app-test-charts.yaml b/.github/workflows/app-test-charts.yaml index 98325789a..422f2f57b 100644 --- a/.github/workflows/app-test-charts.yaml +++ b/.github/workflows/app-test-charts.yaml @@ -118,6 +118,12 @@ jobs: name: bpdm-cleaning-service-dummy-docker path: /tmp + - name: Download System Tester Image + uses: actions/download-artifact@v4 + with: + name: bpdm-system-tester-docker + path: /tmp + - name: Push Pool Image to Kind run: | docker load --input /tmp/bpdm-pool.tar @@ -142,6 +148,12 @@ jobs: docker image tag bpdm-cleaning-service-dummy:test kind-registry:5000/bpdm-cleaning-service-dummy:test docker push kind-registry:5000/bpdm-cleaning-service-dummy:test + - name: Push System Tester Image to Kind + run: | + docker load --input /tmp/bpdm-system-tester.tar + docker image tag bpdm-system-tester:test kind-registry:5000/bpdm-system-tester:test + docker push kind-registry:5000/bpdm-system-tester:test + - name: Create Test Values run: | mkdir charts/bpdm/ci @@ -166,6 +178,11 @@ jobs: registry: kind-registry:5000 repository: bpdm-cleaning-service-dummy tag: test + tests: + image: + registry: kind-registry:5000 + repository: bpdm-system-tester + tag: test EOF echo "cat charts/bpdm/ci/test-values.yaml" cat charts/bpdm/ci/test-values.yaml @@ -205,6 +222,11 @@ jobs: registry: kind-registry:5000 repository: bpdm-cleaning-service-dummy tag: test + tests: + image: + registry: kind-registry:5000 + repository: bpdm-system-tester + tag: test centralidp: keycloak: auth: diff --git a/.github/workflows/deploy-docker-all.yaml b/.github/workflows/deploy-docker-all.yaml index e99a49710..37b464f41 100644 --- a/.github/workflows/deploy-docker-all.yaml +++ b/.github/workflows/deploy-docker-all.yaml @@ -53,4 +53,11 @@ jobs: secrets: inherit with: imageName: bpdm-orchestrator - dockerfilePath: ./docker/orchestrator \ No newline at end of file + dockerfilePath: ./docker/orchestrator + + build-docker-system-tester: + uses: ./.github/workflows/deploy-docker.yaml + secrets: inherit + with: + imageName: bpdm-system-tester + dockerfilePath: ./docker/system-tester \ No newline at end of file diff --git a/.github/workflows/docker-build-and-cache-all.yaml b/.github/workflows/docker-build-and-cache-all.yaml index 2a9cab5e9..dd39808dc 100644 --- a/.github/workflows/docker-build-and-cache-all.yaml +++ b/.github/workflows/docker-build-and-cache-all.yaml @@ -41,3 +41,8 @@ jobs: uses: ./.github/workflows/docker-build-and-cache.yaml with: app: cleaning-service-dummy + + build-system-tester: + uses: ./.github/workflows/docker-build-and-cache.yaml + with: + app: system-tester diff --git a/.github/workflows/docker-build-and-cache.yaml b/.github/workflows/docker-build-and-cache.yaml index 94221601b..7b034d32a 100644 --- a/.github/workflows/docker-build-and-cache.yaml +++ b/.github/workflows/docker-build-and-cache.yaml @@ -30,6 +30,7 @@ on: - gate - orchestrator - cleaning-service-dummy + - system-tester workflow_call: inputs: app: diff --git a/CHANGELOG.md b/CHANGELOG.md index 95688f4e2..c9831460a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C - BPDM Pool: Post endpoint to fetch the BPNL/S/A based on the requested identifiers.([#1052](https://github.com/eclipse-tractusx/bpdm/issues/1052)) - BPDM Gate & Orchestrator: Enhance the error handling mechanism for the orchestrator and gate components by extending the list of available error codes.([#1003](https://github.com/eclipse-tractusx/bpdm/pull/1003#pullrequestreview-2477395867)) - BPDM System Test: Tester module which performs automated end-to-end tests on an existing golden record process.([#1070](https://github.com/eclipse-tractusx/bpdm/pull/1070)) +- BPDM System Test: End-to-end test CI/CD workflow setup for golden record process. ([#1155](https://github.com/eclipse-tractusx/bpdm/issues/1155)) ### Changed diff --git a/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/config/GateClientConfig.kt b/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/config/GateClientConfig.kt index c37ada7e2..3e525a0ae 100644 --- a/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/config/GateClientConfig.kt +++ b/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/config/GateClientConfig.kt @@ -29,7 +29,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -@ConfigurationProperties(prefix = PoolClientConfigurationProperties.PREFIX) +@ConfigurationProperties(prefix = GateClientConfigProperties.PREFIX) data class GateClientConfigProperties( override val baseUrl: String = "http://localhost:8081", val searchChangelogPageSize: Int = 100, diff --git a/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/stepdefinations/ShareGenericNoBpnStepDefs.kt b/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/stepdefinations/ShareGenericNoBpnStepDefs.kt index 418399da7..44a9f7ebd 100644 --- a/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/stepdefinations/ShareGenericNoBpnStepDefs.kt +++ b/bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/stepdefinations/ShareGenericNoBpnStepDefs.kt @@ -81,6 +81,7 @@ class ShareGenericNoBpnStepDefs( private fun uploadInput(seed: String, externalId: String, addressType: AddressType?){ val inputRequest = gateInputDataFactory.createFullValid(seed, externalId).withAddressType(addressType).withoutAnyBpn() + inputRequest.copy(isOwnCompanyData = false) gateClient.businessParters.upsertBusinessPartnersInput(listOf(inputRequest)) } diff --git a/bpdm-system-tester/src/main/resources/application.yml b/bpdm-system-tester/src/main/resources/application.yml index 67a04b585..f2e46dab3 100644 --- a/bpdm-system-tester/src/main/resources/application.yml +++ b/bpdm-system-tester/src/main/resources/application.yml @@ -1,13 +1,29 @@ bpdm: client: pool: - enabled: false + securityEnabled: true + # The base-url of the Pool-API + base-url: http://localhost:8080 provider: - issuer-uri: ${bpdm.security.auth-server-url:http://localhost:8180}/realms/${bpdm.security.realm:master} + issuer-uri: http://localhost:8180/realms/CX-Central registration: authorization-grant-type: client_credentials # Use a default client id for the client credentials request - client-id: BPDM-POOL + client-id: sa-cl7-cx-7 # Please provide a secret here + client-secret: "**********" + gate: + securityEnabled: true + # The base-url of the Pool-API + base-url: http://localhost:8081 + provider: + issuer-uri: http://localhost:8180/realms/CX-Central + registration: + authorization-grant-type: client_credentials + # Use a default client id for the client credentials request + client-id: sa-cl7-cx-7 + # Please provide secret here + client-secret: "**********" + cucumber: glue: "org.eclipse.tractusx.bpdm.test.system.stepdefinations" diff --git a/charts/bpdm/templates/tests/secret.yaml b/charts/bpdm/templates/tests/secret.yaml new file mode 100644 index 000000000..c54e57901 --- /dev/null +++ b/charts/bpdm/templates/tests/secret.yaml @@ -0,0 +1,40 @@ +--- +################################################################################ +# Copyright (c) 2021,2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +apiVersion: v1 +kind: Secret +metadata: + name: "{{ include "bpdm.fullname" . }}-test" + annotations: + "helm.sh/hook": test +type: Opaque +stringData: + defaultSecrets.yml: |- + bpdm: + client: + gate: + base-url: http://{{ include "bpdm.toReleaseName" (list . "bpdm-gate") }} + pool: + base-url: http://{{ include "bpdm.toReleaseName" (list . "bpdm-pool") }} + secrets.yml: |- +{{- if .Values.tests.applicationConfig }} + {{- .Values.tests.applicationConfig | toYaml | nindent 4 }} +{{- end }} + diff --git a/charts/bpdm/templates/tests/test-connection.yaml b/charts/bpdm/templates/tests/test-connection.yaml new file mode 100644 index 000000000..27dcfc36a --- /dev/null +++ b/charts/bpdm/templates/tests/test-connection.yaml @@ -0,0 +1,44 @@ +--- +################################################################################ +# Copyright (c) 2021,2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +################################################################################ + +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "bpdm.fullname" . }}-test" + annotations: + "helm.sh/hook": test +spec: + containers: + - name: java-test + image: "{{ .Values.tests.image.registry }}/{{ .Values.tests.image.repository }}:{{ .Values.tests.image.tag | default .Chart.AppVersion }}" + env: + - name: SPRING_CONFIG_IMPORT + value: "/etc/conf/defaultSecrets.yml,/etc/conf/secrets.yml" + volumeMounts: + - mountPath: /etc/conf + name: config + readOnly: true + volumes: + - name: config + projected: + sources: + - secret: + name: "{{include "bpdm.fullname" .}}-test" + restartPolicy: Never diff --git a/charts/bpdm/values.yaml b/charts/bpdm/values.yaml index 53c808632..9a305ebe4 100644 --- a/charts/bpdm/values.yaml +++ b/charts/bpdm/values.yaml @@ -81,3 +81,20 @@ centralidp: enabled: true keycloak: fullnameOverride: bpdm-centralidp + +tests: + applicationConfig: + bpdm: + client: + gate: + provider: + issuer-uri: http://bpdm-centralidp/auth/realms/CX-Central + pool: + provider: + issuer-uri: http://bpdm-centralidp/auth/realms/CX-Central + image: + registry: docker.io + repository: tractusx/bpdm-system-tester + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" diff --git a/docker/compose/dependencies/postgres-init.sh b/docker/compose/dependencies/postgres-init.sh old mode 100644 new mode 100755 diff --git a/docker/system-tester/Dockerfile b/docker/system-tester/Dockerfile new file mode 100644 index 000000000..f005fbb5e --- /dev/null +++ b/docker/system-tester/Dockerfile @@ -0,0 +1,16 @@ +FROM maven:3.9-eclipse-temurin-21 AS build +COPY . /home/app +WORKDIR /home/app +RUN mvn -B -U clean package -pl bpdm-system-tester -am -DskipTests + +FROM eclipse-temurin:21-jre-alpine +COPY --from=build /home/app/bpdm-system-tester/target/bpdm-system-tester.jar /usr/local/lib/bpdm/app.jar +ARG USERNAME=bpdm +ARG USERID=10001 +ARG GID=10001 +RUN addgroup -g $GID -S $USERNAME +RUN adduser -u $USERID -S $USERNAME $USERNAME +USER $USERNAME +WORKDIR /usr/local/lib/bpdm +EXPOSE 8080 +ENTRYPOINT ["java","-jar","app.jar"]