Skip to content

Commit

Permalink
Merge pull request #2677 from oasislabs/kostko/fix/e2e-storage-sync
Browse files Browse the repository at this point in the history
go/oasis-test-runner: Fix flakiness in storage sync E2E test
  • Loading branch information
kostko authored Feb 14, 2020
2 parents 3c86d95 + 40e0908 commit ab41005
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Empty file added .changelog/2677.trivial.md
Empty file.
26 changes: 22 additions & 4 deletions go/oasis-test-runner/scenario/e2e/storage_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,31 @@ func (sc *storageSyncImpl) Run(childEnv *env.Env) error {
return fmt.Errorf("failed to get checkpoints: %w", err)
}

blk, err := ctrl.RuntimeClient.GetBlock(ctx, &runtimeClient.GetBlockRequest{RuntimeID: runtimeID, Round: 20})
blk, err := ctrl.RuntimeClient.GetBlock(ctx, &runtimeClient.GetBlockRequest{
RuntimeID: runtimeID,
Round: runtimeClient.RoundLatest,
})
if err != nil {
return fmt.Errorf("failed to get latest block: %w", err)
}

// Determine which checkpoints should be there.
rt := sc.net.Runtimes()[1].ToRuntimeDescriptor()
lastCheckpoint := (blk.Header.Round / rt.Storage.CheckpointInterval) * rt.Storage.CheckpointInterval
sc.logger.Info("determined last expected checkpoint round",
"round", lastCheckpoint,
)

blk, err = ctrl.RuntimeClient.GetBlock(ctx, &runtimeClient.GetBlockRequest{
RuntimeID: runtimeID,
Round: lastCheckpoint,
})
if err != nil {
return fmt.Errorf("failed to get block for round 20: %w", err)
return fmt.Errorf("failed to get block %d: %w", lastCheckpoint, err)
}

// There should be at least two checkpoints (for the two roots at round 20). There may be more
// in case garbage collection has not yet pruned the other checkpoints.
// There should be at least two checkpoints. There may be more depending on the state of garbage
// collection process (which may be one checkpoint behind.)
if len(cps) < 2 {
return fmt.Errorf("incorrect number of checkpoints (expected: >=2 got: %d)", len(cps))
}
Expand Down

0 comments on commit ab41005

Please sign in to comment.