UNOMI-948: Add PersistenceService.rangeQuery API#781
Merged
Conversation
Expose rangeQuery on the persistence SPI and implement it for Elasticsearch, OpenSearch, and the in-memory test harness. Add smoke integration tests and strengthen unit-test pagination assertions for totalSize. Related: UNOMI-956 (full PersistenceService IT coverage follow-up).
…earch Elasticsearch used an exclusive upper bound (lt) while OpenSearch and the in-memory test harness treated it as inclusive, so the same call could return different results depending on the backend. Align Elasticsearch on the inclusive semantics, guard both implementations against null from/to so an unbounded side isn't serialized as a literal null, rename the SPI's unused "s" parameter to "fieldName", and update the IT to assert the inclusive boundary directly instead of working around the old mismatch.
testPurgeByDateDelegatesToPersistenceService and testPurgeByScopeDelegatesToPersistenceService build ClusterNode fixtures without setting lastHeartbeat, which defaults to 0. The real scheduler set up in @beforeeach fires cleanupStaleNodes() with initialDelay=0, so it can race the test and delete these fixtures as "stale" before the assertions run, intermittently on CI. Apply the same clusterService.cancelScheduledTasks() fix already used in testCleanupStaleNodes to both tests.
…lTest setUp The previous fix (clusterService.cancelScheduledTasks() inside the two purge tests) didn't actually close the race: cancelTask() only prevents future executions, so if the zero-initial-delay task had already been dispatched to the scheduler's thread pool before the test method's first line ran, cancelling did nothing. setUp() was the one starting these tasks unconditionally, before any test method body got a chance to run. None of the tests actually need the tasks pre-started by setUp() — every test that exercises scheduled-task behavior already calls clusterService.init() itself, which starts them at the right time. Removing the eager start from setUp() closes the race for all tests in the class, not just the two that were observed failing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For project managers
Unomi 3 needs a standard way to find customer profiles and events by numeric ranges—for example ages, scores, or date windows—when teams use either Elasticsearch or OpenSearch. This change adds that missing search capability to the product core so planned 3.x features can rely on it regardless of which search backend a deployment uses. Automated checks confirm basic range search works end-to-end; broader API test coverage is tracked separately on UNOMI-956.
Summary
PersistenceService.rangeQuery(...)to the persistence SPI@OverridePersistenceServiceITsmoke tests (numeric range + pagination) and register inAllITstotalSizeassertions for in-memory range-query paginationJIRA
Test plan
mvn -pl persistence-spi install -DskipTeststhenmvn -pl services test -Dtest=InMemoryPersistenceServiceImplTest$RangeQueryTestsmvn -pl persistence-spi,persistence-elasticsearch/core,persistence-opensearch/core -am compilemvn -f itests/pom.xml compile -DskipTestsPersistenceServiceITviaAllITssuite)