Skip to content

Fix RumActionScopeTest tests failing under high CPU load#3604

Open
abrooksv wants to merge 1 commit into
developfrom
abrooks/fix-flaky-RumActionScopeTest
Open

Fix RumActionScopeTest tests failing under high CPU load#3604
abrooksv wants to merge 1 commit into
developfrom
abrooks/fix-flaky-RumActionScopeTest

Conversation

@abrooksv

@abrooksv abrooksv commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Events created in RumActionScopeTest were using the real time so they were failing under high CPU
  • Also fix the missing resource key test setup not making sense since the key.toString for the resource key had no relation to the key so the null-ing was irrelevant and the assert statement at the end impossible to fail

Motivation

local_ci.sh kept failing locally due to high CPU load

Failure:

Add the seed in your @ForgeConfiguration annotation :
        @ForgeConfiguration(value = Configurator::class, seed = 0x35a017ed8260cL)
RumActionScopeTest > M doNothing W handleEvent(StartResource+any)(String, RumResourceMethod, String) FAILED
    org.mockito.exceptions.verification.NoInteractionsWanted at RumActionScopeTest.kt:2746


Add the seed in your @ForgeConfiguration annotation :
        @ForgeConfiguration(value = Configurator::class, seed = 0x35a01adfc0747L)
RumActionScopeTest > M send Action after threshold W handleEvent(StartResource+any) missing resource key(RumResourceMethod, String) FAILED
    java.lang.AssertionError at RumActionScopeTest.kt:631

@abrooksv abrooksv force-pushed the abrooks/fix-flaky-RumActionScopeTest branch 2 times, most recently from e165b77 to e6cad7a Compare July 2, 2026 22:09
* Events created in RumActionScopeTest were using the real time so they were failing under high CPU
* Also fix the missing resource key test setup not making sense since the key.toString for the resource key had no relation to the key so the null-ing was irrelevant and the assert statement at the end impossible to fail
@abrooksv abrooksv force-pushed the abrooks/fix-flaky-RumActionScopeTest branch from e6cad7a to cc2789d Compare July 2, 2026 22:46
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.81%. Comparing base (0443e2a) to head (cc2789d).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3604      +/-   ##
===========================================
- Coverage    72.85%   72.81%   -0.04%     
===========================================
  Files          975      975              
  Lines        35277    35263      -14     
  Branches      5972     5974       +2     
===========================================
- Hits         25700    25676      -24     
- Misses        7915     7923       +8     
- Partials      1662     1664       +2     

see 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abrooksv abrooksv marked this pull request as ready for review July 3, 2026 02:13
@abrooksv abrooksv requested review from a team as code owners July 3, 2026 02:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc2789d372

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 618 to +621
System.gc()
assertThat(keyRef.get())
.describedAs("resource key should have been garbage collected by now")
.isNull()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid relying on a single GC cycle

On JVMs/CI configurations where System.gc() is ignored, disabled, or collection is simply delayed, this new assertion can fail even though RumActionScope only retains a weak reference to the key. That makes this unit test flaky before it reaches the behavior it is trying to verify; use a deterministic helper/retry loop or avoid asserting immediate collection after one GC request.

Useful? React with 👍 / 👎.

@hamorillo

Copy link
Copy Markdown
Contributor

Just some thoughts: not directly related to this PR, but I would say, we need to get rid of the default value in RumRawEvent instantiations.

override val eventTime: Time = Time() -> override val eventTime: Time

And pass that value to the constructor using TimeProvider.

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.

3 participants