I’m stuck on Stage #NV3
My code is pretty much identical to the code others have submitted and for whom the test passes. For me the test passes locally and it passed once on the test server but more often than not, fails on the test server. I am not sure what the source of flakiness is here.
➜ codecrafters-kafka-rust git:(master) ✗ codecrafters test
Initiating test run...
⚡ This is a turbo test run. https://codecrafters.io/turbo
Running tests. Logs should appear shortly...
[compile] Compiling codecrafters-kafka v0.1.0 (/app)
[compile] Finished `release` profile [optimized] target(s) in 0.73s
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.
[tester::#NV3] Running tests for Stage #NV3 (Send Correlation ID)
[tester::#NV3] $ ./your_program.sh /tmp/server.properties
[tester::#NV3] Sending "ApiVersions" (version: 4) request (Correlation id: 7)
[tester::#NV3] ✓ Correlation ID: 7
[tester::#NV3] Test passed.
[tester::#VI6] Running tests for Stage #VI6 (Bind to a port)
[tester::#VI6] $ ./your_program.sh /tmp/server.properties
[tester::#VI6] Connecting to port 9092...
[tester::#VI6] Test passed.
Test passed. Congrats!
Submit your changes to move to the next step:
$ codecrafters submit
➜ codecrafters-kafka-rust git:(master) ✗ codecrafters submit
Submitting changes (commit: e48a43c)...
⚡ This is a turbo test run. https://codecrafters.io/turbo
Running tests. Logs should appear shortly...
[compile] Compiling codecrafters-kafka v0.1.0 (/app)
[compile] Finished `release` profile [optimized] target(s) in 0.78s
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.
[tester::#NV3] Running tests for Stage #NV3 (Send Correlation ID)
[tester::#NV3] $ ./your_program.sh /tmp/server.properties
[tester::#NV3] Sending "ApiVersions" (version: 4) request (Correlation id: 7)
[tester::#NV3] error reading from connection: read tcp 127.0.0.1:39494->127.0.0.1:9092: read: connection reset by peer
[tester::#NV3] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
View our article on debugging test failures: https://codecrafters.io/debug
Above we see that when I ran codecrafters test
, the tests passed, but when I ran codecrafters submit
, the tests failed.
I have published my code in GitHub - akhi3030/codecrafters-kafka-rust and here’s a snippet of my code:
use std::io::Write;
use std::net::TcpListener;
fn main() {
let listener = TcpListener::bind("127.0.0.1:9092").unwrap();
for stream in listener.incoming() {
match stream {
Ok(mut stream) => {
let buf: [u8; 8] = [0u8, 0, 0, 0, 0, 0, 0, 7];
stream.write_all(&buf).unwrap();
}
Err(e) => {
println!("error: {}", e);
}
}
}
}```