Skip to content

Commit

Permalink
feat(test): add compatibility test for DSP
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Dec 6, 2024
1 parent 04c5f1b commit 396a4e2
Show file tree
Hide file tree
Showing 23 changed files with 157 additions and 885 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 {
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dependencies {
testImplementation(project(":core:common:junit"))
testImplementation(libs.assertj)
testImplementation(libs.awaitility)
testImplementation(libs.testcontainers.junit)
runtimeOnly(libs.parsson)
}

edcBuild {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,39 @@

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 java.util.concurrent.CountDownLatch;

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

@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 RuntimeExtension runtime =
protected static RuntimeExtension runtime =
new RuntimePerClassExtension(new EmbeddedRuntime("CUnT",
new HashMap<>() {
{
Expand All @@ -42,19 +60,27 @@ public class EdcCompatibilityTest {
put("web.http.management.port", "8081");
put("web.http.management.path", "/api/management");
put("web.http.protocol.port", "8282");
put("web.http.protocol.path", "/api/v1/dsp"); // expected by TCK
put("web.http.protocol.path", "/api/dsp"); // expected by TCK
put("web.api.auth.key", "password");
put("edc.dsp.callback.address", "http://localhost:8282/api/v1/dsp");
put("edc.dsp.callback.address", "http://host.docker.internal:8282/api/dsp");
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"
));

@Disabled(value = "Need to disable this test until the connector is 100% compliant with DSP")
@Timeout(60)
@Test
void assertRuntimeReady() throws InterruptedException {
var l = new CountDownLatch(1);
l.await();
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();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
*
*/

package org.eclipse.edc.tck.dsp.guard;
package org.eclipse.edc.tck.dsp;

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

/**
* Registers contract negotiation triggers.
*/
public interface ContractNegotiationTriggerRegistry {

void register(Trigger<ContractNegotiation> trigger);
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
Expand Up @@ -19,4 +19,5 @@ plugins {
dependencies {
api(project(":dist:bom:controlplane-base-bom"))
runtimeOnly(project(":extensions:tck-extension"))
runtimeOnly(libs.parsson)
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 396a4e2

Please sign in to comment.