Skip to content

Commit

Permalink
fix: adopt new test runtime model (#196)
Browse files Browse the repository at this point in the history
* move to per-class runtimes

* checkstyle, DEPENDENCIES
  • Loading branch information
paullatzelsperger authored Jun 7, 2024
1 parent 494d40a commit 6890773
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 29 deletions.
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ maven/mavencentral/com.google.guava/guava/33.2.0-jre, Apache-2.0 AND CC0-1.0 AND
maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657
maven/mavencentral/com.google.protobuf/protobuf-java/3.25.1, BSD-3-Clause, approved, clearlydefined
maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.39.3, Apache-2.0, approved, #14830
maven/mavencentral/com.puppycrawl.tools/checkstyle/10.17.0, LGPL-2.1-or-later, restricted, clearlydefined
maven/mavencentral/com.puppycrawl.tools/checkstyle/10.17.0, LGPL-2.1-or-later AND (Apache-2.0 AND LGPL-2.1-or-later) AND Apache-2.0, approved, #15077
maven/mavencentral/com.squareup.okhttp3/okhttp-dnsoverhttps/4.12.0, Apache-2.0, approved, #11159
maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156
maven/mavencentral/com.squareup.okhttp3/okhttp/4.9.3, Apache-2.0 AND MPL-2.0, approved, #3225
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ edc-spi-dsp = { module = "org.eclipse.edc:dsp-spi", version.ref = "edc" }
edc-spi-dsp-http = { module = "org.eclipse.edc:dsp-http-spi", version.ref = "edc" }
edc-spi-jsonld = { module = "org.eclipse.edc:json-ld-spi", version.ref = "edc" }
edc-spi-transform = { module = "org.eclipse.edc:transform-spi", version.ref = "edc" }
edc-spi-dataplane-selector = { module = "org.eclipse.edc:data-plane-selector-spi", version.ref = "edc" }
failsafe-core = { module = "dev.failsafe:failsafe", version.ref = "failsafe" }
restAssured = { module = "io.rest-assured:rest-assured", version.ref = "restAssured" }

Expand Down
1 change: 0 additions & 1 deletion launchers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {
runtimeOnly(libs.bundles.edc.connector)
runtimeOnly(libs.edc.core.controlplane)
runtimeOnly(libs.edc.core.jetty)
runtimeOnly(libs.edc.core.dataPlane.selector)
runtimeOnly(libs.edc.lib.providers.jersey)
runtimeOnly(libs.edc.lib.boot)

Expand Down
1 change: 1 addition & 0 deletions system-tests/component-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
testImplementation(libs.edc.json.ld.lib)
testImplementation(libs.edc.core.jetty)
testImplementation(libs.edc.junit)
testImplementation(libs.edc.spi.dataplane.selector)

testImplementation(libs.restAssured)
testImplementation(libs.awaitility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import org.eclipse.edc.jsonld.TitaniumJsonLd;
import org.eclipse.edc.jsonld.spi.JsonLd;
import org.eclipse.edc.junit.annotations.ComponentTest;
import org.eclipse.edc.junit.extensions.EdcExtension;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimePerMethodExtension;
import org.eclipse.edc.protocol.dsp.http.spi.dispatcher.DspHttpRemoteMessageDispatcher;
import org.eclipse.edc.spi.message.RemoteMessageDispatcherRegistry;
import org.eclipse.edc.spi.monitor.Monitor;
Expand All @@ -34,7 +35,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.security.SecureRandom;
import java.time.Duration;
Expand Down Expand Up @@ -73,32 +74,31 @@
import static org.mockito.Mockito.when;

@ComponentTest
@ExtendWith(EdcExtension.class)
public class CatalogRuntimeComponentTest {
public static final String TEST_CATALOG_ID = "test-catalog-id";
private static final Duration TEST_TIMEOUT = ofSeconds(10);
private static final ObjectMapper OBJECT_MAPPER = createObjectMapper();
private static final JsonLd JSON_LD_SERVICE = new TitaniumJsonLd(mock(Monitor.class));
private DspHttpRemoteMessageDispatcher dispatcher;
@RegisterExtension
protected static RuntimePerMethodExtension runtimePerClassExtension = new RuntimePerMethodExtension(new EmbeddedRuntime("catalog", Map.of(
// make sure only one crawl-run is performed
"edc.catalog.cache.execution.period.seconds", "2",
// number of crawlers will be limited by the number of crawl-targets
"edc.catalog.cache.partition.num.crawlers", "10",
// give the runtime time to set up everything
"edc.catalog.cache.execution.delay.seconds", "1",
"web.http.catalog.port", valueOf(TestFunctions.CATALOG_QUERY_PORT),
"web.http.catalog.path", TestFunctions.CATALOG_QUERY_BASE_PATH,
"web.http.port", valueOf(getFreePort()),
"web.http.path", "/api/v1",
"web.http.protocol.port", valueOf(getFreePort()),
"web.http.protocol.path", "/api/v1/dsp",
"edc.participant.id", "test-participant"
)));
private final DspHttpRemoteMessageDispatcher dispatcher = mock();

@BeforeEach
void setup(EdcExtension extension) {
extension.setConfiguration(Map.of(
// make sure only one crawl-run is performed
"edc.catalog.cache.execution.period.seconds", "2",
// number of crawlers will be limited by the number of crawl-targets
"edc.catalog.cache.partition.num.crawlers", "10",
// give the runtime time to set up everything
"edc.catalog.cache.execution.delay.seconds", "1",
"web.http.catalog.port", valueOf(TestFunctions.CATALOG_QUERY_PORT),
"web.http.catalog.path", TestFunctions.CATALOG_QUERY_BASE_PATH,
"web.http.port", valueOf(getFreePort()),
"web.http.path", "/api/v1",
"web.http.protocol.port", valueOf(getFreePort()),
"web.http.protocol.path", "/api/v1/dsp",
"edc.participant.id", "test-participant"
));
dispatcher = mock(DspHttpRemoteMessageDispatcher.class);
void setup() {
when(dispatcher.protocol()).thenReturn(DATASPACE_PROTOCOL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.edc.catalog.instrumentation;

import org.eclipse.edc.catalog.spi.CatalogConstants;
import org.eclipse.edc.connector.dataplane.selector.spi.client.DataPlaneClientFactory;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provider;
import org.eclipse.edc.spi.message.RemoteMessageDispatcher;
Expand Down Expand Up @@ -45,4 +46,9 @@ public RemoteMessageDispatcher createDispatcher() {

return dispatcher;
}

@Provider
public DataPlaneClientFactory createDataPlaneClientFactory() {
return mock();
}
}
1 change: 0 additions & 1 deletion system-tests/end2end-test/catalog-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {
runtimeOnly(libs.bundles.edc.connector)
runtimeOnly(libs.edc.core.controlplane)
runtimeOnly(libs.edc.core.jetty)
runtimeOnly(libs.edc.core.dataPlane.selector)
runtimeOnly(libs.edc.lib.providers.jersey)
runtimeOnly(libs.edc.lib.boot)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
package org.eclipse.edc.federatedcatalog.end2end;


import org.eclipse.edc.connector.dataplane.selector.spi.client.DataPlaneClientFactory;
import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance;
import org.eclipse.edc.connector.dataplane.selector.spi.store.DataPlaneInstanceStore;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provider;
import org.eclipse.edc.spi.EdcException;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
Expand All @@ -37,4 +39,9 @@ public void initialize(ServiceExtensionContext context) {
.build();
dataPlaneInstanceStore.create(dpi).orElseThrow(f -> new EdcException(f.getFailureDetail()));
}

@Provider
public DataPlaneClientFactory createDataPlaneClientFactory() {
return dataPlaneInstance -> null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import org.eclipse.edc.jsonld.TitaniumJsonLd;
import org.eclipse.edc.jsonld.util.JacksonJsonLd;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
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.extensions.RuntimePerMethodExtension;
import org.eclipse.edc.protocol.dsp.catalog.transform.from.JsonObjectFromCatalogTransformer;
import org.eclipse.edc.protocol.dsp.catalog.transform.from.JsonObjectFromDataServiceTransformer;
import org.eclipse.edc.protocol.dsp.catalog.transform.from.JsonObjectFromDatasetTransformer;
Expand Down Expand Up @@ -76,7 +79,7 @@ class FederatedCatalogTest {
private static final Endpoint CATALOG_CATALOG = new Endpoint("/catalog", "8093");

@RegisterExtension
static EdcRuntimeExtension connector = new EdcRuntimeExtension(":system-tests:end2end-test:connector-runtime", "connector",
static RuntimeExtension connector = new RuntimePerClassExtension(new EmbeddedRuntime("connector",
configOf("edc.connector.name", "connector1",
"edc.web.rest.cors.enabled", "true",
"web.http.port", CONNECTOR_DEFAULT.port(),
Expand All @@ -89,10 +92,11 @@ class FederatedCatalogTest {
"edc.participant.id", "test-connector",
"web.http.management.path", CONNECTOR_MANAGEMENT.path(),
"edc.web.rest.cors.headers", "origin,content-type,accept,authorization,x-api-key",
"edc.dsp.callback.address", "http://localhost:%s%s".formatted(CONNECTOR_PROTOCOL.port(), CONNECTOR_PROTOCOL.path())));
"edc.dsp.callback.address", "http://localhost:%s%s".formatted(CONNECTOR_PROTOCOL.port(), CONNECTOR_PROTOCOL.path())),
":system-tests:end2end-test:connector-runtime"));

@RegisterExtension
static EdcRuntimeExtension catalog = new EdcRuntimeExtension(":system-tests:end2end-test:catalog-runtime", "catalog",
static RuntimeExtension catalog = new RuntimePerMethodExtension(new EmbeddedRuntime("catalog",
configOf("edc.catalog.cache.execution.delay.seconds", "0",
"edc.catalog.cache.execution.period.seconds", "2",
"edc.catalog.cache.partition.num.crawlers", "5",
Expand All @@ -106,7 +110,8 @@ class FederatedCatalogTest {
"web.http.management.path", CATALOG_MANAGEMENT.path(),
"web.http.catalog.port", CATALOG_CATALOG.port(),
"web.http.catalog.path", CATALOG_CATALOG.path(),
"edc.web.rest.cors.headers", "origin,content-type,accept,authorization,x-api-key"));
"edc.web.rest.cors.headers", "origin,content-type,accept,authorization,x-api-key"),
":system-tests:end2end-test:catalog-runtime"));
private final TypeTransformerRegistry typeTransformerRegistry = new TypeTransformerRegistryImpl();
private final ObjectMapper mapper = JacksonJsonLd.createObjectMapper();
private final CatalogApiClient apiClient = new CatalogApiClient(CATALOG_CATALOG, CONNECTOR_MANAGEMENT, mapper, new TitaniumJsonLd(mock(Monitor.class)), typeTransformerRegistry);
Expand Down

0 comments on commit 6890773

Please sign in to comment.