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

refactor: restructure tests, add JVM based e2e tests #139

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
74 changes: 5 additions & 69 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- '*'
workflow_dispatch:


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -41,74 +42,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 +71,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 +140,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 +207,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
10 changes: 5 additions & 5 deletions .github/workflows/business-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,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 +240,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 +276,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 +309,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
173 changes: 173 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
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


10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ allprojects {
dependencies {
implementation("org.projectlombok:lombok:1.18.26")
implementation("org.slf4j:slf4j-api:2.0.5")
// this is used to counter version conflicts between the JUnit version pulled in by the plugin,
// and the one expected by IntelliJ
testImplementation(platform("org.junit:junit-bom:5.9.2"))
}

// configure which version of the annotation processor to use. defaults to the same version as the plugin
Expand Down Expand Up @@ -120,6 +123,13 @@ allprojects {
}
}

// EdcRuntimeExtension uses this to determine the runtime classpath of the module to run.
tasks.register("printClasspath") {
doLast {
println(sourceSets["main"].runtimeClasspath.asPath)
}
}

}

// the "dockerize" task is added to all projects that use the `shadowJar` plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

package org.eclipse.tractusx.edc.validation.businesspartner;

import static org.eclipse.edc.policy.engine.spi.PolicyEngine.ALL_SCOPES;

import org.eclipse.edc.policy.engine.spi.PolicyEngine;
import org.eclipse.edc.policy.engine.spi.RuleBindingRegistry;
import org.eclipse.edc.policy.model.Duty;
Expand All @@ -35,6 +33,8 @@
import org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerPermissionFunction;
import org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerProhibitionFunction;

import static org.eclipse.edc.policy.engine.spi.PolicyEngine.ALL_SCOPES;

public class BusinessPartnerValidationExtension implements ServiceExtension {

/**
Expand Down
Loading