(t *testing.T)
| 3136 | } |
| 3137 | |
| 3138 | func TestGetShardSizeForUser(t *testing.T) { |
| 3139 | tests := []struct { |
| 3140 | name string |
| 3141 | userID string |
| 3142 | replicationFactor int |
| 3143 | rulerInstanceCount int |
| 3144 | tenantShardSize float64 |
| 3145 | expectedShardSize int |
| 3146 | }{ |
| 3147 | { |
| 3148 | name: "User with fixed shard size with 10 ruler instances", |
| 3149 | userID: "user1", |
| 3150 | rulerInstanceCount: 10, |
| 3151 | replicationFactor: 1, |
| 3152 | tenantShardSize: 2, |
| 3153 | expectedShardSize: 2, |
| 3154 | }, |
| 3155 | { |
| 3156 | name: "User with fixed shard size with 50 ruler instances", |
| 3157 | userID: "user1", |
| 3158 | rulerInstanceCount: 50, |
| 3159 | replicationFactor: 1, |
| 3160 | tenantShardSize: 30, |
| 3161 | expectedShardSize: 30, |
| 3162 | }, |
| 3163 | { |
| 3164 | name: "User with percentage shard size with 10 ruler instances", |
| 3165 | userID: "user1", |
| 3166 | rulerInstanceCount: 10, |
| 3167 | replicationFactor: 1, |
| 3168 | tenantShardSize: 0.6, |
| 3169 | expectedShardSize: 6, |
| 3170 | }, |
| 3171 | { |
| 3172 | name: "User with percentage shard size with 80 ruler instances", |
| 3173 | userID: "user1", |
| 3174 | rulerInstanceCount: 80, |
| 3175 | replicationFactor: 1, |
| 3176 | tenantShardSize: 0.25, |
| 3177 | expectedShardSize: 20, |
| 3178 | }, |
| 3179 | { |
| 3180 | name: "Ensure shard size is at least replication factor", |
| 3181 | userID: "user1", |
| 3182 | rulerInstanceCount: 10, |
| 3183 | replicationFactor: 3, |
| 3184 | tenantShardSize: 0.1, |
| 3185 | expectedShardSize: 3, |
| 3186 | }, |
| 3187 | } |
| 3188 | |
| 3189 | for _, tc := range tests { |
| 3190 | t.Run(tc.name, func(t *testing.T) { |
| 3191 | |
| 3192 | rulerStateMap := make(map[string]ring.InstanceState) |
| 3193 | rulerAZEvenSpread := make(map[string]string) |
| 3194 | rulerIDs := make([]string, tc.rulerInstanceCount) |
| 3195 |
nothing calls this directly
no test coverage detected