Skip to content

Address data races in AEPTestUtil classes#1103

Merged
timkimadobe merged 1 commit intoadobe:dev-testutilsfrom
timkimadobe:fix-data-races
Dec 4, 2024
Merged

Address data races in AEPTestUtil classes#1103
timkimadobe merged 1 commit intoadobe:dev-testutilsfrom
timkimadobe:fix-data-races

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Dec 4, 2024

Note

The changes in this PR should not affect the signature of any existing public APIs, so the patch version will be increased from: testutils-5.2.2 -> testutils-5.2.3

Description

This PR addresses data race issues with public test classes available in AEPTestUtils by protecting access to shared access public vars in a sync queue:
InstrumentedExtension

  • extensionVersion
  • expectedEvents
  • receivedEvents

MockExtension

  • extensionVersion
  • registrationClosure
  • unregistrationClosure
  • eventReceivedClosure

MockDataStore

  • dict

This implementation tested via:
MockExtension

  • EdgeIdentity - IdentityAPITests
    InstrumentedExtension
  • Edge - NetworkResponseHandlerFunctionalTests
    MockDataStore
  • Core - all tests

Related Issue

Motivation and Context

Data race caught by thread sanitizer:

Test Case '-[FunctionalTests.NetworkResponseHandlerFunctionalTests testProcessResponseOnSuccess_afterPersistedResetEvent_savesStorePayloads]' passed (1.246 seconds).
Test Case '-[FunctionalTests.NetworkResponseHandlerFunctionalTests testProcessResponseOnSuccess_afterPersistedResetEvent_updatesLocationHint]' started.

AEPTestUtils/AEPCore/Mocks/PublicTestUtils/InstrumentedExtension.swift:115 Data race in static AEPTestUtils.InstrumentedExtension.reset() -> () at static AEPTestUtils.InstrumentedExtension.receivedEvents : AEPServices.ThreadSafeDictionary<AEPTestUtils.EventSpec, Swift.Array<AEPCore.Event>>

'static AEPTestUtils.InstrumentedExtension.receivedEvents : AEPServices.ThreadSafeDictionary<AEPTestUtils.EventSpec, Swift.Array<AEPCore.Event>>' is a global variable (0x110038f38)

Test Case '-[FunctionalTests.NetworkResponseHandlerFunctionalTests testProcessResponseOnSuccess_afterPersistedResetEvent_updatesLocationHint]' passed (3.407 seconds).
Test Case '-[FunctionalTests.NetworkResponseHandlerFunctionalTests testProcessResponseOnSuccess_afterResetEvent_savesStorePayloads]' started.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests 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