Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bpdm-system-test): create end to end test CI/CD workflow for golden record process #1157

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
22 changes: 22 additions & 0 deletions .github/workflows/app-test-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/deploy-docker-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ jobs:
secrets: inherit
with:
imageName: bpdm-orchestrator
dockerfilePath: ./docker/orchestrator
dockerfilePath: ./docker/orchestrator

build-docker-system-tester:
uses: ./.github/workflows/deploy-docker.yaml
secrets: inherit
with:
imageName: bpdm-system-tester
dockerfilePath: ./docker/system-tester
5 changes: 5 additions & 0 deletions .github/workflows/docker-build-and-cache-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .github/workflows/docker-build-and-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ on:
- gate
- orchestrator
- cleaning-service-dummy
- system-tester
workflow_call:
inputs:
app:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
22 changes: 19 additions & 3 deletions bpdm-system-tester/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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"
40 changes: 40 additions & 0 deletions charts/bpdm/templates/tests/secret.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

44 changes: 44 additions & 0 deletions charts/bpdm/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions charts/bpdm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Empty file modified docker/compose/dependencies/postgres-init.sh
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions docker/system-tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Loading