Skip to content

Conversation

@Denovo1998
Copy link
Contributor

@Denovo1998 Denovo1998 commented Oct 18, 2025

Fixes #24874

Main Issue: #xyz

PIP: #xyz

Motivation

  • The test FunctionAssignmentTailerTest.testErrorNotifier was flaky and intermittently failed with Mockito’s UnfinishedStubbingException.
  • Root cause: the test re-stubbed functionRuntimeManager.processAssignmentMessage while the FunctionAssignmentTailer background thread was concurrently invoking the same mock. This race condition led Mockito to detect “unfinished stubbing.”
  • The goal is to make the test deterministic by preventing concurrent re-stubbing.

Modifications

  • In testErrorNotifier:
    • Introduced two CountDownLatch instances (firstProcessed and release) to coordinate between the test thread and the background tailer thread.
    • Stubbed processAssignmentMessage(eq(message1)) with doAnswer so that the background thread:
      • signals firstProcessed when it reaches the first processing, and
      • blocks on release.await(...) to allow the test thread to safely re-stub behavior.
    • After firstProcessed.await(...), re-stubbed processAssignmentMessage(any()) to throw new RuntimeException("test").
    • Released the blocked first invocation via release.countDown(), then enqueued the second message and asserted that ErrorNotifier was triggered with the expected cause.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: Denovo1998#15

…by synchronizing mock stubbing with CountDownLatch
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.32%. Comparing base (ee33c99) to head (7276a99).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24875      +/-   ##
============================================
- Coverage     74.45%   74.32%   -0.13%     
+ Complexity    33531    33503      -28     
============================================
  Files          1913     1913              
  Lines        149280   149315      +35     
  Branches      17324    17331       +7     
============================================
- Hits         111140   110979     -161     
- Misses        29341    29511     +170     
- Partials       8799     8825      +26     
Flag Coverage Δ
inttests 26.45% <ø> (-0.48%) ⬇️
systests 22.77% <ø> (-0.12%) ⬇️
unittests 73.86% <ø> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 107 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Technoboy- Technoboy- merged commit 387ea92 into apache:master Oct 27, 2025
100 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs ready-to-test type/flaky-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky-test: FunctionAssignmentTailerTest.testErrorNotifier

3 participants