I’m getting an error when test case related to unsupported version runs.
[tester::#NC5] Running tests for Stage #NC5 (Parse API Version)
[tester::#NC5] $ ./your_program.sh /tmp/server.properties
[tester::#NC5] Connecting to broker at: localhost:9092
[tester::#NC5] Connection to broker at localhost:9092 successful
[tester::#NC5] Sending "ApiVersions" (version: -865) request (Correlation id: 95200147)
[tester::#NC5] Hexdump of sent "ApiVersions" request:
[tester::#NC5] Idx | Hex | ASCII
[tester::#NC5] -----+-------------------------------------------------+-----------------
[tester::#NC5] 0000 | 00 00 00 23 00 12 fc 9f 05 ac a3 93 00 09 6b 61 | ...#..........ka
[tester::#NC5] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
[tester::#NC5] 0020 | 6c 69 04 30 2e 31 00 | li.0.1.
[tester::#NC5]
[tester::#NC5] error reading from connection: read tcp 127.0.0.1:57450->127.0.0.1:9092: read: connection reset by peer
[tester::#NC5] Test failed
[tester::#NC5] Terminating program
[tester::#NC5] Program terminated successfully
Here is my code which handles the error case.
if m.Error != 0 {
out := make([]byte, 6)
binary.BigEndian.PutUint32(out, uint32(m.CorrelationID))
binary.BigEndian.PutUint16(out[4:], uint16(m.Error))
err := Send(conn, out)
if err != nil {
fmt.Println("Error sending message to conn: ", err.Error())
return
}
return
}
func Send(c net.Conn, data []byte) error {
err := binary.Write(c, binary.BigEndian, uint32(len(data)))
if err != nil {
return err
}
err = binary.Write(c, binary.BigEndian, data)
if err != nil {
return err
}
return nil
}