mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
swarm/network/stream: fixed iterations for snapshot tests
This commit is contained in:
parent
a2a1131a8b
commit
d1457c7b3c
2 changed files with 25 additions and 59 deletions
|
|
@ -203,15 +203,13 @@ func runFileRetrievalTest(nodeCount int) error {
|
|||
|
||||
// File retrieval check is repeated until all uploaded files are retrieved from all nodes
|
||||
// or until the timeout is reached.
|
||||
allSuccess := false
|
||||
for !allSuccess {
|
||||
allSuccess = true
|
||||
REPEAT:
|
||||
for {
|
||||
for _, id := range nodeIDs {
|
||||
//for each expected chunk, check if it is in the local store
|
||||
localSuccess := true
|
||||
//for each expected file, check if it is in the local store
|
||||
item, ok := sim.NodeItem(id, bucketKeyFileStore)
|
||||
if !ok {
|
||||
return fmt.Errorf("No registry")
|
||||
return fmt.Errorf("No filestore")
|
||||
}
|
||||
fileStore := item.(*storage.FileStore)
|
||||
//check all chunks
|
||||
|
|
@ -219,23 +217,16 @@ func runFileRetrievalTest(nodeCount int) error {
|
|||
reader, _ := fileStore.Retrieve(context.TODO(), hash)
|
||||
//check that we can read the file size and that it corresponds to the generated file size
|
||||
if s, err := reader.Size(ctx, nil); err != nil || s != int64(len(randomFiles[i])) {
|
||||
//allSuccess = false
|
||||
localSuccess = false
|
||||
log.Warn("Retrieve error", "err", err, "hash", hash, "nodeId", id)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
continue REPEAT
|
||||
} else {
|
||||
log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash))
|
||||
}
|
||||
}
|
||||
if !localSuccess {
|
||||
allSuccess = false
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !allSuccess {
|
||||
return fmt.Errorf("Not all retrievals succeeded!")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if result.Error != nil {
|
||||
|
|
@ -303,39 +294,32 @@ func runRetrievalTest(chunkCount int, nodeCount int) error {
|
|||
|
||||
// File retrieval check is repeated until all uploaded files are retrieved from all nodes
|
||||
// or until the timeout is reached.
|
||||
allSuccess := false
|
||||
for !allSuccess {
|
||||
allSuccess = true
|
||||
REPEAT:
|
||||
for {
|
||||
for _, id := range nodeIDs {
|
||||
//for each expected chunk, check if it is in the local store
|
||||
localSuccess := true
|
||||
//check on the node's FileStore (netstore)
|
||||
item, ok := sim.NodeItem(id, bucketKeyFileStore)
|
||||
if !ok {
|
||||
return fmt.Errorf("No registry")
|
||||
return fmt.Errorf("No filestore")
|
||||
}
|
||||
fileStore := item.(*storage.FileStore)
|
||||
//check all chunks
|
||||
for _, hash := range conf.hashes {
|
||||
reader, _ := fileStore.Retrieve(context.TODO(), hash)
|
||||
//check that we can read the file size and that it corresponds to the generated file size
|
||||
//check that we can read the chunk size and that it corresponds to the generated chunk size
|
||||
if s, err := reader.Size(ctx, nil); err != nil || s != int64(chunkSize) {
|
||||
localSuccess = false
|
||||
log.Warn("Retrieve error", "err", err, "hash", hash, "nodeId", id)
|
||||
log.Warn("Retrieve error", "err", err, "hash", hash, "nodeId", id, "size", s)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
continue REPEAT
|
||||
} else {
|
||||
log.Debug(fmt.Sprintf("File with root hash %x successfully retrieved", hash))
|
||||
log.Debug(fmt.Sprintf("Chunk with root hash %x successfully retrieved", hash))
|
||||
}
|
||||
}
|
||||
if !localSuccess {
|
||||
allSuccess = false
|
||||
break
|
||||
}
|
||||
}
|
||||
// all nodes and files found, exit loop and return without error
|
||||
return nil
|
||||
}
|
||||
if !allSuccess {
|
||||
return fmt.Errorf("Not all retrievals succeeded!")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if result.Error != nil {
|
||||
|
|
|
|||
|
|
@ -269,7 +269,6 @@ func runSim(conf *synctestConfig, ctx context.Context, sim *simulation.Simulatio
|
|||
|
||||
// File retrieval check is repeated until all uploaded files are retrieved from all nodes
|
||||
// or until the timeout is reached.
|
||||
allSuccess := false
|
||||
var gDir string
|
||||
var globalStore *mockdb.GlobalStore
|
||||
if *useMockStore {
|
||||
|
|
@ -285,12 +284,11 @@ func runSim(conf *synctestConfig, ctx context.Context, sim *simulation.Simulatio
|
|||
}
|
||||
}()
|
||||
}
|
||||
for !allSuccess {
|
||||
allSuccess = true
|
||||
REPEAT:
|
||||
for {
|
||||
for _, id := range nodeIDs {
|
||||
//for each expected chunk, check if it is in the local store
|
||||
localChunks := conf.idToChunksMap[id]
|
||||
localSuccess := true
|
||||
for _, ch := range localChunks {
|
||||
//get the real chunk by the index in the index array
|
||||
chunk := conf.hashes[ch]
|
||||
|
|
@ -312,9 +310,9 @@ func runSim(conf *synctestConfig, ctx context.Context, sim *simulation.Simulatio
|
|||
}
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("Chunk %s NOT found for id %s", chunk, id))
|
||||
localSuccess = false
|
||||
// Do not get crazy with logging the warn message
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
continue REPEAT
|
||||
} else {
|
||||
evt := &simulations.Event{
|
||||
Type: EventTypeChunkArrived,
|
||||
|
|
@ -325,16 +323,9 @@ func runSim(conf *synctestConfig, ctx context.Context, sim *simulation.Simulatio
|
|||
log.Debug(fmt.Sprintf("Chunk %s IS FOUND for id %s", chunk, id))
|
||||
}
|
||||
}
|
||||
if !localSuccess {
|
||||
allSuccess = false
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !allSuccess {
|
||||
return fmt.Errorf("Not all chunks succeeded!")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -495,13 +486,11 @@ func testSyncingViaDirectSubscribe(t *testing.T, chunkCount int, nodeCount int)
|
|||
}
|
||||
// File retrieval check is repeated until all uploaded files are retrieved from all nodes
|
||||
// or until the timeout is reached.
|
||||
allSuccess := false
|
||||
for !allSuccess {
|
||||
allSuccess = true
|
||||
REPEAT:
|
||||
for {
|
||||
for _, id := range nodeIDs {
|
||||
//for each expected chunk, check if it is in the local store
|
||||
localChunks := conf.idToChunksMap[id]
|
||||
localSuccess := true
|
||||
for _, ch := range localChunks {
|
||||
//get the real chunk by the index in the index array
|
||||
chunk := conf.hashes[ch]
|
||||
|
|
@ -523,23 +512,16 @@ func testSyncingViaDirectSubscribe(t *testing.T, chunkCount int, nodeCount int)
|
|||
}
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("Chunk %s NOT found for id %s", chunk, id))
|
||||
localSuccess = false
|
||||
// Do not get crazy with logging the warn message
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
continue REPEAT
|
||||
} else {
|
||||
log.Debug(fmt.Sprintf("Chunk %s IS FOUND for id %s", chunk, id))
|
||||
}
|
||||
}
|
||||
if !localSuccess {
|
||||
allSuccess = false
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !allSuccess {
|
||||
return fmt.Errorf("Not all chunks succeeded!")
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if result.Error != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue