Skip to content

Update with latest dev changes#364

Merged
emdobrin merged 37 commits intoadobe:feature/upstream-integration-testsfrom
timkimadobe:feature/upstream-integration-tests
Jul 19, 2023
Merged

Update with latest dev changes#364
emdobrin merged 37 commits intoadobe:feature/upstream-integration-testsfrom
timkimadobe:feature/upstream-integration-tests

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented Jul 11, 2023

Description

This PR covers:

  1. Bringing latest dev changes into the integration test feature branch
  2. Updating dev changes to use new testing framework and APIs
  3. Updating some tests to have greater timeout tolerances for setup/teardown process
  4. Updating the build scripts to separate functional and unit test runs into separate job steps
    • This is because in the CI job, occasionally the unit test build process would be interleaved with functional test case runs which was causing errors in test setup, state, and/or teardown. By separating them into distinct commands, the unit test build waits until the functional test run is complete, preventing this class of error.
    • Note: item 3 was rolled back after applying the fix from 4
    • This should also address most of the test case issues described in Fix flaky tests #365
  5. Adding mock network service reset in the per-test-case teardown for every functional test class that uses the mock network service

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.

kevinlind and others added 14 commits May 31, 2023 15:45
* Remove deprecated class XDMFormatters

* Update timestamp field in MobileSDKCommerceSchema in tutorial apps
…nsion version Bump to 4.0.0 (adobe#344)

* Update Min supported version to iOS 11 and tvOS 11. Bump major extension version.

* Clean Makefile and add steps to generate xcframeworks

* Update Github release workflow to add XCframework with the release

* Add ci steps back in Makefile

* Fix Github workflow steps

* Updates based on reviews

* More review updates

* Update README

* Add version to the release artifact

* Update the getting started doc

* Add test command in Makefile to run ios and tvos tests

* Update makefile

* Add commands to remove exisiting coverage reports before running the tests

* Update Makefile

* Add usage sample in comment for check-version command

* Update all extensions to version 4.x

* Remove empty marketing versions

* Update podspec version to 4.0.0
* Update Podfile to use Core staging and Edge* dev branches

* Update SwiftLint version 0.52.0

* Fix format after SwiftLint update
* Update Podfile to use Core/Services production version

* Update podfile for Tutorial apps
Merge to Staging for 4.0.0 release
Staging -> Main v4.0.0 release
Update dependencies to prod and links
* Code changes for chaining parent event to network response events

* Add functional tests for event chaining

* Update method comments, rename parameter to 'parentRequestEvent'

* Rename variable 'requestParentEvent' to 'parentRequestEvent'
# Conflicts:
#	Makefile
#	Podfile.lock
#	README.md
#	Tests/FunctionalTests/NetworkResponseHandlerFunctionalTests.swift
@timkimadobe timkimadobe changed the title Update with merge from latest dev changes Update with latest dev changes Jul 11, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 11, 2023

Codecov Report

Merging #364 (8fe73a8) into feature/upstream-integration-tests (d5e42ab) will increase coverage by 0.19%.
The diff coverage is 100.00%.

@@                          Coverage Diff                           @@
##           feature/upstream-integration-tests     #364      +/-   ##
======================================================================
+ Coverage                               96.54%   96.73%   +0.19%     
======================================================================
  Files                                      28       27       -1     
  Lines                                    1649     1653       +4     
======================================================================
+ Hits                                     1592     1599       +7     
+ Misses                                     57       54       -3     

Comment thread Tests/TestUtils/TestBase.swift Outdated
// Wait .2 seconds in case there are unexpected events that were in the dispatch process during cleanup
usleep(200000)
// usleep(200000)
sleep(1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this change will increase the test run time with 1 sec times no of tests, what are those events that are blocking for so long before the cleanup?

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.

I was thinking this would catch the failure case from #365 -> 1. Test cleanup failure, as there appears to be some order dependent test failures

However, I've reverted back to the original time in hopes it will be sufficient

waitForRegistration.countDown()
})
XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: 2))
XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: 10))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would think even 2 sec is a lot for registration, do you know aprox. how long it actually requires to run on CI?

Copy link
Copy Markdown
Contributor Author

@timkimadobe timkimadobe Jul 13, 2023

Choose a reason for hiding this comment

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

Based on the logs it seems like consistently less than a second

Looking at the logs again for test setup failure cases, it looks like this class of test failure happens when the unit test build process is interleaved with the currently running functional test case (I have other examples, but only showing screenshots for testSendEvent_twoConsecutiveCalls_appendsReceivedClientSideStore to demonstrate)

Successful test setup

Screenshot 2023-07-13 at 3 36 46 PM

Failing test setup

Screenshot 2023-07-13 at 3 36 56 PM

When the test setup happens correctly (ex: this latest build), there is no unit test build interleaved

Should the greatly extended timeout be kept to account for this potential interleaving? Or is there a way to prevent the interleaving from happening?
Since the timeout wait can be satisfied early if all conditions are met, having a large timeout value should not affect runtime of most test cases right?

