From 334a43611620f7da9573fb5cb68cfe3fe2911670 Mon Sep 17 00:00:00 2001 From: Jennie Gao Date: Mon, 30 Oct 2023 16:03:06 -0400 Subject: [PATCH] update tests --- ddtrace/tracer/exec_tracer_test.go | 3 ++- ddtrace/tracer/option_test.go | 6 ++++-- ddtrace/tracer/remote_config_test.go | 18 ++++++++++++------ ddtrace/tracer/tracer_test.go | 6 ++++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ddtrace/tracer/exec_tracer_test.go b/ddtrace/tracer/exec_tracer_test.go index 0ff8e239f9..e00af1d0ee 100644 --- a/ddtrace/tracer/exec_tracer_test.go +++ b/ddtrace/tracer/exec_tracer_test.go @@ -34,7 +34,8 @@ func TestExecutionTraceSpans(t *testing.T) { // multiple times. defer rt.Stop() - _, _, _, stop := startTestTracer(t) + _, _, _, stop, err := startTestTracer(t) + assert.Nil(t, err) defer stop() root, ctx := StartSpanFromContext(context.Background(), "root") diff --git a/ddtrace/tracer/option_test.go b/ddtrace/tracer/option_test.go index 37aa38ffe9..39d6c07469 100644 --- a/ddtrace/tracer/option_test.go +++ b/ddtrace/tracer/option_test.go @@ -558,7 +558,8 @@ func TestTracerOptionsDefaults(t *testing.T) { t.Run("code-override-full-URL", func(t *testing.T) { t.Setenv("DD_TRACE_AGENT_URL", "https://custom:1234") - tracer := newTracer(WithAgentURL("http://testhost:3333")) + tracer, err := newTracer(WithAgentURL("http://testhost:3333")) + assert.Nil(t, err) defer tracer.Stop() c := tracer.config assert.Equal(t, &url.URL{Scheme: "http", Host: "testhost:3333"}, c.agentURL) @@ -569,7 +570,8 @@ func TestTracerOptionsDefaults(t *testing.T) { // Have to use UseLogger directly before tracer logger is set defer log.UseLogger(tp)() t.Setenv("DD_TRACE_AGENT_URL", "https://localhost:1234") - tracer := newTracer(WithAgentURL("go://testhost:3333")) + tracer, err := newTracer(WithAgentURL("go://testhost:3333")) + assert.Nil(t, err) defer tracer.Stop() c := tracer.config assert.Equal(t, &url.URL{Scheme: "https", Host: "localhost:1234"}, c.agentURL) diff --git a/ddtrace/tracer/remote_config_test.go b/ddtrace/tracer/remote_config_test.go index 9bcbd1dc73..394bf5cbbc 100644 --- a/ddtrace/tracer/remote_config_test.go +++ b/ddtrace/tracer/remote_config_test.go @@ -17,7 +17,8 @@ import ( func TestOnRemoteConfigUpdate(t *testing.T) { t.Run("RC sampling rate = 0.5 is applied and can be reverted", func(t *testing.T) { - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() // Apply RC. Assert _dd.rule_psr shows the RC sampling rate (0.2) is applied @@ -41,7 +42,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) { t.Run("DD_TRACE_SAMPLE_RATE=0.1 and RC sampling rate = 0.2", func(t *testing.T) { t.Setenv("DD_TRACE_SAMPLE_RATE", "0.1") - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() // Apply RC. Assert _dd.rule_psr shows the RC sampling rate (0.2) is applied @@ -64,7 +66,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) { }) t.Run("RC header tags = X-Test-Header:my-tag-name is applied and can be reverted", func(t *testing.T) { - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() // Apply RC. Assert global config shows the RC header tag is applied @@ -85,7 +88,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) { t.Run("DD_TRACE_HEADER_TAGS=X-Test-Header:my-tag-name-from-env and RC header tags = X-Test-Header:my-tag-name-from-rc", func(t *testing.T) { t.Setenv("DD_TRACE_HEADER_TAGS", "X-Test-Header:my-tag-name-from-env") - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() // Apply RC. Assert global config shows the RC header tag is applied @@ -106,7 +110,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) { }) t.Run("In code header tags = X-Test-Header:my-tag-name-in-code and RC header tags = X-Test-Header:my-tag-name-from-rc", func(t *testing.T) { - tracer, _, _, stop := startTestTracer(t, WithHeaderTags([]string{"X-Test-Header:my-tag-name-in-code"})) + tracer, _, _, stop, err := startTestTracer(t, WithHeaderTags([]string{"X-Test-Header:my-tag-name-in-code"})) + require.Nil(t, err) defer stop() // Apply RC. Assert global config shows the RC header tag is applied @@ -127,7 +132,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) { }) t.Run("Invalid payload", func(t *testing.T) { - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() input := map[string]remoteconfig.ProductUpdate{ diff --git a/ddtrace/tracer/tracer_test.go b/ddtrace/tracer/tracer_test.go index 16636507ea..141e908e3f 100644 --- a/ddtrace/tracer/tracer_test.go +++ b/ddtrace/tracer/tracer_test.go @@ -1891,7 +1891,8 @@ func TestGitMetadata(t *testing.T) { t.Run("git-metadata-from-dd-tags-with-credentials", func(t *testing.T) { t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:https://user:passwd@github.com/user/repo go_path:somepath") - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() defer maininternal.ResetGitMetadataTags() @@ -1928,7 +1929,8 @@ func TestGitMetadata(t *testing.T) { t.Setenv(maininternal.EnvGitRepositoryURL, "https://u:t@github.com/user/repo_new") t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE") - tracer, _, _, stop := startTestTracer(t) + tracer, _, _, stop, err := startTestTracer(t) + require.Nil(t, err) defer stop() defer maininternal.ResetGitMetadataTags()