From d8bdd71429bf57ee60e55f927d94fed357b12516 Mon Sep 17 00:00:00 2001 From: Anderson Queiroz Date: Tue, 3 Sep 2024 13:49:22 +0200 Subject: [PATCH] fix TestDiagnosticState agent health check (#5333) --- testing/integration/package_version_test.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/testing/integration/package_version_test.go b/testing/integration/package_version_test.go index eab8cb4d7d2..b23d18b2418 100644 --- a/testing/integration/package_version_test.go +++ b/testing/integration/package_version_test.go @@ -102,19 +102,26 @@ func TestComponentBuildHashInDiagnostics(t *testing.T) { } for _, c := range status.Components { + bs, err := json.MarshalIndent(status, "", " ") + if err != nil { + stateBuff.WriteString(fmt.Sprintf("%s not health, could not marshal status outptu: %v", + c.Name, err)) + return false + } + state := client.State(c.State) if state != client.Healthy { - bs, err := json.MarshalIndent(status, "", " ") - if err != nil { - stateBuff.WriteString(fmt.Sprintf("%s not health, could not marshal status outptu: %v", - c.Name, err)) - return false - } stateBuff.WriteString(fmt.Sprintf("%s not health, agent status output: %s", c.Name, bs)) return false } + + if c.VersionInfo.Meta.Commit == "" { + stateBuff.WriteString(fmt.Sprintf("%s health, but no versionInfo. agent status output: %s", + c.Name, bs)) + return false + } } return true