Browse Source

tests: align ApiVersions test expectations with advertised ranges (ListOffsets v0-2, Fetch v0-7)

pull/7231/head
chrislu 2 months ago
parent
commit
4e4e3ce1a8
  1. 28
      weed/mq/kafka/protocol/handler.go
  2. 8
      weed/mq/kafka/protocol/handler_test.go

28
weed/mq/kafka/protocol/handler.go

@ -1688,20 +1688,20 @@ func (h *Handler) handleDeleteTopics(correlationID uint32, requestBody []byte) (
// validateAPIVersion checks if we support the requested API version // validateAPIVersion checks if we support the requested API version
func (h *Handler) validateAPIVersion(apiKey, apiVersion uint16) error { func (h *Handler) validateAPIVersion(apiKey, apiVersion uint16) error {
supportedVersions := map[uint16][2]uint16{ supportedVersions := map[uint16][2]uint16{
18: {0, 3}, // ApiVersions: v0-v3
3: {0, 7}, // Metadata: v0-v7
0: {0, 7}, // Produce: v0-v7
1: {0, 7}, // Fetch: v0-v7
2: {0, 2}, // ListOffsets: v0-v2
19: {0, 4}, // CreateTopics: v0-v4
20: {0, 4}, // DeleteTopics: v0-v4
10: {0, 2}, // FindCoordinator: v0-v2
11: {0, 7}, // JoinGroup: v0-v7
14: {0, 5}, // SyncGroup: v0-v5
8: {0, 2}, // OffsetCommit: v0-v2
9: {0, 2}, // OffsetFetch: v0-v2
12: {0, 4}, // Heartbeat: v0-v4
13: {0, 4}, // LeaveGroup: v0-v4
18: {0, 3}, // ApiVersions: v0-v3
3: {0, 7}, // Metadata: v0-v7
0: {0, 7}, // Produce: v0-v7
1: {0, 7}, // Fetch: v0-v7
2: {0, 2}, // ListOffsets: v0-v2
19: {0, 4}, // CreateTopics: v0-v4
20: {0, 4}, // DeleteTopics: v0-v4
10: {0, 2}, // FindCoordinator: v0-v2
11: {0, 7}, // JoinGroup: v0-v7
14: {0, 5}, // SyncGroup: v0-v5
8: {0, 2}, // OffsetCommit: v0-v2
9: {0, 2}, // OffsetFetch: v0-v2
12: {0, 4}, // Heartbeat: v0-v4
13: {0, 4}, // LeaveGroup: v0-v4
} }
if versionRange, exists := supportedVersions[apiKey]; exists { if versionRange, exists := supportedVersions[apiKey]; exists {

8
weed/mq/kafka/protocol/handler_test.go

@ -142,8 +142,8 @@ func TestHandler_ApiVersions(t *testing.T) {
if minVersion3 != 0 { if minVersion3 != 0 {
t.Errorf("expected min version 0, got: %d", minVersion3) t.Errorf("expected min version 0, got: %d", minVersion3)
} }
if maxVersion3 != 5 {
t.Errorf("expected max version 5, got: %d", maxVersion3)
if maxVersion3 != 2 {
t.Errorf("expected max version 2, got: %d", maxVersion3)
} }
// Fourth API key (CreateTopics) // Fourth API key (CreateTopics)
@ -202,8 +202,8 @@ func TestHandler_ApiVersions(t *testing.T) {
if minVersion7 != 0 { if minVersion7 != 0 {
t.Errorf("expected min version 0, got: %d", minVersion7) t.Errorf("expected min version 0, got: %d", minVersion7)
} }
if maxVersion7 != 11 {
t.Errorf("expected max version 11, got: %d", maxVersion7)
if maxVersion7 != 7 {
t.Errorf("expected max version 7, got: %d", maxVersion7)
} }
// Close client to end handler // Close client to end handler

Loading…
Cancel
Save