(t *testing.T)
| 212 | } |
| 213 | |
| 214 | func TestConsistentCRCHashPartitioner(t *testing.T) { |
| 215 | numPartitions := int32(100) |
| 216 | partitioner := NewConsistentCRCHashPartitioner("mytopic") |
| 217 | |
| 218 | testCases := []partitionerTestCase{ |
| 219 | { |
| 220 | key: "abc123def456", |
| 221 | expectedPartition: 57, |
| 222 | }, |
| 223 | { |
| 224 | // `SheetJS` has a crc32 hash value of 2647669026 (which is -1647298270 as a signed int32) |
| 225 | // Modding the signed value will give a partition of 70. Modding the unsigned value will give 26 |
| 226 | key: "SheetJS", |
| 227 | expectedPartition: 26, |
| 228 | }, |
| 229 | { |
| 230 | key: "9e8c7f4cf45857cfff7645d6", |
| 231 | expectedPartition: 24, |
| 232 | }, |
| 233 | { |
| 234 | key: "3900446192ff85a5f67da10c", |
| 235 | expectedPartition: 75, |
| 236 | }, |
| 237 | { |
| 238 | key: "0f4407b7a67d6d27de372198", |
| 239 | expectedPartition: 50, |
| 240 | }, |
| 241 | } |
| 242 | |
| 243 | for _, tc := range testCases { |
| 244 | partitionAndAssert(t, partitioner, numPartitions, tc) |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | func TestCustomPartitionerWithConsistentHashing(t *testing.T) { |
| 249 | // Setting both `hashUnsigned` and the hash function to `crc32.NewIEEE` is equivalent to using `NewConsistentCRCHashPartitioner` |
nothing calls this directly
no test coverage detected