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(tests): adds pg implementations for E2E tests #382

Merged
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
21 changes: 20 additions & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,23 @@ jobs:
- uses: ./.github/actions/setup-java

- name: Run E2E tests
run: ./gradlew :edc-tests:runtime:build test -DincludeTags="EndToEndTest"
run: ./gradlew test -DincludeTags="EndToEndTest"

postgres-tests:
runs-on: ubuntu-latest
needs: [ verify-formatting ]

services:
postgres:
image: postgres:14.2
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: password

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

- name: Run Postgresql E2E tests
run: ./gradlew test -DincludeTags="PostgresqlIntegrationTest"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.1.0-r0 --no-cache
RUN apk update && apk add curl=8.1.0-r2 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17.0.6_10-jre-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.1.0-r0 --no-cache
RUN apk update && apk add curl=8.1.0-r2 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17.0.6_10-jre-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.1.0-r0 --no-cache
RUN apk update && apk add curl=8.1.0-r2 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17.0.6_10-jre-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.1.0-r0 --no-cache
RUN apk update && apk add curl=8.1.0-r2 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17.0.6_10-jre-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.1.0-r0 --no-cache
RUN apk update && apk add curl=8.1.0-r2 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17.0.6_10-jre-alpine
Expand Down
5 changes: 5 additions & 0 deletions edc-tests/e2e-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ dependencies {
testImplementation(libs.edc.spi.dataplane.selector)
testImplementation(libs.edc.ext.jsonld)
testImplementation(libs.edc.dsp)
testImplementation(testFixtures(libs.edc.sql.core))

testCompileOnly(project(":edc-tests:runtime:extensions"))
testCompileOnly(project(":edc-tests:runtime:runtime-memory"))
testCompileOnly(project(":edc-tests:runtime:runtime-postgresql"))
}

// do not publish
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,14 @@
import org.eclipse.edc.jsonld.TitaniumJsonLd;
import org.eclipse.edc.jsonld.spi.JsonLd;
import org.eclipse.edc.jsonld.util.JacksonJsonLd;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.policy.model.PolicyRegistrationTypes;
import org.eclipse.edc.spi.EdcException;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.system.injection.InjectionContainer;
import org.eclipse.edc.spi.types.TypeManager;
import org.eclipse.edc.spi.types.domain.edr.EndpointDataReference;
import org.eclipse.tractusx.edc.helpers.AssetHelperFunctions;
import org.eclipse.tractusx.edc.helpers.ContractDefinitionHelperFunctions;
import org.eclipse.tractusx.edc.token.MockDapsService;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.net.URI;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

Expand All @@ -63,12 +51,11 @@
import static org.eclipse.tractusx.edc.helpers.TransferProcessHelperFunctions.createTransferRequest;
import static org.mockito.Mockito.mock;

public class Participant extends EdcRuntimeExtension implements BeforeAllCallback, AfterAllCallback {
public class Participant {

private final String managementUrl;
private final String apiKey;
private final String dspEndpoint;
private final TypeManager typeManager = new TypeManager();
private final String runtimeName;
private final String bpn;
private final String backend;
Expand All @@ -77,42 +64,16 @@ public class Participant extends EdcRuntimeExtension implements BeforeAllCallbac

private final ObjectMapper objectMapper = JacksonJsonLd.createObjectMapper();

private DataWiper wiper;

public Participant(String moduleName, String runtimeName, String bpn, Map<String, String> properties) {
super(moduleName, runtimeName, properties);
public Participant(String runtimeName, String bpn, Map<String, String> properties) {
this.managementUrl = URI.create(format("http://localhost:%s%s", properties.get("web.http.management.port"), properties.get("web.http.management.path"))).toString();
this.dspEndpoint = URI.create(format("http://localhost:%s%s", properties.get("web.http.protocol.port"), properties.get("web.http.protocol.path"))).toString();
this.apiKey = properties.get("edc.api.auth.key");
this.bpn = bpn;
this.runtimeName = runtimeName;
this.backend = properties.get("edc.receiver.http.dynamic.endpoint");
this.registerServiceMock(IdentityService.class, new MockDapsService(getBpn()));
jsonLd = new TitaniumJsonLd(mock(Monitor.class));
typeManager.registerTypes(PolicyRegistrationTypes.TYPES.toArray(Class<?>[]::new));

}

@Override
public void beforeTestExecution(ExtensionContext extensionContext) {
//do nothing - we only want to start the runtime once
wiper.clearPersistence();
}

@Override
public void afterTestExecution(ExtensionContext context) {
}

@Override
public void beforeAll(ExtensionContext context) throws Exception {
//only run this once
super.beforeTestExecution(context);
}

@Override
public void afterAll(ExtensionContext context) throws Exception {
super.afterTestExecution(context);
}

/**
* Creates an asset with the given ID and props using the participant's Data Management API
Expand Down Expand Up @@ -335,12 +296,6 @@ public JsonObject getDatasetForAsset(Participant provider, String assetId) {
}


@Override
protected void bootExtensions(ServiceExtensionContext context, List<InjectionContainer<ServiceExtension>> serviceExtensions) {
super.bootExtensions(context, serviceExtensions);
wiper = new DataWiper(context);
}

private RequestSpecification baseRequest() {
return given()
.baseUri(managementUrl)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2023 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
*
*/

package org.eclipse.tractusx.edc.lifecycle;

import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.system.injection.InjectionContainer;
import org.eclipse.tractusx.edc.token.MockDapsService;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.util.List;
import java.util.Map;

public class ParticipantRuntime extends EdcRuntimeExtension implements BeforeAllCallback, AfterAllCallback {


private DataWiper wiper;

public ParticipantRuntime(String moduleName, String runtimeName, String bpn, Map<String, String> properties) {
super(moduleName, runtimeName, properties);
this.registerServiceMock(IdentityService.class, new MockDapsService(bpn));
}

@Override
public void beforeTestExecution(ExtensionContext extensionContext) {
//do nothing - we only want to start the runtime once
wiper.clearPersistence();
}

@Override
public void afterTestExecution(ExtensionContext context) {
}

@Override
public void beforeAll(ExtensionContext context) throws Exception {
//only run this once
super.beforeTestExecution(context);
}

@Override
public void afterAll(ExtensionContext context) throws Exception {
super.afterTestExecution(context);
}


@Override
protected void bootExtensions(ServiceExtensionContext context, List<InjectionContainer<ServiceExtension>> serviceExtensions) {
super.bootExtensions(context, serviceExtensions);
wiper = new DataWiper(context);
}

}
Loading