From a963cc783c404b541727b7680c5c18e1465c997f Mon Sep 17 00:00:00 2001 From: Laszlo Uveges Date: Fri, 22 Nov 2024 15:45:33 +0100 Subject: [PATCH] Fix tests --- service/collector/testdata/expected.1 | 4 ++-- service/collector/testdata/expected.2 | 4 ++-- tests/ats/metrics_test.go | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/service/collector/testdata/expected.1 b/service/collector/testdata/expected.1 index a9b026a5..c7a77fe7 100644 --- a/service/collector/testdata/expected.1 +++ b/service/collector/testdata/expected.1 @@ -1,4 +1,4 @@ # HELP app_operator_app_info Managed apps status. # TYPE app_operator_app_info gauge -app_operator_app_info{app="example",app_version="",catalog="customer",cluster_missing="false",deployed_version="1.0.0",latest_version="1.0.0",name="example",namespace="default",status="deployed",team="honeybadger",upgrade_available="false",version="1.0.0",version_mismatch="false"} 1 -app_operator_app_info{app="hello-world-app",app_version="",catalog="giantswarm",cluster_missing="false",deployed_version="0.3.0",latest_version="0.3.0",name="hello-world-app",namespace="hello-world",status="deployed",team="honeybadger",upgrade_available="false",version="0.3.0",version_mismatch="false"} 1 +app_operator_app_info{app="example",app_version="",catalog="customer",cluster_id="",cluster_missing="false",deployed_version="1.0.0",latest_version="1.0.0",name="example",namespace="default",status="deployed",team="honeybadger",upgrade_available="false",version="1.0.0",version_mismatch="false"} 1 +app_operator_app_info{app="hello-world-app",app_version="",catalog="giantswarm",cluster_id="",cluster_missing="false",deployed_version="0.3.0",latest_version="0.3.0",name="hello-world-app",namespace="hello-world",status="deployed",team="honeybadger",upgrade_available="false",version="0.3.0",version_mismatch="false"} 1 diff --git a/service/collector/testdata/expected.2 b/service/collector/testdata/expected.2 index 56bd7a87..4f6eb614 100644 --- a/service/collector/testdata/expected.2 +++ b/service/collector/testdata/expected.2 @@ -1,4 +1,4 @@ # HELP app_operator_app_info Managed apps status. # TYPE app_operator_app_info gauge -app_operator_app_info{app="example",app_version="",catalog="customer",cluster_missing="false",deployed_version="0.9.0",latest_version="1.0.0",name="example",namespace="default",status="deployed",team="honeybadger",upgrade_available="false",version="1.0.0",version_mismatch="true"} 1 -app_operator_app_info{app="hello-world-app",app_version="",catalog="giantswarm",cluster_missing="false",deployed_version="0.3.0",latest_version="0.3.0",name="hello-world-app",namespace="hello-world",status="deployed",team="honeybadger",upgrade_available="false",version="0.3.0",version_mismatch="false"} 1 +app_operator_app_info{app="example",app_version="",catalog="customer",cluster_id="",cluster_missing="false",deployed_version="0.9.0",latest_version="1.0.0",name="example",namespace="default",status="deployed",team="honeybadger",upgrade_available="false",version="1.0.0",version_mismatch="true"} 1 +app_operator_app_info{app="hello-world-app",app_version="",catalog="giantswarm",cluster_id="",cluster_missing="false",deployed_version="0.3.0",latest_version="0.3.0",name="hello-world-app",namespace="hello-world",status="deployed",team="honeybadger",upgrade_available="false",version="0.3.0",version_mismatch="false"} 1 diff --git a/tests/ats/metrics_test.go b/tests/ats/metrics_test.go index 73bdab56..fd568d4e 100644 --- a/tests/ats/metrics_test.go +++ b/tests/ats/metrics_test.go @@ -239,10 +239,11 @@ func TestMetrics(t *testing.T) { appVersion = expkey.FormatVersion(app.Status.AppVersion) } - expectedAppExporterMetric := fmt.Sprintf("app_operator_app_info{app=\"%s\",app_version=\"%s\",catalog=\"%s\",cluster_missing=\"%s\",deployed_version=\"%s\",latest_version=\"%s\",name=\"%s\",namespace=\"%s\",status=\"%s\",team=\"noteam\",upgrade_available=\"%s\",version=\"%s\",version_mismatch=\"%s\",cluster_id=\"%s\"} 1", + expectedAppExporterMetric := fmt.Sprintf("app_operator_app_info{app=\"%s\",app_version=\"%s\",catalog=\"%s\",cluster_id=\"%s\",cluster_missing=\"%s\",deployed_version=\"%s\",latest_version=\"%s\",name=\"%s\",namespace=\"%s\",status=\"%s\",team=\"noteam\",upgrade_available=\"%s\",version=\"%s\",version_mismatch=\"%s\"} 1", app.Spec.Name, appVersion, app.Spec.Catalog, + "", "false", expkey.FormatVersion(app.Status.Version), // deployed_version "", // latest_version is empty @@ -251,8 +252,7 @@ func TestMetrics(t *testing.T) { app.Status.Release.Status, "false", // upgrade_avaiable is false expkey.FormatVersion(app.Spec.Version), // version is the desired version - strconv.FormatBool(app.Spec.Version != app.Status.Version), - "") + strconv.FormatBool(app.Spec.Version != app.Status.Version)) t.Logf("f\n%s", expectedAppExporterMetric) @@ -262,10 +262,11 @@ func TestMetrics(t *testing.T) { t.Fatalf("expected nil got %#q", err) } - expectedTestAppMetric := fmt.Sprintf("app_operator_app_info{app=\"%s\",app_version=\"%s\",catalog=\"%s\",cluster_missing=\"%s\",deployed_version=\"%s\",latest_version=\"%s\",name=\"%s\",namespace=\"%s\",status=\"%s\",team=\"noteam\",upgrade_available=\"%s\",version=\"%s\",version_mismatch=\"%s\",cluster_id=\"%s\"} 1", + expectedTestAppMetric := fmt.Sprintf("app_operator_app_info{app=\"%s\",app_version=\"%s\",catalog=\"%s\",cluster_id=\"%s\",cluster_missing=\"%s\",deployed_version=\"%s\",latest_version=\"%s\",name=\"%s\",namespace=\"%s\",status=\"%s\",team=\"noteam\",upgrade_available=\"%s\",version=\"%s\",version_mismatch=\"%s\"} 1", testApp.Spec.Name, "1.0.0", testApp.Spec.Catalog, + "kind", "false", expkey.FormatVersion(testApp.Status.Version), // deployed_version "", // latest_version is empty @@ -274,8 +275,7 @@ func TestMetrics(t *testing.T) { testApp.Status.Release.Status, "false", // upgrade_avaiable is false expkey.FormatVersion(testApp.Spec.Version), // version is the desired version - strconv.FormatBool(testApp.Spec.Version != testApp.Status.Version), - "kind") + strconv.FormatBool(testApp.Spec.Version != testApp.Status.Version)) respBytes, err := ioutil.ReadAll(metricsResp.Body) if err != nil {