Skip to content

chore(server): Extended SerializerBase test#7179

Merged
dranikpg merged 4 commits into
dragonflydb:mainfrom
dranikpg:serializer-base-test
Apr 23, 2026
Merged

chore(server): Extended SerializerBase test#7179
dranikpg merged 4 commits into
dragonflydb:mainfrom
dranikpg:serializer-base-test

Conversation

@dranikpg
Copy link
Copy Markdown
Contributor

@dranikpg dranikpg commented Apr 17, 2026

Introduce extended serializer base test with more intricate testing scenarions

The TestDriver extends SerializerBase and becomes one more "consumer" akin to a replica or cluster node. However instead of sending the data, it processes it immediately and verifies additional invariants

@dranikpg dranikpg marked this pull request as ready for review April 19, 2026 13:26
Copilot AI review requested due to automatic review settings April 19, 2026 13:26
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 19, 2026

🤖 Augment PR Summary

Summary: This PR adds a more comprehensive unit test suite around SerializerBase by introducing a dedicated test consumer that exercises snapshot traversal, on-change serialization, and journal ordering.

Changes:

  • Adds serializer_base_test to the server test CMake target list
  • Introduces src/server/serializer_base_test.cc with a TestDriver that extends SerializerBase and also consumes journal events
  • Adds a small delayed-entry resolver (TestDelayDriver) to simulate tiered-value resolution timing
  • Adds tests for static population serialization and list growth under concurrent writes, plus a currently-skipped delayed-expiry scenario
  • Updates serializer_base.h with a forward declaration and friend access to enable test-only introspection of delayed-entry internals

Technical Notes: The tests track “baseline-before-journal” ordering per key and validate invariants by counting baseline emissions vs journal mutations while injecting randomized yields to stress scheduling/interleavings.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 4 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/server/serializer_base_test.cc
auto entry = q_.top();
q_.pop();

util::ThisFiber::SleepUntil(entry.first);
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the entry is popped from q_ before SleepUntil(), calling Pause() while the fiber is sleeping won’t prevent the already-dequeued item from being resolved, which makes the pause/resume semantics unreliable for tests that depend on delaying resolution.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One entry is ok

Change([](TestDriver& d) { d.delay_driver_.Pause(); });

// Let all values to be expire deleted
TEST_current_time_ms = TEST_current_time_ms + 100;
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modifies the global TEST_current_time_ms without restoring it; once the test is un-skipped, this can leak the simulated time shift into subsequent tests and cause hard-to-debug order-dependent failures.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

}

private:
friend struct TestDriver;
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making DelayedEntryHandler befriend a test-only type (TestDriver) in a widely included production header effectively grants private access to any TU that defines dfly::TestDriver, which weakens encapsulation beyond just the test target.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but...

Copy link
Copy Markdown
Contributor

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

Adds a new C++ test that exercises SerializerBase with a more “consumer-like” driver that immediately validates baseline/journal ordering invariants (similar to a replica/cluster consumer), and wires the test into the server test suite.

Changes:

  • Introduces serializer_base_test.cc with a TestDriver (extends SerializerBase + journal consumer) and multiple concurrent test scenarios.
  • Adds TestDriver friendship to DelayedEntryHandler so the test driver can inject/inspect delayed-entry state.
  • Registers the new test target in src/server/CMakeLists.txt.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/server/serializer_base_test.cc New extended SerializerBase tests using a custom driver, background delayed-resolution fiber, and journal parsing to assert invariants.
src/server/serializer_base.h Adds forward declaration + friend struct TestDriver to allow the new test driver to access DelayedEntryHandler internals.
src/server/CMakeLists.txt Adds serializer_base_test to the helio C++ test targets.

Comment thread src/server/serializer_base_test.cc
Comment thread src/server/serializer_base_test.cc
Comment on lines +393 to +394
TEST_F(SerializerBaseTest, DelayedAllDeleted) {
GTEST_SKIP() << "To be fixed";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed with #7185

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg force-pushed the serializer-base-test branch from f8d57a8 to 066c1c1 Compare April 20, 2026 13:45
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg force-pushed the serializer-base-test branch from 066c1c1 to cef349c Compare April 20, 2026 13:46
@dranikpg dranikpg requested review from kostasrim and romange April 20, 2026 18:42
@dranikpg dranikpg merged commit db4b9cd into dragonflydb:main Apr 23, 2026
13 checks passed
@dranikpg dranikpg deleted the serializer-base-test branch April 23, 2026 11:55
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