MCPcopy Create free account
hub / github.com/couchbase/cbft / WaitForPersistence

Function WaitForPersistence

pindex_bleve_test.go:27–55  ·  view source on GitHub ↗
(pindex *cbgt.PIndex, docCount float64)

Source from the content-addressed store, hash-verified

25)
26
27func WaitForPersistence(pindex *cbgt.PIndex, docCount float64) error {
28 for i := 0; i < 100; i++ {
29 stats := map[string]interface{}{
30 "doc_count": float64(0),
31 "num_recs_to_persist": float64(0),
32 }
33 err := addPIndexStats(pindex, stats)
34 if err != nil {
35 return fmt.Errorf("expected nil addPIndexStats err, got: %v", err)
36 }
37 dv, ok := stats["doc_count"]
38 if ok {
39 dc, ok := dv.(float64)
40 if ok && dc == docCount {
41 v, ok1 := stats["num_recs_to_persist"]
42 if ok1 {
43 nrtp, ok1 := v.(float64)
44 if ok1 && nrtp <= 0.0 {
45 return nil
46 }
47 }
48 }
49
50 }
51
52 time.Sleep(50 * time.Millisecond)
53 }
54 return fmt.Errorf("persistence took too long!")
55}
56
57func TestManagerRestart(t *testing.T) {
58 emptyDir, _ := ioutil.TempDir("./tmp", "test")

Calls 1

addPIndexStatsFunction · 0.85

Tested by

no test coverage detected