-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2007 from nordic-institute/e2e-logging-improvements
chore: improve e2e logging and increase performance
- Loading branch information
Showing
5 changed files
with
152 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[admin-service] | ||
global-configuration-generation-rate-in-seconds = 10 | ||
[configuration-client] | ||
#default 60 | ||
update-interval = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...y-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/container/ComposeLoggerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ILoggingEvent> 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"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/security-server/e2e-test/src/intTest/java/org/niis/xroad/e2e/hook/LogPrepHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |