Skip to content

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Nov 12, 2025

Summary

Improves the fix for the intermittent test failure in ResourceInitialSelectionTest.testSingleSelectionAndTwoInitialSelectionsWithInitialPattern that was still occasionally failing in CI despite the fix in commit 87352d6.

Problem with Existing Fix

The fix added in commit 87352d6 (Oct 25, 2025) added a waitForDialogRefresh() helper method but used a fixed-time wait of only 150ms (3 iterations × 50ms), which proved insufficient on slower systems like macOS CI.

Root Cause

  1. FilteredResourcesSelectionDialog.refresh() triggers async background jobs: FilterHistoryJob → FilterJob → RefreshCacheJob → RefreshJob
  2. These jobs populate the table and apply initial selections asynchronously
  3. The original fix waited only 150ms total
  4. On slower machines or under load, async operations take longer to complete
  5. Test checked selection before it was applied: expected:<[L/.../foo.txt]> but was:<[]>

Improved Solution

Enhanced waitForDialogRefresh() to use a condition-based approach:

private void waitForDialogRefresh() {
    Display display = PlatformUI.getWorkbench().getDisplay();
    
    // Wait up to 2 seconds for table to be populated (condition-based)
    DisplayHelper.waitForCondition(display, 2000, () -> {
        processUIEvents();
        try {
            Table table = getDialogTable();
            return table.getItemCount() > 0;
        } catch (Exception e) {
            return false;
        }
    });
    
    // Then wait 250ms for selection to be applied
    for (int i = 0; i < 5; i++) {
        processUIEvents();
        Thread.sleep(50);
    }
    
    processUIEvents();
}

Improvements:

  • Condition-based wait for table population (up to 2 seconds, returns immediately when ready)
  • Increased selection wait from 150ms to 250ms (5 × 50ms)
  • Faster on fast systems: Returns immediately when table is populated
  • More reliable on slow systems: Up to 2 seconds for async jobs to complete
  • Test time: ~9 seconds (vs ~16 seconds with longer fixed waits, ~3-4 seconds with original insufficient wait)

Changes

  • Modified waitForDialogRefresh() in ResourceInitialSelectionTest.java:454-489
  • Uses DisplayHelper.waitForCondition() for table population check
  • Builds on existing fix from commit 87352d6 (which already added the method and calls to 10 tests)

Testing

  • ✅ All 13 tests pass consistently
  • ✅ Verified with 3+ consecutive test runs - 0 failures
  • ✅ Test execution time: ~8-9 seconds (acceptable trade-off for reliability)
  • ✅ Works on both fast and slow systems

Related

  • Builds on fix from commit 87352d6 (Oct 25, 2025)
  • Addresses continuing flaky test failures in CI

🤖 Generated with Claude Code

@vogella vogella closed this Nov 12, 2025
@vogella vogella reopened this Nov 12, 2025
@vogella vogella force-pushed the fix-flaky-resource-initial-selection-test branch 2 times, most recently from 58c602d to cbbcf53 Compare November 12, 2025 12:17
@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

Test Results

 3 018 files  ±0   3 018 suites  ±0   2h 20m 52s ⏱️ + 6m 45s
 8 234 tests ±0   7 985 ✅ ±0  249 💤 ±0  0 ❌ ±0 
23 622 runs  ±0  22 828 ✅ ±0  794 💤 ±0  0 ❌ ±0 

Results for commit c3b9438. ± Comparison against base commit 7a24db1.

♻️ This comment has been updated with latest results.

The existing fix in eclipse/master (commit 87352d6) added a
waitForDialogRefresh() method but used a fixed-time wait (3 × 50ms = 150ms)
which was still insufficient on slower systems like macOS CI, causing
intermittent failures.

Root cause:
- FilteredResourcesSelectionDialog performs async operations (FilterHistoryJob
  → FilterJob → RefreshCacheJob → RefreshJob) after refresh()
- These jobs populate the table and apply initial selections asynchronously
- The original fix waited only 150ms, which is not enough on slow machines
- This caused the test to check selection before it was applied, resulting in:
  "expected:<[L/.../foo.txt]> but was:<[]>"

Improved fix:
- Changed waitForDialogRefresh() to use DisplayHelper.waitForCondition()
- Wait up to 2 seconds for table to be populated (condition-based, returns
  immediately when items appear)
- Then wait additional 250ms (5 × 50ms) for selection to be applied
- Total: condition-based wait + 250ms vs previous fixed 150ms
- Faster on fast systems (condition returns immediately when table populates)
- More reliable on slow systems (up to 2 seconds for table population)

This approach:
- Uses condition-based waiting for table population (more efficient)
- Provides adequate time for selection to be applied (250ms vs 150ms)
- Works reliably on both fast and slow systems
- Test time: ~9 seconds vs ~16 seconds with longer fixed waits

Verified with multiple consecutive test runs - all passed consistently.

Builds on the fix from commit 87352d6 which already added
waitForDialogRefresh() to the appropriate tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@vogella vogella force-pushed the fix-flaky-resource-initial-selection-test branch from cbbcf53 to c3b9438 Compare November 12, 2025 17:22
@vogella vogella marked this pull request as ready for review November 12, 2025 18:16
@vogella vogella merged commit 200996c into eclipse-platform:master Nov 13, 2025
18 checks passed
@vogella vogella deleted the fix-flaky-resource-initial-selection-test branch November 13, 2025 09:48
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.

1 participant