Copy link
Copy Markdown
Contributor

@emdobrin emdobrin Jul 19, 2023

Choose a reason for hiding this comment

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

update: we decided to split the test runs in two steps: unit and functional for each platform, see PR #368

Comment thread Tests/UnitTests/EdgePublicAPITests.swift Outdated
Copy link
Copy Markdown
Contributor Author

@timkimadobe timkimadobe left a comment

Choose a reason for hiding this comment

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

Thank you for the review @emdobrin! Updated based on feedback and added additional context, with some outstanding questions

Comment thread Tests/UnitTests/EdgePublicAPITests.swift Outdated
Comment thread Tests/TestUtils/TestBase.swift Outdated
// Wait .2 seconds in case there are unexpected events that were in the dispatch process during cleanup
usleep(200000)
// usleep(200000)
sleep(1)
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.

I was thinking this would catch the failure case from #365 -> 1. Test cleanup failure, as there appears to be some order dependent test failures

However, I've reverted back to the original time in hopes it will be sufficient

waitForRegistration.countDown()
})
XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: 2))
XCTAssertEqual(DispatchTimeoutResult.success, waitForRegistration.await(timeout: 10))
Copy link
Copy Markdown
Contributor Author

@timkimadobe timkimadobe Jul 13, 2023

Choose a reason for hiding this comment

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

Based on the logs it seems like consistently less than a second

Looking at the logs again for test setup failure cases, it looks like this class of test failure happens when the unit test build process is interleaved with the currently running functional test case (I have other examples, but only showing screenshots for testSendEvent_twoConsecutiveCalls_appendsReceivedClientSideStore to demonstrate)

Successful test setup

Screenshot 2023-07-13 at 3 36 46 PM

Failing test setup

Screenshot 2023-07-13 at 3 36 56 PM

When the test setup happens correctly (ex: this latest build), there is no unit test build interleaved

Should the greatly extended timeout be kept to account for this potential interleaving? Or is there a way to prevent the interleaving from happening?
Since the timeout wait can be satisfied early if all conditions are met, having a large timeout value should not affect runtime of most test cases right?

@timkimadobe timkimadobe force-pushed the feature/upstream-integration-tests branch from ab8dac3 to f73c05b Compare July 15, 2023 00:06
@timkimadobe
Copy link
Copy Markdown
Contributor Author

Note: removed the CI testing workflow changes from this branch in anticipation of #368 being merged into dev. Will merge dev into the fork feature branch to bring the workflow fix once #368 is merged

kevinlind and others added 7 commits July 17, 2023 11:53
* Split unit and functional test steps

Update CircleCI script accordingly

* Reorder unit and functional tests

* Reorder unit and functional in cleanup step

* Test reordering libraries

* Split Makefile rules test-ios and test-tvos to run unit and functional tests separately

* Run functional tests even when unit tests fail in CI

* Move test reports under 'build/reports' folder

---------

Co-authored-by: Kevin Lind <lind@adobe.com>
[CI] Sleep after EventHub.shared.start in API unit tests
# Conflicts:
#	Tests/FunctionalTests/NetworkResponseHandlerFunctionalTests.swift
#	Tests/UnitTests/EdgePublicAPITests.swift
Comment thread Tests/TestUtils/TestBase.swift Outdated
public override func tearDown() {
super.tearDown()

// unregisterInstrumentedExtension()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need this change or can we revert?

Copy link
Copy Markdown
Contributor

@emdobrin emdobrin Jul 19, 2023

Choose a reason for hiding this comment

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

looks like we don't unregister in dev branch either, likely because down bellow we call EventHub.reset() anyway, so that will reset all extensions before next test run.
So, can we remove this commented line then? And I am also curious where else we use this function unregisterInstrumentedExtension

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.

I think we can revert this change! I saw this API available in the TestBase class and just wanted to try it to see if it would address some of the flaky test issues (which ended up being caused by other things)

The unregisterInstrumentedExtension extension isnt used anywhere else that I could see

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for checking, changes look good to me. We can revisit this in the future and see if we can remove the unused API and the associated code in the InstrumentedExtension.

Copy link
Copy Markdown
Contributor Author

@timkimadobe timkimadobe left a comment

Choose a reason for hiding this comment

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

Thanks for the review @emdobrin! Addressed feedback with latest update

Comment thread Tests/TestUtils/TestBase.swift Outdated
public override func tearDown() {
super.tearDown()

// unregisterInstrumentedExtension()
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.

I think we can revert this change! I saw this API available in the TestBase class and just wanted to try it to see if it would address some of the flaky test issues (which ended up being caused by other things)

The unregisterInstrumentedExtension extension isnt used anywhere else that I could see

@emdobrin emdobrin merged commit a43186b into adobe:feature/upstream-integration-tests Jul 19, 2023
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.

4 participants