Skip to content

Commit

Permalink
feat(workflows):[#732] create reusable github actions to set up the u…
Browse files Browse the repository at this point in the history
…mbrella test environment
  • Loading branch information
ds-jhartmann committed Jul 3, 2024
1 parent 4dec8f6 commit 191728a
Show file tree
Hide file tree
Showing 4 changed files with 381 additions and 0 deletions.
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" \
"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'
45 changes: 45 additions & 0 deletions .github/actions/umbrella-irs-logs/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# 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
Loading

0 comments on commit 191728a

Please sign in to comment.