11package dev .streamx .cli ;
22
33import static dev .streamx .cli .test .tools .ResourcePathResolver .absolutePath ;
4+ import static org .assertj .core .api .Assertions .fail ;
45
56import dev .streamx .cli .test .tools .terminal .TerminalCommandRunner ;
67import dev .streamx .cli .test .tools .terminal .process .ShellProcess ;
1011import jakarta .inject .Inject ;
1112import jakarta .inject .Named ;
1213import java .io .IOException ;
14+ import java .nio .charset .StandardCharsets ;
1315import java .nio .file .Files ;
1416import java .nio .file .Path ;
1517import java .time .Duration ;
18+ import org .apache .commons .io .IOUtils ;
19+ import org .apache .commons .lang3 .StringUtils ;
1620import org .eclipse .microprofile .config .inject .ConfigProperty ;
21+ import org .jboss .logging .Logger ;
1722import org .junit .jupiter .api .BeforeAll ;
1823import org .junit .jupiter .api .Test ;
1924import org .junit .jupiter .api .TestInstance ;
@@ -67,7 +72,19 @@ public void shouldPublishAndUnpublishPageUsingStreamOperation() {
6772 "Sent com.streamx.blueprints.page.published.v1 event using stream with key 'hello.html'"
6873 );
6974
70- validateStreamxPage ("hello.html" , "<b>Hello World!</b>" );
75+ // TODO remove the catch
76+ try {
77+ validateStreamxPage ("hello.html" , "<b>Hello World!</b>" );
78+ } catch (Throwable t ) {
79+ String dockerPsOutput = readProcessOutput ("docker ps" );
80+ String containerLine = dockerPsOutput .lines ()
81+ .filter (line -> line .contains ("web-server-sink" ))
82+ .findFirst ().orElseThrow ();
83+ String containerId = StringUtils .substringBefore (containerLine , " " );
84+ String logs = readProcessOutput ("docker logs " + containerId );
85+ Logger log = Logger .getLogger (StreamxCliPublicationIT .class );
86+ log .info ("\n ---- DOCKER CONTAINER LOGS ---\n " + logs );
87+ }
7188
7289 runStreamxIngestionCommand (
7390 "stream_v2" ,
@@ -78,6 +95,18 @@ public void shouldPublishAndUnpublishPageUsingStreamOperation() {
7895 validateStreamxPageNotAvailable ("hello.html" );
7996 }
8097
98+ private static String readProcessOutput (String command ) {
99+ String [] words = command .split (" " );
100+ ProcessBuilder builder = new ProcessBuilder (words );
101+ builder .redirectErrorStream (true ); // merge STDOUT + STDERR
102+ try {
103+ Process process = builder .start ();
104+ return IOUtils .toString (process .getInputStream (), StandardCharsets .UTF_8 );
105+ } catch (IOException ex ) {
106+ return fail ("Error reading output of command" , ex );
107+ }
108+ }
109+
81110 @ Test
82111 public void shouldPublishAndUnpublishPageUsingBatchOperation () {
83112 runStreamxIngestionCommand (
0 commit comments