-
Notifications
You must be signed in to change notification settings - Fork 952
Valkey Fuzzer #2340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Valkey Fuzzer #2340
Conversation
Signed-off-by: Uri Yagelnik <uriy@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #2340 +/- ##
===========================================
Coverage ? 69.94%
===========================================
Files ? 125
Lines ? 68556
Branches ? 0
===========================================
Hits ? 47953
Misses ? 20603
Partials ? 0
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @uriyage! Gave it a run locally, works pretty well.
I had a question about the final report, do you manually analyze all the errors and spot the issues, what is your mechanism around it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uriyage shell we also add a daily job to run the fuzzer?
I also thought about this but unsure about the triage part? |
…ed PR comments Signed-off-by: Uri Yagelnik <uriy@amazon.com>
The errors can be divided into two groups: server-side-observable and client-side-observable. For server-side issues, we can identify crashes, memory corruptions, or memory leaks. With client-side issues, For the first two server-side issues, which are the most common, we can simply validate that after the fuzzer run the server didn't crash and validate that no memory issues were reported (when compiled with ASAN). Client-side issues are more difficult to root cause and require manual work to understand what went wrong. We |
Thanks, I added it to the TCL tests so it will run with all the variations we currently use for TCL testing. Currently, the test will be considered a failure only if the server crashes or becomes unresponsive after the fuzzer run |
Signed-off-by: Uri Yagelnik <uriy@amazon.com>
Add Fuzzing Capability to Valkey
Overview
This PR adds a fuzzing capability to Valkey, allowing developers and users to stress test their Valkey deployments with randomly generated commands. The fuzzer is integrated with the existing valkey-benchmark tool, making it easy to use without requiring additional dependencies.
Key Features
• Command Generator: Automatically generates Valkey commands by retrieving command information directly from the server
• Two Fuzzing Modes:
• Multi-threaded Testing: Each client runs in a dedicated thread to maximize interaction between clients and enable testing of complicated scenarios
• Integration with valkey-benchmark: Uses the existing CLI interface
Implementation Details
• Added new files:
fuzzer_command_generator.h/c
: Dynamically generates valkey commands.fuzzer_client.c
: Orchestrate all the client threads, report test progress, and handle errors.• Modified existing files:
Command Generation Approach
The fuzzer dynamically retrieves command information from the server, allowing it to adapt to different Valkey versions and custom modules. Since the command information generated from JSON files is sometimes limited, not all generated commands will be valid, but approximately 95% valid command generation is achieved.
It is important to generate valid commands to cover as much code path as possible and not just the invalid command/args path. The fuzzer prioritizes generating syntactically and semantically correct commands to ensure thorough testing of the server's core functionality, while still including a small percentage of invalid commands in
aggressive
mode to test error handling pathsConfig modification
For CONFIG SET command, the situation is more complex as the server currently provides limited information through CONFIG GET *. Some hardcoded logic is implemented that will need to be modified in the future. Ideally, the server should provide self-inspection commands to retrieve config keys-values with their properties (enum values, modifiability status, etc.).
Issue Detection
The fuzzer is designed to identify several types of issues:
• Server crashes
• Server memory corruptions / memory leaks(when compiled with ASAN)
• Server unresponsiveness
• Server malformed replies
For unresponsiveness detection, command timeout limits are implemented to ensure no command blocks for excessive periods. If a server doesn't respond within 30 seconds, the fuzzer signals that something is wrong.
Proven Effectiveness
When running against the latest unstable version, the fuzzer has already identified several issues, demonstrating its effectiveness:
How to Use
Run the fuzzer using the valkey-benchmark tool with the --fuzz flag:
The fuzzer supports existing valkey-benchmark options, including TLS and cluster mode configuration.