From e3f69e4fadb4a858a37ee4c772be8610060945a2 Mon Sep 17 00:00:00 2001 From: kasey <489222+kasey@users.noreply.github.com> Date: Thu, 19 May 2022 01:45:58 -0500 Subject: [PATCH] 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 Co-authored-by: Nishant Das --- testing/endtoend/endtoend_test.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/testing/endtoend/endtoend_test.go b/testing/endtoend/endtoend_test.go index 67f1411e1..878d0e862 100644 --- a/testing/endtoend/endtoend_test.go +++ b/testing/endtoend/endtoend_test.go @@ -272,9 +272,7 @@ func (r *testRunner) run() { } if config.ExtraEpochs > 0 { - secondsPerEpoch := uint64(params.BeaconConfig().SlotsPerEpoch.Mul(params.BeaconConfig().SecondsPerSlot)) - 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 { + if err := r.waitExtra(ctx, types.Epoch(config.EpochsToRun+config.ExtraEpochs), conns[0], types.Epoch(config.ExtraEpochs)); err != nil { return errors.Wrap(err, "error while waiting for ExtraEpochs") } 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) - ctx, cancel := context.WithDeadline(ctx, deadline) + ctx, cancel := context.WithDeadline(ctx, dl) defer cancel() for { select { @@ -308,9 +309,15 @@ func (r *testRunner) waitUntilEpoch(ctx context.Context, e types.Epoch, conn *gr default: chainHead, err := beaconClient.GetChainHead(ctx, &emptypb.Empty{}) 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 } }