-
Notifications
You must be signed in to change notification settings - Fork 15
Add validation for SourceUpdate upsert semantics #81
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
base: main
Are you sure you want to change the base?
Add validation for SourceUpdate upsert semantics #81
Conversation
6aca96b to
dd3fb84
Compare
Validates that SourceChange::Update implements correct upsert semantics (create-then-update) with 7 tests covering partial updates, stateless processing, query matching, relationships, and aggregations. All tests pass on in-memory, RocksDB, and Garnet. Signed-off-by: Aman Singh <[email protected]>
dd3fb84 to
9856d8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive test coverage for SourceUpdate upsert semantics in the Drasi continuous query engine. The changes validate that SourceChange::Update correctly implements upsert behavior: creating entities on first update and modifying them on subsequent updates.
- Adds a new test module
source_update_upsertwith 7 test scenarios covering upsert semantics, partial updates, stateless processing, query matching, entity isolation, relationship upserts, and aggregations - Simplifies the
QueryTestConfigtrait by removing an unusedqueryparameter - Integrates the new tests across all storage backend implementations (in-memory, RocksDB, Garnet)
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| shared-tests/src/use_cases/source_update_upsert/queries.rs | Defines 5 reusable Cypher queries for testing different aspects of upsert behavior |
| shared-tests/src/use_cases/source_update_upsert/mod.rs | Implements 7 comprehensive test functions validating upsert semantics across different scenarios |
| shared-tests/src/use_cases/source_update_upsert/README.md | Documents the purpose and importance of upsert semantics testing |
| shared-tests/src/use_cases/mod.rs | Adds the new test module and simplifies QueryTestConfig trait signature |
| shared-tests/src/in_memory/mod.rs | Adds test wrappers for in-memory storage backend |
| index-rocksdb/tests/scenario_tests.rs | Adds test wrappers for RocksDB storage backend |
| index-garnet/tests/scenario_tests.rs | Adds test wrappers for Garnet storage backend |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| //println!("✓ Second SourceUpdate updated existing entity"); | ||
| } | ||
|
|
||
| //println!("✓ Test 1 PASSED: SourceUpdate implements upsert semantics"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: perhaps we should remove these debug messages that are commented out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some other tests also have these, and some have added a suppress on cargo-lint and still use println.
I have kept it here in case in future something goes wrong and we want to quickly debug - just uncomment and use. Otherwise they can also work as doc-comments.
|
|
||
| /// Verifies that entities correctly enter and exit query result sets when property changes affect filter condition matching. | ||
| /// Tests the engine's ability to track entities transitioning between matching and non-matching states. | ||
| pub async fn test_query_matching(config: &(impl QueryTestConfig + Send)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a part of the "upsert" suite of tests?
|
|
||
| /// Confirms that updates to one entity are properly isolated and do not affect other entities in the query. | ||
| /// Ensures the engine correctly manages concurrent entity state without cross-contamination. | ||
| pub async fn test_multiple_entities(config: &(impl QueryTestConfig + Send)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a part of the "upsert" suite of tests?
Description
Validates that SourceChange::Update implements correct upsert semantics (create-then-update) with 7 tests covering partial updates, stateless processing, query matching, relationships, and aggregations.
All tests pass on in-memory, RocksDB, and Garnet.
test_upsert_semantics- Validates first update creates, subsequent updates modifytest_partial_updates- Ensures partial property updates preserve unspecified propertiestest_stateless_processing- Simulates stateless sources sending complete snapshotstest_query_matching- Verifies entities correctly enter/exit result sets on propertychanges
test_multiple_entities- Confirms entity updates are properly isolatedtest_relationship_upsert- Validates upsert works for relationships (edges), not justnodes
test_aggregation_with_upserts- Tests aggregation queries handle entity lifecycletransitions
Type of change