diff options
author | Zipeng WU <zipeng.wu@sonarsource.com> | 2022-08-02 15:41:42 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-08-03 20:03:24 +0000 |
commit | 44dcee705fa9582238aa7db8b4b5b5f1a0fec2b6 (patch) | |
tree | 9bdf4e030f16482e470ea4244d7f85877a50ecd4 /server/sonar-main/src/test | |
parent | 94fe8bdf97cfaa4cdbbd498ce4398e22c3ac710f (diff) | |
download | sonarqube-44dcee705fa9582238aa7db8b4b5b5f1a0fec2b6.tar.gz sonarqube-44dcee705fa9582238aa7db8b4b5b5f1a0fec2b6.zip |
SONAR-17138 sonar.log rotation move inside Sonar Application process
Diffstat (limited to 'server/sonar-main/src/test')
-rw-r--r-- | server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java index 5b9a9a57d25..46584e8b7f0 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java @@ -74,34 +74,24 @@ public class AppLoggingTest { } @Test - public void no_writing_to_sonar_log_file_when_running_from_sonar_script() { - emulateRunFromSonarScript(); - - LoggerContext ctx = underTest.configure(); - - ctx.getLoggerList().forEach(AppLoggingTest::verifyNoFileAppender); - } - - @Test public void root_logger_only_writes_to_console_with_formatting_when_running_from_sonar_script() { - emulateRunFromSonarScript(); - LoggerContext ctx = underTest.configure(); Logger rootLogger = ctx.getLogger(ROOT_LOGGER_NAME); - ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) rootLogger.getAppender("APP_CONSOLE"); + var consoleAppender = (ConsoleAppender<ILoggingEvent>) rootLogger.getAppender("APP_CONSOLE"); verifyAppFormattedLogEncoder(consoleAppender.getEncoder()); - assertThat(rootLogger.iteratorForAppenders()).toIterable().hasSize(1); + var rollingFileAppender = rootLogger.getAppender("file_sonar"); + assertThat(rollingFileAppender).isNotNull(); + assertThat(rootLogger.iteratorForAppenders()).toIterable().hasSize(2); } @Test public void gobbler_logger_writes_to_console_without_formatting_when_running_from_sonar_script() { - emulateRunFromSonarScript(); - LoggerContext ctx = underTest.configure(); Logger gobblerLogger = ctx.getLogger(LOGGER_GOBBLER); verifyGobblerConsoleAppender(gobblerLogger); + assertThat(gobblerLogger.iteratorForAppenders()).toIterable().hasSize(1); } @@ -266,10 +256,6 @@ public class AppLoggingTest { assertThat(((LayoutWrappingEncoder)encoder).getLayout()).isInstanceOf(LogbackJsonLayout.class); } - private void emulateRunFromSonarScript() { - settings.getProps().set("sonar.wrapped", "true"); - } - private void emulateRunFromCommandLine(boolean withAllLogsPrintedToConsole) { if (withAllLogsPrintedToConsole) { settings.getProps().set("sonar.log.console", "true"); |