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

Issues/135 enable parallel maven builds #136

Merged
merged 11 commits into from
Nov 27, 2023
7 changes: 2 additions & 5 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI Build with Maven

on: [push, pull_request]
on: push

jobs:
build:
Expand All @@ -19,4 +16,4 @@ jobs:
java-version: 17
cache: 'maven'
- name: Build with Maven
run: mvn -B verify -fae --file pom.xml -Dgpg.skip
run: mvn --batch-mode --fail-at-end --threads 1C -DforkCount=2 -Dgpg.skip clean verify
9 changes: 3 additions & 6 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# This workflow will publish a Java project with Maven
# For more information see: https://docs.github.com/en/free-pro-team@latest/actions/guides/publishing-java-packages-with-maven

name: Java CI Publish with Maven

on:
pull_request:
types: [closed]
branches: [develop]
types: closed
branches: develop

jobs:
publish:
Expand All @@ -28,4 +25,4 @@ jobs:
- name: Publish with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B deploy --file pom.xml -Dgpg.skip
run: mvn --batch-mode --fail-at-end --threads 1C -DforkCount=2 -Dgpg.skip clean deploy
43 changes: 0 additions & 43 deletions dsf-bpe/dsf-bpe-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,49 +221,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>start-postgres</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<images>
<image>
<name>postgres:15</name>
<run>
<ports>
<port>127.0.0.1:54321:5432</port>
</ports>
<env>
<TZ>Europe/Berlin</TZ>
<POSTGRES_USER>postgres</POSTGRES_USER>
<POSTGRES_PASSWORD>password</POSTGRES_PASSWORD>
<POSTGRES_DB>db</POSTGRES_DB>
</env>
<wait>
<!-- <log>(?s)database system is ready to accept connections.*database system is ready to accept connections</log> -->
<time>2500</time>
</wait>
</run>
</image>
</images>
</configuration>
</execution>
<execution>
<id>stop-postgres</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,45 @@
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.testcontainers.utility.DockerImageName;

import de.rwh.utils.test.LiquibaseTemplateTestClassRule;
import de.rwh.utils.test.LiquibaseTemplateTestRule;
import de.hsheilbronn.mi.utils.test.PostgreSqlContainerLiquibaseTemplateClassRule;
import de.hsheilbronn.mi.utils.test.PostgresTemplateRule;

