Skip to content

Commit

Permalink
feat: add azure dataplane (#755)
Browse files Browse the repository at this point in the history
* feat: add Azure Blob data plane packages

* formatting/checkstyle

* small test runtime simplification

* add test step for dataplane tests

* DEPENDENCIES

* pr remarks - formatting

* pr remarks - constants
  • Loading branch information
paullatzelsperger authored Sep 15, 2023
1 parent b17cbc0 commit 3ac36f1
Show file tree
Hide file tree
Showing 21 changed files with 1,682 additions and 149 deletions.
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
*
*/

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

0 comments on commit 3ac36f1

Please sign in to comment.