From 60acc058ccbd6868a8ad3077082c0033f70265e4 Mon Sep 17 00:00:00 2001 From: Dominik Hanak Date: Thu, 8 Feb 2024 21:13:22 +0100 Subject: [PATCH] Add workaround for different output on different CI's See comment, GHA nodes behave different to Apache CI. Temporary workaround for this --- test/e2e/helpers.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/helpers.go b/test/e2e/helpers.go index a2826631a..2181c137f 100644 --- a/test/e2e/helpers.go +++ b/test/e2e/helpers.go @@ -100,10 +100,15 @@ func getHealthStatusInContainer(podName string, containerName string, ns string) cmd := exec.Command("kubectl", "exec", "-t", podName, "-n", ns, "-c", containerName, "--", "curl", "-s", "localhost:8080/q/health") output, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) + // On Apache CI Nodes, does not return valid JSON, hence we match first and last brackets by index and extract it stringOutput := string(output) startIndex := strings.Index(stringOutput, "{") endIndex := strings.LastIndex(stringOutput, "}") - stringOutput = stringOutput[startIndex-1:endIndex+1] + if (startIndex == 0) { + stringOutput = stringOutput[startIndex:endIndex+1] + } else { + stringOutput = stringOutput[startIndex-1:endIndex+1] + } fmt.Printf("Parsed following JSON object from health Endpoint response: %v\n", stringOutput) err = json.Unmarshal([]byte(stringOutput), &h) if err != nil {