fix flakey tests - #38
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets test flakiness by replacing fixed sleeps/GC assumptions with deterministic waiting/flush helpers and by adding schema-level assertions that validate SQLBuilder output against live Postgres + H2 schemas. It also tightens Redis event handling to avoid processing “self-inflicted” delete notifications and waits for Redis keyspace subscription readiness during DataManager startup.
Changes:
- Reworked multiple tests to use
flushDataManagers()/awaitCondition()instead ofwaitForDataPropagation()andSystem.gc()-based assumptions. - Replaced the old
SQLParseTestpg_dump comparison with new schema contract assertions viaSchemaAssertionsacross Postgres and H2. - Updated Redis integration to (a) ignore local DEL keyspace events and (b) block startup until the subscription is ready.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/test/java/net/staticstudios/data/SQLParseTest.java | Replaces flaky pg_dump-based test with schema contract checks across Postgres/H2 and adds more schema coverage. |
| core/src/test/java/net/staticstudios/data/PersistentValueTest.java | Removes sleeps/GC assumptions; uses flush + polling helpers for deterministic timing. |
| core/src/test/java/net/staticstudios/data/PersistentOneToManyValueCollectionTest.java | Converts handler propagation waits to condition-based polling. |
| core/src/test/java/net/staticstudios/data/PersistentManyToManyCollectionTest.java | Converts handler propagation waits to condition-based polling and adds flush usage. |
| core/src/test/java/net/staticstudios/data/misc/SchemaAssertions.java | Introduces metadata-based schema assertions (tables/columns/PK/FK/indexes/triggers). |
| core/src/test/java/net/staticstudios/data/misc/DataTest.java | Adds flushDataManagers(), awaitCondition(), and awaitGarbageCollection() helpers used by tests. |
| core/src/test/java/net/staticstudios/data/CachedValueTest.java | Replaces sleeps with flush/polling to reduce timing flakiness around Redis cached values. |
| core/src/main/java/net/staticstudios/data/impl/redis/RedisListener.java | Adds subscription readiness wait + local DEL suppression support. |
| core/src/main/java/net/staticstudios/data/impl/h2/H2DataAccessor.java | Marks local Redis deletions to prevent duplicate handling of DEL events. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
36
to
42
| } catch (JedisConnectionException e) { | ||
| if (ThreadUtils.isShuttingDown()) { | ||
| return; | ||
| } | ||
| subscriptionReady.completeExceptionally(e); | ||
| logger.error("Redis connection lost in listener thread", e); | ||
| } |
Comment on lines
+46
to
+50
| try { | ||
| subscriptionReady.get(10, TimeUnit.SECONDS); | ||
| } catch (Exception e) { | ||
| throw new IllegalStateException("Timed out waiting for the Redis event subscription", e); | ||
| } |
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.
No description provided.