(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestConfig_partitionAssignment(t *testing.T) { |
| 50 | instanceID := "block-builder-42" |
| 51 | for _, tc := range []struct { |
| 52 | name string |
| 53 | cfg Config |
| 54 | expectedPartitions []int32 |
| 55 | }{ |
| 56 | { |
| 57 | name: "assigned_partitions", |
| 58 | cfg: Config{ |
| 59 | InstanceID: instanceID, |
| 60 | AssignedPartitionsMap: map[string][]int32{ |
| 61 | instanceID: {1, 2, 56}, |
| 62 | }, |
| 63 | }, |
| 64 | expectedPartitions: []int32{1, 2, 56}, |
| 65 | }, |
| 66 | { |
| 67 | name: "partitions_per_instance", |
| 68 | cfg: Config{ |
| 69 | InstanceID: instanceID, |
| 70 | PartitionsPerInstance: 2, |
| 71 | }, |
| 72 | expectedPartitions: []int32{84, 85}, |
| 73 | }, |
| 74 | { |
| 75 | name: "assigned_partitions takes precedence", |
| 76 | cfg: Config{ |
| 77 | InstanceID: instanceID, |
| 78 | PartitionsPerInstance: 2, |
| 79 | AssignedPartitionsMap: map[string][]int32{ |
| 80 | instanceID: {1, 2, 56}, |
| 81 | }, |
| 82 | }, |
| 83 | expectedPartitions: []int32{1, 2, 56}, |
| 84 | }, |
| 85 | { |
| 86 | name: "falls back to assigned_partitions if ID doesn't have an index", |
| 87 | cfg: Config{ |
| 88 | InstanceID: "block-builder", |
| 89 | AssignedPartitionsMap: map[string][]int32{ |
| 90 | "block-builder": {1, 2, 56}, |
| 91 | }, |
| 92 | PartitionsPerInstance: 2, |
| 93 | }, |
| 94 | expectedPartitions: []int32{1, 2, 56}, |
| 95 | }, |
| 96 | { |
| 97 | name: "returns nil if no instance ID", |
| 98 | cfg: Config{ |
| 99 | InstanceID: "", |
| 100 | AssignedPartitionsMap: map[string][]int32{ |
| 101 | instanceID: {1, 2, 56}, |
| 102 | }, |
| 103 | PartitionsPerInstance: 2, |
| 104 | }, |
| 105 | expectedPartitions: nil, |
| 106 | }, |
nothing calls this directly
no test coverage detected