|
| 1 | +package describegroups_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/segmentio/kafka-go/protocol/describegroups" |
| 7 | + "github.com/segmentio/kafka-go/protocol/prototest" |
| 8 | +) |
| 9 | + |
| 10 | +const ( |
| 11 | + v0 = 0 |
| 12 | + v1 = 1 |
| 13 | + v2 = 2 |
| 14 | + v3 = 3 |
| 15 | + v4 = 4 |
| 16 | + v5 = 5 |
| 17 | +) |
| 18 | + |
| 19 | +func TestDescribeGroupsRequest(t *testing.T) { |
| 20 | + prototest.TestRequest(t, v0, &describegroups.Request{ |
| 21 | + Groups: []string{"test-group"}, |
| 22 | + }) |
| 23 | + |
| 24 | + prototest.TestRequest(t, v1, &describegroups.Request{ |
| 25 | + Groups: []string{"test-group"}, |
| 26 | + }) |
| 27 | + |
| 28 | + prototest.TestRequest(t, v2, &describegroups.Request{ |
| 29 | + Groups: []string{"test-group"}, |
| 30 | + }) |
| 31 | + |
| 32 | + prototest.TestRequest(t, v3, &describegroups.Request{ |
| 33 | + Groups: []string{"test-group"}, |
| 34 | + IncludeAuthorizedOperations: true, |
| 35 | + }) |
| 36 | + |
| 37 | + prototest.TestRequest(t, v4, &describegroups.Request{ |
| 38 | + Groups: []string{"test-group"}, |
| 39 | + IncludeAuthorizedOperations: true, |
| 40 | + }) |
| 41 | + |
| 42 | + prototest.TestRequest(t, v5, &describegroups.Request{ |
| 43 | + Groups: []string{"test-group"}, |
| 44 | + IncludeAuthorizedOperations: true, |
| 45 | + }) |
| 46 | +} |
| 47 | + |
| 48 | +func TestDescribeGroupsResponse(t *testing.T) { |
| 49 | + prototest.TestResponse(t, v0, &describegroups.Response{ |
| 50 | + Groups: []describegroups.ResponseGroup{ |
| 51 | + { |
| 52 | + ErrorCode: 0, |
| 53 | + GroupID: "test-group", |
| 54 | + GroupState: "Stable", |
| 55 | + ProtocolType: "consumer", |
| 56 | + ProtocolData: "range", |
| 57 | + Members: []describegroups.ResponseGroupMember{ |
| 58 | + { |
| 59 | + MemberID: "consumer-1", |
| 60 | + ClientID: "client-1", |
| 61 | + ClientHost: "/127.0.0.1", |
| 62 | + MemberMetadata: []byte{0x00, 0x01}, |
| 63 | + MemberAssignment: []byte{0x00, 0x02}, |
| 64 | + }, |
| 65 | + }, |
| 66 | + }, |
| 67 | + }, |
| 68 | + }) |
| 69 | + |
| 70 | + prototest.TestResponse(t, v1, &describegroups.Response{ |
| 71 | + ThrottleTimeMs: 100, |
| 72 | + Groups: []describegroups.ResponseGroup{ |
| 73 | + { |
| 74 | + ErrorCode: 0, |
| 75 | + GroupID: "test-group", |
| 76 | + GroupState: "Stable", |
| 77 | + ProtocolType: "consumer", |
| 78 | + ProtocolData: "range", |
| 79 | + Members: []describegroups.ResponseGroupMember{ |
| 80 | + { |
| 81 | + MemberID: "consumer-1", |
| 82 | + ClientID: "client-1", |
| 83 | + ClientHost: "/127.0.0.1", |
| 84 | + MemberMetadata: []byte{0x00, 0x01}, |
| 85 | + MemberAssignment: []byte{0x00, 0x02}, |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + }, |
| 90 | + }) |
| 91 | + |
| 92 | + prototest.TestResponse(t, v2, &describegroups.Response{ |
| 93 | + ThrottleTimeMs: 100, |
| 94 | + Groups: []describegroups.ResponseGroup{ |
| 95 | + { |
| 96 | + ErrorCode: 0, |
| 97 | + GroupID: "test-group", |
| 98 | + GroupState: "Stable", |
| 99 | + ProtocolType: "consumer", |
| 100 | + ProtocolData: "range", |
| 101 | + Members: []describegroups.ResponseGroupMember{ |
| 102 | + { |
| 103 | + MemberID: "consumer-1", |
| 104 | + ClientID: "client-1", |
| 105 | + ClientHost: "/127.0.0.1", |
| 106 | + MemberMetadata: []byte{0x00, 0x01}, |
| 107 | + MemberAssignment: []byte{0x00, 0x02}, |
| 108 | + }, |
| 109 | + }, |
| 110 | + }, |
| 111 | + }, |
| 112 | + }) |
| 113 | + |
| 114 | + prototest.TestResponse(t, v3, &describegroups.Response{ |
| 115 | + ThrottleTimeMs: 100, |
| 116 | + Groups: []describegroups.ResponseGroup{ |
| 117 | + { |
| 118 | + ErrorCode: 0, |
| 119 | + GroupID: "test-group", |
| 120 | + GroupState: "Stable", |
| 121 | + ProtocolType: "consumer", |
| 122 | + ProtocolData: "range", |
| 123 | + AuthorizedOperations: 2147483647, |
| 124 | + Members: []describegroups.ResponseGroupMember{ |
| 125 | + { |
| 126 | + MemberID: "consumer-1", |
| 127 | + ClientID: "client-1", |
| 128 | + ClientHost: "/127.0.0.1", |
| 129 | + MemberMetadata: []byte{0x00, 0x01}, |
| 130 | + MemberAssignment: []byte{0x00, 0x02}, |
| 131 | + }, |
| 132 | + }, |
| 133 | + }, |
| 134 | + }, |
| 135 | + }) |
| 136 | + |
| 137 | + prototest.TestResponse(t, v4, &describegroups.Response{ |
| 138 | + ThrottleTimeMs: 100, |
| 139 | + Groups: []describegroups.ResponseGroup{ |
| 140 | + { |
| 141 | + ErrorCode: 0, |
| 142 | + GroupID: "test-group", |
| 143 | + GroupState: "Stable", |
| 144 | + ProtocolType: "consumer", |
| 145 | + ProtocolData: "range", |
| 146 | + AuthorizedOperations: 2147483647, |
| 147 | + Members: []describegroups.ResponseGroupMember{ |
| 148 | + { |
| 149 | + MemberID: "consumer-1", |
| 150 | + GroupInstanceID: "instance-1", |
| 151 | + ClientID: "client-1", |
| 152 | + ClientHost: "/127.0.0.1", |
| 153 | + MemberMetadata: []byte{0x00, 0x01}, |
| 154 | + MemberAssignment: []byte{0x00, 0x02}, |
| 155 | + }, |
| 156 | + }, |
| 157 | + }, |
| 158 | + }, |
| 159 | + }) |
| 160 | + |
| 161 | + prototest.TestResponse(t, v5, &describegroups.Response{ |
| 162 | + ThrottleTimeMs: 100, |
| 163 | + Groups: []describegroups.ResponseGroup{ |
| 164 | + { |
| 165 | + ErrorCode: 0, |
| 166 | + GroupID: "test-group", |
| 167 | + GroupState: "Stable", |
| 168 | + ProtocolType: "consumer", |
| 169 | + ProtocolData: "range", |
| 170 | + AuthorizedOperations: 2147483647, |
| 171 | + Members: []describegroups.ResponseGroupMember{ |
| 172 | + { |
| 173 | + MemberID: "consumer-1", |
| 174 | + GroupInstanceID: "instance-1", |
| 175 | + ClientID: "client-1", |
| 176 | + ClientHost: "/127.0.0.1", |
| 177 | + MemberMetadata: []byte{0x00, 0x01}, |
| 178 | + MemberAssignment: []byte{0x00, 0x02}, |
| 179 | + }, |
| 180 | + }, |
| 181 | + }, |
| 182 | + }, |
| 183 | + }) |
| 184 | +} |
0 commit comments