Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracer TestWithHeaderTags: Clear header tags to work with -count=2 #2262

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

evanj
Copy link
Contributor

@evanj evanj commented Oct 11, 2023

What does this PR do?

This test currently fails when run with -count greater than 2 because it does not clear all the global state. Add a test to ensure there are no header tags set at the end. Clear all headers tags after each test.

This should ensure other tests aren't accidentally depending on this. It will help get the tests to pass with -count=10, which can be useful for tracking down flaky tests.

Motivation

I'm trying to track down race bugs, so I tried to run the tests with -count=10, and they fail.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.

For Datadog employees:

  • If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Unsure? Have a question? Request a review!

This test currently fails when run with -count greater than 2 because
it does not clear all the global state. Add a test to ensure there
are no header tags set at the end. Clear all headers tags after each
test.

This should ensure other tests aren't accidentally depending on this.
It will help get the tests to pass with -count=10, which can be
useful for tracking down flaky tests.
@evanj evanj requested a review from a team October 11, 2023 20:26
@pr-commenter
Copy link

pr-commenter bot commented Oct 11, 2023

Benchmarks

Benchmark execution time: 2023-10-12 14:10:54

Comparing candidate commit 9695a11 in PR branch evan.jones/testwithheadertags-count with baseline commit f72e6dd in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 40 metrics, 1 unstable metrics.

Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but see nit.

t.Run("default-off-at-end", func(t *testing.T) {
defer globalconfig.ClearHeaderTags()
newConfig()
assert.Equal(t, 0, globalconfig.HeaderTagsLen())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to move this assertion into the main test rather than a subtest? This way it also runs when the go test -run flag is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion, thank you! Done.

Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, 👍 to Felix's comment

@evanj evanj mentioned this pull request Oct 12, 2023
5 tasks
@felixge felixge enabled auto-merge (squash) October 12, 2023 16:20
@felixge felixge merged commit 3b5b794 into main Oct 12, 2023
51 of 52 checks passed
@felixge felixge deleted the evan.jones/testwithheadertags-count branch October 12, 2023 16:27
@darccio darccio restored the evan.jones/testwithheadertags-count branch November 16, 2023 15:44
@darccio darccio deleted the evan.jones/testwithheadertags-count branch November 16, 2023 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants