Skip to content

Commit

Permalink
Adjust e2e tests to not account for empty planning cycles
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Petkovski <[email protected]>
  • Loading branch information
fpetkovski committed Dec 4, 2022
1 parent 24fd336 commit 845dfc5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
23 changes: 12 additions & 11 deletions pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ func RepairIssue347(ctx context.Context, logger log.Logger, bkt objstore.Bucket,
return nil
}

func (cg *Group) GetCompactionTasks(ctx context.Context, dir string, planner Planner) ([]GroupCompactionTask, error) {
func (cg *Group) PlanCompactionTasks(ctx context.Context, dir string, planner Planner) ([]GroupCompactionTask, error) {
plannedCompactions, err := planner.Plan(ctx, cg.metasByMinTime)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1326,25 +1326,26 @@ func (c *BucketCompactor) Compact(ctx context.Context) (rerr error) {

tasks := make([]GroupCompactionTask, 0)
for _, g := range groups {
groupTasks, err := g.GetCompactionTasks(ctx, c.compactDir, c.planner)
// Ignore groups with only one block because there is nothing to compact.
if len(g.IDs()) == 1 {
continue
}

groupTasks, err := g.PlanCompactionTasks(ctx, c.compactDir, c.planner)
if err != nil {
return errors.Wrapf(err, "get compaction group tasks: %s", g.Key())
}
tasks = append(tasks, groupTasks...)
}

// Send all groups found during this pass to the compaction workers.
// Send all tasks planned in this pass to the compaction workers.
var taskErrs errutil.MultiError
groupLoop:
tasksLoop:
for _, task := range tasks {
// Ignore groups with only one block because there is nothing to compact.
if len(task.Blocks) == 1 {
continue
}
select {
case groupErr := <-errChan:
taskErrs.Add(groupErr)
break groupLoop
case taskErr := <-errChan:
taskErrs.Add(taskErr)
break tasksLoop
case taskChan <- task:
}
}
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ func testCompactWithStoreGateway(t *testing.T, penaltyDedup bool) {
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(0), "thanos_compact_group_compactions_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(0), "thanos_compact_group_vertical_compactions_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(1), "thanos_compact_group_compactions_failures_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(2), "thanos_compact_group_compaction_runs_started_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(1), "thanos_compact_group_compaction_runs_completed_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(1), "thanos_compact_group_compaction_runs_started_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(0), "thanos_compact_group_compaction_runs_completed_total"))

// However, the blocks have been cleaned because that happens concurrently.
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(2), "thanos_compact_aborted_partial_uploads_deletion_attempts_total"))
Expand Down Expand Up @@ -702,8 +702,8 @@ func testCompactWithStoreGateway(t *testing.T, penaltyDedup bool) {
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(6), "thanos_compact_group_compactions_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(3), "thanos_compact_group_vertical_compactions_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(0), "thanos_compact_group_compactions_failures_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(14), "thanos_compact_group_compaction_runs_started_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(14), "thanos_compact_group_compaction_runs_completed_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(6), "thanos_compact_group_compaction_runs_started_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(6), "thanos_compact_group_compaction_runs_completed_total"))

testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(2), "thanos_compact_downsample_total"))
testutil.Ok(t, c.WaitSumMetrics(e2emon.Equals(0), "thanos_compact_downsample_failures_total"))
Expand All @@ -723,7 +723,7 @@ func testCompactWithStoreGateway(t *testing.T, penaltyDedup bool) {
operationMatcher, err := matchers.NewMatcher(matchers.MatchEqual, "operation", "get")
testutil.Ok(t, err)
testutil.Ok(t, c.WaitSumMetricsWithOptions(
e2emon.Equals(573),
e2emon.Equals(635),
[]string{"thanos_objstore_bucket_operations_total"}, e2emon.WithLabelMatchers(
bucketMatcher,
operationMatcher,
Expand Down Expand Up @@ -773,8 +773,8 @@ func testCompactWithStoreGateway(t *testing.T, penaltyDedup bool) {
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_group_compactions_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_group_vertical_compactions_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_group_compactions_failures_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(7), []string{"thanos_compact_group_compaction_runs_started_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(7), []string{"thanos_compact_group_compaction_runs_completed_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_group_compaction_runs_started_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_group_compaction_runs_completed_total"}, e2emon.WaitMissingMetrics()))

testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_downsample_total"}, e2emon.WaitMissingMetrics()))
testutil.Ok(t, c.WaitSumMetricsWithOptions(e2emon.Equals(0), []string{"thanos_compact_downsample_failures_total"}, e2emon.WaitMissingMetrics()))
Expand Down

0 comments on commit 845dfc5

Please sign in to comment.