Skip to content

Commit 200fb99

Browse files
authored
refactor: refactor Blob Transfer system tests (#80)
1 parent 9a1daa9 commit 200fb99

File tree

48 files changed

+686
-2900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+686
-2900
lines changed

DEPENDENCIES

Lines changed: 43 additions & 153 deletions
Large diffs are not rendered by default.

extensions/common/azure/azure-test/src/testFixtures/java/org/eclipse/edc/azure/testfixtures/AbstractAzureBlobTest.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
package org.eclipse.edc.azure.testfixtures;
1616

17-
import com.azure.storage.blob.BlobContainerClient;
1817
import com.azure.storage.blob.BlobServiceClient;
1918
import org.junit.jupiter.api.AfterEach;
2019
import org.junit.jupiter.api.BeforeEach;
2120
import org.testcontainers.containers.FixedHostPortGenericContainer;
2221
import org.testcontainers.containers.GenericContainer;
2322
import org.testcontainers.junit.jupiter.Container;
2423

25-
import java.io.File;
2624
import java.util.ArrayList;
2725
import java.util.List;
2826
import java.util.UUID;
@@ -35,35 +33,35 @@
3533
public abstract class AbstractAzureBlobTest {
3634

3735

38-
protected static final String ACCOUNT_1_NAME = "account1";
39-
protected static final String ACCOUNT_1_KEY = "key1";
40-
protected static final String ACCOUNT_2_NAME = "account2";
41-
protected static final String ACCOUNT_2_KEY = "key2";
36+
protected static final String PROVIDER_STORAGE_ACCOUNT_NAME = "account1";
37+
protected static final String PROVIDER_STORAGE_ACCOUNT_KEY = "key1";
38+
protected static final String CONSUMER_STORAGE_ACCOUNT_NAME = "account2";
39+
protected static final String CONSUMER_STORAGE_ACCOUNT_KEY = "key2";
4240
protected static final int AZURITE_PORT = getFreePort();
4341
@Container
4442
protected static final GenericContainer<?> AZURITE_CONTAINER = new FixedHostPortGenericContainer<>("mcr.microsoft.com/azure-storage/azurite")
4543
.withFixedExposedPort(AZURITE_PORT, 10000)
46-
.withEnv("AZURITE_ACCOUNTS", "%s:%s;%s:%s".formatted(ACCOUNT_1_NAME, ACCOUNT_1_KEY, ACCOUNT_2_NAME, ACCOUNT_2_KEY));
47-
protected BlobServiceClient blobServiceClient1;
48-
protected BlobServiceClient blobServiceClient2;
49-
protected String account1ContainerName;
44+
.withEnv("AZURITE_ACCOUNTS", "%s:%s;%s:%s".formatted(PROVIDER_STORAGE_ACCOUNT_NAME, PROVIDER_STORAGE_ACCOUNT_KEY, CONSUMER_STORAGE_ACCOUNT_NAME, CONSUMER_STORAGE_ACCOUNT_KEY));
45+
protected BlobServiceClient providerBlobServiceClient;
46+
protected BlobServiceClient consumerBlobServiceClient;
47+
protected String providerContainerName;
5048
protected List<Runnable> containerCleanup = new ArrayList<>();
5149
protected String testRunId = UUID.randomUUID().toString();
5250

5351
@BeforeEach
5452
public void setupClient() {
55-
account1ContainerName = "storage-container-" + testRunId;
53+
providerContainerName = "storage-container-" + testRunId;
5654

57-
blobServiceClient1 = TestFunctions.getBlobServiceClient(ACCOUNT_1_NAME, ACCOUNT_1_KEY, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, ACCOUNT_1_NAME));
58-
blobServiceClient2 = TestFunctions.getBlobServiceClient(ACCOUNT_2_NAME, ACCOUNT_2_KEY, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, ACCOUNT_2_NAME));
55+
providerBlobServiceClient = TestFunctions.getBlobServiceClient(PROVIDER_STORAGE_ACCOUNT_NAME, PROVIDER_STORAGE_ACCOUNT_KEY, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, PROVIDER_STORAGE_ACCOUNT_NAME));
56+
consumerBlobServiceClient = TestFunctions.getBlobServiceClient(CONSUMER_STORAGE_ACCOUNT_NAME, CONSUMER_STORAGE_ACCOUNT_KEY, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, CONSUMER_STORAGE_ACCOUNT_NAME));
5957

60-
createContainer(blobServiceClient1, account1ContainerName);
58+
createContainer(providerBlobServiceClient, providerContainerName);
6159
}
6260

6361
protected void createContainer(BlobServiceClient client, String containerName) {
6462
assertFalse(client.getBlobContainerClient(containerName).exists());
6563

66-
BlobContainerClient blobContainerClient = client.createBlobContainer(containerName);
64+
var blobContainerClient = client.createBlobContainer(containerName);
6765
assertTrue(blobContainerClient.exists());
6866
containerCleanup.add(() -> client.deleteBlobContainer(containerName));
6967
}
@@ -78,10 +76,4 @@ public void teardown() {
7876
}
7977
}
8078
}
81-
82-
protected void putBlob(String name, File file) {
83-
blobServiceClient1.getBlobContainerClient(account1ContainerName)
84-
.getBlobClient(name)
85-
.uploadFromFile(file.getAbsolutePath(), true);
86-
}
8779
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2023 Amadeus
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Amadeus - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.azure.testfixtures;
16+
17+
import org.eclipse.edc.junit.testfixtures.TestUtils;
18+
19+
import java.io.File;
20+
import java.io.FileInputStream;
21+
import java.io.IOException;
22+
import java.util.Properties;
23+
24+
public class AzureSettings {
25+
26+
public static final String AZURE_SETTINGS_FILE = "resources/azure/testing/runtime_settings.properties";
27+
28+
private final Properties properties;
29+
30+
public AzureSettings() {
31+
var absolutePath = azureSettingsFileAbsolutePath();
32+
try (var input = new FileInputStream(absolutePath)) {
33+
properties = new Properties();
34+
properties.load(input);
35+
} catch (IOException e) {
36+
throw new RuntimeException("Error in loading runtime settings properties", e);
37+
}
38+
}
39+
40+
public String getProperty(String key) {
41+
return properties.getProperty(key);
42+
}
43+
44+
public static String azureSettingsFileAbsolutePath() {
45+
return new File(TestUtils.findBuildRoot(), AZURE_SETTINGS_FILE).getAbsolutePath();
46+
}
47+
}

extensions/common/vault/vault-azure/src/test/java/org/eclipse/edc/vault/azure/mgmt/TestResourceManager.java

Lines changed: 0 additions & 97 deletions
This file was deleted.

extensions/data-plane/data-plane-azure-storage/src/test/java/org/eclipse/edc/connector/dataplane/azure/storage/AzureDataPlaneCopyIntegrationTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,45 +60,45 @@ class AzureDataPlaneCopyIntegrationTest extends AbstractAzureBlobTest {
6060
private final String sinkContainerName = createContainerName();
6161
private final String blobName = createBlobName();
6262
private final ExecutorService executor = Executors.newFixedThreadPool(2);
63-
private final Monitor monitor = mock(Monitor.class);
64-
private final Vault vault = mock(Vault.class);
63+
private final Monitor monitor = mock();
64+
private final Vault vault = mock();
6565

66-
private final BlobStoreApi account1Api = new BlobStoreApiImpl(vault, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, ACCOUNT_1_NAME));
67-
private final BlobStoreApi account2Api = new BlobStoreApiImpl(vault, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, ACCOUNT_2_NAME));
66+
private final BlobStoreApi account1Api = new BlobStoreApiImpl(vault, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, PROVIDER_STORAGE_ACCOUNT_NAME));
67+
private final BlobStoreApi account2Api = new BlobStoreApiImpl(vault, "http://127.0.0.1:%s/%s".formatted(AZURITE_PORT, CONSUMER_STORAGE_ACCOUNT_NAME));
6868

6969
@BeforeEach
7070
void setUp() {
71-
createContainer(blobServiceClient2, sinkContainerName);
71+
createContainer(consumerBlobServiceClient, sinkContainerName);
7272
}
7373

