More powerful virtual test server for unit tests#3022
Open
Conversation
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.
Part of #3018, and planned for use with active:active (geo-redundancy) and "hitless" (server maintenance events)
The idea here is to put in place much stronger test infrastructure to allow us to simulate complex server environments as pure unit tests. This builds on top of the toy server; obviously it needs to also be tested against real infrastructure, but that infrastructure is much more complicated to setup and maintain - this is much more workable for unit test scenarios and maintaining core functionality.
Most of the code here is in the "test" and "toys" area; in the core "src" area, I have:
ServerSelectionStrategyto work with anullmuxer (using basic defaults)-MOVEDto self" logic recently added for Valkey cluster to also work for standalone reconnectsinternalconvenienceSlotRange.IsSingleSlotaccessorThis works by:
cluster nodesandcluster slotsThis concept can (and will) also be extended to support:
Example is in MovedUnitTests, but basically:
We can see in the logs output:
The two "Client intercepted" entries are from the tunnel stepping in to avoid socket IO; initially :6379 has all the data (the default position) and :6380 has nothing. The "Client 2 being redirect" means we sent a
-MOVED, but the test passed after following the redirect to the new virtual location.Note that currently slot migrations are atomic in the
Migratemethod; there is no 5-step migration process.