@@ -74,46 +74,62 @@ boolean isLocal() {
7474
7575 @ BeforeAll
7676 void setupObservability () {
77- if (!isLocal ()) {
7877 log .info ("Setting up observability stack..." );
7978 try {
80- // Run the install-observability.sh script
81- ProcessBuilder processBuilder =
82- new ProcessBuilder ("bash" , "../../observability/install-observability.sh" );
83- processBuilder .directory (new File ("sample-operators/metrics-processing" ));
84- processBuilder .redirectErrorStream (true );
85-
86- Process process = processBuilder .start ();
87- BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
88- String line ;
89- while ((line = reader .readLine ()) != null ) {
90- log .info ("Observability setup: {}" , line );
91- }
92-
93- int exitCode = process .waitFor ();
94- if (exitCode != 0 ) {
95- log .warn ("Observability setup script returned exit code: {}" , exitCode );
96- }
79+ // // Find the observability script relative to project root
80+ // File projectRoot = new File(".").getCanonicalFile();
81+ // while (projectRoot != null && !new File(projectRoot, "observability").exists()) {
82+ // projectRoot = projectRoot.getParentFile();
83+ // }
84+ //
85+ // if (projectRoot == null) {
86+ // throw new IllegalStateException("Could not find observability directory");
87+ // }
88+ //
89+ // File scriptFile = new File(projectRoot, "observability/install-observability.sh");
90+ // if (!scriptFile.exists()) {
91+ // throw new IllegalStateException("Observability script not found at: " + scriptFile.getAbsolutePath());
92+ // }
93+ //
94+ // log.info("Running observability setup script: {}", scriptFile.getAbsolutePath());
95+ //
96+ // // Run the install-observability.sh script
97+ // ProcessBuilder processBuilder =
98+ // new ProcessBuilder("/bin/sh", scriptFile.getAbsolutePath());
99+ // processBuilder.redirectErrorStream(true);
100+ //
101+ // processBuilder.environment().putAll(System.getenv());
102+ // Process process = processBuilder.start();
103+ // BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
104+ // String line;
105+ // while ((line = reader.readLine()) != null) {
106+ // log.info("Observability setup: {}", line);
107+ // }
108+ //
109+ // int exitCode = process.waitFor();
110+ // if (exitCode != 0) {
111+ // log.warn("Observability setup script returned exit code: {}", exitCode);
112+ // }
97113
98114 // Wait for Prometheus to be ready
99115 await ()
100- .atMost (Duration .ofMinutes (3 ))
101- .pollInterval (Duration .ofSeconds (5 ))
102- .untilAsserted (
103- () -> {
104- var prometheusPod =
105- operator
106- .getKubernetesClient ()
107- .pods ()
108- .inNamespace (OBSERVABILITY_NAMESPACE )
109- .withLabel ("app" , "prometheus" )
110- .list ()
111- .getItems ()
112- .stream ()
113- .findFirst ();
114- assertThat (prometheusPod ).isPresent ();
115- assertThat (prometheusPod .get ().getStatus ().getPhase ()).isEqualTo ("Running" );
116- });
116+ .atMost (Duration .ofMinutes (3 ))
117+ .pollInterval (Duration .ofSeconds (5 ))
118+ .untilAsserted (
119+ () -> {
120+ var prometheusPod =
121+ operator
122+ .getKubernetesClient ()
123+ .pods ()
124+ .inNamespace (OBSERVABILITY_NAMESPACE )
125+ .withLabel ("app.kubernetes.io/name " , "prometheus" )
126+ .list ()
127+ .getItems ()
128+ .stream ()
129+ .findFirst ();
130+ assertThat (prometheusPod ).isPresent ();
131+ assertThat (prometheusPod .get ().getStatus ().getPhase ()).isEqualTo ("Running" );
132+ });
117133
118134 log .info ("Observability stack is ready" );
119135
@@ -124,17 +140,17 @@ void setupObservability() {
124140 log .error ("Failed to setup observability stack" , e );
125141 throw new RuntimeException (e );
126142 }
127- }
128- }
129143
144+
145+ }
130146 private void setupPrometheusPortForward () {
131147 try {
132148 Pod prometheusPod =
133149 operator
134150 .getKubernetesClient ()
135151 .pods ()
136152 .inNamespace (OBSERVABILITY_NAMESPACE )
137- .withLabel ("app" , "prometheus" )
153+ .withLabel ("app.kubernetes.io/name " , "prometheus" )
138154 .list ()
139155 .getItems ()
140156 .stream ()
0 commit comments