Skip to content

Commit 98e83c6

Browse files
chore: reduce CI test log noise by suppressing known-structural error loggers (#22905)
1 parent 1eb2aa1 commit 98e83c6

9 files changed

Lines changed: 89 additions & 6 deletions

File tree

.github/workflows/analyse-pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125
55
# PR → quiet (unless ci-verbose label), push/schedule → info, workflow_dispatch → user choice
66
MAVEN_ARGS: ${{ (inputs.maven_log == 'debug' && '-X') || (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci-verbose') && '-q') || (inputs.maven_log == 'quiet' && '-q') || '' }}
7+
# Controls log4j2 suppression of expected test errors. ci-verbose label sets to error to show them.
8+
TEST_LOG_SUPPRESSED_LEVEL: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-verbose') && 'error') || (inputs.maven_log == 'debug' && 'error') || 'off' }}
79
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
810
SONAR_TOKEN: ${{ secrets.DHIS2_BOT_SONARCLOUD_TOKEN }}
911
on:

.github/workflows/run-api-analytics-tests-doris.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125
55
# PR → quiet (unless ci-verbose label), push/schedule → info, workflow_dispatch → user choice
66
MAVEN_ARGS: ${{ (inputs.maven_log == 'debug' && '-X') || (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci-verbose') && '-q') || (inputs.maven_log == 'quiet' && '-q') || '' }}
7+
# Controls log4j2 suppression of expected test errors. ci-verbose label sets to error to show them.
8+
TEST_LOG_SUPPRESSED_LEVEL: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-verbose') && 'error') || (inputs.maven_log == 'debug' && 'error') || 'off' }}
79

810
on:
911
pull_request:

.github/workflows/run-api-analytics-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125
55
# PR → quiet (unless ci-verbose label), push/schedule → info, workflow_dispatch → user choice
66
MAVEN_ARGS: ${{ (inputs.maven_log == 'debug' && '-X') || (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci-verbose') && '-q') || (inputs.maven_log == 'quiet' && '-q') || '' }}
7+
# Controls log4j2 suppression of expected test errors. ci-verbose label sets to error to show them.
8+
TEST_LOG_SUPPRESSED_LEVEL: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-verbose') && 'error') || (inputs.maven_log == 'debug' && 'error') || 'off' }}
79

810
on:
911
pull_request:

.github/workflows/run-api-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
MAVEN_OPTS: -Xmx1024m -Xms1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125
55
# PR → quiet (unless ci-verbose label), push/schedule → info, workflow_dispatch → user choice
66
MAVEN_ARGS: ${{ (inputs.maven_log == 'debug' && '-X') || (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci-verbose') && '-q') || (inputs.maven_log == 'quiet' && '-q') || '' }}
7+
# Controls log4j2 suppression of expected test errors. ci-verbose label sets to error to show them.
8+
TEST_LOG_SUPPRESSED_LEVEL: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-verbose') && 'error') || (inputs.maven_log == 'debug' && 'error') || 'off' }}
79

810
on:
911
push:

.github/workflows/run-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=125
55
# PR → quiet (unless ci-verbose label), push/schedule → info, workflow_dispatch → user choice
66
MAVEN_ARGS: ${{ (inputs.maven_log == 'debug' && '-X') || (github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci-verbose') && '-q') || (inputs.maven_log == 'quiet' && '-q') || '' }}
7+
# Controls log4j2 suppression of expected test errors. ci-verbose label sets to error to show them.
8+
TEST_LOG_SUPPRESSED_LEVEL: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-verbose') && 'error') || (inputs.maven_log == 'debug' && 'error') || 'off' }}
79
on:
810
push:
911
branches:

dhis-2/dhis-support/dhis-support-test/src/main/resources/log4j2-test.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<Configuration status="warn">
66
<Properties>
77
<Property name="layout">%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Property>
8+
<!-- CI sets TEST_LOG_SUPPRESSED_LEVEL=error when ci-verbose label is present to show all errors.
9+
Defaults to off which disables these loggers entirely. -->
10+
<Property name="suppressed.level">${env:TEST_LOG_SUPPRESSED_LEVEL:-off}</Property>
811
</Properties>
912

1013
<Appenders>
@@ -17,6 +20,23 @@
1720
</Appenders>
1821

1922
<Loggers>
23+
<!-- Suppress expected errors from tests exercising error paths and from resources
24+
not available in test classpaths (e.g. build.properties, apps-bundle.json).
25+
These are not real failures - the tests pass, but the application logs at ERROR. -->
26+
<Logger name="org.hisp.dhis.scheduling" level="${suppressed.level}"/>
27+
<Logger name="org.hisp.dhis.system" level="${suppressed.level}"/>
28+
<Logger name="org.hisp.dhis.appmanager" level="${suppressed.level}"/>
29+
<Logger name="org.hisp.dhis.fileresource" level="${suppressed.level}"/>
30+
<Logger name="org.hisp.dhis.sms" level="${suppressed.level}"/>
31+
<Logger name="org.hisp.dhis.route" level="${suppressed.level}"/>
32+
<Logger name="org.hisp.dhis.dxf2.gml" level="${suppressed.level}"/>
33+
<Logger name="org.hisp.dhis.rules.engine" level="${suppressed.level}"/>
34+
<Logger name="org.hisp.dhis.tracker.imports.sms" level="${suppressed.level}"/>
35+
<!-- CrudControllerAdvice is the global @ControllerAdvice that catches exceptions from tests
36+
deliberately exercising error paths (e.g. SQL injection tests). The broad package suppression
37+
was replaced with this targeted class to keep other controller errors visible. -->
38+
<Logger name="org.hisp.dhis.webapi.controller.CrudControllerAdvice" level="${suppressed.level}"/>
39+
2040
<Root level="warn">
2141
<!-- Set to error so CI test runs are quiet, we see failed tests easily but still see errors from libraries
2242
we use due to for example misconfigurations or so. If you want to increase the verbosity of specific
@@ -27,6 +47,10 @@
2747
<AppenderRef ref="file" level="warn"/>
2848
</Root>
2949

50+
<!-- Tests that verify uniqueness constraints intentionally trigger duplicate-key
51+
violations; Hibernate logs every such exception at ERROR via SqlExceptionHelper. -->
52+
<Logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="fatal" additivity="false"/>
53+
3054
<!-- A few examples of loggers that might be useful to debug integration test issues.
3155
Adding an AppenderRef is necessary to overrule the log level we have set on the Root AppenderRefs.
3256
Once you add an AppenderRef to a Logger you need to set additivity to false otherwise logs might appear twice

dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/security/oauth2/authorization/Dhis2OAuth2AuthorizationServiceIntegrationTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import static org.junit.jupiter.api.Assertions.assertNull;
3535

3636
import java.time.Instant;
37-
import java.util.List;
3837
import java.util.Map;
3938
import java.util.Set;
4039
import java.util.UUID;
@@ -172,11 +171,6 @@ void testFindByAuthorizationCode() {
172171
// When
173172
authorizationService.save(authorization);
174173

175-
List<Dhis2OAuth2Authorization> all = authorizationService.getAll();
176-
for (Dhis2OAuth2Authorization oAuth2Authorization : all) {
177-
System.out.println(oAuth2Authorization);
178-
}
179-
180174
OAuth2Authorization foundAuthorization =
181175
authorizationService.findByToken(
182176
"code-value", new OAuth2TokenType(OAuth2ParameterNames.CODE));

dhis-2/dhis-test-integration/src/test/resources/log4j2-test.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<Configuration status="warn">
33
<Properties>
44
<Property name="layout">%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Property>
5+
<!-- CI sets TEST_LOG_SUPPRESSED_LEVEL=error when ci-verbose label is present to show all errors.
6+
Defaults to off which disables these loggers entirely. -->
7+
<Property name="suppressed.level">${env:TEST_LOG_SUPPRESSED_LEVEL:-off}</Property>
58
</Properties>
69

710
<Appenders>
@@ -14,6 +17,23 @@
1417
</Appenders>
1518

1619
<Loggers>
20+
<!-- Suppress expected errors from tests exercising error paths and from resources
21+
not available in test classpaths (e.g. build.properties, apps-bundle.json).
22+
These are not real failures - the tests pass, but the application logs at ERROR. -->
23+
<Logger name="org.hisp.dhis.scheduling" level="${suppressed.level}"/>
24+
<Logger name="org.hisp.dhis.system" level="${suppressed.level}"/>
25+
<Logger name="org.hisp.dhis.appmanager" level="${suppressed.level}"/>
26+
<Logger name="org.hisp.dhis.fileresource" level="${suppressed.level}"/>
27+
<Logger name="org.hisp.dhis.sms" level="${suppressed.level}"/>
28+
<Logger name="org.hisp.dhis.route" level="${suppressed.level}"/>
29+
<Logger name="org.hisp.dhis.dxf2.gml" level="${suppressed.level}"/>
30+
<Logger name="org.hisp.dhis.rules.engine" level="${suppressed.level}"/>
31+
<Logger name="org.hisp.dhis.tracker.imports.sms" level="${suppressed.level}"/>
32+
<!-- CrudControllerAdvice is the global @ControllerAdvice that catches exceptions from tests
33+
deliberately exercising error paths (e.g. SQL injection tests). The broad package suppression
34+
was replaced with this targeted class to keep other controller errors visible. -->
35+
<Logger name="org.hisp.dhis.webapi.controller.CrudControllerAdvice" level="${suppressed.level}"/>
36+
1737
<Root level="warn">
1838
<!-- Set to error so CI test runs are quiet, we see failed tests easily but still see errors from libraries
1939
we use due to for example misconfigurations or so. If you want to increase the verbosity of specific
@@ -30,6 +50,10 @@
3050
as they propagate up from the Logger to its parent which is the Root.
3151
Check the log4j2 config documentation for more details. Uncomment the various loggers to debug the tests. -->
3252

53+
<!-- Tests that verify uniqueness constraints intentionally trigger duplicate-key
54+
violations; Hibernate logs every such exception at ERROR via SqlExceptionHelper. -->
55+
<Logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="fatal" additivity="false"/>
56+
3357
<!-- DHIS2 -->
3458
<!--
3559
<Logger name="org.hisp.dhis.migration" level="info" additivity="false">

dhis-2/dhis-test-web-api/src/test/resources/log4j2-test.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<Configuration status="warn">
33
<Properties>
44
<Property name="layout">%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Property>
5+
<!-- CI sets TEST_LOG_SUPPRESSED_LEVEL=error when ci-verbose label is present to show all errors.
6+
Defaults to off which disables these loggers entirely. -->
7+
<Property name="suppressed.level">${env:TEST_LOG_SUPPRESSED_LEVEL:-off}</Property>
58
</Properties>
69

710
<Appenders>
@@ -18,6 +21,23 @@
1821
</Appenders>
1922

2023
<Loggers>
24+
<!-- Suppress expected errors from tests exercising error paths and from resources
25+
not available in test classpaths (e.g. build.properties, apps-bundle.json).
26+
These are not real failures - the tests pass, but the application logs at ERROR. -->
27+
<Logger name="org.hisp.dhis.scheduling" level="${suppressed.level}"/>
28+
<Logger name="org.hisp.dhis.system" level="${suppressed.level}"/>
29+
<Logger name="org.hisp.dhis.appmanager" level="${suppressed.level}"/>
30+
<Logger name="org.hisp.dhis.fileresource" level="${suppressed.level}"/>
31+
<Logger name="org.hisp.dhis.sms" level="${suppressed.level}"/>
32+
<Logger name="org.hisp.dhis.route" level="${suppressed.level}"/>
33+
<Logger name="org.hisp.dhis.dxf2.gml" level="${suppressed.level}"/>
34+
<Logger name="org.hisp.dhis.rules.engine" level="${suppressed.level}"/>
35+
<Logger name="org.hisp.dhis.tracker.imports.sms" level="${suppressed.level}"/>
36+
<!-- CrudControllerAdvice is the global @ControllerAdvice that catches exceptions from tests
37+
deliberately exercising error paths (e.g. SQL injection tests). The broad package suppression
38+
was replaced with this targeted class to keep other controller errors visible. -->
39+
<Logger name="org.hisp.dhis.webapi.controller.CrudControllerAdvice" level="${suppressed.level}"/>
40+
2141
<Root level="warn">
2242
<!-- Set to error so CI test runs are quiet, we see failed tests easily but still see errors from libraries
2343
we use due to for example misconfigurations or so. If you want to increase the verbosity of specific
@@ -30,6 +50,17 @@
3050

3151
<Logger name="org.openapitools.codegen" level="off"/>
3252

53+
<!-- Analytics tables do not exist in the test database, so any test that drives
54+
the analytics engine (e.g. ADEX) produces expected "relation does not exist"
55+
SQL errors. The tests still pass; suppress the noise. -->
56+
<Logger name="org.hisp.dhis.analytics.data.JdbcAnalyticsManager" level="fatal" additivity="false"/>
57+
<Logger name="org.hisp.dhis.analytics.data.handler.DataHandler" level="fatal" additivity="false"/>
58+
<Logger name="org.hisp.dhis.analytics.util.AnalyticsUtils" level="fatal" additivity="false"/>
59+
60+
<!-- Tests that verify uniqueness constraints intentionally trigger duplicate-key
61+
violations; Hibernate logs every such exception at ERROR via SqlExceptionHelper. -->
62+
<Logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" level="fatal" additivity="false"/>
63+
3364
<!-- A few examples of loggers that might be useful to debug integration test issues.
3465
Adding an AppenderRef is necessary to overrule the log level we have set on the Root AppenderRefs.
3566
Once you add an AppenderRef to a Logger you need to set additivity to false otherwise logs might appear twice

0 commit comments

Comments
 (0)