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

fix(API): subscription cancel unit test failing intermittently #927

Merged
merged 3 commits into from
Dec 3, 2020

Conversation

wooj2
Copy link
Contributor

@wooj2 wooj2 commented Dec 1, 2020

While implementing start/stop for datastore, I noticed these tests were failing because the SubscriptionConnectionFactory was able to throw an exception and fail, prior to cancel() execution happening. When this happens, the operation ends up in a finished state rather than the expected canceled state.

So.. to remedy this, I re-worked these tests by using the existing MockSubscriptionConnectionFactory to test various cases.

To reproduce the unexpected behavior, revert these changes, and add a sleep(2) right before the call to operation.cancel(), then run the test.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@wooj2 wooj2 requested a review from lawmicha December 1, 2020 23:25
@codecov
Copy link

codecov bot commented Dec 1, 2020

Codecov Report

Merging #927 (612d38f) into main (6ea2f1e) will increase coverage by 0.09%.
The diff coverage is 92.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #927      +/-   ##
==========================================
+ Coverage   69.00%   69.10%   +0.09%     
==========================================
  Files         898      898              
  Lines       36697    36819     +122     
==========================================
+ Hits        25324    25442     +118     
- Misses      11373    11377       +4     
Flag Coverage Δ
API_plugin_unit_test 64.02% <92.91%> (+1.46%) ⬆️
Analytics_plugin_unit_test 72.38% <ø> (ø)
Auth_plugin_unit_test 64.61% <ø> (ø)
DataStore_plugin_unit_test 83.66% <ø> (ø)
Predictions_plugin_unit_test 49.69% <ø> (ø)
Storage_plugin_unit_test 74.74% <ø> (ø)
build_test_amplify 63.08% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...n/AWSGraphQLSubscriptionOperationCancelTests.swift 93.24% <92.91%> (+0.93%) ⬆️
.../DataStore/Model/Internal/Schema/ModelSchema.swift 85.29% <0.00%> (-2.95%) ⬇️
...Hub/DefaultPluginTests/DefaultHubPluginTests.swift 87.20% <0.00%> (-1.17%) ⬇️
...in/Operation/AWSGraphQLSubscriptionOperation.swift 70.94% <0.00%> (+0.85%) ⬆️
...s/AWSHubPlugin/Internal/HubChannelDispatcher.swift 97.05% <0.00%> (+2.94%) ⬆️
Amplify/Categories/Hub/HubFilter.swift 57.89% <0.00%> (+5.26%) ⬆️
...ugins/AWSHubPlugin/Internal/SerialDispatcher.swift 88.23% <0.00%> (+5.88%) ⬆️
...PICategoryPluginTests/Mocks/MockSubscription.swift 100.00% <0.00%> (+18.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ea2f1e...9f214e0. Read the comment docs.

Copy link
Contributor

@lawmicha lawmicha left a comment

Choose a reason for hiding this comment

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

suggestion on the use of expectation over semaphore

@wooj2 wooj2 merged commit cbc597e into main Dec 3, 2020
@wooj2 wooj2 deleted the fix/apiUt branch December 3, 2020 20:53
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