Skip to content

Commit b2137b1

Browse files
authored
Fixed TestBucketStore_ManyParts_e2e (#3841)
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 <[email protected]>
1 parent 46d0106 commit b2137b1

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

pkg/objstore/cos/cos.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (b *Bucket) listObjects(ctx context.Context, objectPrefix string, options .
229229

230230
// If recursive iteration is enabled we should pass an empty delimiter.
231231
delimiter := dirDelim
232-
if !objstore.ApplyIterOptions(options...).Recursive {
232+
if objstore.ApplyIterOptions(options...).Recursive {
233233
delimiter = ""
234234
}
235235

pkg/objstore/gcs/gcs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error, opt
100100

101101
// If recursive iteration is enabled we should pass an empty delimiter.
102102
delimiter := DirDelim
103-
if !objstore.ApplyIterOptions(options...).Recursive {
103+
if objstore.ApplyIterOptions(options...).Recursive {
104104
delimiter = ""
105105
}
106106

pkg/objstore/inmem.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ func (b *InMemBucket) Iter(_ context.Context, dir string, f func(string) error,
6565
if params.Recursive {
6666
// Any object matching the prefix should be included.
6767
unique[filename] = struct{}{}
68-
} else {
69-
parts := strings.SplitAfter(filename, DirDelim)
70-
unique[strings.Join(parts[:dirPartsCount+1], "")] = struct{}{}
68+
continue
7169
}
70+
71+
parts := strings.SplitAfter(filename, DirDelim)
72+
unique[strings.Join(parts[:dirPartsCount+1], "")] = struct{}{}
7273
}
7374
b.mtx.RUnlock()
7475

pkg/objstore/oss/oss.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error, opt
195195
dir = strings.TrimSuffix(dir, objstore.DirDelim) + objstore.DirDelim
196196
}
197197

198-
var delimiter alioss.Option
199-
if !objstore.ApplyIterOptions(options...).Recursive {
200-
delimiter = alioss.Delimiter(objstore.DirDelim)
198+
delimiter := alioss.Delimiter(objstore.DirDelim)
199+
if objstore.ApplyIterOptions(options...).Recursive {
200+
delimiter = nil
201201
}
202202

203203
marker := alioss.Marker("")

pkg/objstore/swift/swift.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,12 @@ func (c *Container) Iter(_ context.Context, dir string, f func(string) error, op
200200
dir = strings.TrimSuffix(dir, string(DirDelim)) + string(DirDelim)
201201
}
202202

203-
listOptions := &swift.ObjectsOpts{Prefix: dir}
204-
if !objstore.ApplyIterOptions(options...).Recursive {
205-
listOptions.Delimiter = DirDelim
203+
listOptions := &swift.ObjectsOpts{
204+
Prefix: dir,
205+
Delimiter: DirDelim,
206+
}
207+
if objstore.ApplyIterOptions(options...).Recursive {
208+
listOptions.Delimiter = rune(0)
206209
}
207210

208211
return c.connection.ObjectsWalk(c.name, listOptions, func(opts *swift.ObjectsOpts) (interface{}, error) {

pkg/store/bucket_e2e_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ func prepareStoreWithTestBlocks(t testing.TB, dir string, bkt objstore.Bucket, m
196196

197197
// TODO(bwplotka): Benchmark Series.
198198
func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) {
199+
t.Helper()
200+
199201
mint, maxt := s.store.TimeRange()
200202
testutil.Equals(t, s.minTime, mint)
201203
testutil.Equals(t, s.maxTime, maxt)

0 commit comments

Comments
 (0)