Skip to content

Commit

Permalink
refactor: extract validator-data-address-s3 module
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jun 21, 2024
1 parent 484fb46 commit 5b8b629
Show file tree
Hide file tree
Showing 35 changed files with 330 additions and 438 deletions.
70 changes: 4 additions & 66 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ concurrency:
cancel-in-progress: true

jobs:

Checkstyle:
permissions:
id-token: write
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -43,81 +40,23 @@ jobs:
with:
command: ./gradlew test jacocoTestReport

Component-Tests:
env:
JACOCO: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/setup-build@main

- name: Component Tests
uses: eclipse-edc/.github/.github/actions/run-tests@main
with:
command: ./gradlew jacocoTestReport -DincludeTags="ComponentTest"

End-To-End-Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/setup-build@main

- name: End to End Integration Tests
uses: eclipse-edc/.github/.github/actions/run-tests@main
with:
command: ./gradlew test -DincludeTags="EndToEndTest"

API-Tests:
env:
JACOCO: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/setup-build@main

- name: Component Tests
uses: eclipse-edc/.github/.github/actions/run-tests@main
with:
command: ./gradlew test jacocoTestReport -DincludeTags="ApiTest"

Aws-Integration-Tests:
runs-on: ubuntu-latest

env:
S3_ACCESS_KEY_ID: root
S3_SECRET_ACCESS_KEY: password

services:
minio-source:
image: bitnami/minio:latest
ports:
- 9000:9000
env:
MINIO_ROOT_USER: root
MINIO_ROOT_PASSWORD: password
minio-destination:
image: bitnami/minio:latest
ports:
- 9002:9000
env:
MINIO_ROOT_USER: root
MINIO_ROOT_PASSWORD: password

steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/setup-build@main

- name: AWS Tests
- name: End to End Integration Tests
uses: eclipse-edc/.github/.github/actions/run-tests@main
with:
command: ./gradlew -p extensions test -DincludeTags="AwsS3IntegrationTest"
command: ./gradlew test -DincludeTags="EndToEndTest"

Upload-Test-Report:
needs:
- Unit-Tests
- Aws-Integration-Tests
- End-To-End-Tests
- Component-Tests

permissions:
checks: write
Expand All @@ -139,8 +78,7 @@ jobs:
Upload-Coverage-Report-To-Codecov:
needs:
- Unit-Tests
- Component-Tests
- API-Tests
- End-To-End-Tests
runs-on: ubuntu-latest
if: always()
steps:
Expand Down
1 change: 1 addition & 0 deletions extensions/common/aws/aws-s3-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins {
}

