Skip to content

Commit

Permalink
Merge pull request #139 from catenax-ng/feature/refactor_tests
Browse files Browse the repository at this point in the history
refactor: restructure tests, add JVM based e2e tests
  • Loading branch information
SebastianBezold authored Mar 27, 2023
2 parents 28dc524 + af90dec commit 79e8906
Show file tree
Hide file tree
Showing 92 changed files with 1,093 additions and 145 deletions.
96 changes: 27 additions & 69 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
#
# Copyright (c) 2023 ZF Friedrichshafen AG
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2021, 2023 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: "Build"

Expand All @@ -20,6 +42,7 @@ on:
- '*'
workflow_dispatch:


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -41,74 +64,9 @@ jobs:
[ ! -z "${{ secrets.GPG_PASSPHRASE }}" ] && echo "::set-output name=GPG_PASSPHRASE::true"
exit 0
verify-formatting:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/[email protected]

-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'
-
name: Verify proper formatting
run: ./gradlew spotlessCheck

- name: Run Checkstyle
run: |
./gradlew checkstyleMain checkstyleTest
echo "Running Checkstyle is currently a placeholder"
sonar:
needs: [ secret-presence, verify-formatting ]
if: |
needs.secret-presence.outputs.SONAR_TOKEN
runs-on: ubuntu-latest
steps:
# Set-Up
-
name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'
-
name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# Analyse
-
name: Build with Maven and analyze with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
JACOCO: true
run: |-
./gradlew sonar \
-Pcoverage,failsafe \
-Dsonar.projectKey=${GITHUB_REPOSITORY_OWNER}_product-edc \
-Dsonar.organization=${GITHUB_REPOSITORY_OWNER} \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=${GITHUB_WORKSPACE}/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml \
-Dsonar.verbose=true
build-extensions:
runs-on: ubuntu-latest
needs: [ secret-presence, verify-formatting ]
needs: [ secret-presence]
steps:
# Set-Up
-
Expand All @@ -135,7 +93,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [ secret-presence, verify-formatting ]
needs: [ secret-presence]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -204,7 +162,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [ secret-presence, verify-formatting ]
needs: [ secret-presence]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -271,7 +229,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [secret-presence, verify-formatting, build-controlplane, build-dataplane, build-extensions]
needs: [secret-presence, build-controlplane, build-dataplane, build-extensions]

# do not run on PR branches, do not run on main
if: |
Expand Down
32 changes: 27 additions & 5 deletions .github/workflows/business-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
#
# Copyright (c) 2023 ZF Friedrichshafen AG
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
# Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2021, 2023 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: "Business Tests"

Expand Down Expand Up @@ -133,10 +155,10 @@ jobs:
retry_on: error
command: |-
# Update helm dependencies
helm dependency update edc-tests/src/main/resources/deployment/helm/supporting-infrastructure
helm dependency update edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure
# Install the all-in-one supporting infrastructure environment (daps, vault, pgsql, minio)
helm install infrastructure edc-tests/src/main/resources/deployment/helm/supporting-infrastructure \
helm install infrastructure edc-tests/cucumber/src/main/resources/deployment/helm/supporting-infrastructure \
--wait-for-jobs --timeout=120s

# GH pipelines constrained by cpu, so give helm some time to register all resources \w k8s
Expand Down Expand Up @@ -240,7 +262,7 @@ jobs:
{
"args": [
"-c",
"cd /product-edc && ./gradlew edc-tests:test -Dcucumber=true"
"cd /product-edc && ./gradlew edc-tests:cucumber:test -Dcucumber=true"
],
"command": [
"/bin/sh"
Expand Down Expand Up @@ -276,7 +298,7 @@ jobs:
cat << EOF >> pod.json
"image": "openjdk:11-jdk-slim",
"name": "edc-tests",
"name": "edc-tests-cucumber",
"volumeMounts": [
{
"mountPath": "/product-edc",
Expand Down Expand Up @@ -309,7 +331,7 @@ jobs:
}
EOF
kubectl run -i --image=openjdk:11-jdk-slim --restart=Never --rm edc-tests --overrides="$(cat pod.json)"
kubectl run -i --image=openjdk:11-jdk-slim --restart=Never --rm edc-tests-cucumber --overrides="$(cat pod.json)"
#################
### Tear Down ###
Expand Down
193 changes: 193 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH
# Copyright (c) 2021, 2023 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: "Verify"

on:
push:
branches:
- main
- develop
tags:
- '[0-9]+.[0-9]+.[0-9]+'
release:
types:
- published
pull_request:
paths-ignore:
- 'charts/**'
- 'docs/**'
- '**/*.md'
branches:
- '*'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
secret-presence:
runs-on: ubuntu-latest
outputs:
SONAR_TOKEN: ${{ steps.secret-presence.outputs.SONAR_TOKEN }}
steps:
-
name: Check whether secrets exist
id: secret-presence
run: |
[ ! -z "${{ secrets.SONAR_TOKEN }}" ] && echo "::set-output name=SONAR_TOKEN::true"
exit 0
verify-formatting:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/[email protected]

-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'
-
name: Verify proper formatting
run: ./gradlew spotlessCheck

- name: Run Checkstyle
run: |
./gradlew checkstyleMain checkstyleTest
echo "Running Checkstyle is currently a placeholder"
unit-tests:
runs-on: ubuntu-latest
needs: [verify-formatting]
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'

- name: Run Unit tests
run: ./gradlew test

integration-tests:
runs-on: ubuntu-latest
needs: [verify-formatting]
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'

- name: Run Integration tests
run: ./gradlew test -DincludeTags="ComponentTest"

api-tests:
runs-on: ubuntu-latest
needs: [verify-formatting]
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'

- name: Run API tests
run: ./gradlew test -DincludeTags="ApiTest"

end-to-end-tests:
runs-on: ubuntu-latest
needs: [verify-formatting]
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'

- name: Run E2E tests
run: ./gradlew test -DincludeTags="EndToEndTest"

sonar:
needs: [ secret-presence, verify-formatting ]
if: |
needs.secret-presence.outputs.SONAR_TOKEN
runs-on: ubuntu-latest
steps:
# Set-Up
-
name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
-
name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
cache: 'gradle'
-
name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# Analyse
-
name: Build with Maven and analyze with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
JACOCO: true
run: |-
./gradlew sonar \
-Pcoverage,failsafe \
-Dsonar.projectKey=${GITHUB_REPOSITORY_OWNER}_product-edc \
-Dsonar.organization=${GITHUB_REPOSITORY_OWNER} \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=${GITHUB_WORKSPACE}/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml \
-Dsonar.verbose=true
Loading

0 comments on commit 79e8906

Please sign in to comment.