Skip to content

Commit

Permalink
Store test logs in CI (#781)
Browse files Browse the repository at this point in the history
* Capture test logs in CI

If test logs were saved, store them as CI artifacts

* Only keep logs for failed tests

* Catch tests who didn't define names into a generic filename

Signed-off-by: Horacio Mijail Anton Quiles <hmijail@gmail.com>

Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>
  • Loading branch information
hmijail and macfarla authored Apr 30, 2020
1 parent 3cc4dc3 commit 823a0f2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ commands:
- store_test_results:
path: build/test-results

capture_test_logs:
description: "Capture test logs"
steps:
- store_artifacts:
path: acceptance-tests/tests/build/acceptanceTestLogs
destination: acceptance-tests-logs

jobs:
assemble:
executor: besu_executor_xl
Expand Down Expand Up @@ -152,6 +159,7 @@ jobs:
GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}')
./gradlew --no-daemon acceptanceTest $GRADLE_ARGS
- capture_test_results
- capture_test_logs

buildDocker:
executor: besu_executor_med
Expand Down
34 changes: 32 additions & 2 deletions acceptance-tests/tests/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Properties>
<Property name="root.log.level">INFO</Property>
</Properties>

<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
Expand All @@ -13,11 +14,27 @@
<Console name="SubProcessConsole" target="SYSTEM_OUT">
<PatternLayout pattern="%X{test} | %X{node} | %msg%n" />
</Console>

<Routing name="PerTestFile">
<Routes pattern="${ctx:class}-${ctx:test}">
<Route key="$${ctx:class}-$${ctx:test}">
<!-- The class and test names failed to resolve, so use a catch-all filename -->
<File
name="Appends to AllTestsMissingExtraLoggingConf.log"
filename="build/acceptanceTestLogs/AllTestsMissingExtraLoggingConf.log"
append="true"
createOnDemand="true"
>
<PatternLayout>
<pattern>%X{node} | %d{HH:mm:ss.SSS} | %t | %-5level | %c{1} | %msg%n</pattern>
<replace regex="^ \| " replacement=""/>
</PatternLayout>
</File>
</Route>
<Route>
<!-- The default route sends the log to an on-demand file whose name contains the class and test names -->
<File
name="Test-${ctx:class}-${ctx:test}"
name="Creates CLASSNAME.TESTNAME.log"
filename="build/acceptanceTestLogs/${ctx:class}.${ctx:test}.log"
append="false"
createOnDemand="true"
Expand All @@ -32,16 +49,29 @@
</Routing>
<Routing name="PerTestSubprocessFile">
<Routes pattern="${ctx:class}-${ctx:test}">
<Route key="$${ctx:class}-$${ctx:test}">
<!-- The class and test names failed to resolve, so use a catch-all filename -->
<File
name="Appends to AllTestsMissingExtraLoggingConf.log"
filename="build/acceptanceTestLogs/AllTestsMissingExtraLoggingConf.log"
append="true"
createOnDemand="true"
>
<PatternLayout pattern="%X{node} | %msg%n" />
</File>
</Route>
<Route>
<!-- The default route sends the log to an on-demand file whose name contains the class and test names -->
<File
name="TestSubprocess-${ctx:class}-${ctx:test}"
name="Appends to CLASSNAME.TESTNAME.log"
filename="build/acceptanceTestLogs/${ctx:class}.${ctx:test}.log"
append="true"
createOnDemand="true"
>
<PatternLayout pattern="%X{node} | %msg%n" />
</File>
</Route>

</Routes>
</Routing>

Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ allprojects {
* with the 'include' option above since it is a pattern, but this is a slightly more convenient
* option.
* - 'root.log.level' and 'evm.log.level': allow to control the log level used during the tests.
* - 'acctests.keepLogsOfPassingTests': log files of failed acceptance tests are always saved.
* This property additionally keeps the log files of successful tests.
*
*/
test {
jvmArgs = [
Expand Down

0 comments on commit 823a0f2

Please sign in to comment.