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

Feature/226 test enhancements for integration testing #732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/actions/cucumber-integration-test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# 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
#
---
name: IRS Cucumber Integration Test execution
description: "Runs the IRS Cucumber Integration Tests"
inputs:
regularUserApiKey:
description: "API Key for IRS regular user"
required: true
adminUserApiKey:
description: "API Key for IRS admin user"
required: true
cucumberPublishToken:
description: "Token to publish the cucumber report"
required: true
executionFilter:
description: "JUnit5 filter for feature file annotations"
required: true

runs:
using: composite
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Prepare expected files
run: |
chmod +x ./local/testing/testdata/prepare-expected-files.sh
./local/testing/testdata/prepare-expected-files.sh "BPNL00000003AYRE"
shell: bash

- name: Run Tests with Maven
shell: bash
env:
REGULAR_USER_API_KEY: ${{ inputs.regularUserApiKey }}
ADMIN_USER_API_KEY: ${{ inputs.adminUserApiKey }}
ISSUE_FILTER: ${{ inputs.executionFilter }}
CUCUMBER_PUBLISH_TOKEN: ${{ inputs.cucumberPublishToken }}
# workaround replacement since injecting the token via environment variable does not work
run: |
sed -i "s/CUCUMBER_TOKEN_IRS_PLACEHOLDER/${CUCUMBER_PUBLISH_TOKEN}/g" irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/RunCucumberTest.java

mvn clean verify -P cucumber -Dgroups="$ISSUE_FILTER" -pl irs-cucumber-tests -am --batch-mode 2> irs-cucumber-tests/report-banner.txt

- name: Publish Cucumber Results
uses: EnricoMi/[email protected]
if: always()
with:
files: |
irs-cucumber-tests/target/cucumber-junit-report.xml

- name: Get Cucumber Report
if: always()
shell: bash
id: get-cucumber-report
run: |
grep -E "^│.*│$" irs-cucumber-tests/report-banner.txt > irs-cucumber-tests/cucumber-report.txt
sed -i 's/│//g' irs-cucumber-tests/cucumber-report.txt
cat irs-cucumber-tests/cucumber-report.txt
cat irs-cucumber-tests/cucumber-report.txt >> $GITHUB_STEP_SUMMARY

- name: Find previous comment in PR
if: always() && github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'View your Cucumber Report at'

- name: Create or update comment in PR
if: always() && github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: 'irs-cucumber-tests/cucumber-report.txt'
edit-mode: replace

- name: Upload Report
if: always()
uses: actions/upload-artifact@v4
with:
path: 'irs-cucumber-tests/target/report.html'
150 changes: 150 additions & 0 deletions .github/actions/setup-umbrella-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# 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
#
---
name: Umbrella E2E Test Environment
description: "Sets up the Umbrella E2E Test Environment"
runs:
using: composite
steps:
- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@0ad70e2299366b0e1552c7240f4e4567148f723e #v2.0.4
with:
# upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions
version: v0.20.0
node_image: 'kindest/node:v1.27.3'

- name: Get Cluster info
shell: bash
run: kubectl cluster-info --context kind-kind

- name: Informational - describe node
shell: bash
run: |
kubectl get nodes --show-labels
kubectl describe node

- name: Set up Helm
uses: azure/setup-helm@b7246b12e77f7134dc2d460a3d5bad15bbe29390 # v4.1.0
with:
version: 'latest'

- name: Checkout umbrella chart
uses: actions/checkout@v4
with:
repository: eclipse-tractusx/tractus-x-umbrella
ref: chore/e2e-irs-preparation

- name: Build iatp mock
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: ./iatp-mock/
push: true
tags: kind-registry:5000/iatp-mock:testing

- name: Install umbrella chart
shell: bash
run: |
helm dependency update charts/tx-data-provider
helm dependency update charts/umbrella
helm install umbrella charts/umbrella -f charts/umbrella/values-adopter-irs.yaml --timeout 5m \
--namespace e2e-testing --create-namespace --debug \
--set iatpmock.image.repository=kind-registry:5000/iatp-mock --set iatpmock.image.tag=testing

- name: Verify installation
if: always()
shell: bash
run: |
kubectl get pods -n e2e-testing
kubectl logs svc/bdrs-server -n e2e-testing
kubectl logs svc/mock-util-service -n e2e-testing
kubectl logs svc/umbrella-dataprovider-edc-controlplane -n e2e-testing
kubectl get ingresses -n e2e-testing

- name: Checkout IRS chart
uses: actions/checkout@v4

- name: Cache maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build IRS
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: .
push: true
tags: kind-registry:5000/irs-api:testing

