I’m stuck on Stage #PV1
My code is passing tests for this stage but tester is running tests from previous stage (#NC5) again and that’s not handled in my code. Are we supposed to evolve code in a way it handles all the previous stages? Am I missing something here?
Here are my logs:
remote: [tester::#PV1] Running tests for Stage #PV1 (Handle APIVersions requests)
remote: [tester::#PV1] $ ./your_program.sh /tmp/server.properties
remote: [tester::#PV1] Connecting to broker at: localhost:9092
remote: [your_program] Logs from your program will appear here!
remote: [tester::#PV1] Connection to broker at localhost:9092 successful
remote: [tester::#PV1] Sending "ApiVersions" (version: 4) request (Correlation id: 1630436662)
remote: [tester::#PV1] Hexdump of sent "ApiVersions" request:
remote: [tester::#PV1] Idx | Hex | ASCII
remote: [tester::#PV1] -----+-------------------------------------------------+-----------------
remote: [tester::#PV1] 0000 | 00 00 00 23 00 12 00 04 61 2e 7d 36 00 09 6b 61 | ...#....a.}6..ka
remote: [tester::#PV1] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
remote: [tester::#PV1] 0020 | 6c 69 04 30 2e 31 00 | li.0.1.
remote: [tester::#PV1]
remote: [tester::#PV1] Hexdump of received "ApiVersions" response:
remote: [tester::#PV1] Idx | Hex | ASCII
remote: [tester::#PV1] -----+-------------------------------------------------+-----------------
remote: [tester::#PV1] 0000 | 00 00 00 13 61 2e 7d 36 00 00 02 00 12 00 00 00 | ....a.}6........
remote: [tester::#PV1] 0010 | 0a 00 00 00 00 00 00 | .......
remote: [tester::#PV1]
remote: [tester::#PV1] [Decoder] - .ResponseHeader
remote: [tester::#PV1] [Decoder] - .correlation_id (1630436662)
remote: [tester::#PV1] [Decoder] - .ResponseBody
remote: [tester::#PV1] [Decoder] - .error_code (0)
remote: [tester::#PV1] [Decoder] - .num_api_keys (1)
remote: [tester::#PV1] [Decoder] - .ApiKeys[0]
remote: [tester::#PV1] [Decoder] - .api_key (18)
remote: [tester::#PV1] [Decoder] - .min_version (0)
remote: [tester::#PV1] [Decoder] - .max_version (10)
remote: [tester::#PV1] [Decoder] - .TAG_BUFFER
remote: [tester::#PV1] [Decoder] - .throttle_time_ms (0)
remote: [tester::#PV1] [Decoder] - .TAG_BUFFER
remote: [tester::#PV1] ✓ Correlation ID: 1630436662
remote: [tester::#PV1] ✓ Error code: 0 (NO_ERROR)
remote: [tester::#PV1] ✓ API keys array is non-empty
remote: [tester::#PV1] ✓ API version 4 is supported for API_VERSIONS
remote: [tester::#PV1] Test passed.
remote: [tester::#PV1] Terminating program
remote: [your_program] Received data: [0 18 0 4] (1630436662)
remote: [tester::#PV1] Program terminated successfully
remote:
remote: [tester::#NC5] Running tests for Stage #NC5 (Parse API Version)
remote: [tester::#NC5] $ ./your_program.sh /tmp/server.properties
remote: [tester::#NC5] Connecting to broker at: localhost:9092
remote: [your_program] Logs from your program will appear here!
remote: [tester::#NC5] Connection to broker at localhost:9092 successful
remote: [tester::#NC5] Sending "ApiVersions" (version: -24371) request (Correlation id: 841604514)
remote: [tester::#NC5] Hexdump of sent "ApiVersions" request:
remote: [tester::#NC5] Idx | Hex | ASCII
remote: [tester::#NC5] -----+-------------------------------------------------+-----------------
remote: [tester::#NC5] 0000 | 00 00 00 23 00 12 a0 cd 32 29 dd a2 00 09 6b 61 | ...#....2)....ka
remote: [tester::#NC5] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
remote: [tester::#NC5] 0020 | 6c 69 04 30 2e 31 00 | li.0.1.
remote: [tester::#NC5]
remote: [tester::#NC5] Hexdump of received "ApiVersions" response:
remote: [tester::#NC5] Idx | Hex | ASCII
remote: [tester::#NC5] -----+-------------------------------------------------+-----------------
remote: [tester::#NC5] 0000 | 00 00 00 13 32 29 dd a2 00 00 02 00 12 00 00 00 | ....2)..........
remote: [tester::#NC5] 0010 | 0a 00 00 00 00 00 00 | .......
remote: [tester::#NC5]
remote: [tester::#NC5] [Decoder] - .Response
remote: [tester::#NC5] [Decoder] - .message_length (19)
remote: [tester::#NC5] [Decoder] - .ResponseHeader
remote: [tester::#NC5] [Decoder] - .correlation_id (841604514)
remote: [tester::#NC5] [Decoder] - .error_code (0)
remote: [tester::#NC5] ✓ Correlation ID: 841604514
remote: [tester::#NC5] Expected Error code to be 35, got 0
remote: [tester::#NC5] Test failed
remote: [tester::#NC5] Terminating program
remote: [your_program] Received data: [0 18 160 205] (841604514)
remote: [tester::#NC5] Program terminated successfully
And here’s a snippet of my code:
resp := make([]byte, 23)
// message size
binary.BigEndian.PutUint32(resp[0:4], 19)
copy(resp[4:8], buffer[8:12]) // correlation id
// API Versions Response Body
// error code
binary.BigEndian.PutUint16(resp[8:10], 0)
// API Versions array
// length of array = 1 byte
resp[10] = 0x02
// element 1
// api key (2 bytes), min version (2 bytes), max version (2 bytes), tag buffer (0x00) (1 byte)
binary.BigEndian.PutUint16(resp[11:13], 18) // api key
binary.BigEndian.PutUint16(resp[13:15], 0) // min version
binary.BigEndian.PutUint16(resp[15:17], 10) // max version
resp[17] = 0 // tag buffer
binary.BigEndian.PutUint32(resp[18:], 0) // throttle time
resp[22] = 0 // tag buffer
_, err = conn.Write(resp)
if err != nil {
fmt.Println("Error writing data: ", err.Error())
os.Exit(1)
}