Skip to content

Commit

Permalink
integration: add text for presence of certain labels in certain metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nadiamoe committed Jan 15, 2025
1 parent 934c665 commit 7b04031
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@ func TestSMK6(t *testing.T) {
}
})

t.Run("labels are present", func(t *testing.T) {
t.Parallel()

// requiredLabels maps metric names to label names that are required to be present on that metric.
requiredLabels := map[string][]string{
// FIXME: probe_http_info will not contain these labels if the request failed, so an instance of this metric
// fails this test.
//"probe_http_info": {"tls_version", "proto"},
"probe_http_duration_seconds": {"phase"},
"checks_total": {"result"},
}

for _, mf := range mfs {
for _, m := range mf.Metric {
required := requiredLabels[*mf.Name]
for _, req := range required {
if !slices.ContainsFunc(m.Label, func(lp *prometheus.LabelPair) bool { return *lp.Name == req }) {
t.Fatalf("metric %q does not contain label %q", *mf.Name, req)
}
}
}
}
})

t.Run("labels are not present", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 7b04031

Please sign in to comment.