File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed
jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -86,17 +86,23 @@ private static void connectionTest(
8686 private static void checkConnectionLogs (JmxScraperContainer scraper , boolean expectedOk ) {
8787
8888 String [] logLines = scraper .getLogs ().split ("\n " );
89- String lastLine = logLines [logLines .length - 1 ];
90-
91- if (expectedOk ) {
92- assertThat (lastLine )
93- .describedAs ("should log connection success" )
94- .endsWith ("JMX connection test OK" );
95- } else {
96- assertThat (lastLine )
97- .describedAs ("should log connection failure" )
98- .endsWith ("JMX connection test ERROR" );
99- }
89+
90+ // usually only the last line can be checked, however when it fails with an exception
91+ // the stack trace is last in the output, so it's simpler to check all lines of log output
92+
93+ assertThat (logLines )
94+ .anySatisfy (
95+ line -> {
96+ if (expectedOk ) {
97+ assertThat (line )
98+ .describedAs ("should log connection success" )
99+ .contains ("JMX connection test OK" );
100+ } else {
101+ assertThat (line )
102+ .describedAs ("should log connection failure" )
103+ .contains ("JMX connection test ERROR" );
104+ }
105+ });
100106 }
101107
102108 private static void waitTerminated (GenericContainer <?> container ) {
You can’t perform that action at this time.
0 commit comments