Skip to content

Stabilize flaky Android tests and harden API 37 logout handling - #3026

Merged
brandonpage merged 3 commits into
forcedotcom:devfrom
brandonpage:codex/fix-flaky-unit-tests
Sep 3, 2026
Merged

brandonpage merged 3 commits into
forcedotcom:devfrom
brandonpage:codex/fix-flaky-unit-tests

Conversation

@brandonpage

@brandonpage brandonpage commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • prevent late JavaScript test results from blocking or being attributed to the next test
  • increase timeouts for the slower MobileSync and SmartStore JavaScript suites
  • wait for Android teardown work to become idle before removing instrumentation state
  • add production null-account logout protection and a regression test
  • merge Firebase rerun XML into sharded reports so passing retries are classified as flaky successes

API 37 production hardening

The API 37 failure included a Binder buffer crash while Android was delivering com.salesforce.CLEANUP after repeated teardown sign-out calls. UserAccountManager.signoutCurrentUser now resolves the current account once and returns without invoking logout when no account exists.

This prevents accidental or repeated null-account sign-out calls in production from emitting unnecessary cleanup and logout broadcasts, reducing one-way Binder traffic in the same path that triggered the API 37 crash. Direct SalesforceSDKManager.logout(null) behavior remains unchanged for callers that intentionally request global cleanup.

NativeLoginManagerTest now relies on this production guard instead of duplicating the account check, while retaining waitForIdleSync for real logout cleanup. UserAccountManagerTest verifies that no LOGOUT_COMPLETE broadcast is emitted when there is no current account.

Verification

  • red/green regression: null-account sign-out test failed before the guard because LOGOUT_COMPLETE was broadcast, then passed after the guard
  • NativeLoginManagerTest plus UserAccountManagerTest: 44/44 passed on API 36
  • targeted API 37 remaining SalesforceSDK shard from the original failure investigation: 838/838 passed after teardown stabilization
  • sharded rerun control-flow check failed before the workflow change and passed after it
  • exact embedded XML merger passed fixtures for both successful and failed retry outcomes
  • workflow YAML parsed successfully and the extracted Copy Test Results shell body passed bash syntax validation
  • git diff --check passed

Related CI runs:

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
1 Warning
⚠️ libs/SalesforceSDK/src/com/salesforce/androidsdk/accounts/UserAccountManager.java#L113 - Do not place Android context classes in static fields (static reference to UserAccountManager which has field context pointing to Context); this is a memory leak

Generated by 🚫 Danger

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
2 Warnings
⚠️ libs/SalesforceHybrid/src/com/salesforce/androidsdk/phonegap/plugin/TestRunnerPlugin.java#L71 - The indentation string here is different from on the previous line (" " vs \t)
⚠️ libs/SalesforceHybrid/src/com/salesforce/androidsdk/phonegap/plugin/TestRunnerPlugin.java#L105 - The indentation string here is different from on the previous line (" " vs \t)

Generated by 🚫 Danger

if (currentAccount != null) {
SalesforceSDKManager.getInstance().logout(
currentAccount, frontActivity, showLoginPage, reason);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This production hardening actually came from CI crashing on API 37 when one of the tests called signoutCurrentUser with a null currentUser. The issue is a byproduct of the Android 17 MessageQueue rewrite. Yay for tests (unintentionally) catching real issues.

@brandonpage
brandonpage merged commit 462535c into forcedotcom:dev Sep 3, 2026
9 of 11 checks passed
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.

2 participants