diff --git a/Docker/centralserver/files/etc/xroad/conf.d/local.ini b/Docker/centralserver/files/etc/xroad/conf.d/local.ini new file mode 100644 index 0000000000..67eb203747 --- /dev/null +++ b/Docker/centralserver/files/etc/xroad/conf.d/local.ini @@ -0,0 +1,5 @@ +[admin-service] +global-configuration-generation-rate-in-seconds = 10 +[configuration-client] +#default 60 +update-interval = 10 \ No newline at end of file diff --git a/src/gradle.properties b/src/gradle.properties index bc7c071088..d46ed569c7 100644 --- a/src/gradle.properties +++ b/src/gradle.properties @@ -62,8 +62,8 @@ commonsCompressVersion=1.26.0 commonsIOVersion=2.15.1 commonsLang3Version=3.14.0 commonsConfiguration2Version=2.9.0 -testAutomationFrameworkVersion=0.2.16 -awaitilityVersion=4.2.0 +testAutomationFrameworkVersion=0.2.17 +awaitilityVersion=4.2.1 bucket4jVersion=7.4.0 assertjVersion=3.24.2 assertj.version=${assertjVersion} diff --git a/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/ComposeLoggerFactory.java b/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/ComposeLoggerFactory.java new file mode 100644 index 0000000000..0201db33d9 --- /dev/null +++ b/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/ComposeLoggerFactory.java @@ -0,0 +1,72 @@ +/* + * The MIT License + * Copyright (c) 2019- Nordic Institute for Interoperability Solutions (NIIS) + * Copyright (c) 2018 Estonian Information System Authority (RIA), + * Nordic Institute for Interoperability Solutions (NIIS), Population Register Centre (VRK) + * Copyright (c) 2015-2017 Estonian Information System Authority (RIA), Population Register Centre (VRK) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.niis.xroad.e2e.container; + +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.encoder.PatternLayoutEncoder; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.FileAppender; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class ComposeLoggerFactory { + public static final String CONTAINER_LOGS_DIR = "container-logs"; + + private static final String APPENDER_NAME = "REPORT"; + private static final String LOG_PATTERN = "%d{HH:mm:ss.SS} [%logger{50}] %msg%n"; + + public Logger create(String containerName) { + var context = (LoggerContext) LoggerFactory.getILoggerFactory(); + + FileAppender fileAppender = new FileAppender<>(); + fileAppender.setContext(context); + fileAppender.setName(APPENDER_NAME); + fileAppender.setFile(createFilePath(containerName)); + fileAppender.setEncoder(createEncoder(context)); + fileAppender.start(); + + Logger logger = context.getLogger(containerName.toUpperCase()); + logger.addAppender(fileAppender); + logger.setAdditive(false); + + return logger; + } + + private PatternLayoutEncoder createEncoder(LoggerContext context) { + PatternLayoutEncoder encoder = new PatternLayoutEncoder(); + encoder.setContext(context); + encoder.setPattern(LOG_PATTERN); + encoder.start(); + + return encoder; + } + + private String createFilePath(String containerName) { + return System.getProperty("testExecLogDir") + "/" + CONTAINER_LOGS_DIR + "/" + containerName + "-test-automation.log"; + } +} diff --git a/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/EnvSetup.java b/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/EnvSetup.java index 5c724611eb..6450b7829f 100644 --- a/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/EnvSetup.java +++ b/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/EnvSetup.java @@ -34,6 +34,7 @@ import org.springframework.stereotype.Service; import org.testcontainers.containers.ComposeContainer; import org.testcontainers.containers.ContainerState; +import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.containers.wait.strategy.Wait; import java.io.File; @@ -58,6 +59,7 @@ public class EnvSetup implements TestableContainerInitializer { public static final String SS1 = "ss1"; public static final String HURL = "hurl"; + private final ComposeLoggerFactory composeLoggerFactory; private final CustomProperties customProperties; private ComposeContainer environment; @@ -83,7 +85,10 @@ public void initialize() { .withEnv("SS_IMG", customProperties.getSsImage()) .withEnv("CA_IMG", customProperties.getCaImage()) .withEnv("IS_SOAP_IMG", customProperties.getIssoapImage()) - + .withLogConsumer(HURL, createLogConsumer(HURL)) + .withLogConsumer(CS, createLogConsumer(CS)) + .withLogConsumer(SS0, createLogConsumer(SS0)) + .withLogConsumer(SS1, createLogConsumer(SS1)) .waitingFor(CS, Wait.forLogMessage("^.*xroad-center entered RUNNING state.*$", 1)); environment.start(); @@ -92,6 +97,10 @@ public void initialize() { } } + private Slf4jLogConsumer createLogConsumer(String containerName) { + return new Slf4jLogConsumer(new ComposeLoggerFactory().create(containerName)); + } + @SuppressWarnings("checkstyle:magicnumber") private void waitForHurl() { await() @@ -104,6 +113,10 @@ private void waitForHurl() { .map(container -> !container.isRunning()) .orElse(false); }); + + var gracePeriod = Duration.ofSeconds(30); + log.info("Waiting grace period of {} before continuing..", gracePeriod); + await().pollDelay(gracePeriod).timeout(gracePeriod.plusMinutes(1)).until(() -> true); } @PreDestroy diff --git a/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/hook/LogPrepHook.java b/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/hook/LogPrepHook.java new file mode 100644 index 0000000000..57a3da3a03 --- /dev/null +++ b/src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/hook/LogPrepHook.java @@ -0,0 +1,59 @@ +/* + * The MIT License + * Copyright (c) 2019- Nordic Institute for Interoperability Solutions (NIIS) + * Copyright (c) 2018 Estonian Information System Authority (RIA), + * Nordic Institute for Interoperability Solutions (NIIS), Population Register Centre (VRK) + * Copyright (c) 2015-2017 Estonian Information System Authority (RIA), Population Register Centre (VRK) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.niis.xroad.e2e.hook; + +import com.nortal.test.core.services.hooks.AfterSuiteHook; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.nio.file.Path; + +import static java.nio.file.Files.move; +import static org.niis.xroad.e2e.container.ComposeLoggerFactory.CONTAINER_LOGS_DIR; + +@Slf4j +@Component +public class LogPrepHook implements AfterSuiteHook { + @Override + public void afterSuite() { + log.info("Moving container logs to final destination."); + try { + move( + Path.of(System.getProperty("testExecLogDir"), CONTAINER_LOGS_DIR), + Path.of(System.getProperty("testExecLogDir"), "allure-report", CONTAINER_LOGS_DIR) + ); + } catch (Exception e) { + log.error("Failed to move container logs to their final destination.", e); + } + } + + @Override + @SuppressWarnings("checkstyle:MagicNumber") + public int afterSuitOrder() { + // Exec after allure report is generated. We just want to attach it to final report. + return 50100; + } +}