Skip to content

fix flakey tests - #38

Merged
Sammster10 merged 1 commit into
masterfrom
fix/fix-flakey-tests
Aug 5, 2026
Merged

fix flakey tests#38
Sammster10 merged 1 commit into
masterfrom
fix/fix-flakey-tests

Conversation

@Sammster10

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

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 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 of waitForDataPropagation() and System.gc()-based assumptions.
  • Replaced the old SQLParseTest pg_dump comparison with new schema contract assertions via SchemaAssertions across 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);
}
@Sammster10
Sammster10 merged commit 4d1c1a5 into master Aug 5, 2026
2 checks passed
@Sammster10
Sammster10 deleted the fix/fix-flakey-tests branch August 5, 2026 05:35
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.

2 participants