From d59b3b219632d43df5c3cf5518c00df3b1f83304 Mon Sep 17 00:00:00 2001 From: Andrew Glaude Date: Thu, 21 Nov 2024 14:32:18 -0500 Subject: [PATCH 1/3] Avoid looking up core agent hostname in tests that don't need it to avoid flakes --- comp/trace/config/config_test.go | 256 ++++++++++++++++--------------- 1 file changed, 130 insertions(+), 126 deletions(-) diff --git a/comp/trace/config/config_test.go b/comp/trace/config/config_test.go index 73517aec3e2e6..5412c921c79a9 100644 --- a/comp/trace/config/config_test.go +++ b/comp/trace/config/config_test.go @@ -18,7 +18,6 @@ import ( "path/filepath" "reflect" "regexp" - "runtime" "strings" "testing" "text/template" @@ -149,7 +148,7 @@ func TestSplitTagRegex(t *testing.T) { func TestTelemetryEndpointsConfig(t *testing.T) { t.Run("default", func(t *testing.T) { - config := buildConfigComponent(t) + config := buildConfigComponent(t, true) cfg := config.Object() require.NotNil(t, cfg) @@ -163,7 +162,7 @@ func TestTelemetryEndpointsConfig(t *testing.T) { "apm_config.telemetry.dd_url": "http://example.com/", } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -177,7 +176,7 @@ func TestTelemetryEndpointsConfig(t *testing.T) { "apm_config.telemetry.dd_url": "111://abc.com", } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -192,7 +191,7 @@ func TestTelemetryEndpointsConfig(t *testing.T) { "site": "new_site.example.com", } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -210,7 +209,7 @@ func TestTelemetryEndpointsConfig(t *testing.T) { "apm_config.telemetry.additional_endpoints": additionalEndpoints, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -233,7 +232,7 @@ func TestTelemetryEndpointsConfig(t *testing.T) { "apm_config.telemetry.additional_endpoints": additionalEndpoints, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -301,7 +300,7 @@ func TestConfigHostname(t *testing.T) { t.Skip() } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/site_override.yaml"}, Overrides: overrides, })) @@ -313,7 +312,7 @@ func TestConfigHostname(t *testing.T) { }) t.Run("file", func(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -326,7 +325,7 @@ func TestConfigHostname(t *testing.T) { t.Run("env", func(t *testing.T) { t.Setenv("DD_HOSTNAME", "onlyenv") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/site_override.yaml"}, })) cfg := config.Object() @@ -338,7 +337,7 @@ func TestConfigHostname(t *testing.T) { t.Run("file+env", func(t *testing.T) { t.Setenv("DD_HOSTNAME", "envoverride") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -352,7 +351,7 @@ func TestConfigHostname(t *testing.T) { "serverless.enabled": true, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/site_default.yaml"}, Overrides: overrides, })) @@ -405,7 +404,7 @@ func TestConfigHostname(t *testing.T) { bin := makeProgram(t, "host.name", 0) defer os.Remove(bin) - config := buildConfigComponent(t) + config := buildConfigComponent(t, false) cfg := config.Object() require.NotNil(t, cfg) @@ -419,7 +418,7 @@ func TestConfigHostname(t *testing.T) { bin := makeProgram(t, "", 0) defer os.Remove(bin) - config := buildConfigComponent(t) + config := buildConfigComponent(t, false) cfg := config.Object() require.NotNil(t, cfg) @@ -432,7 +431,7 @@ func TestConfigHostname(t *testing.T) { bin := makeProgram(t, "", 0) defer os.Remove(bin) - config := buildConfigComponent(t) + config := buildConfigComponent(t, false) cfg := config.Object() require.NotNil(t, cfg) @@ -447,7 +446,7 @@ func TestConfigHostname(t *testing.T) { bin := makeProgram(t, "", 1) defer os.Remove(bin) - config := buildConfigComponent(t) + config := buildConfigComponent(t, false) cfg := config.Object() require.NotNil(t, cfg) @@ -460,7 +459,7 @@ func TestConfigHostname(t *testing.T) { bin := makeProgram(t, "some text", 1) defer os.Remove(bin) - config := buildConfigComponent(t) + config := buildConfigComponent(t, false) cfg := config.Object() require.NotNil(t, cfg) @@ -483,7 +482,7 @@ func TestSite(t *testing.T) { "vector": {"./testdata/observability_pipelines_worker_override.yaml", "https://observability_pipelines_worker.domain.tld:8443"}, } { t.Run(name, func(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: tt.file}, })) cfg := config.Object() @@ -495,7 +494,7 @@ func TestSite(t *testing.T) { } func TestDefaultConfig(t *testing.T) { - config := buildConfigComponent(t) + config := buildConfigComponent(t, true) cfg := config.Object() require.NotNil(t, cfg) @@ -516,7 +515,7 @@ func TestDefaultConfig(t *testing.T) { } func TestNoAPMConfig(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/no_apm_config.yaml"}, })) cfg := config.Object() @@ -530,7 +529,7 @@ func TestNoAPMConfig(t *testing.T) { } func TestDisableLoggingConfig(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/disable_file_logging.yaml"}, })) cfg := config.Object() @@ -541,7 +540,7 @@ func TestDisableLoggingConfig(t *testing.T) { } func TestFullYamlConfig(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -642,7 +641,7 @@ func TestFullYamlConfig(t *testing.T) { } func TestFileLoggingDisabled(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/disable_file_logging.yaml"}, })) @@ -653,7 +652,7 @@ func TestFileLoggingDisabled(t *testing.T) { } func TestUndocumentedYamlConfig(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/undocumented.yaml"}, })) cfg := config.Object() @@ -711,7 +710,7 @@ func TestNormalizeEnvFromDDEnv(t *testing.T) { t.Run("", func(t *testing.T) { t.Setenv("DD_ENV", in) - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/no_apm_config.yaml"}, })) cfg := config.Object() @@ -733,7 +732,7 @@ func TestNormalizeEnvFromDDTags(t *testing.T) { t.Run("", func(t *testing.T) { t.Setenv("DD_TAGS", in) - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/no_apm_config.yaml"}, })) cfg := config.Object() @@ -755,7 +754,7 @@ func TestNormalizeEnvFromConfig(t *testing.T) { "./testdata/non-normalized_env_host_tag.yaml", } { t.Run("", func(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: cfgFile}, })) @@ -784,7 +783,7 @@ func TestLoadEnv(t *testing.T) { t.Setenv(tt.envOld, "1,2,3") t.Setenv(tt.envNew, "4,5,6") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -803,7 +802,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "123") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -815,7 +814,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_SITE" t.Run(env, func(t *testing.T) { t.Setenv(env, "my-site.com") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/site_default.yaml"}, })) @@ -828,7 +827,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_APM_ENABLED" t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -840,7 +839,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_APM_DD_URL" t.Run(env, func(t *testing.T) { t.Setenv(env, "my-site.com") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -852,7 +851,7 @@ func TestLoadEnv(t *testing.T) { env = "HTTPS_PROXY" t.Run(env, func(t *testing.T) { t.Setenv(env, "my-proxy.url") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -864,7 +863,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_PROXY_HTTPS" t.Run(env, func(t *testing.T) { t.Setenv(env, "my-proxy.url") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -876,7 +875,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_HOSTNAME" t.Run(env, func(t *testing.T) { t.Setenv(env, "local.host") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -888,7 +887,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_BIND_HOST" t.Run(env, func(t *testing.T) { t.Setenv(env, "bindhost.com") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, false, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -904,7 +903,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "1234") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -918,7 +917,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "4321") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -931,7 +930,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/undocumented.yaml"}, })) cfg := config.Object() @@ -944,7 +943,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "12.3") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/undocumented.yaml"}, })) cfg := config.Object() @@ -960,7 +959,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "1,2,3") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object() @@ -974,7 +973,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "web|http.request=1,db|sql.query=0.5") - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -991,7 +990,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `[{"name":"name1", "pattern":"pattern1"}, {"name":"name2","pattern":"pattern2","repl":"replace2"}]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -1018,7 +1017,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `important1 important2:value1`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -1032,7 +1031,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["important1:value with a space"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1046,7 +1045,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `important1 important2:^value1$`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -1060,7 +1059,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["important1:^value with a space$"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) @@ -1075,7 +1074,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `bad1:value1`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1088,7 +1087,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["bad1:value with a space"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1101,7 +1100,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["bad1:value with a space","bad2:value with spaces"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1117,7 +1116,7 @@ func TestLoadEnv(t *testing.T) { env = "DD_APM_FILTER_TAGS_REGEX_REJECT" t.Run(env, func(t *testing.T) { t.Setenv(env, `bad1:^value1$`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1129,7 +1128,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["bad1:value with a space"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1146,7 +1145,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "50") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1165,7 +1164,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "6") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/deprecated-max-tps-apm.yaml"}, })) @@ -1180,7 +1179,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "6") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1201,7 +1200,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "12") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1217,7 +1216,7 @@ func TestLoadEnv(t *testing.T) { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1233,7 +1232,7 @@ func TestLoadEnv(t *testing.T) { } { t.Run(envKey, func(t *testing.T) { t.Setenv(envKey, "7") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1247,7 +1246,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "337.41") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1260,7 +1259,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `{"url1": ["key1", "key2"], "url2": ["key3"]}`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1276,7 +1275,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-site.com") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1290,7 +1289,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-site.com") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1304,7 +1303,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-key") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1318,7 +1317,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `{"url1": ["key1", "key2"], "url2": ["key3"]}`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1339,7 +1338,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-diagnostics-site.com") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1353,7 +1352,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-diagnostics-key") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1367,7 +1366,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `{"diagnostics-url1": ["diagnostics-key1", "diagnostics-key2"], "diagnostics-url2": ["diagnostics-key3"]}`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1388,7 +1387,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-site.com") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1401,7 +1400,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "my-key") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1414,7 +1413,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `{"url1": ["key1", "key2"], "url2": ["key3"]}`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1435,7 +1434,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "false") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1450,7 +1449,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "false") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1463,7 +1462,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1477,7 +1476,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["client_id", "product_id"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1494,7 +1493,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["key1", "key2"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1511,7 +1510,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1525,7 +1524,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1539,7 +1538,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1553,7 +1552,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1569,7 +1568,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1583,7 +1582,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["document_id", "template_id"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1600,7 +1599,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["key1", "key2"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1617,7 +1616,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1631,7 +1630,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1645,7 +1644,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1659,7 +1658,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1673,7 +1672,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["id1", "id2"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1690,7 +1689,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["key1", "key2"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1707,7 +1706,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, "true") - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1721,7 +1720,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["id1", "id2"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1738,7 +1737,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `["key1", "key2"]`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1755,7 +1754,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `{"url1": ["key1", "key2"], "url2": ["key3"]}`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1776,7 +1775,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { assert := func(in string, _ []string) { t.Setenv(env, in) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1802,7 +1801,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `install_id_foo_bar`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1816,7 +1815,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `host_injection`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1830,7 +1829,7 @@ func TestLoadEnv(t *testing.T) { t.Run(env, func(t *testing.T) { t.Setenv(env, `1699621675`) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := c.Object() @@ -1862,7 +1861,7 @@ func TestFargateConfig(t *testing.T) { } { t.Run("", func(t *testing.T) { env.SetFeatures(t, data.features...) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/no_apm_config.yaml"}, })) @@ -1876,7 +1875,7 @@ func TestFargateConfig(t *testing.T) { func TestSetMaxMemCPU(t *testing.T) { t.Run("default, non-containerized", func(t *testing.T) { - config := buildConfigComponent(t) + config := buildConfigComponent(t, true) cfg := config.Object() require.NotNil(t, cfg) @@ -1887,7 +1886,7 @@ func TestSetMaxMemCPU(t *testing.T) { }) t.Run("default, containerized", func(t *testing.T) { - config := buildConfigComponent(t) + config := buildConfigComponent(t, true) cfg := config.Object() require.NotNil(t, cfg) @@ -1903,7 +1902,7 @@ func TestSetMaxMemCPU(t *testing.T) { "apm_config.max_memory": "200", } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -1918,7 +1917,7 @@ func TestSetMaxMemCPU(t *testing.T) { "apm_config.max_memory": "300", } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -1931,7 +1930,7 @@ func TestSetMaxMemCPU(t *testing.T) { func TestPeerTagsAggregation(t *testing.T) { t.Run("default-enabled", func(t *testing.T) { - config := buildConfigComponent(t) + config := buildConfigComponent(t, true) cfg := config.Object() assert.True(t, cfg.PeerTagsAggregation) assert.Nil(t, cfg.PeerTags) @@ -1948,7 +1947,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_service_aggregation": true, "apm_config.peer_tags_aggregation": false, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.False(t, cfg.PeerTagsAggregation) @@ -1961,7 +1960,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_service_aggregation": true, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.True(t, cfg.PeerTagsAggregation) @@ -1978,7 +1977,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_service_aggregation": false, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.True(t, cfg.PeerTagsAggregation) @@ -1996,7 +1995,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_tags_aggregation": true, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.True(t, cfg.PeerTagsAggregation) @@ -2014,7 +2013,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_tags_aggregation": false, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.False(t, cfg.PeerTagsAggregation) @@ -2027,7 +2026,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_tags": []string{"user_peer_tag"}, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.False(t, cfg.PeerTagsAggregation) @@ -2039,7 +2038,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_tags": []string{"user_peer_tag"}, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() assert.True(t, cfg.PeerTagsAggregation) assert.Equal(t, []string{"user_peer_tag"}, cfg.PeerTags) @@ -2055,7 +2054,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_tags_aggregation": true, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.True(t, cfg.PeerTagsAggregation) @@ -2068,7 +2067,7 @@ func TestPeerTagsAggregation(t *testing.T) { "apm_config.peer_service_aggregation": true, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) assert.True(t, cfg.PeerTagsAggregation) @@ -2084,7 +2083,7 @@ func TestPeerTagsAggregation(t *testing.T) { func TestComputeStatsBySpanKind(t *testing.T) { t.Run("default-enabled", func(t *testing.T) { - config := buildConfigComponent(t) + config := buildConfigComponent(t, true) cfg := config.Object() @@ -2096,7 +2095,7 @@ func TestComputeStatsBySpanKind(t *testing.T) { overrides := map[string]interface{}{ "apm_config.compute_stats_by_span_kind": false, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -2108,7 +2107,7 @@ func TestComputeStatsBySpanKind(t *testing.T) { "apm_config.compute_stats_by_span_kind": true, } - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{Overrides: overrides})) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{Overrides: overrides})) cfg := config.Object() require.NotNil(t, cfg) @@ -2124,7 +2123,7 @@ func TestGenerateInstallSignature(t *testing.T) { err = os.WriteFile(cfgFile, cfgContent, 0644) assert.NoError(t, err) - c := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + c := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: cfgFile}, })) @@ -2153,7 +2152,7 @@ func TestGenerateInstallSignature(t *testing.T) { func TestMockConfig(t *testing.T) { t.Setenv("DD_SITE", "datadoghq.eu") - config := buildConfigComponent(t, fx.Supply(corecomp.Params{})) + config := buildConfigComponent(t, true, fx.Supply(corecomp.Params{})) cfg := config.Object() require.NotNil(t, cfg) @@ -2162,7 +2161,7 @@ func TestMockConfig(t *testing.T) { } func TestMockDefaultConfig(t *testing.T) { - config := buildConfigComponent(t, fx.Supply(corecomp.Params{})) + config := buildConfigComponent(t, true, fx.Supply(corecomp.Params{})) cfg := config.Object() require.NotNil(t, cfg) @@ -2171,8 +2170,7 @@ func TestMockDefaultConfig(t *testing.T) { } func TestGetCoreConfigHandler(t *testing.T) { - t.Skip("skipping flaky test - APMSP-1390") - config := buildConfigComponent(t, fx.Supply(corecomp.Params{})) + config := buildConfigComponent(t, true, fx.Supply(corecomp.Params{})) handler := config.GetConfigHandler().(http.HandlerFunc) @@ -2209,8 +2207,10 @@ func TestGetCoreConfigHandler(t *testing.T) { } func TestDisableReceiverConfig(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/disable_receiver.yaml"}, + // Setting an explicit hostname here avoids a flake related to creating a grpc connection to a core agent that doesn't exist + Overrides: map[string]interface{}{"hostname": "testhostname"}, })) cfg := config.Object() @@ -2220,16 +2220,15 @@ func TestDisableReceiverConfig(t *testing.T) { } func TestOnUpdateAPIKeyCallback(t *testing.T) { - // APMSP-1494 - if runtime.GOOS == "darwin" { - t.Skip("skipping flaky test on darwin") - } var n int callback := func(_, _ string) { n++ } - config := buildConfigComponent(t) + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ + // Setting an explicit hostname here avoids a flake related to creating a grpc connection to a core agent that doesn't exist + Overrides: map[string]interface{}{"hostname": "testhostname"}, + })) config.OnUpdateAPIKey(callback) @@ -2238,13 +2237,18 @@ func TestOnUpdateAPIKeyCallback(t *testing.T) { assert.Equal(t, 1, n) } -func buildConfigComponent(t *testing.T, coreConfigOptions ...fx.Option) Component { +func buildConfigComponent(t *testing.T, setHostnameInConfig bool, coreConfigOptions ...fx.Option) Component { t.Helper() coreConfig := fxutil.Test[corecomp.Component](t, corecomp.MockModule(), fx.Options(coreConfigOptions...), ) + // set the hostname in the config to avoid trying to create a connection to the core agent + // (This can be slow and flaky in tests that don't need to run this logic) + if setHostnameInConfig { + coreConfig.SetWithoutSource("hostname", "testhostname") + } taggerComponent := fxutil.Test[taggermock.Mock](t, fx.Replace(coreConfig), From 148e0c3d1cbdd82f34e72af5d41c7210304e4176 Mon Sep 17 00:00:00 2001 From: Andrew Glaude Date: Thu, 21 Nov 2024 14:57:39 -0500 Subject: [PATCH 2/3] Whoops missed this duplicate hostname config --- comp/trace/config/config_test.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/comp/trace/config/config_test.go b/comp/trace/config/config_test.go index 5412c921c79a9..c17d4325221be 100644 --- a/comp/trace/config/config_test.go +++ b/comp/trace/config/config_test.go @@ -2209,8 +2209,6 @@ func TestGetCoreConfigHandler(t *testing.T) { func TestDisableReceiverConfig(t *testing.T) { config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/disable_receiver.yaml"}, - // Setting an explicit hostname here avoids a flake related to creating a grpc connection to a core agent that doesn't exist - Overrides: map[string]interface{}{"hostname": "testhostname"}, })) cfg := config.Object() @@ -2225,10 +2223,7 @@ func TestOnUpdateAPIKeyCallback(t *testing.T) { n++ } - config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ - // Setting an explicit hostname here avoids a flake related to creating a grpc connection to a core agent that doesn't exist - Overrides: map[string]interface{}{"hostname": "testhostname"}, - })) + config := buildConfigComponent(t, true) config.OnUpdateAPIKey(callback) From 8141c90d168d3eb328b5c5cbb753865887af98ec Mon Sep 17 00:00:00 2001 From: Andrew Glaude Date: Thu, 21 Nov 2024 16:04:09 -0500 Subject: [PATCH 3/3] missed a file --- comp/trace/config/config_otlp_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comp/trace/config/config_otlp_test.go b/comp/trace/config/config_otlp_test.go index c7429b3588547..eb092218859c1 100644 --- a/comp/trace/config/config_otlp_test.go +++ b/comp/trace/config/config_otlp_test.go @@ -20,7 +20,7 @@ import ( ) func TestFullYamlConfigWithOTLP(t *testing.T) { - config := buildConfigComponent(t, fx.Replace(corecomp.MockParams{ + config := buildConfigComponent(t, true, fx.Replace(corecomp.MockParams{ Params: corecomp.Params{ConfFilePath: "./testdata/full.yaml"}, })) cfg := config.Object()