Skip to content

Commit

Permalink
Fix one flaky test in random_reader_test.go (#2531)
Browse files Browse the repository at this point in the history
* fix flaky test

* minor improvement
  • Loading branch information
sethiay authored Sep 25, 2024
1 parent 83d85f5 commit 35ce836
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions flaky_tests.lst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ TestAppendObjectCreator
# b/361477653
TestParallelDiropsTestSuite/TestParallelReadDirs

# b/362686470
RandomReaderTest.Test_ReadAt_CacheMissDueToInvalidJob

# b/362905593
TestParallelDiropsWithoutCachesTestSuite/TestParallelReadDirsForDifferentDirs

Expand Down
10 changes: 5 additions & 5 deletions internal/gcsx/random_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,6 @@ func (t *RandomReaderTest) Test_ReadAt_SequentialToRandomSubsequentReadOffsetLes
ExpectTrue(reflect.DeepEqual(testContent[start3:end3], buf3))
}

// TODO: re-enable test after fixing b/362686470
/*
func (t *RandomReaderTest) Test_ReadAt_CacheMissDueToInvalidJob() {
t.rr.wrapped.fileCacheHandler = t.cacheHandler
objectSize := t.object.Size
Expand All @@ -924,7 +922,10 @@ func (t *RandomReaderTest) Test_ReadAt_CacheMissDueToInvalidJob() {
ExpectFalse(cacheHit)
AssertTrue(reflect.DeepEqual(testContent, buf))
job := t.jobManager.GetJob(t.object.Name, t.bucket.Name())
AssertTrue(job == nil || job.GetStatus().Name == downloader.Completed)
if job != nil {
jobStatus := job.GetStatus().Name
AssertTrue(jobStatus == downloader.Downloading || jobStatus == downloader.Completed, fmt.Sprintf("the actual status is %v", jobStatus))
}
err = t.rr.wrapped.fileCacheHandler.InvalidateCache(t.object.Name, t.bucket.Name())
AssertEq(nil, err)
// Second reader (rc2) is required, since first reader (rc) is completely read.
Expand All @@ -939,7 +940,6 @@ func (t *RandomReaderTest) Test_ReadAt_CacheMissDueToInvalidJob() {
ExpectTrue(reflect.DeepEqual(testContent, buf))
ExpectEq(nil, t.rr.wrapped.fileCacheHandle)
}
*/

func (t *RandomReaderTest) Test_ReadAt_CachePopulatedAndThenCacheMissDueToInvalidJob() {
t.rr.wrapped.fileCacheHandler = t.cacheHandler
Expand All @@ -956,7 +956,7 @@ func (t *RandomReaderTest) Test_ReadAt_CachePopulatedAndThenCacheMissDueToInvali
job := t.jobManager.GetJob(t.object.Name, t.bucket.Name())
if job != nil {
jobStatus := job.GetStatus().Name
AssertTrue(jobStatus == downloader.Downloading || jobStatus == downloader.Completed)
AssertTrue(jobStatus == downloader.Downloading || jobStatus == downloader.Completed, fmt.Sprintf("the actual status is %v", jobStatus))
}
err = t.rr.wrapped.fileCacheHandler.InvalidateCache(t.object.Name, t.bucket.Name())
AssertEq(nil, err)
Expand Down

0 comments on commit 35ce836

Please sign in to comment.