From e754f395a8a8563110c7353be94fe07b3e607731 Mon Sep 17 00:00:00 2001 From: Salva Corts Date: Mon, 21 Oct 2024 09:41:35 +0200 Subject: [PATCH] test tenant const --- pkg/pattern/drain/drain_test.go | 37 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/pkg/pattern/drain/drain_test.go b/pkg/pattern/drain/drain_test.go index bf455f1088c80..c2beda4b44d5f 100644 --- a/pkg/pattern/drain/drain_test.go +++ b/pkg/pattern/drain/drain_test.go @@ -14,12 +14,15 @@ import ( "github.com/grafana/loki/v3/pkg/logql/log/pattern" ) +const ( + testTenant = "fake" +) + func TestDrain_TrainExtractsPatterns(t *testing.T) { t.Parallel() // Set this so the test will print the patterns found, in string slice format for easy copy-paste outputPatternsForTestUpdate := false - tests := []struct { drain *Drain inputFile string @@ -27,7 +30,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { format string }{ { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: `testdata/agent-logfmt.txt`, format: FormatLogfmt, patterns: []string{ @@ -56,7 +59,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: `testdata/ingester-logfmt.txt`, format: FormatLogfmt, patterns: []string{ @@ -66,7 +69,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: `testdata/drone-json.txt`, format: FormatJSON, patterns: []string{ @@ -79,7 +82,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/distributor-logfmt.txt", format: FormatLogfmt, patterns: []string{ @@ -91,7 +94,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/journald.txt", format: FormatUnknown, patterns: []string{ @@ -211,7 +214,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/kafka.txt", format: FormatUnknown, patterns: []string{ @@ -232,7 +235,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/kubernetes.txt", format: FormatUnknown, patterns: []string{ @@ -273,7 +276,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/vault.txt", format: FormatUnknown, patterns: []string{ @@ -281,7 +284,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/calico.txt", format: FormatUnknown, patterns: []string{ @@ -374,7 +377,7 @@ func TestDrain_TrainExtractsPatterns(t *testing.T) { }, }, { - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputFile: "testdata/grafana-ruler.txt", format: FormatLogfmt, patterns: []string{ @@ -470,7 +473,7 @@ func TestDrain_TrainGeneratesPatternsMatchableByLokiPatternFilter(t *testing.T) }{ { name: "should extract patterns that all lines match", - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputLines: []string{ "test 1 test test", "test 2 test test", @@ -480,7 +483,7 @@ func TestDrain_TrainGeneratesPatternsMatchableByLokiPatternFilter(t *testing.T) }, { name: "should extract patterns that match if line ends with newlines", - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputLines: []string{ `test 1 test test `, @@ -494,7 +497,7 @@ func TestDrain_TrainGeneratesPatternsMatchableByLokiPatternFilter(t *testing.T) }, { name: "should extract patterns that match if line ends with empty space", - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputLines: []string{ `test 1 test test `, `test 2 test test `, @@ -504,7 +507,7 @@ func TestDrain_TrainGeneratesPatternsMatchableByLokiPatternFilter(t *testing.T) }, { name: "should extract patterns that match if line starts with empty space", - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputLines: []string{ ` test 1 test test`, ` test 2 test test`, @@ -514,7 +517,7 @@ func TestDrain_TrainGeneratesPatternsMatchableByLokiPatternFilter(t *testing.T) }, { name: "Scheduler patterns are matchable", - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputLines: []string{ `ts=2024-05-30T12:50:36.648377186Z caller=scheduler_processor.go:143 level=warn msg="error contacting scheduler" err="rpc error: code = Unavailable desc = connection error: desc = \"error reading server preface: EOF\"" addr=10.0.151.101:9095`, `ts=2024-05-30T12:50:36.350575929Z caller=scheduler_processor.go:143 level=warn msg="error contacting scheduler" err="rpc error: code = Unavailable desc = connection error: desc = \"error reading server preface: EOF\"" addr=10.0.151.101:9095`, @@ -611,7 +614,7 @@ func TestDrain_PruneTreeClearsOldBranches(t *testing.T) { }{ { name: "should prune old branches", - drain: New("", DefaultConfig(), &fakeLimits{}, "", nil), + drain: New(testTenant, DefaultConfig(), &fakeLimits{}, "", nil), inputLines: []string{ "test test test A", "test test test B",