MCPcopy
hub / github.com/grafana/tempo / TestConfig_partitionAssignment

Function TestConfig_partitionAssignment

modules/blockbuilder/config_test.go:49–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func 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 },

Callers

nothing calls this directly

Calls 3

AssignedPartitionsMethod · 0.80
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected