From f86ceea803ab557117f8cc4a423f16207edf3406 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 21 Dec 2020 18:20:43 -0500 Subject: [PATCH] config: remove test cases for impossible scenarios AEInterval is overridden by NonUserSource, so there is no way for a user to set this value. These two cases represented impossible real world scenarios. Instead the test is replaced with one that shows that the AEInterval can not be set by config. This change allows us to remove the hcltail and jsontail fields from testCase --- agent/config/runtime_test.go | 40 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index 6457f2afd9..2d300ff4fc 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -38,17 +38,15 @@ import ( type testCase struct { desc string args []string - pre func() // setup(t *testing.T) - json []string - hcl []string + pre func() // setup(t *testing.T) patch func(rt *RuntimeConfig) // expected err string // expectedErr warns []string // expectedWarnings opts LoadOpts - // TODO: move all of these to opts - hcltail, jsontail []string + json []string + hcl []string } // TestConfigFlagsAndEdgecases tests the command line flags and @@ -1720,18 +1718,14 @@ func TestLoad_IntegrationWithFlags(t *testing.T) { err: "Multiple public IPv6 addresses found. Please configure one", }, { - desc: "ae_interval invalid == 0", - args: []string{`-data-dir=` + dataDir}, - jsontail: []string{`{ "ae_interval": "0s" }`}, - hcltail: []string{`ae_interval = "0s"`}, - err: `ae_interval cannot be 0s. Must be positive`, - }, - { - desc: "ae_interval invalid < 0", - args: []string{`-data-dir=` + dataDir}, - jsontail: []string{`{ "ae_interval": "-1s" }`}, - hcltail: []string{`ae_interval = "-1s"`}, - err: `ae_interval cannot be -1s. Must be positive`, + desc: "ae_interval is overridden by NonUserSource", + args: []string{`-data-dir=` + dataDir}, + json: []string{`{ "ae_interval": "-1s" }`}, + hcl: []string{`ae_interval = "-1s"`}, + patch: func(rt *RuntimeConfig) { + rt.DataDir = dataDir + rt.AEInterval = time.Minute + }, }, { desc: "acl_datacenter invalid", @@ -4876,9 +4870,10 @@ func testConfig(t *testing.T, tests []testCase, dataDir string) { t.Fatal(tt.desc, ": JSON and HCL test case out of sync") } - srcs, tails := tt.json, tt.jsontail + // select the source + srcs := tt.json if format == "hcl" { - srcs, tails = tt.hcl, tt.hcltail + srcs = tt.hcl } // build the description @@ -4914,13 +4909,6 @@ func testConfig(t *testing.T, tests []testCase, dataDir string) { Data: data, }) } - for i, data := range tails { - b.Tail = append(b.Tail, FileSource{ - Name: fmt.Sprintf("tail-%d.%s", i, format), - Format: format, - Data: data, - }) - } actual, err := b.BuildAndValidate() switch {