Skip to content

Commit 56f45bb

Browse files
fix(test): fix storage flaky tests
Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
1 parent 2b8479f commit 56f45bb

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

pkg/storage/local/local_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,24 @@ func TestDedupeLinks(t *testing.T) {
12971297
So(err, ShouldBeNil)
12981298
})
12991299

1300+
Convey("test RunDedupeForDigest directly, trigger stat error on original blob", func() {
1301+
// rebuild with dedupe true
1302+
imgStore := local.NewImageStore(dir, false, storage.DefaultGCDelay,
1303+
true, true, log, metrics, nil, cacheDriver)
1304+
1305+
duplicateBlobs := []string{
1306+
path.Join(dir, "dedupe1", "blobs", "sha256", blobDigest1),
1307+
path.Join(dir, "dedupe1", "blobs", "sha256", blobDigest2),
1308+
}
1309+
1310+
// remove original blob so that it can not be statted
1311+
err := os.Remove(path.Join(dir, "dedupe1", "blobs", "sha256", blobDigest1))
1312+
So(err, ShouldBeNil)
1313+
1314+
err = imgStore.RunDedupeForDigest(godigest.Digest(blobDigest1), true, duplicateBlobs)
1315+
So(err, ShouldNotBeNil)
1316+
})
1317+
13001318
Convey("Intrerrupt rebuilding and restart, checking idempotency", func() {
13011319
for i := 0; i < 10; i++ {
13021320
taskScheduler, cancel := runAndGetScheduler()

pkg/storage/s3/s3_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
20262026
imgStore.RunDedupeBlobs(time.Duration(0), taskScheduler)
20272027

20282028
// wait until rebuild finishes
2029-
time.Sleep(5 * time.Second)
2029+
time.Sleep(10 * time.Second)
20302030

20312031
cancel()
20322032

@@ -2068,7 +2068,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
20682068
imgStore.RunDedupeBlobs(time.Duration(0), taskScheduler)
20692069

20702070
// wait until rebuild finishes
2071-
time.Sleep(5 * time.Second)
2071+
time.Sleep(10 * time.Second)
20722072

20732073
cancel()
20742074

@@ -2108,7 +2108,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
21082108
imgStore.RunDedupeBlobs(time.Duration(0), taskScheduler)
21092109

21102110
// wait until rebuild finishes
2111-
time.Sleep(3 * time.Second)
2111+
time.Sleep(5 * time.Second)
21122112
})
21132113

21142114
Convey("Trigger Stat error while getting original blob", func() {
@@ -2161,7 +2161,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
21612161
imgStore.RunDedupeBlobs(time.Duration(0), taskScheduler)
21622162

21632163
// wait until rebuild finishes
2164-
time.Sleep(3 * time.Second)
2164+
time.Sleep(5 * time.Second)
21652165
})
21662166

21672167
Convey("Trigger GetNextDigestWithBlobPaths path not found err", func() {
@@ -2180,7 +2180,7 @@ func TestRebuildDedupeIndex(t *testing.T) {
21802180
imgStore.RunDedupeBlobs(time.Duration(0), taskScheduler)
21812181

21822182
// wait until rebuild finishes
2183-
time.Sleep(3 * time.Second)
2183+
time.Sleep(5 * time.Second)
21842184
})
21852185

21862186
Convey("Rebuild from true to false", func() {

0 commit comments

Comments
 (0)