(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestRulerWithUserIndexUpdater(t *testing.T) { |
| 146 | s, err := e2e.NewScenario(networkName) |
| 147 | require.NoError(t, err) |
| 148 | defer s.Close() |
| 149 | |
| 150 | // Start dependencies. |
| 151 | consul := e2edb.NewConsul() |
| 152 | minio := e2edb.NewMinio(9000, rulestoreBucketName) |
| 153 | require.NoError(t, s.StartAndWaitReady(consul, minio)) |
| 154 | |
| 155 | // Configure the ruler. |
| 156 | rulerFlags := mergeFlags( |
| 157 | BlocksStorageFlags(), |
| 158 | RulerFlags(), |
| 159 | RulerShardingFlags(consul.NetworkHTTPEndpoint()), |
| 160 | map[string]string{ |
| 161 | "-ruler.sharding-strategy": "shuffle-sharding", |
| 162 | "-ruler-storage.users-scanner.strategy": "user_index", |
| 163 | "-ruler-storage.users-scanner.user-index.update-interval": "15s", |
| 164 | "-ruler.tenant-shard-size": "1", |
| 165 | // Since we're not going to run any rule, we don't need the |
| 166 | // store-gateway to be configured to a valid address. |
| 167 | "-querier.store-gateway-addresses": "localhost:12345", |
| 168 | // Enable the bucket index so we can skip the initial bucket scan. |
| 169 | "-blocks-storage.bucket-store.bucket-index.enabled": "true", |
| 170 | "-ruler.poll-interval": "2s", |
| 171 | "-log.level": "info", |
| 172 | }, |
| 173 | ) |
| 174 | |
| 175 | ruler := e2ecortex.NewRuler( |
| 176 | "ruler", |
| 177 | consul.NetworkHTTPEndpoint(), |
| 178 | rulerFlags, |
| 179 | "", |
| 180 | ) |
| 181 | |
| 182 | require.NoError(t, s.StartAndWaitReady(ruler)) |
| 183 | |
| 184 | // Create a client with the ruler address configured |
| 185 | c, err := e2ecortex.NewClient("", "", "", ruler.HTTPEndpoint(), "user-1") |
| 186 | require.NoError(t, err) |
| 187 | |
| 188 | ruleGroup := createTestRuleGroup(t) |
| 189 | ns := "ns" |
| 190 | |
| 191 | // Set the rule group into the ruler |
| 192 | require.NoError(t, c.SetRuleGroup(ruleGroup, ns)) |
| 193 | |
| 194 | // To make sure user index file is updated/scanned |
| 195 | require.NoError(t, ruler.WaitSumMetricsWithOptions(e2e.Greater(float64(0)), []string{"cortex_user_index_last_successful_update_timestamp_seconds"}), |
| 196 | e2e.WithLabelMatchers(labels.MustNewMatcher(labels.MatchEqual, "component", "ruler")), |
| 197 | ) |
| 198 | |
| 199 | require.NoError(t, ruler.WaitSumMetricsWithOptions(e2e.GreaterOrEqual(float64(1)), []string{"cortex_user_index_scan_succeeded_total"}), |
| 200 | e2e.WithLabelMatchers(labels.MustNewMatcher(labels.MatchEqual, "component", "ruler")), |
| 201 | ) |
| 202 | } |
nothing calls this directly
no test coverage detected