Skip to content

Commit 1532d9f

Browse files
authored
fix(proto): ensure req+resp requiredVersion match (#2548)
Add a test to ensure that the requiredVersion of the request and response pairs matches. Accordingly fix DescribeConfigs which had a V1_0_0_0 instead of V1_1_0_0 bug for V1 in the Response Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>
1 parent 2a5f0f6 commit 1532d9f

3 files changed

+11
-6
lines changed

describe_configs_request.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ func (r *DescribeConfigsRequest) isValidVersion() bool {
109109

110110
func (r *DescribeConfigsRequest) requiredVersion() KafkaVersion {
111111
switch r.Version {
112-
case 1:
113-
return V1_1_0_0
114112
case 2:
115113
return V2_0_0_0
116-
default:
114+
case 1:
115+
return V1_1_0_0
116+
case 0:
117117
return V0_11_0_0
118+
default:
119+
return V2_0_0_0
118120
}
119121
}

describe_configs_response.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ func (r *DescribeConfigsResponse) isValidVersion() bool {
122122

123123
func (r *DescribeConfigsResponse) requiredVersion() KafkaVersion {
124124
switch r.Version {
125-
case 1:
126-
return V1_0_0_0
127125
case 2:
128126
return V2_0_0_0
129-
default:
127+
case 1:
128+
return V1_1_0_0
129+
case 0:
130130
return V0_11_0_0
131+
default:
132+
return V2_0_0_0
131133
}
132134
}
133135

request_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ func TestAllocateBodyProtocolVersions(t *testing.T) {
241241
resp := allocateResponseBody(req)
242242
assert.NotNil(t, resp, fmt.Sprintf("%s has no matching response type in allocateResponseBody", reflect.TypeOf(req)))
243243
assert.Equal(t, req.isValidVersion(), resp.isValidVersion(), fmt.Sprintf("%s isValidVersion should match %s", reflect.TypeOf(req), reflect.TypeOf(resp)))
244+
assert.Equal(t, req.requiredVersion(), resp.requiredVersion(), fmt.Sprintf("%s requiredVersion should match %s", reflect.TypeOf(req), reflect.TypeOf(resp)))
244245
for _, body := range []protocolBody{req, resp} {
245246
assert.Equal(t, key, body.key())
246247
assert.Equal(t, version, body.version())

0 commit comments

Comments
 (0)