public class AbstractDaoTest extends AbstractDbTest
{
public static final String DAO_DB_TEMPLATE_NAME = "dao_template";

protected static final BasicDataSource adminDataSource = createAdminBasicDataSource();
protected static final BasicDataSource liquibaseDataSource = createLiquibaseDataSource();
protected static final BasicDataSource defaultDataSource = createDefaultDataSource();
protected static final BasicDataSource camundaDataSource = createCamundaDataSource();
protected static BasicDataSource defaultDataSource;
protected static BasicDataSource camundaDataSource;

@ClassRule
public static final LiquibaseTemplateTestClassRule liquibaseRule = new LiquibaseTemplateTestClassRule(
adminDataSource, LiquibaseTemplateTestClassRule.DEFAULT_TEST_DB_NAME, DAO_DB_TEMPLATE_NAME,
liquibaseDataSource, CHANGE_LOG_FILE, CHANGE_LOG_PARAMETERS, true);
public static final PostgreSqlContainerLiquibaseTemplateClassRule liquibaseRule = new PostgreSqlContainerLiquibaseTemplateClassRule(
DockerImageName.parse("postgres:15"), ROOT_USER, "bpe", "bpe_template", CHANGE_LOG_FILE,
CHANGE_LOG_PARAMETERS, true);

@Rule
public final PostgresTemplateRule templateRule = new PostgresTemplateRule(liquibaseRule);

@BeforeClass
public static void beforeClass() throws Exception
{
defaultDataSource = createDefaultDataSource(liquibaseRule.getHost(), liquibaseRule.getMappedPort(5432),
liquibaseRule.getDatabaseName());
defaultDataSource.start();
liquibaseDataSource.start();
adminDataSource.start();

camundaDataSource = createCamundaDataSource(liquibaseRule.getHost(), liquibaseRule.getMappedPort(5432),
liquibaseRule.getDatabaseName());
camundaDataSource.start();
}

@AfterClass
public static void afterClass() throws Exception
{
defaultDataSource.close();
liquibaseDataSource.close();
adminDataSource.close();
camundaDataSource.close();
}
if (defaultDataSource != null)
defaultDataSource.close();

@Rule
public final LiquibaseTemplateTestRule templateRule = new LiquibaseTemplateTestRule(adminDataSource,
LiquibaseTemplateTestClassRule.DEFAULT_TEST_DB_NAME, DAO_DB_TEMPLATE_NAME);
if (camundaDataSource != null)
camundaDataSource.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ public abstract class AbstractDbTest
protected static final String DATABASE_CAMUNDA_USER = "camunda_user";
protected static final String DATABASE_CAMUNDA_USER_PASSWORD = "camunda_user_password";

protected static final String DATABASE_URL = "jdbc:postgresql://localhost:54321/db";
protected static final String ROOT_USER = "postgres";

protected static final Map<String, String> CHANGE_LOG_PARAMETERS = Map.of("db.liquibase_user", "postgres",
protected static final Map<String, String> CHANGE_LOG_PARAMETERS = Map.of("db.liquibase_user", ROOT_USER,
"db.server_users_group", DATABASE_USERS_GROUP, "db.server_user", DATABASE_USER, "db.server_user_password",
DATABASE_USER_PASSWORD, "db.camunda_users_group", DATABASE_CAMUNDA_USERS_GROUP, "db.camunda_user",
DATABASE_CAMUNDA_USER, "db.camunda_user_password", DATABASE_CAMUNDA_USER_PASSWORD);

public static BasicDataSource createDefaultDataSource()
public static BasicDataSource createDefaultDataSource(String host, int port, String databaseName)
{
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(Driver.class.getName());
dataSource.setUrl(DATABASE_URL);
dataSource.setUrl("jdbc:postgresql://" + host + ":" + port + "/" + databaseName);
dataSource.setUsername(DATABASE_USER);
dataSource.setPassword(DATABASE_USER_PASSWORD);
dataSource.setDefaultReadOnly(true);
Expand All @@ -46,40 +46,11 @@ public static BasicDataSource createDefaultDataSource()
return dataSource;
}

public static BasicDataSource createLiquibaseDataSource()
public static BasicDataSource createCamundaDataSource(String host, int port, String databaseName)
{
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(Driver.class.getName());
dataSource.setUrl(DATABASE_URL);
dataSource.setUsername("postgres");
dataSource.setPassword("password");
dataSource.setDefaultReadOnly(true);

dataSource.setTestOnBorrow(true);
dataSource.setValidationQuery("SELECT 1");

return dataSource;
}

public static BasicDataSource createAdminBasicDataSource()
{
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(Driver.class.getName());
dataSource.setUrl("jdbc:postgresql://localhost:54321/postgres");
dataSource.setUsername("postgres");
dataSource.setPassword("password");

dataSource.setTestOnBorrow(true);
dataSource.setValidationQuery("SELECT 1");

return dataSource;
}

public static BasicDataSource createCamundaDataSource()
{
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(Driver.class.getName());
dataSource.setUrl(DATABASE_URL);
dataSource.setUrl("jdbc:postgresql://" + host + ":" + port + "/" + databaseName);
dataSource.setUsername(DATABASE_CAMUNDA_USER);
dataSource.setPassword(DATABASE_CAMUNDA_USER_PASSWORD);
dataSource.setDefaultReadOnly(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.dsf.common.auth;

import java.util.Objects;
import java.util.function.Supplier;

import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.security.Authenticator;
import org.eclipse.jetty.security.ServerAuthException;
Expand All @@ -15,11 +18,13 @@ public class StatusPortAuthenticator implements Authenticator
{
private static final String STATUS_PATH = "/status";

private final int statusPort;
private final Supplier<Integer> statusPortSupplier;

public StatusPortAuthenticator(int statusPort)
public StatusPortAuthenticator(Supplier<Integer> statusPortSupplier)
{
this.statusPort = statusPort;
Objects.requireNonNull(statusPortSupplier, "statusPortSupplier");

this.statusPortSupplier = statusPortSupplier;
}

@Override
Expand All @@ -37,7 +42,7 @@ public boolean isStatusPortRequest(ServletRequest req)
{
HttpServletRequest request = (HttpServletRequest) req;
return HttpMethod.GET.is(request.getMethod()) && STATUS_PATH.equals(request.getPathInfo())
&& statusPort == request.getLocalPort();
&& statusPortSupplier.get() != null && statusPortSupplier.get() == request.getLocalPort();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import java.util.function.Function;

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;

public abstract class AbstractHttpJettyConfig extends AbstractJettyConfig
{
@Override
protected Function<Server, Connector> apiConnector()
protected Function<Server, ServerConnector> apiConnector()
{
return httpApiConnector();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import java.util.function.Function;

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;

public abstract class AbstractHttpsJettyConfig extends AbstractJettyConfig
{
@Override
protected Function<Server, Connector> apiConnector()
protected Function<Server, ServerConnector> apiConnector()
{
return httpsApiConnector();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.security.openid.OpenIdAuthenticator;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
Expand Down Expand Up @@ -191,26 +191,26 @@ public abstract class AbstractJettyConfig
@Value("#{'${dev.dsf.proxy.noProxy:}'.trim().split('(,[ ]?)|(\\\\n)')}")
private List<String> proxyNoProxy;

protected abstract Function<Server, Connector> apiConnector();
protected abstract Function<Server, ServerConnector> apiConnector();

protected abstract String mavenServerModuleName();

protected abstract List<Class<? extends ServletContainerInitializer>> servletContainerInitializers();

protected final Function<Server, Connector> httpApiConnector()
protected final Function<Server, ServerConnector> httpApiConnector()
{
return JettyServer.httpConnector(apiHost, apiPort, clientCertificateHeaderName);
}

protected final Function<Server, Connector> httpsApiConnector()
protected final Function<Server, ServerConnector> httpsApiConnector()
{
final char[] keyStorePassword = UUID.randomUUID().toString().toCharArray();
return JettyServer.httpsConnector(apiHost, apiPort, clientCertificateTrustStore(),
serverCertificateKeyStore(keyStorePassword), keyStorePassword,
!oidcAuthorizationCodeFlowEnabled && !oidcBearerTokenEnabled);
}

protected final Function<Server, Connector> statusConnector()
protected final Function<Server, ServerConnector> statusConnector()
{
return JettyServer.statusConnector(statusHost, statusPort);
}
Expand Down Expand Up @@ -321,7 +321,7 @@ private Path checkOptionalFile(String file, String fileDescription) throws IOExc
}
}

private void configureSecurityHandler(WebAppContext webAppContext)
private void configureSecurityHandler(WebAppContext webAppContext, Supplier<Integer> statusPortSupplier)
{
SessionHandler sessionHandler = webAppContext.getSessionHandler();
DsfLoginService dsfLoginService = new DsfLoginService(webAppContext);
Expand Down Expand Up @@ -382,7 +382,7 @@ else if (oidcBackChannelPath == null)
openIdLoginService = new DsfOpenIdLoginService(openIdConfiguration, dsfLoginService);
}

StatusPortAuthenticator statusPortAuthenticator = new StatusPortAuthenticator(statusPort);
StatusPortAuthenticator statusPortAuthenticator = new StatusPortAuthenticator(statusPortSupplier);
ClientCertificateAuthenticator clientCertificateAuthenticator = new ClientCertificateAuthenticator(
clientCertificateTrustStore());
DelegatingAuthenticator delegatingAuthenticator = new DelegatingAuthenticator(sessionHandler,
Expand Down
Loading