@@ -414,6 +414,50 @@ func TestCompactor_ShouldRetryCompactionOnFailureWhileDiscoveringUsersFromBucket
414
414
))
415
415
}
416
416
417
+ func TestCompactor_ShouldIncrementCompactionErrorIfFailedToCompactASingleTenant (t * testing.T ) {
418
+ t .Parallel ()
419
+
420
+ userID := "test-user"
421
+ bucketClient := & bucket.ClientMock {}
422
+ bucketClient .MockIter ("" , []string {userID }, nil )
423
+ bucketClient .MockIter (userID + "/" , []string {userID + "/01DTVP434PA9VFXSW2JKB3392D" }, nil )
424
+ bucketClient .MockIter (userID + "/markers/" , nil , nil )
425
+ bucketClient .MockExists (path .Join (userID , cortex_tsdb .TenantDeletionMarkPath ), false , nil )
426
+ bucketClient .MockGet (userID + "/01DTVP434PA9VFXSW2JKB3392D/meta.json" , mockBlockMetaJSON ("01DTVP434PA9VFXSW2JKB3392D" ), nil )
427
+ bucketClient .MockGet (userID + "/01DTVP434PA9VFXSW2JKB3392D/deletion-mark.json" , "" , nil )
428
+ bucketClient .MockGet (userID + "/bucket-index.json.gz" , "" , nil )
429
+ bucketClient .MockUpload (userID + "/bucket-index.json.gz" , nil )
430
+
431
+ c , _ , tsdbPlannerMock , _ , registry := prepare (t , prepareConfig (), bucketClient )
432
+ tsdbPlannerMock .On ("Plan" , mock .Anything , mock .Anything ).Return ([]* metadata.Meta {}, errors .New ("Failed to plan" ))
433
+ require .NoError (t , services .StartAndAwaitRunning (context .Background (), c ))
434
+
435
+ // Wait until all retry attempts have completed.
436
+ cortex_testutil .Poll (t , time .Second , 1.0 , func () interface {} {
437
+ return prom_testutil .ToFloat64 (c .compactionRunsFailed )
438
+ })
439
+
440
+ require .NoError (t , services .StopAndAwaitTerminated (context .Background (), c ))
441
+
442
+ assert .NoError (t , prom_testutil .GatherAndCompare (registry , strings .NewReader (`
443
+ # TYPE cortex_compactor_runs_started_total counter
444
+ # HELP cortex_compactor_runs_started_total Total number of compaction runs started.
445
+ cortex_compactor_runs_started_total 1
446
+
447
+ # TYPE cortex_compactor_runs_completed_total counter
448
+ # HELP cortex_compactor_runs_completed_total Total number of compaction runs successfully completed.
449
+ cortex_compactor_runs_completed_total 0
450
+
451
+ # TYPE cortex_compactor_runs_failed_total counter
452
+ # HELP cortex_compactor_runs_failed_total Total number of compaction runs failed.
453
+ cortex_compactor_runs_failed_total 1
454
+ ` ),
455
+ "cortex_compactor_runs_started_total" ,
456
+ "cortex_compactor_runs_completed_total" ,
457
+ "cortex_compactor_runs_failed_total" ,
458
+ ))
459
+ }
460
+
417
461
func TestCompactor_ShouldIterateOverUsersAndRunCompaction (t * testing.T ) {
418
462
t .Parallel ()
419
463
0 commit comments