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

Try to fix flaky profiler spec #3185

Merged
merged 2 commits into from
Oct 5, 2023
Merged

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Oct 5, 2023

What does this PR do?

This test attempts a fix to the flaky profiler tests that were added in #3162 (and that bit us in #3179).

I'm not able to reproduce the issue locally, but I suspect the issue is that the spec as written was racy:

  1. We start a background thread and synchronize with it via a queue
  2. The thing we assert on happens AFTER the synchronization (e.g. some method called after the queue is used to signal)

Thus, I suspect the issue is that once in a while, Ruby switches threads at just the wrong time: between 1 and 2, and thus our assertion fails.

Instead, I've changed the specs to have a wait_for step that waits for the stack trace of the thread to be what we previously only assumed it to be, and only then do we run the other assertions.

I call this fix "an attempt" since I wasn't able to reproduce the issue, BUT overall it's harmless: either I got it right and this fixes it for now, or I got it wrong, and we'll keep seeing the flaky specs, and I'll figure out something else to try.

Motivation:

Profiler always aims to have no flaky tests.

Additional Notes:

N/A

How to test the change?

Validate that CI is still green, and stays that way ;)

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Fixes datadog/ruby-guild#53

**What does this PR do?**

This test attempts a fix to the flaky profiler tests that were added in
 #3162 (and that bit us in #3179).

I'm not able to reproduce the issue locally, but I suspect the issue
is that the spec as written was racy:

1. We start a background thread and synchronize with it via a queue
2. The thing we assert on happens AFTER the synchronization (e.g.
   some method called after the queue is used to signal)

Thus, I suspect the issue is that once in a while, Ruby switches
threads at just the wrong time: between 1 and 2, and thus our
assertion fails.

Instead, I've changed the specs  to have a `wait_for` step that waits
for the stack trace of the thread to be what we previously only assumed
it to be, and only then do we run the other assertions.

I call this fix "an attempt" since I wasn't able to reproduce the
issue, BUT overall it's harmless: either I got it right and this
fixes it for got, or I got it wrong, and we'll keep seeing the
flaky specs, and I'll figure out something else to try.

**Motivation:**

Profiler always aims to have no flaky tests.

**Additional Notes:**

N/A

**How to test the change?**

Validate that CI is still green, and stays that way ;)

Fixes DataDog/ruby-guild#53
@ivoanjo ivoanjo requested a review from a team as a code owner October 5, 2023 09:48
@github-actions github-actions bot added the dev/testing Involves testing processes (e.g. RSpec) label Oct 5, 2023
@ivoanjo ivoanjo merged commit 3248f24 into master Oct 5, 2023
176 checks passed
@ivoanjo ivoanjo deleted the ivoanjo/maybe-fix-flaky-profiler-spec branch October 5, 2023 17:37
@github-actions github-actions bot added this to the 1.15.0 milestone Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/testing Involves testing processes (e.g. RSpec)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants