MCPcopy Create free account
hub / github.com/couchbase/moss / waitForCompactionCleanup

Function waitForCompactionCleanup

store_test.go:2237–2255  ·  view source on GitHub ↗

Since file deletions happen asynchronously, sometimes it is possible that the deleted file still lingers around. To ensure this does not cause test failures, retry a few times before just returning the contents of the directory.

(tmpDir string, secsToWait int)

Source from the content-addressed store, hash-verified

2235// To ensure this does not cause test failures, retry a few times
2236// before just returning the contents of the directory.
2237func waitForCompactionCleanup(tmpDir string, secsToWait int) (
2238 fileInfos []os.FileInfo, err error) {
2239 fileInfos, err = ioutil.ReadDir(tmpDir)
2240 if err != nil {
2241 return
2242 }
2243 for retry := secsToWait; retry > 0 && len(fileInfos) != 1; retry-- {
2244 file, erro := os.Open(tmpDir)
2245 if erro != nil {
2246 return fileInfos, erro
2247 }
2248 file.Sync()
2249 file.Close()
2250
2251 time.Sleep(1 * time.Second)
2252 fileInfos, err = ioutil.ReadDir(tmpDir)
2253 }
2254 return
2255}
2256
2257func TestCompactionWithAndWithoutRegularSync(t *testing.T) {
2258 numItems := 1000000

Callers 2

testStoreCompactionFunction · 0.85
Test_DGMLoadFunction · 0.85

Calls 2

SyncMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…