run e2e for 12 epochs (#10717)

* run for the original number of epochs

* to avoid race, wait 1/2 epoch after 1st ready node

* Update testing/endtoend/minimal_e2e_test.go

* Update testing/endtoend/minimal_e2e_test.go

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
kasey 2022-05-19 01:45:58 -05:00 committed by GitHub
parent 092e9e1d19
commit e3f69e4fad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,9 +272,7 @@ func (r *testRunner) run() {
} }
if config.ExtraEpochs > 0 { if config.ExtraEpochs > 0 {
secondsPerEpoch := uint64(params.BeaconConfig().SlotsPerEpoch.Mul(params.BeaconConfig().SecondsPerSlot)) if err := r.waitExtra(ctx, types.Epoch(config.EpochsToRun+config.ExtraEpochs), conns[0], types.Epoch(config.ExtraEpochs)); err != nil {
dl := time.Now().Add(time.Second * time.Duration(config.ExtraEpochs*secondsPerEpoch))
if err := r.waitUntilEpoch(ctx, types.Epoch(config.EpochsToRun+config.ExtraEpochs), conns[0], dl); err != nil {
return errors.Wrap(err, "error while waiting for ExtraEpochs") return errors.Wrap(err, "error while waiting for ExtraEpochs")
} }
syncEvaluators := []e2etypes.Evaluator{ev.FinishedSyncing, ev.AllNodesHaveSameHead} syncEvaluators := []e2etypes.Evaluator{ev.FinishedSyncing, ev.AllNodesHaveSameHead}
@ -297,9 +295,12 @@ func (r *testRunner) run() {
} }
} }
func (r *testRunner) waitUntilEpoch(ctx context.Context, e types.Epoch, conn *grpc.ClientConn, deadline time.Time) error { func (r *testRunner) waitExtra(ctx context.Context, e types.Epoch, conn *grpc.ClientConn, extra types.Epoch) error {
spe := uint64(params.BeaconConfig().SlotsPerEpoch.Mul(params.BeaconConfig().SecondsPerSlot))
dl := time.Now().Add(time.Second * time.Duration(uint64(extra)*spe))
beaconClient := eth.NewBeaconChainClient(conn) beaconClient := eth.NewBeaconChainClient(conn)
ctx, cancel := context.WithDeadline(ctx, deadline) ctx, cancel := context.WithDeadline(ctx, dl)
defer cancel() defer cancel()
for { for {
select { select {
@ -308,9 +309,15 @@ func (r *testRunner) waitUntilEpoch(ctx context.Context, e types.Epoch, conn *gr
default: default:
chainHead, err := beaconClient.GetChainHead(ctx, &emptypb.Empty{}) chainHead, err := beaconClient.GetChainHead(ctx, &emptypb.Empty{})
if err != nil { if err != nil {
return err log.Warnf("while querying connection %s for chain head got error=%s", conn.Target(), err.Error())
} }
if chainHead.HeadEpoch >= e { if chainHead.HeadEpoch > e {
// no need to wait, other nodes should be caught up
return nil
}
if chainHead.HeadEpoch == e {
// wait until halfway into the epoch to give other nodes time to catch up
time.Sleep(time.Second * time.Duration(spe/2))
return nil return nil
} }
} }