This commit is contained in:
zelig 2018-01-23 15:06:37 +01:00
parent ebec92e928
commit 97e4497c49

View file

@ -107,10 +107,15 @@ func testSyncBetweenNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
dbs[i] = storage.NewDBAPI(sim.Stores[i].(*storage.LocalStore)) dbs[i] = storage.NewDBAPI(sim.Stores[i].(*storage.LocalStore))
} }
totalHashes := 0 totalHashes := 0
for i := 1; i < nodes; i++ { hashCounts := make([]int, nodes)
for i := nodes - 1; i >= 0; i-- {
if i < nodes-1 {
hashCounts[i] = hashCounts[i+1]
}
dbs[i].Iterator(0, math.MaxUint64, po, func(key storage.Key, index uint64) bool { dbs[i].Iterator(0, math.MaxUint64, po, func(key storage.Key, index uint64) bool {
hashes[i] = append(hashes[i], key) hashes[i] = append(hashes[i], key)
totalHashes++ totalHashes++
hashCounts[i]++
return true return true
}) })
} }
@ -160,29 +165,34 @@ func testSyncBetweenNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
default: default:
} }
var found int var pass bool
for i, n := range hashes { var i int
for _, key := range n { log.Error("staring dbs check")
chunk, err := dbs[0].Get(key) for i = nodes - 1; i >= 0; i-- {
nodeHashCount := hashCounts[i]
nodeHashFound := 0
for j := i; j < nodes; j++ {
nodeHashes := hashes[j]
for _, key := range nodeHashes {
chunk, err := dbs[i].Get(key)
if err == storage.ErrFetching { if err == storage.ErrFetching {
<-chunk.ReqC <-chunk.ReqC
found++ nodeHashFound++
} else if err == nil { } else if err == nil {
found++ nodeHashFound++
} else {
log.Error("not found", "index", i, "origin", j, "key", key.Hex(), "err", err)
} }
}
log.Error("staring dbs check", "key", key) }
for j := i; j > 0; j-- { log.Error("sync check", "node", sim.IDs[i], "index", i, "bin", po, "found", nodeHashFound, "total", nodeHashCount)
_, err := dbs[j].Get(key) pass = nodeHashFound == nodeHashCount
if err != nil { if !pass {
log.Error("get from node", "node", sim.IDs[j], "nodeID", j, "key", key.Hex(), "err", err)
break break
} }
} }
} // log.Error("sync check", "bin", po, "found", found, "total", totalHashes)
} // pass := found == totalHashes
log.Error("sync check", "bin", po, "found", found, "total", totalHashes)
pass := found == totalHashes
if !pass { if !pass {
return false, nil return false, nil
} }