diff --git a/.github/workflows/nightly-tests.yaml b/.github/workflows/nightly-tests.yaml new file mode 100644 index 00000000000..c2f6709584f --- /dev/null +++ b/.github/workflows/nightly-tests.yaml @@ -0,0 +1,20 @@ +name: "Run Nightly Tests" +on: + schedule: + - "0 0 * * *" # run at 00:00 UTC + workflow_dispatch: + +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + +jobs: + Run-Dsp-Compatibility-Test: + name: "Run DSP Compatibility Test" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: eclipse-edc/.github/.github/actions/setup-build@main + - name: DSP Compatibility + run: | + ./gradlew -p system-tests/dsp-compatibility-tests test -DincludeTags="NightlyTest" -PverboseTest=true \ No newline at end of file diff --git a/core/common/junit/src/main/java/org/eclipse/edc/junit/annotations/NightlyTest.java b/core/common/junit/src/main/java/org/eclipse/edc/junit/annotations/NightlyTest.java new file mode 100644 index 00000000000..6977e21e344 --- /dev/null +++ b/core/common/junit/src/main/java/org/eclipse/edc/junit/annotations/NightlyTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.edc.junit.annotations; + +import org.junit.jupiter.api.Tag; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation for Nightly testing. This is typically triggered by a nightly build action from CI. + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@IntegrationTest +@Tag("NightlyTest") +public @interface NightlyTest { +} + diff --git a/settings.gradle.kts b/settings.gradle.kts index 814a17efa3c..f8e37f07fcf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -225,6 +225,7 @@ include(":extensions:data-plane-selector:store:sql:data-plane-instance-store-sql include(":extensions:policy-monitor:store:sql:policy-monitor-store-sql") +include(":extensions:tck-extension") // modules for launchers, i.e. runnable compositions of the app ------------------------------------ include(":launchers:dpf-selector") @@ -297,6 +298,8 @@ include(":system-tests:sts-api:sts-api-test-runtime") include(":system-tests:telemetry:telemetry-test-runner") include(":system-tests:telemetry:telemetry-test-runtime") include(":system-tests:bom-tests") +include(":system-tests:dsp-compatibility-tests:connector-under-test") +include(":system-tests:dsp-compatibility-tests:compatibility-test-runner") // BOM modules ---------------------------------------------------------------- include(":dist:bom:controlplane-base-bom") diff --git a/system-tests/dsp-compatibility-tests/compatibility-test-runner/build.gradle.kts b/system-tests/dsp-compatibility-tests/compatibility-test-runner/build.gradle.kts new file mode 100644 index 00000000000..a8c5ac21790 --- /dev/null +++ b/system-tests/dsp-compatibility-tests/compatibility-test-runner/build.gradle.kts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + java +} + +dependencies { + testImplementation(project(":core:common:junit")) + testImplementation(libs.assertj) + testImplementation(libs.awaitility) + testImplementation(libs.testcontainers.junit) + runtimeOnly(libs.parsson) +} + +edcBuild { + publish.set(false) +} diff --git a/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/EdcCompatibilityTest.java b/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/EdcCompatibilityTest.java new file mode 100644 index 00000000000..622fe570988 --- /dev/null +++ b/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/EdcCompatibilityTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.edc.tck.dsp; + +import org.eclipse.edc.junit.annotations.NightlyTest; +import org.eclipse.edc.junit.extensions.EmbeddedRuntime; +import org.eclipse.edc.junit.extensions.RuntimeExtension; +import org.eclipse.edc.junit.extensions.RuntimePerClassExtension; +import org.eclipse.edc.junit.testfixtures.TestUtils; +import org.eclipse.edc.spi.monitor.ConsoleMonitor; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.testcontainers.containers.BindMode; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.SelinuxContext; +import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.nio.file.Path; +import java.util.HashMap; + +import static org.eclipse.edc.util.io.Ports.getFreePort; + +@Disabled(value = "Need to disable this test until the connector is 100% compliant with DSP") +@NightlyTest +@Testcontainers +public class EdcCompatibilityTest { + + private static final GenericContainer TCK_CONTAINER = new TckContainer<>("eclipsedataspacetck/dsp-tck-runtime:latest"); + + private static String resource(String s) { + return Path.of(TestUtils.getResource("docker.tck.properties")).toString(); + } + + @RegisterExtension + protected static RuntimeExtension runtime = + new RuntimePerClassExtension(new EmbeddedRuntime("CUnT", + new HashMap<>() { + { + put("edc.participant.id", "CONNECTOR_UNDER_TEST"); + put("web.http.port", "8080"); + put("web.http.path", "/api"); + put("web.http.version.port", String.valueOf(getFreePort())); + put("web.http.version.path", "/api/version"); + put("web.http.control.port", String.valueOf(getFreePort())); + put("web.http.control.path", "/api/control"); + put("web.http.management.port", "8081"); + put("web.http.management.path", "/api/management"); + put("web.http.protocol.port", "8282"); // this must match the configured connector url in resources/docker.tck.properties + put("web.http.protocol.path", "/api/dsp"); // this must match the configured connector url in resources/docker.tck.properties + put("web.api.auth.key", "password"); + put("edc.dsp.callback.address", "http://host.docker.internal:8282/api/dsp"); // host.docker.internal is required by the container to communicate with the host + put("edc.management.context.enabled", "true"); + put("edc.hostname", "host.docker.internal"); + put("edc.component.id", "DSP-compatibility-test"); + } + }, + ":system-tests:dsp-compatibility-tests:connector-under-test" + )); + + @Timeout(60) + @Test + void assertDspCompatibility() { + // pipe the docker container's log to this console at the INFO level + var monitor = new ConsoleMonitor(">>> TCK Runtime (Docker)", ConsoleMonitor.Level.INFO, true); + TCK_CONTAINER.addFileSystemBind(resource("docker.tck.properties"), "/etc/tck/config.properties", BindMode.READ_ONLY, SelinuxContext.SINGLE); + TCK_CONTAINER.withLogConsumer(outputFrame -> monitor.info(outputFrame.getUtf8String())); + TCK_CONTAINER.waitingFor(new LogMessageWaitStrategy().withRegEx(".*Test run complete.*")); + TCK_CONTAINER.start(); + + // todo: obtain test report from the container + } +} + diff --git a/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/TckContainer.java b/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/TckContainer.java new file mode 100644 index 00000000000..a8c041fb453 --- /dev/null +++ b/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/TckContainer.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +package org.eclipse.edc.tck.dsp; + +import org.testcontainers.containers.GenericContainer; + +public class TckContainer> extends GenericContainer { + public TckContainer(String imageName) { + super(imageName); + addFixedExposedPort(8083, 8083); // TCK will use this as callback address - must be fixed! + } + +} diff --git a/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/resources/docker.tck.properties b/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/resources/docker.tck.properties new file mode 100644 index 00000000000..ac9a013c499 --- /dev/null +++ b/system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/resources/docker.tck.properties @@ -0,0 +1,55 @@ +# +# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +# +# 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 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Contributors: +# Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation +# +# +# Contains sample configuration options +dataspacetck.debug=true +dataspacetck.dsp.local.connector=false +dataspacetck.dsp.connector.agent.id=CONNECTOR_UNDER_TEST +dataspacetck.dsp.connector.http.url=http://host.docker.internal:8282/api/dsp/ +dataspacetck.dsp.connector.http.headers.authorization="{\"region\": \"any\", \"audience\": \"any\", \"clientId\":\"any\"}" +dataspacetck.dsp.connector.negotiation.initiate.url=http://host.docker.internal:8687/tck/negotiations/requests +dataspacetck.dsp.default.wait=10000000 +# must be 0.0.0.0 for docker inet binding to work +dataspacetck.callback.address=http://0.0.0.0:8083 +# Sets the dataset and offer ids to use for contract negotiation scenarios +CN_01_01_DATASETID=ACN0101 +CN_01_01_OFFERID=CD123:ACN0101:456 +CN_01_02_DATASETID=ACN0102 +CN_01_02_OFFERID=CD123:ACN\ + 0102:456 +CN_01_03_DATASETID=ACN0103 +CN_01_03_OFFERID=CD123:ACN0103:456 +CN_01_04_DATASETID=ACN0104 +CN_01_04_OFFERID=CD123:ACN0104:456 +CN_02_01_DATASETID=ACN0201 +CN_02_01_OFFERID=CD123:ACN0201:456 +CN_02_02_DATASETID=ACN0202 +CN_02_02_OFFERID=CD123:ACN0202:456 +CN_02_03_DATASETID=ACN0203 +CN_02_03_OFFERID=CD123:ACN0203:456 +CN_02_04_DATASETID=ACN0204 +CN_02_04_OFFERID=CD123:ACN0204:456 +CN_02_05_DATASETID=ACN0205 +CN_02_05_OFFERID=CD123:ACN0205:456 +CN_02_06_DATASETID=ACN0206 +CN_02_06_OFFERID=CD123:ACN0206:456 +CN_02_07_DATASETID=ACN0207 +CN_02_07_OFFERID=CD123:ACN0207:456 +CN_03_01_DATASETID=ACN0301 +CN_03_01_OFFERID=CD123:ACN0301:456 +CN_03_02_DATASETID=ACN0302 +CN_03_02_OFFERID=CD123:ACN0302:456 +CN_03_03_DATASETID=ACN0303 +CN_03_03_OFFERID=CD123:ACN0303:456 +CN_03_04_DATASETID=ACN0304 +CN_03_04_OFFERID=CD123:ACN0304:456 diff --git a/system-tests/dsp-compatibility-tests/connector-under-test/build.gradle.kts b/system-tests/dsp-compatibility-tests/connector-under-test/build.gradle.kts new file mode 100644 index 00000000000..8e61b408813 --- /dev/null +++ b/system-tests/dsp-compatibility-tests/connector-under-test/build.gradle.kts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + * + * SPDX-License-Identifier: Apache-2.0 + * + * Contributors: + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation + * + */ + +plugins { + `java-library` +} + +dependencies { + api(project(":dist:bom:controlplane-base-bom")) + runtimeOnly(project(":extensions:tck-extension")) + runtimeOnly(libs.parsson) +} \ No newline at end of file diff --git a/system-tests/dsp-compatibility-tests/connector-under-test/src/main/java/org/eclipse/edc/tck/dsp/missing.txt b/system-tests/dsp-compatibility-tests/connector-under-test/src/main/java/org/eclipse/edc/tck/dsp/missing.txt new file mode 100644 index 00000000000..bc87f648dda --- /dev/null +++ b/system-tests/dsp-compatibility-tests/connector-under-test/src/main/java/org/eclipse/edc/tck/dsp/missing.txt @@ -0,0 +1 @@ +the test harness extension should go here \ No newline at end of file diff --git a/system-tests/dsp-compatibility-tests/connector-under-test/tck-runtime.env b/system-tests/dsp-compatibility-tests/connector-under-test/tck-runtime.env new file mode 100644 index 00000000000..4d78a6fa08c --- /dev/null +++ b/system-tests/dsp-compatibility-tests/connector-under-test/tck-runtime.env @@ -0,0 +1,19 @@ +# control plane specific config +WEB_HTTP_PORT=8080 +WEB_HTTP_PATH="/api" +WEB_HTTP_MANAGEMENT_PORT=8081 +WEB_HTTP_MANAGEMENT_PATH="/api/management/" +WEB_HTTP_PROTOCOL_PORT=8082 +WEB_HTTP_PROTOCOL_PATH="/api/dsp" +WEB_HTTP_CONTROL_PORT=8183 +WEB_HTTP_CONTROL_PATH="/api/control" +WEB_HTTP_CATALOG_PORT=8184 +WEB_HTTP_CATALOG_PATH="/api/catalog" +WEB_HTTP_VERSION_PORT=8185 +WEB_HTTP_VERSION_PATH="/api/version" +EDC_API_AUTH_KEY="password" +EDC_IAM_DID_WEB_USE_HTTPS="false" +EDC_DSP_CALLBACK_ADDRESS="http://localhost:8082/api/dsp" +EDC_PARTICIPANT_ID=CONNECTOR_UNDER_TEST" +EDC_MANAGEMENT_CONTEXT_ENABLED=true +