Skip to content

Commit 396a4e2

Browse files
feat(test): add compatibility test for DSP
1 parent 04c5f1b commit 396a4e2

File tree

23 files changed

+157
-885
lines changed

23 files changed

+157
-885
lines changed

.github/workflows/nightly-tests.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "Run Nightly Tests"
2+
on:
3+
schedule:
4+
- "0 0 * * *" # run at 00:00 UTC
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: ${{ github.workflow}}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
Run-Dsp-Compatibility-Test:
13+
name: "Run DSP Compatibility Test"
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: eclipse-edc/.github/.github/actions/setup-build@main
18+
- name: DSP Compatibility
19+
run: |
20+
./gradlew -p system-tests/dsp-compatibility-tests test -DincludeTags="NightlyTest" -PverboseTest=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.junit.annotations;
16+
17+
import org.junit.jupiter.api.Tag;
18+
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* Annotation for Nightly testing. This is typically triggered by a nightly build action from CI.
26+
*/
27+
@Target({ ElementType.TYPE })
28+
@Retention(RetentionPolicy.RUNTIME)
29+
@IntegrationTest
30+
@Tag("NightlyTest")
31+
public @interface NightlyTest {
32+
}
33+

system-tests/dsp-compatibility-tests/compatibility-test-runner/build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ dependencies {
2020
testImplementation(project(":core:common:junit"))
2121
testImplementation(libs.assertj)
2222
testImplementation(libs.awaitility)
23+
testImplementation(libs.testcontainers.junit)
24+
runtimeOnly(libs.parsson)
2325
}
2426

