Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply latest AEPTestUtil updates (5.1.0) #1057

Merged
merged 10 commits into from
Jul 19, 2024

Conversation

timkimadobe
Copy link
Contributor

Description

This PR brings over the latest updates from AEPTestUtils (up to 5.1.0) and also updates NetworkRequestHelper class to use ThreadSafeDictionary and ThreadSafeArray instead of a queue at the class level.

  • The ThreadSafe changes have been tested with Edge extension functional and integration tests locally

There is a breaking change where the parameter name expectationTimeout has been renamed to timeout across NetworkRequestHelper, MockNetworkService, and RealNetworkService

Related Issue

Motivation and Context

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.

…afe version

Create extension to ThreadSafeDictionary for additional features
Remove use of queue at the method level for multi thread protection
Use Swifty syntax for dictionary defaults
…access

Instead of putting entire assertion logic into queue task, only put the dictionary read operation in the task and use the local copy in the rest of the logic. This way, the semaphore is not blocking network requests and responses from being recorded
return nil
let testableNetworkRequest = TestableNetworkRequest(from: networkRequest)
return queue.sync {
return self.expectedNetworkRequests[testableNetworkRequest]?.await(timeout: timeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the queue to only query expectedNetworkRequests and move the await outside ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Updated

@timkimadobe timkimadobe requested a review from praveek July 18, 2024 02:51

func retryInterval(for entity: DataEntity) -> TimeInterval {
return 1
}

func processHit(entity: DataEntity, completion: @escaping (Bool) -> Void) {
processedHits.append(entity)
completion(hitResult)
queue.sync {
completion(_hitResult)
Copy link
Contributor

@praveek praveek Jul 18, 2024

Choose a reason for hiding this comment

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

Can you use the dispatch queue when accessing _hitReques and call the completion handler outside the queue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Updated to get the value (relying on _hitResult's queue get implementation) but call the completion handler outside the queue

… queue but move completion call outside of queue
@timkimadobe timkimadobe requested a review from praveek July 19, 2024 01:00
queue.sync {
completion(_hitResult)
}
var hitResult = _hitResult
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove this line so that completion(hitResult) directly reads the boolean using the property defined in the class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@timkimadobe timkimadobe requested a review from praveek July 19, 2024 03:16
@praveek praveek merged commit e5b6890 into adobe:dev-testutils Jul 19, 2024
17 checks passed
@timkimadobe timkimadobe deleted the latest-testutil-updates branch July 19, 2024 22:45
praveek added a commit that referenced this pull request Aug 30, 2024
* Initial setup for AEPTestUtils as local module within Core

* Update AEPTestUtils podspec configuration

1. Version to 5.0.2
2. Homepage to point to Core repo URL
3. License format to match all other podspecs in Core
4. Source to point to Core repo URL
5. Source files point to PublicTestUtils under Core and Services
6. Core and Services dependency restricted to 5.2.0 < 6

* Create contribution guide for AEPTestUtils

* Add more info for how to add test helper files in AEPTestUtils contribution guide

* Create AEPTestUtils specific version update script and workflow action

* Workflow debug steps

* Add more debug steps to workflow

* Update shell

* Fix version taken from workflow input

* Update sed command usage

* Version script updates

* Script updates

* fix workflow script

* Update workflow

* Rename AEPTestUtil version script and workflow file names for clarity

Remove debug prints from both files

* Update dependencies update logic

* Revert "Update dependencies update logic"

This reverts commit 6fc046f.

* Use per dependency check instead

* Create Package.swift for AEPTestUtils

* Revert "Create Package.swift for AEPTestUtils"

This reverts commit 52a0561.

* Revert copyright year to original

* Add back existing files

* Try to trigger cache miss

* Fix incorrect project target AEPCoreMocks Compile Sources file paths for some files

* Revert "Try to trigger cache miss"

This reverts commit a8f6801.

* Update TestUtils contributing guide documentation for clarity

* Consolidate version update script, adding logic to handle TestUtils specific flow

* Update TestUtils version workflow to use updated version script

* Bump AEPTestUtils podspec version

* Create podspec verification script for AEPTestUtils

* Create test workflow to run AEPTestUtils podspec check script

* Remove the dependency on internal AEPServicesMocks in public AEPTestUtils files

* Update AEPCore and AEPServices podspecs to allow for ENABLE_TESTING_SEARCH_PATHS

* Fix testable flag in AEPCore and AEPServices podspecs

* Try adding ENABLE_TESTING_SEARCH_PATHS flag to AEPTestUtils

* Try adding ENABLED_TESTABILITY flag to AEPTestUtils podspec

* Fix typo in podspec 'ENABLE_TESTABILITY' flag

* Update podspecs to use test target

* Try different flags for AEPTestUtils

* Try different flags for AEPTestUtils

* Tweak AEPTestUtils flags

* Update validation script to use test target instead of regular

* Check removing custom flags

* Remove custom flag stuff from podspecs

* Create release workflow for AEPTestUtils with validation as a prereq

* release_testutils.yml  - Fix script path and temp disable main branch check

* release_testutils.yml - add step to install xcodegen

* release_testutils.yml - update runner to macos and add version format validation

* Update podspec_version logic

* temp disable podspec validation

* Add git author information

* Testing removing git author and reenabling main branch if

* Hardcode `main` branch for release_testutils workflow

Reenable all steps

* Remove temp workflow

* Add makefile rule for testutils podspec validation and update workflow usage

* Temp disable main branch checkout

* Reenable main branch checkout

* Revert "Remove the dependency on internal AEPServicesMocks in public AEPTestUtils files"

This reverts commit 58c3687.

* Revert "Remove temp workflow"

This reverts commit ef41e52.

* Remove test workflow again

* update-versions.sh - Remove multiplatform sed compatibility in favor of original macOS version

Update testutils version workflow to use macOS runner

* Apply latest AEPTestUtil updates (5.1.0) (#1057)

* Bring over latest AEPTestUtils changes (since 5.1.0)
* Make utilities Threadsafe
* Update AEPTestUtils version to 5.2.0

* Improve AEPTestUtils Network Service helper class multi thread handling and method docs (#1058)

* NetworkRequestHelper.swift - Reorder methods by functionality, update method docs, add deprecation to flatten map method

* RealNetworkService.swift - Update method docs and method ordering

* MockNetworkService.swift - Update method docs and method ordering

* NetworkRequestHelper.swift - Update method to perform await outside of sync block

* NetworkRequestHelper.swift - Update to use Log and add error log for invalid URL string

* Update JSON comparison APIs (#1059)

* Remove deprecated APIs and add support for new path options

* Add support for new path options ElementCount and ValueNotEqual

Remove deprecated logic and path interpretation logic
Reorder methods based on usage and dependency

* Enhance test failure messages and update variable name from wildcard to accurate any order

Update failure message strings to use regular multiline strings to reduce unused syntax

* XCTestCase+AnyCodableAsserts.swift - Update code docs

* Apply lint

* Update access level to private

* Create JSON comparison API migration docs (#1062)

* Create JSON comparison API migration docs

* Simplify path options usage example

Reorder migration patterns sections
Add additional example using type match as default for mixed exact vs type match validation section

* Fix flaky Identity tests (#1061)

---------

Co-authored-by: Praveen <praveek@users.noreply.github.com>
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