Skip to content

Commit

Permalink
Test logs and summary in the directory
Browse files Browse the repository at this point in the history
  • Loading branch information
vsuharnikov committed Oct 4, 2024
1 parent 849e595 commit 1ec30be
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
24 changes: 17 additions & 7 deletions consensus-client-it/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ libraryDependencies ++= Seq(
"org.testcontainers" % "testcontainers" % "1.20.2" % Test
)

Test / fork := true
Test / javaOptions ++= Seq(
s"-Dlogback.configurationFile=${(Test / resourceDirectory).value}/logback-test.xml" // Fixes a logback blaming for multiple configs
)
Test / envVars ++= Map(
"CONFIGS_DIR" -> s"${baseDirectory.value}/../local-network/configs",
"LOGS_DIR" -> s"${target.value}/test-logs"
val logsDirectory = settingKey[File]("The directory for logs")

inConfig(Test)(
Seq(
logsDirectory := {
val r = target.value / "test-logs"
r.mkdirs()
r
},
fork := true,
javaOptions ++= Seq(
s"-Dlogback.configurationFile=${(Test / resourceDirectory).value}/logback-test.xml", // Fixes a logback blaming for multiple configs
s"-Dcc.it.configs.dir=${baseDirectory.value.getParent}/local-network/configs",
s"-Dcc.it.logs.dir=${logsDirectory.value}"
),
testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-fFWD", (logsDirectory.value / "summary.log").toString)
)
)
21 changes: 19 additions & 2 deletions consensus-client-it/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="pattern" value="%date{HH:mm:ss.SSS,UTC} %-5level [%.10thread] %logger{26} - %msg%n%rEx"/>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>${pattern}</pattern>
</encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter>
<file>${cc.it.logs.dir:-target/logs}/test.log</file>
<append>false</append>
<encoder>
<pattern>%date %-5level [%.15thread] %logger{100} - %msg%n</pattern>
<pattern>${pattern}</pattern>
</encoder>
</appender>

Expand All @@ -12,7 +28,8 @@
<!-- Containers initialization logs -->
<logger name="tc" level="WARN"/>

<root level="${logback.test.level:-TRACE}">
<root level="TRACE">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ abstract class BaseContainer(val hostName: String) {
}

object BaseContainer {
val ConfigsDir: Path = Path.of(System.getenv("CONFIGS_DIR"))
val DefaultLogsDir: Path = Path.of(System.getenv("LOGS_DIR"))
val ConfigsDir: Path = Path.of(System.getProperty("cc.it.configs.dir"))
val DefaultLogsDir: Path = Path.of(System.getProperty("cc.it.logs.dir"))
}

0 comments on commit 1ec30be

Please sign in to comment.