1
0

containerized Jenkins (#179)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/179
Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
Michael Hoennig
2025-06-18 13:51:38 +02:00
parent d351c9a2c1
commit ad1537b856
14 changed files with 283 additions and 142 deletions

View File

@@ -89,6 +89,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assumptions.assumeThat;
import static org.springframework.util.FileCopyUtils.copyToByteArray;
@Tag("migrationTest")
@Tag("importHostingAssets")
@DataJpaTest(properties = {
"spring.datasource.url=${HSADMINNG_POSTGRES_JDBC_URL:jdbc:tc:postgresql:15.5-bookworm:///importHostingAssetsTC}",

View File

@@ -34,7 +34,7 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TE
* <p>During a release, the generated dump has to be committed to git and will be used in future test-runs
* until it gets replaced with a new dump at the next release.</p>
*/
@Tag("officeIntegrationTest")
@Tag("migrationTest")
@DataJpaTest(properties = {
"spring.datasource.url=jdbc:tc:postgresql:15.5-bookworm:///liquibaseMigrationTestTC",
"hsadminng.superuser=${HSADMINNG_SUPERUSER:import-superuser@hostsharing.net}",

View File

@@ -46,6 +46,7 @@ import static org.junit.platform.commons.util.StringUtils.isNotBlank;
public abstract class UseCase<T extends UseCase<?>> {
private static final HttpClient client = HttpClient.newHttpClient();
private static final int HTTP_TIMEOUT_SECONDS = 20; // FIXME: configurable in environment
private final ObjectMapper objectMapper = new ObjectMapper();
protected final ScenarioTest testSuite;
@@ -160,7 +161,7 @@ public abstract class UseCase<T extends UseCase<?>> {
.GET()
.uri(new URI("http://localhost:" + testSuite.port + uriPath))
.header("Authorization", "Bearer " + ScenarioTest.RUN_AS_USER)
.timeout(seconds(10))
.timeout(seconds(HTTP_TIMEOUT_SECONDS))
.build();
final var response = client.send(request, BodyHandlers.ofString());
return new HttpResponse(HttpMethod.GET, uriPath, null, response);
@@ -175,7 +176,7 @@ public abstract class UseCase<T extends UseCase<?>> {
.uri(new URI("http://localhost:" + testSuite.port + uriPath))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + ScenarioTest.RUN_AS_USER)
.timeout(seconds(10))
.timeout(seconds(HTTP_TIMEOUT_SECONDS))
.build();
final var response = client.send(request, BodyHandlers.ofString());
return new HttpResponse(HttpMethod.POST, uriPath, requestBody, response);
@@ -190,7 +191,7 @@ public abstract class UseCase<T extends UseCase<?>> {
.uri(new URI("http://localhost:" + testSuite.port + uriPath))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + ScenarioTest.RUN_AS_USER)
.timeout(seconds(10))
.timeout(seconds(HTTP_TIMEOUT_SECONDS))
.build();
final var response = client.send(request, BodyHandlers.ofString());
return new HttpResponse(HttpMethod.PATCH, uriPath, requestBody, response);
@@ -204,7 +205,7 @@ public abstract class UseCase<T extends UseCase<?>> {
.uri(new URI("http://localhost:" + testSuite.port + uriPath))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + ScenarioTest.RUN_AS_USER)
.timeout(seconds(10))
.timeout(seconds(HTTP_TIMEOUT_SECONDS))
.build();
final var response = client.send(request, BodyHandlers.ofString());
return new HttpResponse(HttpMethod.DELETE, uriPath, null, response);

View File

@@ -5,6 +5,7 @@ import net.hostsharing.hsadminng.mapper.Array;
import net.hostsharing.hsadminng.mapper.StrictMapper;
import net.hostsharing.hsadminng.persistence.EntityManagerWrapper;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +42,11 @@ class ContextIntegrationTests {
@PersistenceContext
private EntityManager em;
@BeforeAll
static void disableRyuk() {
System.setProperty("testcontainers.ryuk.disabled", "true");
}
@Test
void defineWithoutHttpServletRequestUsesCallStack() {