dependencies {
api(project(":spi:common:aws-spi"))
api(libs.edc.spi.transfer)
api(libs.edc.spi.validation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.Objects;
import java.util.stream.Stream;

import static org.eclipse.edc.aws.s3.S3BucketSchema.ACCESS_KEY_ID;
import static org.eclipse.edc.aws.s3.S3BucketSchema.SECRET_ACCESS_KEY;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.ACCESS_KEY_ID;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.SECRET_ACCESS_KEY;
import static org.eclipse.edc.validator.spi.Violation.violation;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@
#

org.eclipse.edc.aws.s3.S3CoreExtension
org.eclipse.edc.aws.s3.S3DataAddressValidatorExtension
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.aws.s3.S3BucketSchema.ACCESS_KEY_ID;
import static org.eclipse.edc.aws.s3.S3BucketSchema.SECRET_ACCESS_KEY;
import static org.eclipse.edc.aws.s3.S3BucketSchema.TYPE;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.ACCESS_KEY_ID;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.SECRET_ACCESS_KEY;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.TYPE;
import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat;

public class S3DataAddressCredentialsValidatorTest {
Expand Down
2 changes: 1 addition & 1 deletion extensions/common/aws/aws-s3-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for running integration tests against AWS S3 by environment variable:
$ IT_AWS_ENDPOINT=https://s3.us-east-1.amazonaws.com/ \
IT_AWS_REGION=us-east-1 \
IT_AWS_PROFILE=myprofie \
./gradlew clean test -DincludeTags="AwsS3IntegrationTest"
./gradlew clean test -DincludeTags="EndToEndTest"
```

`IT_AWS_REGION` must be set to your region code in order to avoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.eclipse.edc.aws.s3.testfixtures;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import software.amazon.awssdk.regions.Region;

Expand All @@ -30,7 +29,10 @@

/**
* Base class for tests that need an S3 bucket created and deleted on every test run.
*
* @deprecated it is not used anymore in the Technology-Aws repository, so it will be removed.
*/
@Deprecated(since = "0.7.1")
public abstract class AbstractS3Test {

protected static final String REGION = propOrEnv("it.aws.region", Region.US_EAST_1.id());
Expand All @@ -46,16 +48,13 @@ public abstract class AbstractS3Test {
protected String bucketName = "test-bucket-" + UUID.randomUUID() + "-" + REGION;

protected S3TestClient sourceClient = S3TestClient.create(SOURCE_MINIO_ENDPOINT, REGION);

protected S3TestClient destinationClient = S3TestClient.create(DESTINATION_MINIO_ENDPOINT, REGION);

protected static final String OBJECT_PREFIX = "object-prefix/";

protected static final String OBJECT_NAME = "text-document.txt";

protected static final String KEY_NAME = "key-name";

@BeforeAll
@BeforeEach
void prepareAll() {
await().atLeast(Duration.ofSeconds(2))
.atMost(Duration.ofSeconds(15))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class S3TestClient {
private S3TestClient(String url, String region) {
this.url = url;
this.s3Endpoint = URI.create(propOrEnv("it.aws.endpoint", url));
AwsClientProviderConfiguration configuration = AwsClientProviderConfiguration.Builder.newInstance()
var configuration = AwsClientProviderConfiguration.Builder.newInstance()
.credentialsProvider(this::getCredentials)
.endpointOverride(this.s3Endpoint)
.build();
Expand Down Expand Up @@ -93,7 +93,7 @@ public static S3TestClient create(String url, String region) {
*
* @return true if HTTP status [200..300[
*/
protected boolean isAvailable() throws IOException {
public boolean isAvailable() throws IOException {
var httpClient = testHttpClient();
var healthRq = new Request.Builder().url(s3Endpoint + "/minio/health/live").get().build();
try (var response = httpClient.execute(healthRq)) {
Expand Down Expand Up @@ -178,7 +178,7 @@ public CompletableFuture<ResponseBytes<GetObjectResponse>> getObject(String buck
.getObject(GetObjectRequest.builder().bucket(bucketName).key(key).build(), new ByteArrayAsyncResponseTransformer<>());
}

protected boolean isMinio() {
public boolean isMinio() {
return url.equals(s3Endpoint.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@

/**
* Annotation for AWS S3 integration testing. It applies specific Junit Tag.
*
* @deprecated not used anymore, please use {@link org.eclipse.edc.junit.annotations.EndToEndTest}.
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@IntegrationTest
@Tag("AwsS3IntegrationTest")
@Deprecated(since = "0.7.1")
public @interface AwsS3IntegrationTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* 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
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

plugins {
`java-library`
}

dependencies {
api(project(":spi:common:aws-spi"))
api(libs.edc.spi.validation)

testImplementation(libs.edc.junit)
}


Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
*
*/

package org.eclipse.edc.aws.s3;
package org.eclipse.edc.aws.s3.validator;

import org.eclipse.edc.aws.s3.validation.S3DestinationDataAddressValidator;
import org.eclipse.edc.aws.s3.validation.S3SourceDataAddressValidator;
import org.eclipse.edc.aws.s3.spi.S3BucketSchema;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.validator.spi.DataAddressValidatorRegistry;

import static org.eclipse.edc.aws.s3.S3DataAddressValidatorExtension.NAME;
import static org.eclipse.edc.aws.s3.validator.S3DataAddressValidatorExtension.NAME;

@Extension(NAME)
public class S3DataAddressValidatorExtension implements ServiceExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.aws.s3.validation;
package org.eclipse.edc.aws.s3.validator;

import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.validator.spi.ValidationResult;
Expand All @@ -21,8 +21,8 @@
import java.util.Objects;
import java.util.stream.Stream;

import static org.eclipse.edc.aws.s3.S3BucketSchema.BUCKET_NAME;
import static org.eclipse.edc.aws.s3.S3BucketSchema.REGION;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.BUCKET_NAME;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.REGION;
import static org.eclipse.edc.validator.spi.Violation.violation;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.aws.s3.validation;
package org.eclipse.edc.aws.s3.validator;

import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.validator.spi.ValidationResult;
Expand All @@ -22,12 +22,12 @@
import java.util.ArrayList;
import java.util.stream.Stream;

import static org.eclipse.edc.aws.s3.S3BucketSchema.BUCKET_NAME;
import static org.eclipse.edc.aws.s3.S3BucketSchema.KEY_NAME;
import static org.eclipse.edc.aws.s3.S3BucketSchema.KEY_PREFIX;
import static org.eclipse.edc.aws.s3.S3BucketSchema.OBJECT_NAME;
import static org.eclipse.edc.aws.s3.S3BucketSchema.OBJECT_PREFIX;
import static org.eclipse.edc.aws.s3.S3BucketSchema.REGION;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.BUCKET_NAME;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.KEY_NAME;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.KEY_PREFIX;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.OBJECT_NAME;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.OBJECT_PREFIX;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.REGION;
import static org.eclipse.edc.validator.spi.Violation.violation;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# 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
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
#

org.eclipse.edc.aws.s3.validator.S3DataAddressValidatorExtension
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
*
*/

package org.eclipse.edc.aws.s3;
package org.eclipse.edc.aws.s3.validator;


import org.eclipse.edc.aws.s3.validation.S3DestinationDataAddressValidator;
import org.eclipse.edc.aws.s3.validation.S3SourceDataAddressValidator;
import org.eclipse.edc.aws.s3.spi.S3BucketSchema;
import org.eclipse.edc.junit.extensions.DependencyInjectionExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.validator.spi.DataAddressValidatorRegistry;
Expand All @@ -31,7 +30,7 @@
import static org.mockito.Mockito.verify;

@ExtendWith(DependencyInjectionExtension.class)
public class S3DestinationDataAddressValidatorExtensionTest {
public class S3DataAddressValidatorExtensionTest {

private final DataAddressValidatorRegistry registry = mock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
*
*/

package org.eclipse.edc.aws.s3.validation;
package org.eclipse.edc.aws.s3.validator;

import org.eclipse.edc.spi.types.domain.DataAddress;
import org.eclipse.edc.validator.spi.ValidationFailure;
import org.eclipse.edc.validator.spi.Violation;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.aws.s3.S3BucketSchema.BUCKET_NAME;
import static org.eclipse.edc.aws.s3.S3BucketSchema.REGION;
import static org.eclipse.edc.aws.s3.S3BucketSchema.TYPE;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.BUCKET_NAME;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.REGION;
import static org.eclipse.edc.aws.s3.spi.S3BucketSchema.TYPE;
import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat;

public class S3DestinationDataAddressValidatorTest {
Expand Down
Loading

0 comments on commit 5b8b629

Please sign in to comment.