7474
@Test
7575
void transfer_success() {
76-
String content = "test-content";
77-
blobServiceClient1.getBlobContainerClient(account1ContainerName)
76+
var content = "test-content";
77+
providerBlobServiceClient.getBlobContainerClient(providerContainerName)
7878
.getBlobClient(blobName)
7979
.upload(BinaryData.fromString(content));
8080

81-
String account1KeyName = "test-account-key-name1";
81+
var account1KeyName = "test-account-key-name1";
8282
var source = DataAddress.Builder.newInstance()
8383
.type(TYPE)
84-
.property(ACCOUNT_NAME, ACCOUNT_1_NAME)
85-
.property(CONTAINER_NAME, account1ContainerName)
84+
.property(ACCOUNT_NAME, PROVIDER_STORAGE_ACCOUNT_NAME)
85+
.property(CONTAINER_NAME, providerContainerName)
8686
.property(BLOB_NAME, blobName)
8787
.keyName(account1KeyName)
8888
.build();
89-
when(vault.resolveSecret(account1KeyName)).thenReturn(ACCOUNT_1_KEY);
89+
when(vault.resolveSecret(account1KeyName)).thenReturn(PROVIDER_STORAGE_ACCOUNT_KEY);
9090

91-
String account2KeyName = "test-account-key-name2";
91+
var account2KeyName = "test-account-key-name2";
9292
var destination = DataAddress.Builder.newInstance()
9393
.type(TYPE)
94-
.property(ACCOUNT_NAME, ACCOUNT_2_NAME)
94+
.property(ACCOUNT_NAME, CONSUMER_STORAGE_ACCOUNT_NAME)
9595
.property(CONTAINER_NAME, sinkContainerName)
9696
.keyName(account2KeyName)
9797
.build();
9898

99-
when(vault.resolveSecret(ACCOUNT_2_NAME + "-key1"))
100-
.thenReturn(ACCOUNT_2_KEY);
101-
var account2SasToken = account2Api.createContainerSasToken(ACCOUNT_2_NAME, sinkContainerName, "w", OffsetDateTime.MAX.minusDays(1));
99+
when(vault.resolveSecret(CONSUMER_STORAGE_ACCOUNT_NAME + "-key1"))
100+
.thenReturn(CONSUMER_STORAGE_ACCOUNT_KEY);
101+
var account2SasToken = account2Api.createContainerSasToken(CONSUMER_STORAGE_ACCOUNT_NAME, sinkContainerName, "w", OffsetDateTime.MAX.minusDays(1));
102102
var secretToken = new AzureSasToken(account2SasToken, Long.MAX_VALUE);
103103
when(vault.resolveSecret(account2KeyName))
104104
.thenReturn(typeManager.writeValueAsString(secretToken));
@@ -121,7 +121,7 @@ void transfer_success() {
121121
.succeedsWithin(500, TimeUnit.MILLISECONDS)
122122
.satisfies(transferResult -> assertThat(transferResult.succeeded()).isTrue());
123123

124-
var destinationBlob = blobServiceClient2
124+
var destinationBlob = consumerBlobServiceClient
125125
.getBlobContainerClient(sinkContainerName)
126126
.getBlobClient(blobName);
127127
assertThat(destinationBlob.exists())

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ edc-transfer-dataplane = { module = "org.eclipse.edc:transfer-data-plane", versi
7676
edc-transfer-httppull-receiver = { module = "org.eclipse.edc:transfer-pull-http-receiver", version.ref = "edc" }
7777
edc-transfer-httppull-receiver-dynamic = { module = "org.eclipse.edc:transfer-pull-http-dynamic-receiver", version.ref = "edc" }
7878
edc-util = { module = "org.eclipse.edc:util", version.ref = "edc" }
79+
edc-management-api-test-fixtures = { module = "org.eclipse.edc:management-api-test-fixtures", version.ref = "edc" }
7980

8081
# EDC dependencies for testing
8182
edc-sql-core = { module = "org.eclipse.edc:sql-core", version.ref = "edc" }

settings.gradle.kts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,11 @@ include(":extensions:identity-hub:identity-hub-store-cosmos")
6868
include(":extensions:registration-service:participant-store-cosmos")
6969

7070
// system test modules
71+
include(":system-tests:azure-blob-transfer-tests")
7172
include(":system-tests:azure-data-factory-tests")
72-
include(":system-tests:azure-tests")
73-
//include(":system-tests:e2e-transfer-test:control-plane-cosmosdb")
74-
include(":system-tests:e2e-transfer-test:control-plane")
75-
include(":system-tests:e2e-transfer-test:runner")
76-
include(":system-tests:tests")
7773
include(":system-tests:runtimes:azure-data-factory-transfer-consumer")
7874
include(":system-tests:runtimes:azure-data-factory-transfer-provider")
7975
include(":system-tests:runtimes:azure-storage-transfer-consumer")
8076
include(":system-tests:runtimes:azure-storage-transfer-provider")
81-
include(":system-tests:e2e-transfer-test:backend-service")
82-
include(":system-tests:e2e-transfer-test:data-plane")
77+
include(":system-tests:azure-blob-transfer-fixtures")
8378
include(":version-catalog")
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2022 Microsoft Corporation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Microsoft Corporation - initial API and implementation
12+
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
13+
*
14+
*/
15+
16+
plugins {
17+
`java-test-fixtures`
18+
}
19+
20+
dependencies {
21+
testFixturesApi(project(":extensions:common:azure:azure-blob-core"))
22+
testFixturesApi(libs.edc.jsonld)
23+
testFixturesApi(testFixtures(libs.edc.management.api.test.fixtures))
24+
25+
testFixturesImplementation(libs.restAssured)
26+
testFixturesImplementation(libs.azure.storageblob)
27+
testFixturesImplementation(libs.edc.junit)
28+
testFixturesImplementation(libs.assertj)
29+
}
30+
31+
edcBuild {
32+
publish.set(false)
33+
}

0 commit comments

Comments
 (0)