Skip to content

Commit

Permalink
Fixed TestBucketStore_ManyParts_e2e (thanos-io#3841)
Browse files Browse the repository at this point in the history
https://app.circleci.com/pipelines/github/thanos-io/thanos/5120/workflows/efd2a21d-13b7-4035-99e3-cb1af8023694/jobs/13809

This fail is only visible for anyone from Thanos Team proposing PR, due
to extra tests against bucket providers.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka authored and Andre Branchizio committed Mar 11, 2021
1 parent 7c69c08 commit 05ac4d1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/objstore/cos/cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (b *Bucket) listObjects(ctx context.Context, objectPrefix string, options .

// If recursive iteration is enabled we should pass an empty delimiter.
delimiter := dirDelim
if !objstore.ApplyIterOptions(options...).Recursive {
if objstore.ApplyIterOptions(options...).Recursive {
delimiter = ""
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/objstore/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error, opt

// If recursive iteration is enabled we should pass an empty delimiter.
delimiter := DirDelim
if !objstore.ApplyIterOptions(options...).Recursive {
if objstore.ApplyIterOptions(options...).Recursive {
delimiter = ""
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/objstore/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ func (b *InMemBucket) Iter(_ context.Context, dir string, f func(string) error,
if params.Recursive {
// Any object matching the prefix should be included.
unique[filename] = struct{}{}
} else {
parts := strings.SplitAfter(filename, DirDelim)
unique[strings.Join(parts[:dirPartsCount+1], "")] = struct{}{}
continue
}

parts := strings.SplitAfter(filename, DirDelim)
unique[strings.Join(parts[:dirPartsCount+1], "")] = struct{}{}
}
b.mtx.RUnlock()

Expand Down
6 changes: 3 additions & 3 deletions pkg/objstore/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error, opt
dir = strings.TrimSuffix(dir, objstore.DirDelim) + objstore.DirDelim
}

var delimiter alioss.Option
if !objstore.ApplyIterOptions(options...).Recursive {
delimiter = alioss.Delimiter(objstore.DirDelim)
delimiter := alioss.Delimiter(objstore.DirDelim)
if objstore.ApplyIterOptions(options...).Recursive {
delimiter = nil
}

marker := alioss.Marker("")
Expand Down
9 changes: 6 additions & 3 deletions pkg/objstore/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ func (c *Container) Iter(_ context.Context, dir string, f func(string) error, op
dir = strings.TrimSuffix(dir, string(DirDelim)) + string(DirDelim)
}

listOptions := &swift.ObjectsOpts{Prefix: dir}
if !objstore.ApplyIterOptions(options...).Recursive {
listOptions.Delimiter = DirDelim
listOptions := &swift.ObjectsOpts{
Prefix: dir,
Delimiter: DirDelim,
}
if objstore.ApplyIterOptions(options...).Recursive {
listOptions.Delimiter = rune(0)
}

return c.connection.ObjectsWalk(c.name, listOptions, func(opts *swift.ObjectsOpts) (interface{}, error) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/store/bucket_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ func prepareStoreWithTestBlocks(t testing.TB, dir string, bkt objstore.Bucket, m

// TODO(bwplotka): Benchmark Series.
func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) {
t.Helper()

mint, maxt := s.store.TimeRange()
testutil.Equals(t, s.minTime, mint)
testutil.Equals(t, s.maxTime, maxt)
Expand Down

0 comments on commit 05ac4d1

Please sign in to comment.