(t *testing.T)
| 1023 | } |
| 1024 | |
| 1025 | func TestPartitionRingGetTokenRangesForPartition(t *testing.T) { |
| 1026 | gen := initTokenGenerator(t) |
| 1027 | |
| 1028 | tests := map[string]struct { |
| 1029 | partitionTokens map[int][]uint32 |
| 1030 | expected map[int]TokenRanges |
| 1031 | }{ |
| 1032 | "single instance in zone": { |
| 1033 | partitionTokens: map[int][]uint32{ |
| 1034 | 0: gen.GenerateTokens(512, nil), |
| 1035 | }, |
| 1036 | expected: map[int]TokenRanges{ |
| 1037 | 0: {0, math.MaxUint32}, |
| 1038 | }, |
| 1039 | }, |
| 1040 | "simple ranges": { |
| 1041 | partitionTokens: map[int][]uint32{ |
| 1042 | 0: {25, 75}, |
| 1043 | 1: {10, 50, 100}, |
| 1044 | }, |
| 1045 | expected: map[int]TokenRanges{ |
| 1046 | 0: {10, 24, 50, 74}, |
| 1047 | 1: {0, 9, 25, 49, 75, math.MaxUint32}, |
| 1048 | }, |
| 1049 | }, |
| 1050 | "grouped tokens": { |
| 1051 | partitionTokens: map[int][]uint32{ |
| 1052 | 0: {10, 20, 30, 40, 50}, |
| 1053 | 1: {1000, 2000, 3000, 4000}, |
| 1054 | }, |
| 1055 | expected: map[int]TokenRanges{ |
| 1056 | 0: {0, 49, 4000, math.MaxUint32}, |
| 1057 | 1: {50, 3999}, |
| 1058 | }, |
| 1059 | }, |
| 1060 | "consecutive tokens": { |
| 1061 | partitionTokens: map[int][]uint32{ |
| 1062 | 0: {99}, |
| 1063 | 1: {100}, |
| 1064 | }, |
| 1065 | expected: map[int]TokenRanges{ |
| 1066 | 0: {0, 98, 100, math.MaxUint32}, |
| 1067 | 1: {99, 99}, |
| 1068 | }, |
| 1069 | }, |
| 1070 | "extremes": { |
| 1071 | partitionTokens: map[int][]uint32{ |
| 1072 | 0: {0}, |
| 1073 | 1: {math.MaxUint32}, |
| 1074 | }, |
| 1075 | expected: map[int]TokenRanges{ |
| 1076 | 0: {math.MaxUint32, math.MaxUint32}, |
| 1077 | 1: {0, math.MaxUint32 - 1}, |
| 1078 | }, |
| 1079 | }, |
| 1080 | } |
| 1081 | |
| 1082 | for testName, testData := range tests { |
nothing calls this directly
no test coverage detected