Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,6 @@ jobs:
mvn -B install --file src/pom.xml
mvn -B verify --file src/server-am/pom.xml
mvn -B verify --file src/server-cm/pom.xml
mvn -B clean package --file src/server-cm/pom.xml -Pembedded-jetty
mvn -B verify --file src/server-qm/pom.xml
mvn -B verify --file src/server-rm/pom.xml
20 changes: 20 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ gated behind the `acceptance` Maven profile.

The `acceptance` profile (adds `refimpl-tests`) is **off by default**.

### Packaging targets (`server-cm`)

`server-cm` keeps `<packaging>war</packaging>` and shares `src/server-cm/src/main/webapp/`
(`WEB-INF/web.xml`, JSPs, static assets, `oauth-webapp`, Swagger UI) across three builds:

# 1. Jetty WAR (default; uses server-cm/Dockerfile)
mvn -B clean package --file pom.xml -pl server-cm -am

# 2. Tomcat WAR (adds JSTL impl; uses server-cm/tomcat.Dockerfile)
mvn -B clean package --file pom.xml -pl server-cm -am -Pwith-jstl-impl

# 3. Single-JAR Embedded Jetty 12 (builds target/server-cm.jar + target/lib/; uses server-cm/slim.Dockerfile)
mvn -B clean package --file pom.xml -pl server-cm -am -Pembedded-jetty
java -jar server-cm/target/server-cm.jar

To run Docker Compose or acceptance tests against the slim embedded-Jetty `server-cm` image:

docker compose -f docker-compose.yml -f docker-compose.slim.yml up --build
mvn -B clean verify --file pom.xml -Pacceptance -Dserver.cm.slim=true

## Tests

