Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jan 20, 2025
1 parent 2e9e0cb commit 9ba52d1
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import java.time.Clock;

import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;

@EndToEndTest
Expand All @@ -32,7 +31,6 @@ class Basic01basicConnectorTest {
@RegisterExtension
static RuntimeExtension connector = new RuntimePerClassExtension(new EmbeddedRuntime(
"connector",
emptyMap(),
":basic:basic-01-basic-connector"
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.jupiter.api.extension.RegisterExtension;

import static io.restassured.RestAssured.given;
import static java.util.Collections.emptyMap;
import static org.hamcrest.CoreMatchers.containsString;

@EndToEndTest
Expand All @@ -31,7 +30,6 @@ class Basic02healthEndpointTest {
@RegisterExtension
static RuntimeExtension controlPlane = new RuntimePerClassExtension(new EmbeddedRuntime(
"connector",
emptyMap(),
":basic:basic-02-health-endpoint"
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.io.File;
import java.util.Map;

import static io.restassured.RestAssured.given;
import static org.eclipse.edc.junit.testfixtures.TestUtils.findBuildRoot;
import static org.eclipse.edc.samples.util.ConfigPropertiesLoader.fromPropertiesFile;
import static org.hamcrest.CoreMatchers.containsString;

@EndToEndTest
Expand All @@ -34,11 +31,8 @@ class Basic03configurationTest {
@RegisterExtension
static RuntimeExtension controlPlane = new RuntimePerClassExtension(new EmbeddedRuntime(
"connector",
Map.of(
"edc.fs.config", new File(findBuildRoot(), "basic/basic-03-configuration/config.properties").getAbsolutePath()
),
":basic:basic-03-configuration"
));
).configurationProvider(fromPropertiesFile("basic/basic-03-configuration/config.properties")));

@Test
void shouldStartConnector() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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.spi.system.configuration.ConfigFactory;

import java.util.Map;

Expand All @@ -27,6 +28,7 @@
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_KEY;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_VALUE;
import static org.eclipse.edc.samples.util.ConfigPropertiesLoader.fromPropertiesFile;
import static org.eclipse.edc.samples.util.TransferUtil.post;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
Expand Down Expand Up @@ -74,17 +76,15 @@ private static RuntimeExtension getRuntime(
String moduleName,
String configPropertiesFilePath
) {
return new RuntimePerClassExtension(new EmbeddedRuntime(
moduleName,
Map.of(
EDC_KEYSTORE, getFileFromRelativePath(CERT_PFX_FILE_PATH).getAbsolutePath(),
EDC_KEYSTORE_PASSWORD, KEYSTORE_PASSWORD,
EDC_FS_CONFIG, getFileFromRelativePath(configPropertiesFilePath).getAbsolutePath(),
CRAWLER_EXECUTION_DELAY, Integer.toString(CRAWLER_EXECUTION_DELAY_VALUE),
CRAWLER_EXECUTION_PERIOD, Integer.toString(CRAWLER_EXECUTION_PERIOD_VALUE)
),
modulePath
));
return new RuntimePerClassExtension(new EmbeddedRuntime(moduleName, modulePath)
.configurationProvider(fromPropertiesFile(configPropertiesFilePath))
.configurationProvider(() -> ConfigFactory.fromMap(Map.of(
EDC_KEYSTORE, getFileFromRelativePath(CERT_PFX_FILE_PATH).getAbsolutePath(),
EDC_KEYSTORE_PASSWORD, KEYSTORE_PASSWORD,
CRAWLER_EXECUTION_DELAY, Integer.toString(CRAWLER_EXECUTION_DELAY_VALUE),
CRAWLER_EXECUTION_PERIOD, Integer.toString(CRAWLER_EXECUTION_PERIOD_VALUE)))
)
);
}

public static String createAsset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
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.samples.util.ConfigPropertiesLoader;
import org.eclipse.edc.spi.system.configuration.ConfigFactory;

import java.util.Map;

Expand Down Expand Up @@ -57,14 +59,12 @@ private static RuntimeExtension getConnector(
String moduleName,
String configPropertiesFilePath
) {
return new RuntimePerClassExtension(new EmbeddedRuntime(
moduleName,
Map.of(
EDC_KEYSTORE, getFileFromRelativePath(CERT_PFX_FILE_PATH).getAbsolutePath(),
EDC_KEYSTORE_PASSWORD, KEYSTORE_PASSWORD,
EDC_FS_CONFIG, getFileFromRelativePath(configPropertiesFilePath).getAbsolutePath()
),
modulePath
));
return new RuntimePerClassExtension(new EmbeddedRuntime(moduleName, modulePath)
.configurationProvider(ConfigPropertiesLoader.fromPropertiesFile(configPropertiesFilePath))
.configurationProvider(() -> ConfigFactory.fromMap(Map.of(
EDC_KEYSTORE, getFileFromRelativePath(CERT_PFX_FILE_PATH).getAbsolutePath(),
EDC_KEYSTORE_PASSWORD, KEYSTORE_PASSWORD))
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
import org.junit.jupiter.api.extension.RegisterExtension;

import java.time.Duration;
import java.util.Map;

import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.NegotiationCommon.getContractNegotiationState;
import static org.eclipse.edc.samples.common.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.PolicyCommon.createAsset;
import static org.eclipse.edc.samples.common.PolicyCommon.createContractDefinition;
import static org.eclipse.edc.samples.common.PolicyCommon.createPolicy;
import static org.eclipse.edc.samples.util.ConfigPropertiesLoader.fromPropertiesFile;
import static org.eclipse.edc.samples.util.TransferUtil.POLL_INTERVAL;

@EndToEndTest
Expand Down Expand Up @@ -93,17 +92,15 @@ void runSampleSteps() {
private static RuntimeExtension provider() {
return new RuntimePerClassExtension(new EmbeddedRuntime(
"provider",
Map.of("edc.fs.config", getFileFromRelativePath(SAMPLE_FOLDER + "/policy-enforcement-provider/config.properties").getAbsolutePath()),
":policy:policy-01-policy-enforcement:policy-enforcement-provider"
));
).configurationProvider(fromPropertiesFile(SAMPLE_FOLDER + "/policy-enforcement-provider/config.properties")));
}

private static RuntimeExtension consumer(String configurationFilePath) {
return new RuntimePerClassExtension(new EmbeddedRuntime(
"consumer",
Map.of("edc.fs.config", getFileFromRelativePath(configurationFilePath).getAbsolutePath()),
":policy:policy-01-policy-enforcement:policy-enforcement-consumer"
));
).configurationProvider(fromPropertiesFile(configurationFilePath)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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.spi.system.configuration.ConfigFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.containers.GenericContainer;
Expand All @@ -43,7 +44,7 @@
import static org.assertj.core.api.Fail.fail;
import static org.eclipse.edc.samples.common.FileTransferCloudCommon.runNegotiation;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.util.ConfigPropertiesLoader.fromPropertiesFile;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

Expand Down Expand Up @@ -105,18 +106,15 @@ public class Transfer05fileTransferCloudTest {
.withLogConsumer(frame -> System.out.print(frame.getUtf8String()));

@RegisterExtension
protected static RuntimeExtension consumer = new RuntimePerClassExtension(new EmbeddedRuntime(
CONSUMER,
Map.of(
EDC_FS_CONFIG, getFileFromRelativePath(CLOUD_CONSUMER_CONFIG_PROPERTIES_FILE_PATH).getAbsolutePath()
),
CONSUMER_MODULE_PATH
));
protected static RuntimeExtension consumer = new RuntimePerClassExtension(
new EmbeddedRuntime(CONSUMER, CONSUMER_MODULE_PATH)
.configurationProvider(fromPropertiesFile(CLOUD_CONSUMER_CONFIG_PROPERTIES_FILE_PATH))
);

@RegisterExtension
protected static RuntimeExtension provider = new RuntimePerClassExtension(new EmbeddedRuntime(
PROVIDER,
Map.ofEntries(
protected static RuntimeExtension provider = new RuntimePerClassExtension(
new EmbeddedRuntime(PROVIDER, PROVIDER_MODULE_PATH)
.configurationProvider(() -> ConfigFactory.fromMap(Map.ofEntries(
entry("edc.participant.id", "provider"),
entry("edc.dsp.callback.address", "http://localhost:19194/protocol"),
entry("web.http.port", "19191"),
Expand All @@ -140,10 +138,9 @@ EDC_FS_CONFIG, getFileFromRelativePath(CLOUD_CONSUMER_CONFIG_PROPERTIES_FILE_PAT
entry("edc.vault.hashicorp.health.check.enabled", "false"),
entry("edc.blobstore.endpoint.template", "http://127.0.0.1:" + getAzuritePort() + "/%s"),
entry("edc.aws.access.key", "accessKeyId"),
entry("edc.aws.secret.access.key", "secretAccessKey")
),
PROVIDER_MODULE_PATH
));
entry("edc.aws.secret.access.key", "secretAccessKey")))
)
);

@Test
void pushFile() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.edc.samples.transfer.streaming;

import okhttp3.mockwebserver.MockWebServer;
import org.eclipse.edc.connector.controlplane.test.system.utils.LazySupplier;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
Expand All @@ -29,7 +30,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Map;
import java.util.UUID;

import static java.util.concurrent.Executors.newScheduledThreadPool;
Expand All @@ -38,7 +38,7 @@
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.util.ConfigPropertiesLoader.fromPropertiesFile;

@EndToEndTest
public class Streaming01httpToHttpTest {
Expand All @@ -49,36 +49,26 @@ public class Streaming01httpToHttpTest {
private static final StreamingParticipant PROVIDER = StreamingParticipant.Builder.newStreamingInstance()
.name("provider")
.id("provider")
.managementEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:18181/management")))
.protocolEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:18182/protocol")))
.controlEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:18183/control")))
.controlPlaneManagement(new LazySupplier<>(() -> URI.create("http://localhost:18181/management")))
.controlPlaneProtocol(new LazySupplier<>(() -> URI.create("http://localhost:18182/protocol")))
.build();

private static final StreamingParticipant CONSUMER = StreamingParticipant.Builder.newStreamingInstance()
.name("consumer")
.id("consumer")
.managementEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:28181/management")))
.protocolEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:28182/protocol")))
.controlEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:28183/control")))
.controlPlaneManagement(new LazySupplier<>(() -> URI.create("http://localhost:28181/management")))
.controlPlaneProtocol(new LazySupplier<>(() -> URI.create("http://localhost:28182/protocol")))
.build();

@RegisterExtension
static RuntimeExtension providerConnector = new RuntimePerClassExtension(new EmbeddedRuntime(
"provider",
Map.of(
"edc.fs.config", getFileFromRelativePath(SAMPLE_FOLDER + "/streaming-01-runtime/provider.properties").getAbsolutePath()
),
":transfer:streaming:streaming-01-http-to-http:streaming-01-runtime"
));
"provider", ":transfer:streaming:streaming-01-http-to-http:streaming-01-runtime"
).configurationProvider(fromPropertiesFile(SAMPLE_FOLDER + "/streaming-01-runtime/provider.properties")));

@RegisterExtension
static RuntimeExtension consumerConnector = new RuntimePerClassExtension(new EmbeddedRuntime(
"consumer",
Map.of(
"edc.fs.config", getFileFromRelativePath(SAMPLE_FOLDER + "/streaming-01-runtime/consumer.properties").getAbsolutePath()
),
":transfer:streaming:streaming-01-http-to-http:streaming-01-runtime"
));
"consumer", ":transfer:streaming:streaming-01-http-to-http:streaming-01-runtime"
).configurationProvider(fromPropertiesFile(SAMPLE_FOLDER + "/streaming-01-runtime/consumer.properties")));
private final int httpReceiverPort = Ports.getFreePort();
private final MockWebServer consumerReceiverServer = new MockWebServer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;
import org.eclipse.edc.connector.controlplane.test.system.utils.LazySupplier;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
Expand All @@ -37,7 +38,6 @@
import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executors;

Expand All @@ -46,7 +46,7 @@
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.util.ConfigPropertiesLoader.fromPropertiesFile;

@Testcontainers
@EndToEndTest
Expand All @@ -60,16 +60,14 @@ public class Streaming02KafkaToHttpTest {
private static final StreamingParticipant PROVIDER = StreamingParticipant.Builder.newStreamingInstance()
.name("provider")
.id("provider")
.managementEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:18181/management")))
.protocolEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:18182/protocol")))
.controlEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:18183/control")))
.controlPlaneManagement(new LazySupplier<>(() -> URI.create("http://localhost:18181/management")))
.controlPlaneProtocol(new LazySupplier<>(() -> URI.create("http://localhost:18182/protocol")))
.build();
private static final StreamingParticipant CONSUMER = StreamingParticipant.Builder.newStreamingInstance()
.name("consumer")
.id("consumer")
.managementEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:28181/management")))
.protocolEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:28182/protocol")))
.controlEndpoint(new StreamingParticipant.Endpoint(URI.create("http://localhost:28183/control")))
.controlPlaneManagement(new LazySupplier<>(() -> URI.create("http://localhost:28181/management")))
.controlPlaneProtocol(new LazySupplier<>(() -> URI.create("http://localhost:28182/protocol")))
.build();

@Container
Expand All @@ -81,24 +79,15 @@ public class Streaming02KafkaToHttpTest {
@RegisterExtension
static RuntimeExtension providerConnector = new RuntimePerClassExtension(new EmbeddedRuntime(
"provider",
Map.of(
"edc.fs.config",
getFileFromRelativePath(SAMPLE_FOLDER + "/streaming-02-runtime/provider.properties")
.getAbsolutePath()
),
":transfer:streaming:streaming-02-kafka-to-http:streaming-02-runtime"
));
).configurationProvider(fromPropertiesFile(SAMPLE_FOLDER + "/streaming-02-runtime/provider.properties")));

@RegisterExtension
static RuntimeExtension consumerConnector = new RuntimePerClassExtension(new EmbeddedRuntime(
"consumer",
Map.of(
"edc.fs.config",
getFileFromRelativePath(SAMPLE_FOLDER + "/streaming-02-runtime/consumer.properties")
.getAbsolutePath()
),
":transfer:streaming:streaming-02-kafka-to-http:streaming-02-runtime"
));
).configurationProvider(fromPropertiesFile(SAMPLE_FOLDER + "/streaming-02-runtime/consumer.properties")));

private final int httpReceiverPort = Ports.getFreePort();
private final MockWebServer consumerReceiverServer = new MockWebServer();

Expand Down
Loading

0 comments on commit 9ba52d1

Please sign in to comment.