Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add azure dataplane #755

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ jobs:
- name: Run Postgresql E2E tests
run: ./gradlew test -DincludeTags="PostgresqlIntegrationTest" -PverboseTest=true

dataplane-tests:
runs-on: ubuntu-latest
needs: [ verify-formatting, verify-license-headers ]

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-java

- name: Run Azure/S3 dataplane tests
run: ./gradlew -p edc-tests/edc-dataplane test -DincludeTags="AzureCosmosDbIntegrationTest,AwsS3IntegrationTest"

miw-integration-tests:
runs-on: ubuntu-latest
needs: [ verify-formatting, verify-license-headers ]
Expand Down Expand Up @@ -183,7 +194,7 @@ jobs:
docker exec docker-environment-postgres-1 /opt/seed.sh

- name: Run MIW Integration tests
run: |
run: |
./gradlew -p edc-tests/miw-tests test -DincludeTags="MiwIntegrationTest" -PverboseTest=true
- name: Run SSI E2E tests
run: |
Expand Down
285 changes: 142 additions & 143 deletions DEPENDENCIES

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions edc-dataplane/edc-dataplane-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
runtimeOnly(libs.edc.config.filesystem)
runtimeOnly(libs.edc.auth.tokenbased)
runtimeOnly(libs.edc.dpf.awss3)
runtimeOnly(libs.edc.dpf.azblob)
runtimeOnly(libs.edc.dpf.oauth2)
runtimeOnly(libs.edc.dpf.http)

Expand Down
45 changes: 45 additions & 0 deletions edc-tests/edc-dataplane/cloud-transfer-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
*
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

paullatzelsperger marked this conversation as resolved.
Show resolved Hide resolved
plugins {
`java-library`
}

dependencies {

testImplementation(project(":edc-tests:e2e-tests"))
testImplementation(libs.edc.junit)
testImplementation(libs.restAssured)

// test runtime config
testImplementation(libs.edc.config.filesystem)
testImplementation(libs.edc.dpf.http)
testImplementation(libs.edc.auth.tokenbased)
testImplementation(libs.testcontainers.junit)
testImplementation(testFixtures(libs.edc.azure.test))
testImplementation(libs.edc.aws.s3.core)
testImplementation(testFixtures(libs.edc.aws.s3.test))
testImplementation(libs.aws.s3)
testImplementation(libs.aws.s3transfer)
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
*
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

package org.eclipse.tractusx.edc.dataplane.transfer.test;

import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.models.BlobItem;
import com.azure.storage.blob.sas.BlobContainerSasPermission;
import com.azure.storage.blob.sas.BlobServiceSasSignatureValues;

import java.io.IOException;
import java.io.InputStream;
import java.time.OffsetDateTime;
import java.util.List;

import static org.eclipse.edc.azure.testfixtures.TestFunctions.getBlobServiceClient;

/**
* Helper class that internally uses Azure SDK classes to create containers, upload blobs, generate SAS tokens, etc.
*/
public class AzureBlobHelper {
private final String accountName;
private final String key;
private final String host;
private final int port;
private BlobServiceClient blobServiceClient;

public AzureBlobHelper(String accountName, String key, String host, int port) {
this.accountName = accountName;
this.key = key;
this.host = host;
this.port = port;
}

public BlobContainerClient createContainer(String containerName) {
return blobClient().createBlobContainer(containerName);
}

private BlobServiceClient blobClient() {
if (blobServiceClient == null) {
var endpoint = "http://%s:%s/%s".formatted(host, port, accountName);
blobServiceClient = getBlobServiceClient(accountName, key, endpoint);
}
return blobServiceClient;
}

public void uploadBlob(BlobContainerClient client, InputStream inputStream, String targetBlobName) {
client.getBlobClient(targetBlobName).upload(inputStream, true);
}

public void uploadBlob(BlobContainerClient client, String resourceName) {
try (var is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName)) {
client.getBlobClient(resourceName).upload(is, true);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public List<String> listBlobs(String container) {
if (blobClient().listBlobContainers().stream().noneMatch(bci -> bci.getName().equalsIgnoreCase(container))) {
return List.of();
}
return blobClient()
.getBlobContainerClient(container)
.listBlobs()
.stream().map(BlobItem::getName)
.toList();
}

public String generateAccountSas(String containerName) {
var expiry = OffsetDateTime.MAX.minusDays(1);
var permissions = BlobContainerSasPermission.parse("w");
var vals = new BlobServiceSasSignatureValues(expiry, permissions);
return blobClient().getBlobContainerClient(containerName).generateSas(vals);
}
}
Loading