Skip to content

Commit

Permalink
Merge pull request etcd-io#3959 from xiang90/fix_storage_test
Browse files Browse the repository at this point in the history
storage: make RestoreContinueUnfinishedCompaction more reliable
  • Loading branch information
xiang90 committed Dec 4, 2015
2 parents e0e80b3 + a0eca5f commit 127b529
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions storage/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,22 @@ func TestRestoreContinueUnfinishedCompaction(t *testing.T) {
revbytes := newRevBytes()
// TODO: compact should delete main=2 key too
revToBytes(revision{main: 1}, revbytes)
tx = s1.b.BatchTx()
tx.Lock()
ks, _ := tx.UnsafeRange(keyBucketName, revbytes, nil, 0)
if len(ks) != 0 {
t.Errorf("key for rev %+v still exists, want deleted", bytesToRev(revbytes))

// The disk compaction is done asynchronously and requires more time on slow disk.
// try 5 times for CI with slow IO.
for i := 0; i < 5; i++ {
tx = s1.b.BatchTx()
tx.Lock()
ks, _ := tx.UnsafeRange(keyBucketName, revbytes, nil, 0)
if len(ks) != 0 {
time.Sleep(100 * time.Millisecond)
continue
}
tx.Unlock()
return
}
tx.Unlock()

t.Errorf("key for rev %+v still exists, want deleted", bytesToRev(revbytes))
}

func TestTxnBlockBackendForceCommit(t *testing.T) {
Expand Down

0 comments on commit 127b529

Please sign in to comment.