Skip to content

Commit 7cd7b53

Browse files
authored
build: fix compilation (#133)
1 parent 1374b14 commit 7cd7b53

File tree

7 files changed

+51
-98
lines changed

7 files changed

+51
-98
lines changed

e2e-tests/src/test/java/com/huawei/cloud/fixtures/HuaweiParticipant.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
package com.huawei.cloud.fixtures;
1616

1717
import com.fasterxml.jackson.annotation.JsonCreator;
18+
import org.eclipse.edc.connector.controlplane.test.system.utils.LazySupplier;
1819
import org.eclipse.edc.connector.controlplane.test.system.utils.Participant;
20+
import org.eclipse.edc.spi.system.configuration.Config;
21+
import org.eclipse.edc.spi.system.configuration.ConfigFactory;
1922

2023
import java.net.URI;
21-
import java.time.Duration;
2224
import java.util.HashMap;
2325
import java.util.Map;
2426

@@ -30,30 +32,29 @@ public class HuaweiParticipant extends Participant {
3032

3133
private static final String IAM_OTC_CLOUD_URL = "https://iam.eu-de.otc.t-systems.com";
3234

33-
private static final Duration TIMEOUT = Duration.ofMillis(10000);
34-
private Endpoint controlEndpoint;
3535
private String apiKey;
36+
private final LazySupplier<URI> controlEndpoint = new LazySupplier<>(() -> URI.create("http://localhost:" + getFreePort() + "/control"));
3637

37-
public Endpoint getControlEndpoint() {
38-
return controlEndpoint;
38+
public URI getControlEndpoint() {
39+
return controlEndpoint.get();
3940
}
4041

41-
public Map<String, String> controlPlaneConfiguration() {
42-
return new HashMap<>() {
42+
public Config controlPlaneConfig() {
43+
var settings = (Map<String, String>) new HashMap<String, String>() {
4344
{
4445
put(PARTICIPANT_ID, id);
4546
put("edc.api.auth.key", apiKey);
4647
put("web.http.port", String.valueOf(getFreePort()));
4748
put("web.http.path", "/api");
48-
put("web.http.protocol.port", String.valueOf(protocolEndpoint.getUrl().getPort()));
49-
put("web.http.protocol.path", protocolEndpoint.getUrl().getPath());
50-
put("web.http.management.port", String.valueOf(managementEndpoint.getUrl().getPort()));
51-
put("web.http.management.path", managementEndpoint.getUrl().getPath());
52-
put("web.http.control.port", String.valueOf(controlEndpoint.getUrl().getPort()));
53-
put("web.http.control.path", controlEndpoint.getUrl().getPath());
49+
put("web.http.protocol.port", String.valueOf(controlPlaneProtocol.get().getPort()));
50+
put("web.http.protocol.path", controlPlaneProtocol.get().getPath());
51+
put("web.http.management.port", String.valueOf(controlPlaneManagement.get().getPort()));
52+
put("web.http.management.path", controlPlaneManagement.get().getPath());
53+
put("web.http.control.port", String.valueOf(controlEndpoint.get().getPort()));
54+
put("web.http.control.path", controlEndpoint.get().getPath());
5455
put("web.http.public.path", "/public");
5556
put("web.http.public.port", String.valueOf(getFreePort()));
56-
put("edc.dsp.callback.address", protocolEndpoint.getUrl().toString());
57+
put("edc.dsp.callback.address", controlPlaneProtocol.get().toString());
5758
put("edc.connector.name", name);
5859
put("edc.component.id", "connector-test");
5960
put("edc.dataplane.token.validation.endpoint", "http://token-validation.com");
@@ -63,6 +64,8 @@ public Map<String, String> controlPlaneConfiguration() {
6364
put("edc.transfer.proxy.token.signer.privatekey.alias", "privatekey");
6465
}
6566
};
67+
68+
return ConfigFactory.fromMap(settings);
6669
}
6770

6871
public static final class Builder extends Participant.Builder<HuaweiParticipant, Builder> {
@@ -83,11 +86,8 @@ public Builder apiKey(String apiKey) {
8386

8487
@Override
8588
public HuaweiParticipant build() {
86-
super.managementEndpoint(new Endpoint(URI.create("http://localhost:" + getFreePort() + "/api/management"), Map.of("X-Api-Key", participant.apiKey)));
87-
super.protocolEndpoint(new Endpoint(URI.create("http://localhost:" + getFreePort() + "/protocol")));
88-
super.build();
89-
participant.controlEndpoint = new Endpoint(URI.create("http://localhost:" + getFreePort() + "/control"), Map.of());
90-
return participant;
89+
participant.enrichManagementRequest = request -> request.header("X-Api-Key", participant.apiKey);
90+
return super.build();
9191
}
9292
}
9393
}

e2e-tests/src/test/java/com/huawei/cloud/tests/ObsTransferEndToEndTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,14 @@ public class ObsTransferEndToEndTest {
8383
@RegisterExtension
8484
static RuntimeExtension consumer = new RuntimePerClassExtension(new EmbeddedRuntime(
8585
"consumer",
86-
CONSUMER.controlPlaneConfiguration(),
8786
":launchers:e2e-test"
88-
));
87+
).configurationProvider(CONSUMER::controlPlaneConfig));
8988

9089
@RegisterExtension
9190
static RuntimeExtension provider = new RuntimePerClassExtension(new EmbeddedRuntime(
9291
"provider",
93-
PROVIDER.controlPlaneConfiguration(),
9492
":launchers:e2e-test"
95-
));
93+
).configurationProvider(PROVIDER::controlPlaneConfig));
9694

9795
@Container
9896
private final GenericContainer<?> providerContainer = new GenericContainer<>(MINIO_DOCKER_IMAGE)
@@ -142,7 +140,7 @@ void transfer_singleFile() throws IOException {
142140
consumerClient.createBucket(destBucket);
143141

144142
var flowRequest = createFlowRequest(destBucket, consumerEndpoint, srcBucket, TESTFILE_NAME, providerEndpoint).build();
145-
var url = PROVIDER.getControlEndpoint().getUrl().toString() + "/v1/dataflows";
143+
var url = PROVIDER.getControlEndpoint() + "/v1/dataflows";
146144

147145
var startMessage = registry.transform(flowRequest, JsonObject.class).orElseThrow(failTest());
148146

@@ -178,7 +176,7 @@ void transfer_multipleFilesWithPrefix() throws IOException {
178176
consumerClient.createBucket(destBucket);
179177

180178
var flowRequest = createFlowRequest(destBucket, consumerEndpoint, srcBucket, "file", providerEndpoint).build();
181-
var url = PROVIDER.getControlEndpoint().getUrl().toString() + "/v1/dataflows";
179+
var url = PROVIDER.getControlEndpoint() + "/v1/dataflows";
182180

183181

184182
var startMessage = registry.transform(flowRequest, JsonObject.class).orElseThrow(failTest());

e2e-tests/src/test/java/com/huawei/cloud/tests/OtcTransferEndToEndTest.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,22 @@
2020
import com.huawei.cloud.obs.ObsClientProviderImpl;
2121
import com.huawei.cloud.obs.OtcTest;
2222
import com.obs.services.ObsClient;
23-
import com.obs.services.model.ObsObject;
2423
import jakarta.json.Json;
2524
import jakarta.json.JsonObject;
2625
import jakarta.json.JsonValue;
2726
import org.eclipse.edc.connector.controlplane.test.system.utils.Participant;
2827
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates;
2928
import org.eclipse.edc.connector.dataplane.spi.Endpoint;
3029
import org.eclipse.edc.connector.dataplane.spi.iam.PublicEndpointGeneratorService;
31-
import org.eclipse.edc.junit.extensions.EdcClassRuntimesExtension;
32-
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
30+
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
31+
import org.eclipse.edc.junit.extensions.RuntimeExtension;
32+
import org.eclipse.edc.junit.extensions.RuntimePerClassExtension;
3333
import org.junit.jupiter.api.AfterEach;
3434
import org.junit.jupiter.api.BeforeEach;
3535
import org.junit.jupiter.api.Test;
3636
import org.junit.jupiter.api.extension.RegisterExtension;
3737

3838
import java.time.Duration;
39-
import java.util.List;
4039
import java.util.Map;
4140
import java.util.UUID;
4241

@@ -68,23 +67,16 @@ public class OtcTransferEndToEndTest {
6867
private static final String OBS_OTC_CLOUD_URL = "https://obs.eu-de.otc.t-systems.com";
6968

7069

71-
static EdcRuntimeExtension providerRuntime = new EdcRuntimeExtension(
72-
":launchers:e2e-test",
73-
"consumer",
74-
CONSUMER.controlPlaneConfiguration()
75-
);
70+
static EmbeddedRuntime providerRuntime = new EmbeddedRuntime("consumer", ":launchers:e2e-test")
71+
.configurationProvider(CONSUMER::controlPlaneConfig);
7672

77-
static EdcRuntimeExtension consumerRuntime = new EdcRuntimeExtension(
78-
":launchers:e2e-test",
79-
"provider",
80-
PROVIDER.controlPlaneConfiguration()
81-
);
73+
static EmbeddedRuntime consumerRuntime = new EmbeddedRuntime("provider", ":launchers:e2e-test")
74+
.configurationProvider(PROVIDER::controlPlaneConfig);
8275

8376
@RegisterExtension
84-
static EdcClassRuntimesExtension runtimes = new EdcClassRuntimesExtension(
85-
providerRuntime,
86-
consumerRuntime
87-
);
77+
static RuntimeExtension provider = new RuntimePerClassExtension(providerRuntime);
78+
@RegisterExtension
79+
static RuntimeExtension consumer = new RuntimePerClassExtension(consumerRuntime);
8880

8981
private String id;
9082
private String sourceBucket;
@@ -105,8 +97,8 @@ void setup() {
10597
var consumerClientProviderImp = (ObsClientProviderImpl) consumerRuntime.getService(ObsClientProvider.class);
10698
consumerClientProviderImp.getVault().storeSecret("publickey", PUBLIC_KEY);
10799
consumerClientProviderImp.getVault().storeSecret("privatekey", PRIVATE_KEY);
108-
var providerEndpointGeneratorService = (PublicEndpointGeneratorService) providerRuntime.getService(PublicEndpointGeneratorService.class);
109-
var consumerEndpointGeneratorService = (PublicEndpointGeneratorService) consumerRuntime.getService(PublicEndpointGeneratorService.class);
100+
var providerEndpointGeneratorService = providerRuntime.getService(PublicEndpointGeneratorService.class);
101+
var consumerEndpointGeneratorService = consumerRuntime.getService(PublicEndpointGeneratorService.class);
110102
var endpoint = new Endpoint("endpoint", "obs");
111103
providerEndpointGeneratorService.addGeneratorFunction("HttpData", dataAddress1 -> endpoint);
112104
consumerEndpointGeneratorService.addGeneratorFunction("HttpData", dataAddress1 -> endpoint);
@@ -132,7 +124,7 @@ void obsToObsTransfer() {
132124
assertThat(TransferProcessStates.valueOf(state).code()).isGreaterThanOrEqualTo(COMPLETED.code());
133125
});
134126

135-
List<ObsObject> consumerObsObjectList = consumerClient.listObjects(destBucket).getObjects();
127+
var consumerObsObjectList = consumerClient.listObjects(destBucket).getObjects();
136128
if (!consumerObsObjectList.isEmpty()) {
137129
assertThat(consumerObsObjectList)
138130
.allSatisfy(obsObject -> assertThat(obsObject.getObjectKey()).isEqualTo(TESTFILE_NAME));
@@ -146,8 +138,8 @@ void cleanup() {
146138
}
147139

148140
private JsonObject getOfferForAsset(Participant provider, String assetId) {
149-
JsonObject dataset = CONSUMER.getDatasetForAsset(provider, assetId);
150-
JsonObject policy = ((JsonValue) dataset.getJsonArray("http://www.w3.org/ns/odrl/2/hasPolicy").get(0)).asJsonObject();
141+
var dataset = CONSUMER.getDatasetForAsset(provider, assetId);
142+
var policy = dataset.getJsonArray("http://www.w3.org/ns/odrl/2/hasPolicy").get(0).asJsonObject();
151143
return Json.createObjectBuilder(policy).add("http://www.w3.org/ns/odrl/2/assigner", Json.createObjectBuilder().add("@id", provider.getId())).add("http://www.w3.org/ns/odrl/2/target", Json.createObjectBuilder().add("@id", (JsonValue) dataset.get("@id"))).build();
152144
}
153145

extensions/common/obs/obs-core/src/main/java/com/huawei/cloud/obs/ObsCoreExtension.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
@Provides(ObsClientProvider.class)
3535
public class ObsCoreExtension implements ServiceExtension {
3636

37-
@Setting(value = "The key of the secret where the AWS Access Key Id is stored")
37+
@Setting(description = "The key of the secret where the AWS Access Key Id is stored")
3838
public static final String HUAWEI_ACCESS_KEY = "edc.huawei.obs.alias.ak";
39-
@Setting(value = "The key of the secret where the AWS Secret Access Key is stored")
39+
@Setting(description = "The key of the secret where the AWS Secret Access Key is stored")
4040
public static final String HUAWEI_SECRET_KEY = "edc.huawei.obs.alias.sk";
41-
@Setting(value = "If valued, the AWS clients will point to the specified endpoint")
41+
@Setting(description = "If valued, the AWS clients will point to the specified endpoint")
4242
public static final String HUAWEI_IAM_ENDPOINT = "edc.huawei.iam.endpoint";
4343
protected static final String NAME = "OBS Core";
4444
private ObsClientProvider clientProvider;

extensions/control-plane/provision-obs/src/main/java/com/huawei/cloud/provision/obs/ObsProvisionExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ObsProvisionExtension implements ServiceExtension {
3232

3333
public static final String NAME = "OBS Provision";
3434

35-
@Setting(value = "Duration in seconds of the temporary token", defaultValue = "" + ObsProvisionExtension.PROVISIONER_DEFAULT_TOKEN_DURATION)
35+
@Setting(description = "Duration in seconds of the temporary token", defaultValue = "" + ObsProvisionExtension.PROVISIONER_DEFAULT_TOKEN_DURATION)
3636
private static final String PROVISION_TOKEN_DURATION = "edc.obs.provision.token.duration";
3737

3838
private static final int PROVISIONER_DEFAULT_TOKEN_DURATION = 60 * 30;

extensions/control-plane/store/contract-negotiation-store-gaussdb/src/test/java/com/huawei/cloud/store/gaussdb/contractnegotiationstore/GaussDbContractNegotiationStoreTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,6 @@ void findById_notExist() {
145145
assertThat(getContractNegotiationStore().findById("not-exist")).isNull();
146146
}
147147

148-
@Test
149-
@DisplayName("Find entity by its correlation ID")
150-
void findForCorrelationId() {
151-
var negotiation = createNegotiation("test-cn1");
152-
getContractNegotiationStore().save(negotiation);
153-
154-
assertThat(getContractNegotiationStore().findForCorrelationId(negotiation.getCorrelationId()))
155-
.usingRecursiveComparison()
156-
.isEqualTo(negotiation);
157-
}
158-
159148
@Test
160149
@DisplayName("Find ContractAgreement by contract ID")
161150
void findContractAgreement() {

extensions/control-plane/store/data-plane-instance-store-gaussdb/src/test/java/com/huawei/cloud/store/gaussdb/assetindex/GaussDbDataPlaneInstanceStoreTest.java

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.eclipse.edc.connector.dataplane.selector.store.sql.SqlDataPlaneInstanceStore;
2323
import org.eclipse.edc.connector.dataplane.selector.store.sql.schema.DataPlaneInstanceStatements;
2424
import org.eclipse.edc.connector.dataplane.selector.store.sql.schema.postgres.PostgresDataPlaneInstanceStatements;
25-
import org.eclipse.edc.spi.types.domain.DataAddress;
2625
import org.eclipse.edc.sql.QueryExecutor;
2726
import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry;
2827
import org.eclipse.edc.transaction.spi.TransactionContext;
@@ -39,7 +38,6 @@
3938

4039
import static com.huawei.cloud.gaussdb.testfixtures.GaussDbTestExtension.DEFAULT_DATASOURCE_NAME;
4140
import static org.assertj.core.api.Assertions.assertThat;
42-
import static org.eclipse.edc.spi.result.StoreFailure.Reason.ALREADY_EXISTS;
4341

4442
@GaussDbTest
4543
@ExtendWith(GaussDbTestExtension.class)
@@ -59,7 +57,7 @@ static void deleteTable(GaussDbTestExtension.SqlHelper runner) {
5957

6058
@BeforeEach
6159
void setup(GaussDbTestExtension.SqlHelper runner, TransactionContext transactionContext, QueryExecutor queryExecutor, DataSourceRegistry reg, Clock clock) {
62-
String lease = "lease";
60+
var lease = "lease";
6361
dataPlaneInstanceStore = new SqlDataPlaneInstanceStore(reg, DEFAULT_DATASOURCE_NAME, transactionContext, SQL_STATEMENTS, new ObjectMapper(), queryExecutor, clock, lease);
6462

6563
runner.truncateTable("edc_data_plane_instance");
@@ -68,42 +66,22 @@ void setup(GaussDbTestExtension.SqlHelper runner, TransactionContext transaction
6866
@Test
6967
void save() {
7068
var inst = TestFunctions.createInstance("test-id");
71-
getStore().create(inst);
69+
getStore().save(inst);
7270
assertThat(getStore().getAll()).usingRecursiveFieldByFieldElementComparator().containsExactly(inst);
7371
}
7472

75-
@Test
76-
void save_whenExists_shouldNotUpsert() {
77-
var inst = TestFunctions.createInstance("test-id");
78-
getStore().create(inst);
79-
80-
var inst2 = DataPlaneInstance.Builder.newInstance()
81-
.id("test-id")
82-
.url("http://somewhere.other:9876/api/v2") //different URL
83-
.build();
84-
85-
var result = getStore().create(inst2);
86-
87-
assertThat(result.failed()).isTrue();
88-
assertThat(result.getFailure().getReason()).isEqualTo(ALREADY_EXISTS);
89-
90-
assertThat(getStore().getAll()).hasSize(1).usingRecursiveFieldByFieldElementComparator().containsExactly(inst);
91-
}
92-
9373
@Test
9474
void update_whenExists_shouldUpdate() {
9575
var inst = TestFunctions.createInstance("test-id");
96-
getStore().create(inst);
76+
getStore().save(inst);
9777

9878

9979
var inst2 = DataPlaneInstance.Builder.newInstance()
10080
.id("test-id")
10181
.url("http://somewhere.other:9876/api/v2") //different URL
10282
.build();
10383

104-
var result = getStore().update(inst2);
105-
106-
assertThat(result.succeeded()).isTrue();
84+
getStore().save(inst2);
10785

10886
assertThat(getStore().getAll()).hasSize(1).usingRecursiveFieldByFieldElementComparator().containsExactly(inst2);
10987
}
@@ -112,7 +90,7 @@ void update_whenExists_shouldUpdate() {
11290
void save_shouldReturnCustomInstance() {
11391
var custom = TestFunctions.createCustomInstance("test-id", "name");
11492

115-
getStore().create(custom);
93+
getStore().save(custom);
11694

11795
var customInstance = getStore().findById(custom.getId());
11896

@@ -126,7 +104,7 @@ void save_shouldReturnCustomInstance() {
126104
@Test
127105
void findById() {
128106
var inst = TestFunctions.createInstance("test-id");
129-
getStore().create(inst);
107+
getStore().save(inst);
130108

131109
assertThat(getStore().findById("test-id")).usingRecursiveComparison().isEqualTo(inst);
132110
}
@@ -143,8 +121,8 @@ void getAll() {
143121

144122
var store = getStore();
145123

146-
store.create(doc1);
147-
store.create(doc2);
124+
store.save(doc1);
125+
store.save(doc2);
148126

149127
var foundItems = store.getAll();
150128

@@ -159,10 +137,6 @@ public class TestFunctions {
159137
TestFunctions() {
160138
}
161139

162-
public static DataAddress createAddress(String type) {
163-
return DataAddress.Builder.newInstance().type("test-type").keyName(type).property("someprop", "someval").build();
164-
}
165-
166140
public static DataPlaneInstance createInstance(String id) {
167141
return org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance.Builder.newInstance().id(id).url("http://somewhere.com:1234/api/v1").build();
168142
}
@@ -172,4 +146,4 @@ public static DataPlaneInstance createCustomInstance(String id, String name) {
172146
}
173147
}
174148

175-
}
149+
}

0 commit comments

Comments
 (0)