Skip to content

Conversation

@amansinghoriginal
Copy link
Member

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.

  1. test_upsert_semantics - Validates first update creates, subsequent updates modify
  2. test_partial_updates - Ensures partial property updates preserve unspecified properties
  3. test_stateless_processing - Simulates stateless sources sending complete snapshots
  4. test_query_matching - Verifies entities correctly enter/exit result sets on property
    changes
  5. test_multiple_entities - Confirms entity updates are properly isolated
  6. test_relationship_upsert - Validates upsert works for relationships (edges), not just
    nodes
  7. test_aggregation_with_upserts - Tests aggregation queries handle entity lifecycle
    transitions

Type of change

  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Drasi (issue link optional).

@amansinghoriginal amansinghoriginal force-pushed the 4core-upsert-validation-tests-for-kusto branch 2 times, most recently from 6aca96b to dd3fb84 Compare October 27, 2025 01:40
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]>
@amansinghoriginal amansinghoriginal force-pushed the 4core-upsert-validation-tests-for-kusto branch from dd3fb84 to 9856d8d Compare October 27, 2025 02:35
@amansinghoriginal amansinghoriginal marked this pull request as ready for review October 27, 2025 02:35
@amansinghoriginal amansinghoriginal requested a review from a team as a code owner October 27, 2025 02:35
@danielgerlag danielgerlag requested a review from Copilot October 28, 2025 23:38
Copy link

Copilot AI left a 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_upsert with 7 test scenarios covering upsert semantics, partial updates, stateless processing, query matching, entity isolation, relationship upserts, and aggregations
  • Simplifies the QueryTestConfig trait by removing an unused query parameter
  • 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");
Copy link
Contributor

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

Copy link
Member Author

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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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?

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