### Without Docker (default)
Expand Down
5 changes: 5 additions & 0 deletions src/docker-compose.slim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
server-cm:
build:
context: ./
dockerfile: server-cm/slim.Dockerfile
20 changes: 8 additions & 12 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,29 @@ services:
dockerfile: server-rm/Dockerfile
ports:
- "127.0.0.1:8800:8080"
# Uncomment to configure the base URL for reverse proxy or custom domain deployments
# environment:
# - LYO_BASEURL=https://mytoolchain.example.com:9443/refimpl/rm
environment:
- LYO_BASEURL=http://localhost:8800/
server-cm:
build:
context: ./
dockerfile: server-cm/Dockerfile
ports:
- "127.0.0.1:8801:8080"
# Uncomment to configure the base URL for reverse proxy or custom domain deployments
# environment:
# - LYO_BASEURL=https://mytoolchain.example.com:9443/refimpl/cm
environment:
- LYO_BASEURL=http://localhost:8801/
server-qm:
build:
context: ./
dockerfile: server-qm/Dockerfile
ports:
- "127.0.0.1:8802:8080"
# Uncomment to configure the base URL for reverse proxy or custom domain deployments
# environment:
# - LYO_BASEURL=https://mytoolchain.example.com:9443/refimpl/qm
environment:
- LYO_BASEURL=http://localhost:8802/
server-am:
build:
context: ./
dockerfile: server-am/Dockerfile
ports:
- "127.0.0.1:8803:8080"
# Uncomment to configure the base URL for reverse proxy or custom domain deployments
# environment:
# - LYO_BASEURL=https://mytoolchain.example.com:9443/refimpl/am
environment:
- LYO_BASEURL=http://localhost:8803/
12 changes: 7 additions & 5 deletions src/refimpl-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>co.oslc.refimpl</groupId>
Expand All @@ -22,7 +23,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<useModulePath>false</useModulePath> <!-- https://issues.apache.org/jira/browse/SUREFIRE-1809 -->
<useModulePath>false</useModulePath> <!--
https://issues.apache.org/jira/browse/SUREFIRE-1809 -->
<useFile>false</useFile>
</configuration>
</plugin>
Expand Down Expand Up @@ -57,8 +59,8 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.21.4</version>
<artifactId>testcontainers-junit-jupiter</artifactId>
<version>2.0.5</version>
<scope>test</scope>
</dependency>
<!-- Playwright -->
Expand Down
36 changes: 25 additions & 11 deletions src/refimpl-tests/src/test/java/co/oslc/refimpl/tests/OslcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import java.io.File;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -26,31 +28,43 @@ public class OslcTest {
static final int QM_PORT = 8080;
static final int AM_PORT = 8080;

public static ComposeContainer environment = new ComposeContainer(new File("src/test/resources/docker-compose.yml"))
public static ComposeContainer environment = new ComposeContainer(composeFiles())
.withExposedService(RM_SVC, RM_PORT,
Wait.forLogMessage(".*main: Started oejs.Server@.*", 1)
Wait.forLogMessage(".*Started oejs\\.Server@.*", 1)
.withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
.withExposedService(CM_SVC, CM_PORT,
Wait.forLogMessage(".*main: Started oejs.Server@.*", 1)
Wait.forLogMessage(".*Started oejs\\.Server@.*", 1)
.withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
.withExposedService(QM_SVC, QM_PORT,
Wait.forLogMessage(".*main: Started oejs.Server@.*", 1)
Wait.forLogMessage(".*Started oejs\\.Server@.*", 1)
.withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
.withExposedService(AM_SVC, AM_PORT,
Wait.forLogMessage(".*main: Started oejs.Server@.*", 1)
.withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)))
.withLocalCompose(true);
Wait.forLogMessage(".*Started oejs\\.Server@.*", 1)
.withStartupTimeout(Duration.ofSeconds(STARTUP_TIMEOUT)));

static {
environment.start();
}

private static List<File> composeFiles() {
List<File> files = new ArrayList<>();
files.add(new File("src/test/resources/docker-compose.yml"));
boolean slim = Boolean.parseBoolean(System.getProperty(
"server.cm.slim",
System.getenv().getOrDefault("SERVER_CM_SLIM", "false")));
if (slim) {
files.add(new File("src/test/resources/docker-compose.slim.yml"));
}
System.out.println("Using compose files: " + files);
return files;
}

@ParameterizedTest
@CsvSource({
RM_SVC + ", " + RM_PORT,
CM_SVC + ", " + CM_PORT,
QM_SVC + ", " + QM_PORT,
AM_SVC + ", " + AM_PORT
RM_SVC + ", " + RM_PORT,
CM_SVC + ", " + CM_PORT,
QM_SVC + ", " + QM_PORT,
AM_SVC + ", " + AM_PORT
})
void rootservicesDataTableTest(String svc, int port) {
assertEquals(200, testRootServices(svc, port));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
public class SwaggerTest extends OslcTest {

static final Map<String, Integer> fixedPorts = Map.of(
RM_SVC, 8800,
CM_SVC, 8801,
QM_SVC, 8802,
AM_SVC, 8803
);
RM_SVC, 8800,
CM_SVC, 8801,
QM_SVC, 8802,
AM_SVC, 8803);

static Playwright playwright;
static Browser browser;
Expand All @@ -43,9 +42,11 @@ static void setupSpec() {
@AfterAll
static void cleanupSpec() {
System.out.println("Closing browser...");
if (browser != null) browser.close();
if (browser != null)
browser.close();
System.out.println("Closing Playwright...");
if (playwright != null) playwright.close();
if (playwright != null)
playwright.close();
}

void waitForService(String url) {
Expand Down Expand Up @@ -83,10 +84,10 @@ void waitForService(String url) {

@ParameterizedTest
@CsvSource({
RM_SVC,
CM_SVC,
QM_SVC,
AM_SVC
RM_SVC,
CM_SVC,
QM_SVC,
AM_SVC
})
void swaggerUiShouldBeAccessible(String svc) {
var serviceHost = "localhost";
Expand All @@ -100,7 +101,7 @@ void swaggerUiShouldBeAccessible(String svc) {
var authHeader = "Basic " + Base64.getEncoder().encodeToString("admin:admin".getBytes());
try (var context = browser.newContext(new Browser.NewContextOptions()
.setExtraHTTPHeaders(Map.of("Authorization", authHeader)));
var page = context.newPage()) {
var page = context.newPage()) {

// Debugging: Log console messages (WARN+) and network errors
page.onConsoleMessage(msg -> {
Expand All @@ -113,7 +114,8 @@ void swaggerUiShouldBeAccessible(String svc) {
});
page.onResponse(response -> {
if (response.status() >= 400) {
System.out.println("Network Error: " + response.url() + " returned " + response.status() + " " + response.statusText());
System.out.println("Network Error: " + response.url() + " returned " + response.status() + " "
+ response.statusText());
}
});

Expand All @@ -140,7 +142,10 @@ void swaggerUiShouldBeAccessible(String svc) {
// /serviceProviders/{serviceProviderId}/service2/requirementCollections/selector
// This is only for RM.
if (RM_SVC.equals(svc)) {
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("GET /serviceProviders/{serviceProviderId}/service2/requirementCollections/selector")).first().waitFor();
page.getByRole(AriaRole.BUTTON,
new Page.GetByRoleOptions().setName(
"GET /serviceProviders/{serviceProviderId}/service2/requirementCollections/selector"))
.first().waitFor();
}

assertEquals("Swagger UI", title);
Expand Down
5 changes: 5 additions & 0 deletions src/refimpl-tests/src/test/resources/docker-compose.slim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
server-cm:
build:
context: ../../../../
dockerfile: server-cm/slim.Dockerfile
8 changes: 8 additions & 0 deletions src/refimpl-tests/src/test/resources/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@ services:
dockerfile: server-rm/Dockerfile
ports:
- "8800:8080"
environment:
- LYO_BASEURL=http://localhost:8800/
server-cm:
build:
context: ../../../../
dockerfile: server-cm/Dockerfile
ports:
- "8801:8080"
environment:
- LYO_BASEURL=http://localhost:8801/
server-qm:
build:
context: ../../../../
dockerfile: server-qm/Dockerfile
ports:
- "8802:8080"
environment:
- LYO_BASEURL=http://localhost:8802/
server-am:
build:
context: ../../../../
dockerfile: server-am/Dockerfile
ports:
- "8803:8080"
environment:
- LYO_BASEURL=http://localhost:8803/
Loading