Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed TestBucketStore_ManyParts_e2e #3841

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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