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

test(datastore): Add OptimisticConcurrency tests #12795

Merged
merged 21 commits into from
Jan 8, 2024

Conversation

stocaaro
Copy link
Contributor

@stocaaro stocaaro commented Jan 4, 2024

Description of changes

Outcomes:

  • Update graphql service fake to mimic OptimisticConcurrency(OCC) conflict resolution
  • Add OptimisticConcurrency (OCC) tests for all cases covered by the existing Automerge tests
  • Update service call cont expectation to reflect multiple event types, provide more rich feedback for failures

Description of how you validated changes

By comparing sample app results to test expectations and iterating until they align.

There is existing odd behavior where errors occur at in low latency conditions where the retry message includes null values for fields, which overwrites external updates. I will do sample app testing to confirm that this is consistent with the real world behavior.

Related changes

  1. refactor(datastore): Move conflict resolution tests to their own file #12728
  2. refactor(datastore): Refactor conflict resolution tests optimize for concise/readable #12732
  3. refactor(datastore): Refactor test names and make subscription events more sample app like #12740
  4. 🌱 test(datastore): Add OptimisticConcurrency tests
  5. fix(datastore): Update outbox comparison logic to fix update versioning problems stocaaro/amplify-js#87

Checklist

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

Copy link
Member

@david-mcafee david-mcafee left a comment

Choose a reason for hiding this comment

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

Overall this looks great! I do think removing the incorrect comment is a blocker, since it would lead to significant confusion (at least for me!) down the line. Other than that, just one correction to a typo :)

@stocaaro
Copy link
Contributor Author

stocaaro commented Jan 5, 2024

@david-mcafee - Appreciate the suggestions. I've accepted both suggested changes and have re-read all of the comments to make sure nothing else thats coming across is auto-merge centric.

david-mcafee
david-mcafee previously approved these changes Jan 6, 2024
Copy link
Member

@david-mcafee david-mcafee left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Comment on lines 507 to 511
} else {
merged = {
...this.populatedFields(existing),
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This else branch looks like a no-op. Since the fake is branching on canOccMerge() first anyway, I think I'd prefer that this throw to alert us that "we shouldn't be here", unless I'm failing to see or grok a use-case for this branch.

I think this is the only area of the PR that concerns me at the moment. Unless I'm just having a slow brain day, can we either turn this into a throw or add a comment explaining the branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rereading this, I think this branch will never be reached since I have extracted the canOccMerge function, we're essentially doing the version check twice. I'll get a refactor out around this.

@stocaaro stocaaro merged commit d541745 into aws-amplify:main Jan 8, 2024
30 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.

None yet

4 participants