Skip to content

Commit

Permalink
feat: add compatibility tests for DSP (#4667)
Browse files Browse the repository at this point in the history
* use TCK extension in tests

* feat(test): add compatibility test for DSP
  • Loading branch information
paullatzelsperger authored Dec 9, 2024
1 parent 2df7397 commit 81feb70
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/nightly-tests.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 {
}

3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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
}
}

Original file line number Diff line number Diff line change
@@ -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<SELF extends TckContainer<SELF>> extends GenericContainer<SELF> {
public TckContainer(String imageName) {
super(imageName);
addFixedExposedPort(8083, 8083); // TCK will use this as callback address - must be fixed!
}

}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
the test harness extension should go here
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 81feb70

Please sign in to comment.