Skip to content

Commit

Permalink
avoid data plane registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jun 10, 2024
1 parent 8f322a8 commit 9f6f7d0
Show file tree
Hide file tree
Showing 25 changed files with 10 additions and 220 deletions.
18 changes: 0 additions & 18 deletions advanced/advanced-01-open-telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ docker compose -f advanced/advanced-01-open-telemetry/docker-compose.yaml up --a

Open a new terminal.

Register data planes for provider and consumer:

```bash
curl -H 'Content-Type: application/json' \
-H "X-Api-Key: password" \
-d @transfer/transfer-00-prerequisites/resources/dataplane/register-data-plane-provider.json \
-X POST "http://localhost:19193/management/v2/dataplanes" \
-s | jq
```

```bash
curl -H 'Content-Type: application/json' \
-H "X-Api-Key: password" \
-d @transfer/transfer-00-prerequisites/resources/dataplane/register-data-plane-consumer.json \
-X POST "http://localhost:29193/management/v2/dataplanes" \
-s | jq
```

Create an asset:

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
implementation(libs.edc.data.plane.selector.api)
implementation(libs.edc.data.plane.selector.core)

implementation(libs.edc.data.plane.self.registration)
implementation(libs.edc.data.plane.control.api)
implementation(libs.edc.data.plane.public.api)
implementation(libs.edc.data.plane.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
"@vocab": "https://w3id.org/edc/v0.0.1/ns/"
},
"@type": "ContractRequest",
"counterPartyAddress": "http://provider:19194/protocol",
"counterPartyAddress": "http://localhost:19194/protocol",
"protocol": "dataspace-protocol-http",
"policy": {
"@context": "http://www.w3.org/ns/odrl.jsonld",
"@id": "{{contract-offer-id}}",
"@type": "Offer",
"permission": [],
"prohibition": [],
"obligation": [],
"assigner": "provider",
"target": "assetId"
}
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ edc-data-plane-http = { module = "org.eclipse.edc:data-plane-http", version.ref
edc-data-plane-kafka = { module = "org.eclipse.edc:data-plane-kafka", version.ref = "edc" }
edc-data-plane-selector-api = { module = "org.eclipse.edc:data-plane-selector-api", version.ref = "edc" }
edc-data-plane-selector-core = { module = "org.eclipse.edc:data-plane-selector-core", version.ref = "edc" }
edc-data-plane-self-registration = { module = "org.eclipse.edc:data-plane-self-registration", version.ref = "edc" }
edc-data-plane-spi = { module = "org.eclipse.edc:data-plane-spi", version.ref = "edc" }
edc-data-plane-util = { module = "org.eclipse.edc:data-plane-util", version.ref = "edc" }
edc-dsp = { module = "org.eclipse.edc:dsp", version.ref = "edc" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import static org.eclipse.edc.samples.common.NegotiationCommon.fetchDatasetFromCatalog;
import static org.eclipse.edc.samples.common.NegotiationCommon.getContractAgreementId;
import static org.eclipse.edc.samples.common.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

Expand Down Expand Up @@ -67,14 +66,14 @@ static void setUp() {

@Test
void runSampleSteps() {
runPrerequisites();
createAsset();
createPolicy();
createContractDefinition();
var catalogDatasetId = fetchDatasetFromCatalog(FETCH_DATASET_FROM_CATALOG_FILE_PATH);
var contractNegotiationId = negotiateContract(NEGOTIATE_CONTRACT_FILE_PATH, catalogDatasetId);
var contractAgreementId = getContractAgreementId(contractNegotiationId);
var transferProcessId = startTransfer(getFileContentFromRelativePath(START_TRANSFER_FILE_PATH), contractAgreementId);
var transferRequest = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH);
var transferProcessId = startTransfer(transferRequest, contractAgreementId);
checkTransferStatus(transferProcessId, STARTED);
assertJaegerState();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@

package org.eclipse.edc.samples.common;

import io.restassured.http.ContentType;
import org.apache.http.HttpStatus;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;

import java.util.Map;

import static io.restassured.RestAssured.given;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;

public class PrerequisitesCommon {
public static final String API_KEY_HEADER_KEY = "X-Api-Key";
public static final String API_KEY_HEADER_VALUE = "password";
public static final String PROVIDER_MANAGEMENT_URL = "http://localhost:19193/management";
public static final String CONSUMER_MANAGEMENT_URL = "http://localhost:29193/management";
public static final String CONSUMER_PUBLIC_URL = "http://localhost:29291/public";

private static final String CONNECTOR_MODULE_PATH = ":transfer:transfer-00-prerequisites:connector";
private static final String PROVIDER = "provider";
Expand All @@ -41,11 +37,9 @@ public class PrerequisitesCommon {
private static final String KEYSTORE_PASSWORD = "123456";
private static final String PROVIDER_CONFIG_PROPERTIES_FILE_PATH = "transfer/transfer-00-prerequisites/resources/configuration/provider-configuration.properties";
private static final String CONSUMER_CONFIG_PROPERTIES_FILE_PATH = "transfer/transfer-00-prerequisites/resources/configuration/consumer-configuration.properties";
private static final String REGISTER_DATA_PLANE_PROVIDER_JSON = "transfer/transfer-00-prerequisites/resources/dataplane/register-data-plane-provider.json";

public static EdcRuntimeExtension getProvider() {
return getConnector(CONNECTOR_MODULE_PATH, PROVIDER, PROVIDER_CONFIG_PROPERTIES_FILE_PATH);

}

public static EdcRuntimeExtension getConsumer() {
Expand All @@ -56,14 +50,6 @@ public static EdcRuntimeExtension getConsumer(String modulePath) {
return getConnector(modulePath, CONSUMER, CONSUMER_CONFIG_PROPERTIES_FILE_PATH);
}

public static void registerDataPlaneProvider() {
registerDataPlane(PROVIDER_MANAGEMENT_URL, REGISTER_DATA_PLANE_PROVIDER_JSON);
}

public static void runPrerequisites() {
registerDataPlaneProvider();
}

private static EdcRuntimeExtension getConnector(
String modulePath,
String moduleName,
Expand All @@ -79,19 +65,4 @@ EDC_FS_CONFIG, getFileFromRelativePath(configPropertiesFilePath).getAbsolutePath
)
);
}

private static void registerDataPlane(String host, String payloadPath) {
var requestBody = getFileFromRelativePath(payloadPath);

given()
.headers(API_KEY_HEADER_KEY, API_KEY_HEADER_VALUE)
.contentType(ContentType.JSON)
.body(requestBody)
.when()
.post(host + "/v2/dataplanes")
.then()
.log()
.ifError()
.statusCode(HttpStatus.SC_OK);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static org.eclipse.edc.samples.common.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;

@EndToEndTest
public class Transfer01negotiationTest {
Expand All @@ -45,7 +44,6 @@ public class Transfer01negotiationTest {

@Test
void runSampleSteps() {
runPrerequisites();
createAsset();
createPolicy();
createContractDefinition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import static org.eclipse.edc.samples.common.PrerequisitesCommon.CONSUMER_MANAGEMENT_URL;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;
import static org.hamcrest.Matchers.emptyString;
Expand All @@ -56,7 +55,6 @@ public class Transfer02consumerPullTest {

@Test
void runSampleSteps() {
runPrerequisites();
var requestBody = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH);
var contractAgreementId = runNegotiation();
var transferProcessId = startTransfer(requestBody, contractAgreementId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

Expand All @@ -58,7 +57,6 @@ static void setUp() {

@Test
void runSampleSteps() {
runPrerequisites();
var contractAgreementId = runNegotiation();
var requestBody = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH);
var transferProcessId = startTransfer(requestBody, contractAgreementId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

Expand All @@ -59,7 +58,6 @@ static void setUp() {
void runSampleSteps() {
var standardOutputStream = new ByteArrayOutputStream();
System.setOut(new PrintStream(standardOutputStream));
runPrerequisites();
var requestBody = getFileContentFromRelativePath(START_TRANSFER_FILE_PATH);
var contractAgreementId = runNegotiation();
var transferProcessId = startTransfer(requestBody, contractAgreementId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.UUID;

Expand Down Expand Up @@ -90,7 +89,6 @@ void setUp() throws IOException {
@Test
void streamData() throws IOException {
var source = Files.createTempDirectory("source");
PROVIDER.registerDataPlane(List.of("HttpStreaming"), List.of("HttpData"), List.of("HttpData-PUSH"));

PROVIDER.createAsset(getFileContentFromRelativePath(SAMPLE_FOLDER + "/asset.json")
.replace("{{sourceFolder}}", source.toString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -108,9 +107,6 @@ void setUp() throws IOException {

@Test
void streamData() {

PROVIDER.registerDataPlane(List.of("Kafka"), List.of("HttpData"), List.of("HttpData-PUSH"));

PROVIDER.createAsset(getFileContentFromRelativePath(SAMPLE_FOLDER + "/1-asset.json")
.replace("{{bootstrap.servers}}", kafkaContainer.getBootstrapServers())
.replace("{{max.duration}}", MAX_DURATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@

package org.eclipse.edc.samples.transfer.streaming;

import jakarta.json.Json;
import org.eclipse.edc.connector.controlplane.test.system.utils.Participant;

import java.util.List;
import java.util.UUID;

import static io.restassured.http.ContentType.JSON;
import static jakarta.json.Json.createArrayBuilder;
import static jakarta.json.Json.createObjectBuilder;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE;
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_PREFIX;

/**
* Essentially a wrapper around the management API enabling to test interactions with other participants, eg. catalog, transfer...
Expand All @@ -42,25 +33,6 @@ public String getName() {
return name;
}

public void registerDataPlane(List<String> sourceTypes, List<String> destinationTypes, List<Object> transferTypes) {
var jsonObject = Json.createObjectBuilder()
.add(CONTEXT, createObjectBuilder().add(EDC_PREFIX, EDC_NAMESPACE))
.add(ID, UUID.randomUUID().toString())
.add(EDC_NAMESPACE + "url", controlEndpoint.getUrl() + "/transfer")
.add(EDC_NAMESPACE + "allowedSourceTypes", createArrayBuilder(sourceTypes))
.add(EDC_NAMESPACE + "allowedDestTypes", createArrayBuilder(destinationTypes))
.add(EDC_NAMESPACE + "allowedTransferTypes", createArrayBuilder(transferTypes))
.build();

managementEndpoint.baseRequest()
.contentType(JSON)
.body(jsonObject.toString())
.when()
.post("/v2/dataplanes")
.then()
.statusCode(200);
}

public String createAsset(String requestBody) {
return managementEndpoint.baseRequest()
.contentType(JSON)
Expand Down
9 changes: 0 additions & 9 deletions transfer/streaming/streaming-01-http-to-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ export EDC_FS_CONFIG=transfer/streaming/streaming-01-http-to-http/streaming-01-r
java -jar transfer/streaming/streaming-01-http-to-http/streaming-01-runtime/build/libs/connector.jar
```

#### Register Data Plane on provider
The provider connector needs to be aware of the streaming capabilities of the embedded dataplane, which can be registered with
this call:
```shell
curl -H 'Content-Type: application/json' -d @transfer/streaming/streaming-01-http-to-http/dataplane.json -X POST "http://localhost:18181/management/v2/dataplanes"
```

If you look at the `dataplane.json` you'll notice that the supported source is `HttpStreaming` and the supported sink is `HttpData`.

#### Register Asset, Policy Definition and Contract Definition on provider
A "source" folder must first be created where the data plane will get the messages to be sent to the consumers.
To do this, create a temp folder:
Expand Down
9 changes: 0 additions & 9 deletions transfer/streaming/streaming-01-http-to-http/dataplane.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
implementation(libs.edc.transfer.data.plane.signaling)
implementation(libs.edc.data.plane.spi)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.data.plane.self.registration)
implementation(libs.edc.data.plane.http)
}

Expand Down
10 changes: 0 additions & 10 deletions transfer/streaming/streaming-02-kafka-to-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ export EDC_FS_CONFIG=transfer/streaming/streaming-02-kafka-to-http/streaming-02-
java -jar transfer/streaming/streaming-02-kafka-to-http/streaming-02-runtime/build/libs/connector.jar
```

### Register Data Plane on provider

The provider connector needs to be aware of the kafka streaming capabilities of the embedded dataplane, which can be registered with
this call:
```shell
curl -H 'Content-Type: application/json' -d @transfer/streaming/streaming-02-kafka-to-http/0-dataplane.json -X POST "http://localhost:18181/management/v2/dataplanes" -s | jq
```

If you look at the `0-dataplane.json` you'll notice that the supported source is `Kafka` and the supported sink is `HttpData`.

### Register Asset, Policy Definition and Contract Definition on provider

A "source" kafka topic must first be created where the data plane will get the event records to be sent to the consumers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
implementation(libs.edc.transfer.data.plane.signaling)
implementation(libs.edc.data.plane.spi)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.data.plane.self.registration)
implementation(libs.edc.data.plane.http)
implementation(libs.edc.data.plane.kafka)

Expand Down
Loading

0 comments on commit 9f6f7d0

Please sign in to comment.