Skip to content

Commit

Permalink
feat(ci): use E2E tests for BOM smoke tests (#4550)
Browse files Browse the repository at this point in the history
* feat(ci): use E2E tests for BOM Smoke tests

* pr remarks
  • Loading branch information
paullatzelsperger authored Oct 15, 2024
1 parent 8cd7cc2 commit c777edd
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 33 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Run Tests
on:
workflow_dispatch:
push:
branches: [main, release/*, bugfix/*]
branches: [ main, release/*, bugfix/* ]
pull_request:
branches: [main, release/*, bugfix/*]
branches: [ main, release/*, bugfix/* ]
paths-ignore:
- "**.md"
- "docs/**"
Expand Down Expand Up @@ -91,15 +91,3 @@ jobs:
uses: eclipse-edc/.github/.github/workflows/verify-openapi.yml@main
secrets: inherit

Verify-EDC-BOM:
strategy:
fail-fast: false

# we can't test the "controlplane-oauth2-com" because it only starts successfully if the public key is already in the vault
matrix:
bom-directory:
["dist/bom/controlplane-dcp-bom", "dist/bom/sts-feature-bom"]
uses: eclipse-edc/.github/.github/workflows/verify-bom.yml@main
with:
module-dir: ${{ matrix.bom-directory }}
properties-file: example.properties
7 changes: 0 additions & 7 deletions dist/bom/controlplane-dcp-bom/example.properties

This file was deleted.

5 changes: 0 additions & 5 deletions dist/bom/controlplane-oauth2-bom/example.properties

This file was deleted.

6 changes: 0 additions & 6 deletions dist/bom/dataplane-base-bom/example.properties

This file was deleted.

1 change: 0 additions & 1 deletion dist/bom/sts-feature-bom/example.properties

This file was deleted.

1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ include(":system-tests:sts-api:sts-api-test-runner")
include(":system-tests:sts-api:sts-api-test-runtime")
include(":system-tests:telemetry:telemetry-test-runner")
include(":system-tests:telemetry:telemetry-test-runtime")
include(":system-tests:bom-tests")

// BOM modules ----------------------------------------------------------------
include(":dist:bom:controlplane-base-bom")
Expand Down
31 changes: 31 additions & 0 deletions system-tests/bom-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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
}

dependencies {
testImplementation(project(":core:common:junit"))
testImplementation(project(":core:common:lib:boot-lib"))
testImplementation(libs.restAssured)
testImplementation(libs.assertj)
testImplementation(libs.awaitility)
testImplementation(libs.mockserver.netty)
testImplementation(libs.mockserver.client)
}

edcBuild {
publish.set(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* 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
*
*/

package org.eclipse.edc.test.bom;

import org.eclipse.edc.boot.vault.InMemoryVault;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
import org.eclipse.edc.junit.extensions.RuntimePerMethodExtension;
import org.eclipse.edc.spi.security.Vault;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockserver.integration.ClientAndServer;

import java.util.Map;

import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.junit.testfixtures.TestUtils.getResourceFileContentAsString;
import static org.eclipse.edc.util.io.Ports.getFreePort;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;
import static org.mockserver.stop.Stop.stopQuietly;

public class BomSmokeTests {
abstract static class SmokeTest {
public static final String DEFAULT_PORT = "8080";
public static final String DEFAULT_PATH = "/api";

@Test
void assertRuntimeReady() {
await().untilAsserted(() -> given()
.baseUri("http://localhost:" + DEFAULT_PORT + DEFAULT_PATH + "/check/startup")
.get()
.then()
.statusCode(200)
.log().ifValidationFails()
.body("isSystemHealthy", equalTo(true)));

}
}

@Nested
@EndToEndTest
class ControlPlaneDcp extends SmokeTest {

@RegisterExtension
protected RuntimeExtension runtime =
new RuntimePerMethodExtension(new EmbeddedRuntime("control-plane-dcp-bom",
Map.of(
"edc.iam.sts.oauth.token.url", "https://sts.com/token",
"edc.iam.sts.oauth.client.id", "test-client",
"edc.iam.sts.oauth.client.secret.alias", "test-alias",
"web.http.port", DEFAULT_PORT,
"web.http.path", DEFAULT_PATH,
"web.http.management.port", "8081",
"web.http.management.path", "/api/management"),
":dist:bom:controlplane-dcp-bom"
));
}

@Nested
@EndToEndTest
class ControlPlaneOauth2 extends SmokeTest {

@RegisterExtension
protected static RuntimeExtension runtime =
new RuntimePerMethodExtension(new EmbeddedRuntime("control-plane-oauth2-bom",
Map.of(
"edc.oauth.token.url", "https://oauth2.com/token",
"edc.oauth.certificate.alias", "test-alias",
"edc.oauth.private.key.alias", "private-test-alias",
"web.http.management.port", "8081",
"web.http.management.path", "/api/management",
"web.http.port", DEFAULT_PORT,
"web.http.path", DEFAULT_PATH,
"edc.oauth.provider.jwks.url", "http://localhost:9999/jwks",
"edc.oauth.client.id", "test-client"),
":dist:bom:controlplane-oauth2-bom"
));
private static ClientAndServer jwksServer;

@BeforeAll
static void setup() {
var v = new InMemoryVault(mock());
v.storeSecret("test-alias", getResourceFileContentAsString("cert.pem"));
runtime.registerServiceMock(Vault.class, v);

// mock the JWKS server, respond with some arbitrary JWKS
jwksServer = ClientAndServer.startClientAndServer(9999);
jwksServer.when(request().withPath("/jwks").withMethod("GET"))
.respond(response().withStatusCode(200).withBody(getResourceFileContentAsString("jwks_response.json")));
}

@AfterAll
static void cleanup() {
stopQuietly(jwksServer);
}
}

@Nested
@EndToEndTest
public class DataPlaneBase extends SmokeTest {

private static ClientAndServer server;
@RegisterExtension
protected RuntimeExtension runtime =
new RuntimePerMethodExtension(new EmbeddedRuntime("data-plane-base-bom",
Map.of(
"edc.transfer.proxy.token.verifier.publickey.alias", "test-alias",
"edc.transfer.proxy.token.signer.privatekey.alias", "private-alias",
"edc.dpf.selector.url", "http://localhost:%s/selector".formatted(server.getPort()),
"web.http.control.port", "8081",
"web.http.control.path", "/api/control",
"web.http.port", DEFAULT_PORT,
"web.http.path", DEFAULT_PATH),
":dist:bom:dataplane-base-bom"
));

@BeforeAll
static void setup() {
server = ClientAndServer.startClientAndServer(getFreePort());
server.when(request().withPath("/selector"))
.respond(response().withStatusCode(200));
}

@AfterAll
static void afterAll() {
stopQuietly(server);
}
}

@Nested
@EndToEndTest
class StsFeature extends SmokeTest {

@RegisterExtension
protected RuntimeExtension runtime =
new RuntimePerMethodExtension(new EmbeddedRuntime("data-plane-base-bom",
Map.of(
"web.http.port", DEFAULT_PORT,
"web.http.path", DEFAULT_PATH,
"edc.api.accounts.key", "password"),
":dist:bom:sts-feature-bom"
));
}
}
13 changes: 13 additions & 0 deletions system-tests/bom-tests/src/test/resources/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIIB7DCCAVWgAwIBAgIGAYHYExlWMA0GCSqGSIb3DQEBCwUAMA8xDTALBgNVBAMM
BFRlc3QwHhcNMjIwNzA3MDk1MjE5WhcNMzIwNzA0MDk1MjE5WjAPMQ0wCwYDVQQD
DARUZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHggAW6QF9E2N2y37U
xcacS+LFZwyVIFJkd/Zbe4JF0N+qqPGgRO8kMYiXb12geuJ+lxobLQkOlsnztkfX
htVLkYoruSthMQORC/fZDhP1eV5KpR0LVACoQmLJBTbKE2tOJh5HODxvzhiV+Bi5
DAWOhmkA1dYo1UFg8ORt/YzOvQIDAQABo1MwUTAdBgNVHQ4EFgQUwxs2XndsvlwH
4JqFpqMXF9mEDVAwHwYDVR0jBBgwFoAUwxs2XndsvlwH4JqFpqMXF9mEDVAwDwYD
VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQCajJWQ7x7TEZvCRXWr3J43
WFoOZBjhKwDtNySoeF/mJvxEcWzeCfxvqO/zQ16+vMj/+1kW7+eex8dSYBfRtb83
MjOtKQYd4PU5uH4QqFFyJ3oH72ZItTAikfuRcrV0Gu7lsLSkLjglUFAREr8aI0QC
0SDLUMXw7nNsSJ/s2yIiVw==
-----END CERTIFICATE-----
20 changes: 20 additions & 0 deletions system-tests/bom-tests/src/test/resources/jwks_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"keys": [
{
"kty": "RSA",
"kid": "1438289820780",
"use": "sig",
"alg": "RS256",
"n": "idWPro_QiAFOdMsJD163lcDIPogOwXogRo3Pct2MMyeE2GAGqV20Sc8QUbuLDfPl-7Hi9IfFOz--JY6QL5l92eV-GJXkTmidUEooZxIZSp3ghRxLCqlyHeF5LuuM5LPRFDeF4YWFQT_D2eNo_w95g6qYSeOwOwGIfaHa2RMPcQAiM6LX4ot-Z7Po9z0_3ztFa02m3xejEFr2rLRqhFl3FZJaNnwTUk6an6XYsunxMk3Ya3lRaKJReeXeFtfTpShgtPiAl7lIfLJH9h26h2OAlww531DpxHSm1gKXn6bjB0NTC55vJKft4wXoc_0xKZhnWmjQE8d9xE8e1Z3Ll1LYbw",
"e": "AQAB"
},
{
"kty": "RSA",
"kid": "1438289856256",
"use": "sig",
"alg": "RS256",
"n": "zo5cKcbFECeiH8eGx2D-DsFSpjSKbTVlXD6uL5JAy9rYIv7eYEP6vrKeX-x1z70yEdvgk9xbf9alc8siDfAz3rLCknqlqL7XGVAQL0ZP63UceDmD60LHOzMrx4eR6p49B3rxFfjvX2SWSV3-1H6XNyLk_ALbG6bGCFGuWBQzPJB4LMKCrOFq-6jtRKOKWBXYgkYkaYs5dG-3e2ULbq-y2RdgxYh464y_-MuxDQfvUgP787XKfcXP_XjJZvyuOEANjVyJYZSOyhHUlSGJapQ8ztHdF-swsnf7YkePJ2eR9fynWV2ZoMaXOdidgZtGTa4R1Z4BgH2C0hKJiqRy9fB7Gw",
"e": "AQAB"
}
]
}

0 comments on commit c777edd

Please sign in to comment.