MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestOverridesAPIWithS3Error

Function TestOverridesAPIWithS3Error

integration/overrides_test.go:290–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

288}
289
290func TestOverridesAPIWithS3Error(t *testing.T) {
291 s, err := e2e.NewScenario(networkName)
292 require.NoError(t, err)
293 defer s.Close()
294
295 minio := e2edb.NewMinio(9001, "cortex")
296 require.NoError(t, s.StartAndWaitReady(minio))
297
298 runtimeConfig := map[string]interface{}{
299 "overrides": map[string]interface{}{
300 "user1": map[string]interface{}{
301 "ingestion_rate": 5000,
302 },
303 },
304 "api_allowed_limits": []string{
305 "ingestion_rate",
306 "max_global_series_per_user",
307 "max_global_series_per_metric",
308 "ingestion_burst_size",
309 "ruler_max_rules_per_rule_group",
310 "ruler_max_rule_groups_per_tenant",
311 },
312 }
313 uploadRuntimeConfig(t, minio, runtimeConfig)
314
315 cortexSvc := e2ecortex.NewSingleBinary("cortex-overrides-s3-error", defaultArgsOverrides(minio), "")
316 require.NoError(t, s.StartAndWaitReady(cortexSvc))
317
318 // Delete runtime.yaml from S3 to simulate file being missing
319 s3Client, err := s3.NewBucketWithConfig(nil, s3.Config{
320 Endpoint: minio.HTTPEndpoint(),
321 Insecure: true,
322 Bucket: "cortex",
323 AccessKey: e2edb.MinioAccessKey,
324 SecretKey: e2edb.MinioSecretKey,
325 }, "overrides-test-delete", nil)
326 require.NoError(t, err)
327 require.NoError(t, s3Client.Delete(context.Background(), "runtime.yaml"))
328
329 t.Run("GET overrides when runtime.yaml is missing", func(t *testing.T) {
330 req, err := http.NewRequest("GET", "http://"+cortexSvc.HTTPEndpoint()+"/api/v1/user-overrides", nil)
331 require.NoError(t, err)
332 req.Header.Set("X-Scope-OrgID", "user1")
333
334 resp, err := http.DefaultClient.Do(req)
335 require.NoError(t, err)
336 defer resp.Body.Close()
337
338 assert.Equal(t, http.StatusInternalServerError, resp.StatusCode)
339 })
340
341 t.Run("POST overrides when runtime.yaml is missing", func(t *testing.T) {
342 newOverrides := map[string]interface{}{
343 "ingestion_rate": 6000,
344 }
345 requestBody, err := json.Marshal(newOverrides)
346 require.NoError(t, err)
347

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
StartAndWaitReadyMethod · 0.95
StopMethod · 0.95
NewScenarioFunction · 0.92
NewSingleBinaryFunction · 0.92
uploadRuntimeConfigFunction · 0.85
defaultArgsOverridesFunction · 0.85
HTTPEndpointMethod · 0.80
DeleteMethod · 0.65
RunMethod · 0.65
SetMethod · 0.65
DoMethod · 0.65

Tested by

no test coverage detected