- name: Install Helm chart
shell: bash
run: |
helm dependency update ./charts/item-relationship-service
helm install irs ./charts/item-relationship-service --namespace e2e-testing \
-f ./charts/item-relationship-service/values-umbrella.yaml

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.10.7
cache: 'pip'
- run: pip install -r local/testing/testdata/requirements.txt
shell: bash

- uses: azure/setup-kubectl@v3

- run: |
kubectl wait --for=condition=available deployment/umbrella-dataprovider-dtr --timeout=60s --namespace e2e-testing
kubectl wait --for=condition=available deployment/umbrella-dataprovider-edc-controlplane --timeout=60s --namespace e2e-testing
kubectl wait --for=condition=available deployment/umbrella-dataprovider-edc-dataplane --timeout=60s --namespace e2e-testing
kubectl wait --for=condition=available deployment/umbrella-dataprovider-submodelserver --timeout=60s --namespace e2e-testing

kubectl port-forward svc/umbrella-dataprovider-dtr 4444:8080 --namespace e2e-testing &
kubectl port-forward svc/umbrella-dataprovider-edc-controlplane 8888:8081 --namespace e2e-testing &
kubectl port-forward svc/umbrella-dataprovider-submodelserver 9999:8080 --namespace e2e-testing &
shell: bash

- name: Setup test data
run: |
chmod +x ./local/testing/testdata/upload-testdata.sh
./local/testing/testdata/upload-testdata.sh "TEST2" "BPNL00000003AYRE" "BPNL00000003AZQP" \
"http://umbrella-dataprovider-submodelserver:8080" "http://localhost:9999" \
"http://umbrella-dataprovider-dtr:8080/api/v3" "http://localhost:4444/api/v3" \
"http://umbrella-dataprovider-edc-controlplane:8084" "http://localhost:8888" \
"http://umbrella-dataprovider-edc-dataplane:8081"
shell: bash

- name: Wait for deployment
id: deployment-ready
shell: bash
run: |
kubectl wait --for=condition=available deployment/irs-item-relationship-service --timeout=60s --namespace e2e-testing
kubectl port-forward svc/irs-item-relationship-service 8080:8080 --namespace e2e-testing &

- name: Get Pods
if: always() && steps.deployment-ready.outcome == 'success'
shell: bash
run: |
kubectl get pods --namespace e2e-testing
kubectl logs svc/irs-item-relationship-service -n e2e-testing

curl --request GET --url http://localhost:8080/irs/aspectmodels \
--header 'Content-Type: application/json' --header 'X-API-KEY: password'
46 changes: 46 additions & 0 deletions .github/actions/umbrella-irs-logs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# 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
#
---
name: IRS Umbrella logs
description: "Retrieves the IRS logs and uploads them as artifact"
runs:
using: composite
steps:
- uses: azure/setup-kubectl@v3

- name: Wait for deployment
id: deployment-ready
shell: bash
run: |
kubectl wait --for=condition=available deployment/irs-item-relationship-service --timeout=60s --namespace e2e-testing

- name: Get IRS logs
if: always() && steps.deployment-ready.outcome == 'success'
id: irs-logs
shell: bash
run: |
kubectl logs svc/irs-item-relationship-service -n e2e-testing > irs_logs.txt

- name: Upload pod logs
if: always() && steps.irs-logs.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: irs_logs-logs
path: irs_logs.txt
63 changes: 63 additions & 0 deletions .github/workflows/cucumber-integration-test-UMBRELLA.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# 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
#
name: IRS Umbrella Cucumber Integration test execution

on:
workflow_dispatch: # Trigger manually
push:
branches:
- 'main'
paths-ignore:
- '**/*.md'
- '**/*.txt'
- 'charts/**'
- '.config/**'
- 'docs/**'
- 'local/**'
- 'irs-load-tests/**'
schedule:
- cron: '0 2 * * 1-5' # At 02:00 on every day-of-week from Monday through Friday.

# Cancel previous Test executions if a new one is triggered.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
execute-e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: setup env
id: setup-env
uses: ./.github/actions/setup-umbrella-env

- name: trigger integration test
uses: ./.github/actions/cucumber-integration-test
with:
regularUserApiKey: "password"
adminUserApiKey: "password"
cucumberPublishToken: ${{ secrets.IRS_CUCUMBER_PUBLISH_TOKEN }}
executionFilter: "!Ignore & !INACTIVE & INTEGRATION_TEST & UMBRELLA"

- name: Attach logs
if: always() && steps.setup-env.outcome == 'success'
uses: ./.github/actions/umbrella-irs-logs
Loading
Loading