From 53bab986162fa219d1e0f7761e7b5a8e61545076 Mon Sep 17 00:00:00 2001 From: Martin Chodur Date: Thu, 3 Feb 2022 10:34:55 +0100 Subject: [PATCH] cr: fix docs and test Signed-off-by: Martin Chodur --- docs/components/tools.md | 3 +++ pkg/replicate/scheme_test.go | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/components/tools.md b/docs/components/tools.md index 5562344e19..efa9dc475b 100644 --- a/docs/components/tools.md +++ b/docs/components/tools.md @@ -522,6 +522,9 @@ Flags: other matchers will be ignored. When specified, this command will be run only once after successful replication. Repeated field + --ignore-marked-for-deletion + Do not replicate blocks that have deletion + mark. --log.format=logfmt Log format to use. Possible options: logfmt or json. --log.level=info Log filtering level. diff --git a/pkg/replicate/scheme_test.go b/pkg/replicate/scheme_test.go index 7419a59ba0..8d88f096f7 100644 --- a/pkg/replicate/scheme_test.go +++ b/pkg/replicate/scheme_test.go @@ -74,11 +74,12 @@ func testDeletionMark(ulid ulid.ULID) *metadata.DeletionMark { func TestReplicationSchemeAll(t *testing.T) { testBlockID := testULID(0) var cases = []struct { - name string - selector labels.Selector - blockIDs []ulid.ULID - prepare func(ctx context.Context, t *testing.T, originBucket, targetBucket *objstore.InMemBucket) - assert func(ctx context.Context, t *testing.T, originBucket, targetBucket *objstore.InMemBucket) + name string + selector labels.Selector + blockIDs []ulid.ULID + ignoreMarkedForDeletion bool + prepare func(ctx context.Context, t *testing.T, originBucket, targetBucket *objstore.InMemBucket) + assert func(ctx context.Context, t *testing.T, originBucket, targetBucket *objstore.InMemBucket) }{ { name: "EmptyOrigin", @@ -126,7 +127,8 @@ func TestReplicationSchemeAll(t *testing.T) { }, }, { - name: "MarkedForDeletion", + name: "MarkedForDeletion", + ignoreMarkedForDeletion: true, prepare: func(ctx context.Context, t *testing.T, originBucket, targetBucket *objstore.InMemBucket) { ulid := testULID(0) meta := testMeta(ulid) @@ -142,9 +144,7 @@ func TestReplicationSchemeAll(t *testing.T) { _ = originBucket.Upload(ctx, path.Join(ulid.String(), "index"), bytes.NewReader(nil)) }, assert: func(ctx context.Context, t *testing.T, originBucket, targetBucket *objstore.InMemBucket) { - if len(targetBucket.Objects()) != 0 { - t.Fatal("TargetBucket should have been empty but is not.") - } + testutil.Equals(t, map[string][]byte{}, targetBucket.Objects()) }, }, { @@ -374,7 +374,7 @@ func TestReplicationSchemeAll(t *testing.T) { selector = c.selector } - filter := NewBlockFilter(logger, selector, []compact.ResolutionLevel{compact.ResolutionLevelRaw}, []int{1}, c.blockIDs, true).Filter + filter := NewBlockFilter(logger, selector, []compact.ResolutionLevel{compact.ResolutionLevelRaw}, []int{1}, c.blockIDs, c.ignoreMarkedForDeletion).Filter fetcher, err := block.NewMetaFetcher(logger, 32, objstore.WithNoopInstr(originBucket), "", nil, nil) testutil.Ok(t, err)