2527
edcBuild {

system-tests/dsp-compatibility-tests/compatibility-test-runner/src/test/java/org/eclipse/edc/tck/dsp/EdcCompatibilityTest.java

+33-7
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,39 @@
1414

1515
package org.eclipse.edc.tck.dsp;
1616

17+
import org.eclipse.edc.junit.annotations.NightlyTest;
1718
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
1819
import org.eclipse.edc.junit.extensions.RuntimeExtension;
1920
import org.eclipse.edc.junit.extensions.RuntimePerClassExtension;
21+
import org.eclipse.edc.junit.testfixtures.TestUtils;
22+
import org.eclipse.edc.spi.monitor.ConsoleMonitor;
23+
import org.junit.jupiter.api.Disabled;
2024
import org.junit.jupiter.api.Test;
25+
import org.junit.jupiter.api.Timeout;
2126
import org.junit.jupiter.api.extension.RegisterExtension;
27+
import org.testcontainers.containers.BindMode;
28+
import org.testcontainers.containers.GenericContainer;
29+
import org.testcontainers.containers.SelinuxContext;
30+
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
31+
import org.testcontainers.junit.jupiter.Testcontainers;
2232

33+
import java.nio.file.Path;
2334
import java.util.HashMap;
24-
import java.util.concurrent.CountDownLatch;
2535

2636
import static org.eclipse.edc.util.io.Ports.getFreePort;
2737

38+
@NightlyTest
39+
@Testcontainers
2840
public class EdcCompatibilityTest {
2941

42+
private static final GenericContainer<?> TCK_CONTAINER = new TckContainer<>("eclipsedataspacetck/dsp-tck-runtime:latest");
43+
44+
private static String resource(String s) {
45+
return Path.of(TestUtils.getResource("docker.tck.properties")).toString();
46+
}
47+
3048
@RegisterExtension
31-
protected RuntimeExtension runtime =
49+
protected static RuntimeExtension runtime =
3250
new RuntimePerClassExtension(new EmbeddedRuntime("CUnT",
3351
new HashMap<>() {
3452
{
@@ -42,19 +60,27 @@ public class EdcCompatibilityTest {
4260
put("web.http.management.port", "8081");
4361
put("web.http.management.path", "/api/management");
4462
put("web.http.protocol.port", "8282");
45-
put("web.http.protocol.path", "/api/v1/dsp"); // expected by TCK
63+
put("web.http.protocol.path", "/api/dsp"); // expected by TCK
4664
put("web.api.auth.key", "password");
47-
put("edc.dsp.callback.address", "http://localhost:8282/api/v1/dsp");
65+
put("edc.dsp.callback.address", "http://host.docker.internal:8282/api/dsp");
4866
put("edc.management.context.enabled", "true");
67+
put("edc.hostname", "host.docker.internal");
68+
put("edc.component.id", "DSP-compatibility-test");
4969
}
5070
},
5171
":system-tests:dsp-compatibility-tests:connector-under-test"
5272
));
5373

74+
@Disabled(value = "Need to disable this test until the connector is 100% compliant with DSP")
75+
@Timeout(60)
5476
@Test
55-
void assertRuntimeReady() throws InterruptedException {
56-
var l = new CountDownLatch(1);
57-
l.await();
77+
void assertDspCompatibility() {
78+
// pipe the docker container's log to this console at the INFO level
79+
var monitor = new ConsoleMonitor(">>> TCK Runtime (Docker)", ConsoleMonitor.Level.INFO, true);
80+
TCK_CONTAINER.addFileSystemBind(resource("docker.tck.properties"), "/etc/tck/config.properties", BindMode.READ_ONLY, SelinuxContext.SINGLE);
81+
TCK_CONTAINER.withLogConsumer(outputFrame -> monitor.info(outputFrame.getUtf8String()));
82+
TCK_CONTAINER.waitingFor(new LogMessageWaitStrategy().withRegEx(".*Test run complete.*"));
83+
TCK_CONTAINER.start();
5884
}
5985
}
6086

Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
*
1313
*/
1414

15-
package org.eclipse.edc.tck.dsp.guard;
15+
package org.eclipse.edc.tck.dsp;
1616

17-
import org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractNegotiation;
17+
import org.testcontainers.containers.GenericContainer;
1818

19-
/**
20-
* Registers contract negotiation triggers.
21-
*/
22-
public interface ContractNegotiationTriggerRegistry {
23-
24-
void register(Trigger<ContractNegotiation> trigger);
19+
public class TckContainer<SELF extends TckContainer<SELF>> extends GenericContainer<SELF> {
20+
public TckContainer(String imageName) {
21+
super(imageName);
22+
addFixedExposedPort(8083, 8083); // TCK will use this as callback address - must be fixed!
23+
}
2524

2625
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Apache License, Version 2.0 which is available at
6+
# https://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# SPDX-License-Identifier: Apache-2.0
9+
#
10+
# Contributors:
11+
# Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
12+
#
13+
#
14+
# Contains sample configuration options
15+
dataspacetck.debug=true
16+
dataspacetck.dsp.local.connector=false
17+
dataspacetck.dsp.connector.agent.id=CONNECTOR_UNDER_TEST
18+
dataspacetck.dsp.connector.http.url=http://host.docker.internal:8282/api/dsp/
19+
dataspacetck.dsp.connector.http.headers.authorization="{\"region\": \"any\", \"audience\": \"any\", \"clientId\":\"any\"}"
20+
dataspacetck.dsp.connector.negotiation.initiate.url=http://host.docker.internal:8687/tck/negotiations/requests
21+
dataspacetck.dsp.default.wait=10000000
22+
# must be 0.0.0.0 for docker inet binding to work
23+
dataspacetck.callback.address=http://0.0.0.0:8083
24+
# Sets the dataset and offer ids to use for contract negotiation scenarios
25+
CN_01_01_DATASETID=ACN0101
26+
CN_01_01_OFFERID=CD123:ACN0101:456
27+
CN_01_02_DATASETID=ACN0102
28+
CN_01_02_OFFERID=CD123:ACN\
29+
0102:456
30+
CN_01_03_DATASETID=ACN0103
31+
CN_01_03_OFFERID=CD123:ACN0103:456
32+
CN_01_04_DATASETID=ACN0104
33+
CN_01_04_OFFERID=CD123:ACN0104:456
34+
CN_02_01_DATASETID=ACN0201
35+
CN_02_01_OFFERID=CD123:ACN0201:456
36+
CN_02_02_DATASETID=ACN0202
37+
CN_02_02_OFFERID=CD123:ACN0202:456
38+
CN_02_03_DATASETID=ACN0203
39+
CN_02_03_OFFERID=CD123:ACN0203:456
40+
CN_02_04_DATASETID=ACN0204
41+
CN_02_04_OFFERID=CD123:ACN0204:456
42+
CN_02_05_DATASETID=ACN0205
43+
CN_02_05_OFFERID=CD123:ACN0205:456
44+
CN_02_06_DATASETID=ACN0206
45+
CN_02_06_OFFERID=CD123:ACN0206:456
46+
CN_02_07_DATASETID=ACN0207
47+
CN_02_07_OFFERID=CD123:ACN0207:456
48+
CN_03_01_DATASETID=ACN0301
49+
CN_03_01_OFFERID=CD123:ACN0301:456
50+
CN_03_02_DATASETID=ACN0302
51+
CN_03_02_OFFERID=CD123:ACN0302:456
52+
CN_03_03_DATASETID=ACN0303
53+
CN_03_03_OFFERID=CD123:ACN0303:456
54+
CN_03_04_DATASETID=ACN0304
55+
CN_03_04_OFFERID=CD123:ACN0304:456

system-tests/dsp-compatibility-tests/connector-under-test/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ plugins {
1919
dependencies {
2020
api(project(":dist:bom:controlplane-base-bom"))
2121
runtimeOnly(project(":extensions:tck-extension"))
22+
runtimeOnly(libs.parsson)
2223
}

system-tests/dsp-compatibility-tests/connector-under-test/src/main/java/org/eclipse/edc/tck/dsp/controller/ContractNegotiationRequest.java

-25
This file was deleted.

system-tests/dsp-compatibility-tests/connector-under-test/src/main/java/org/eclipse/edc/tck/dsp/controller/TckControllerExtension.java

-66
This file was deleted.

system-tests/dsp-compatibility-tests/connector-under-test/src/main/java/org/eclipse/edc/tck/dsp/controller/TckWebhookController.java

-63
This file was deleted.

0 commit comments

Comments
 (0)