How do I debug test failures in the Redis Challenge?

First, make sure that you've read this article. It contains information that is common to all challenges.

Required Tools

The easiest way to debug problems with your redis implementation is to compare it to the official implementation. To do this, we'll need a few tools handy.

redis-cli, redis-server

Make sure you have redis-cli and redis-server installed. We'll use redis-cli to test commands against your redis implementation, and redis-server as a reference to compare with.

Wireshark

Since redis-cli & redis-server communicate with each over using TCP, we'll need a tool to inspect TCP messages. Install Wireshark

Methodology

1. Setup Wireshark to capture and display TCP traffic

Run Wireshark and use "tcp.port == 6379 or tcp.port == 6380" as a display filter. We'll use this in step 4 to view captured packets.

2. Start your redis server implementation (on port 6379)

You'll find instructions for this in your repository's README (like here). Your server will run on port 6379, which is the port we've configured Wireshark to capture data on.

3. Start the official redis server implementation (on port 6380)

Run "redis-server --port 6380" to do this.

3. Send a few commands to your server using redis-cli

Use redis-cli to send commands to your server. 

Note: You can also use the redis-cli interactive mode / REPL, but keep in mind that it sends a COMMAND command when it boots, which we don't implement in the Redis challenge.

If your redis implementation doesn't send a valid response, you might see an error like this: 
These error messages can be cryptic, and in some cases the Redis client might just hang waiting for bytes that never arrive.

4. View capture data in Wireshark

Once you've sent a few commands, head back to Wireshark and you'll now see some captured packets. You can inspect these to see exactly what data your implementation responded with.

Notice the "*1 $4 ping" at the bottom? That's the PING command, encoded using the Redis protocol.

5. Compare with official redis implementation

Now that you know exactly what data your Redis server is sending, you can compare it with the official redis implementation to verify that it is working properly. 

Send commands using `redis-cli -p 6380 <command>`.

Inspect the output in Wireshark (as mentioned in step 4) to see how the official Redis implementation differs from yours.


If everything seems correct and you're still seeing test failures, it's possible that the Codecrafters tester program is at fault. Please let us know at hello@codecrafters.io if that's the case! 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.