Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uvegla committed Nov 22, 2024
1 parent 0ef9829 commit a963cc7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions service/collector/testdata/expected.1
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions service/collector/testdata/expected.2
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions tests/ats/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit a963cc7

Please sign in to comment.