From 09c00606cb911e9b9a5497d2b231a6dd49b5fb20 Mon Sep 17 00:00:00 2001 From: Ziya Suzen Date: Thu, 7 Nov 2024 18:25:14 +0000 Subject: [PATCH] Fix test --- surveyor/surveyor_test.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/surveyor/surveyor_test.go b/surveyor/surveyor_test.go index 87f9426..9beb538 100644 --- a/surveyor/surveyor_test.go +++ b/surveyor/surveyor_test.go @@ -20,6 +20,7 @@ import ( "io" "net/http" "os" + "regexp" "strings" "sync" "testing" @@ -326,23 +327,23 @@ func TestSurveyor_AccountJetStreamAssets(t *testing.T) { t.Fatal(err) } - want := []string{ - "nats_core_account_bytes_recv", - "nats_core_account_bytes_sent", - "nats_core_account_conn_count", - "nats_core_account_count", - "nats_core_account_jetstream_enabled", - `nats_core_account_jetstream_stream_count{account="JS"} 10`, - `nats_core_account_jetstream_consumer_count{account="JS",stream="repl1"} 5`, - `nats_core_account_jetstream_consumer_count{account="JS",stream="repl2"} 5`, - `nats_core_account_jetstream_consumer_count{account="JS",stream="single1"} 5`, - `nats_core_account_jetstream_tiered_storage_used{account="JS",tier="R1"}`, - `nats_core_account_jetstream_tiered_storage_used{account="JS",tier="R3"}`, - `nats_core_account_jetstream_tiered_storage_reserved{account="JS",tier="R1"}`, - `nats_core_account_jetstream_tiered_storage_reserved{account="JS",tier="R3"}`, + want := []*regexp.Regexp{ + regexp.MustCompile(`nats_core_account_bytes_recv`), + regexp.MustCompile(`nats_core_account_bytes_sent`), + regexp.MustCompile(`nats_core_account_conn_count`), + regexp.MustCompile(`nats_core_account_count`), + regexp.MustCompile(`nats_core_account_jetstream_enabled`), + regexp.MustCompile(`nats_core_account_jetstream_stream_count\{account="JS"} 10`), + regexp.MustCompile(`nats_core_account_jetstream_consumer_count\{account="JS",raft_group="[^"]+",stream="repl1"} 5`), + regexp.MustCompile(`nats_core_account_jetstream_consumer_count\{account="JS",raft_group="[^"]+",stream="repl2"} 5`), + regexp.MustCompile(`nats_core_account_jetstream_consumer_count\{account="JS",raft_group="[^"]+",stream="single1"} 5`), + regexp.MustCompile(`nats_core_account_jetstream_tiered_storage_used\{account="JS",tier="R1"}`), + regexp.MustCompile(`nats_core_account_jetstream_tiered_storage_used\{account="JS",tier="R3"}`), + regexp.MustCompile(`nats_core_account_jetstream_tiered_storage_reserved\{account="JS",tier="R1"}`), + regexp.MustCompile(`nats_core_account_jetstream_tiered_storage_reserved\{account="JS",tier="R3"}`), } for _, m := range want { - if !strings.Contains(output, m) { + if !m.MatchString(output) { t.Logf("output: %s", output) t.Fatalf("missing: %s", m) }