Browse Source

Merge pull request #6062 from heyitsanthony/fix-test-periodic

compactor: fix race in TestPeriodic
Anthony Romano 9 years ago
parent
commit
3d8e4ace47
1 changed files with 5 additions and 2 deletions
  1. 5 2
      compactor/compactor_test.go

+ 5 - 2
compactor/compactor_test.go

@@ -40,12 +40,15 @@ func TestPeriodic(t *testing.T) {
 	defer tb.Stop()
 	defer tb.Stop()
 
 
 	n := int(time.Hour / checkCompactionInterval)
 	n := int(time.Hour / checkCompactionInterval)
+	// collect 3 hours of revisions
 	for i := 0; i < 3; i++ {
 	for i := 0; i < 3; i++ {
+		// advance one hour, one revision for each interval
 		for j := 0; j < n; j++ {
 		for j := 0; j < n; j++ {
-			rg.Wait(1)
 			fc.Advance(checkCompactionInterval)
 			fc.Advance(checkCompactionInterval)
+			rg.Wait(1)
 		}
 		}
-
+		// ready to acknowledge hour "i"; unblock clock
+		fc.Advance(checkCompactionInterval)
 		a, err := compactable.Wait(1)
 		a, err := compactable.Wait(1)
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)