diff --git a/endtoend/BUILD.bazel b/endtoend/BUILD.bazel index 4ccb21e94e..e24f64fe49 100644 --- a/endtoend/BUILD.bazel +++ b/endtoend/BUILD.bazel @@ -4,12 +4,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test") go_test( name = "go_default_test", - size = "large", + size = "enormous", testonly = True, srcs = [ "endtoend_test.go", "long_minimal_e2e_test.go", - "minimal_e2e_genesis_test.go", "minimal_e2e_test.go", "minimal_slashing_e2e_test.go", ], @@ -21,7 +20,7 @@ go_test( "//validator", "@com_github_ethereum_go_ethereum//cmd/geth", ], - shard_count = 4, + shard_count = 3, tags = [ "block-network", "e2e", diff --git a/endtoend/endtoend_test.go b/endtoend/endtoend_test.go index 5d97efe000..60647c67ef 100644 --- a/endtoend/endtoend_test.go +++ b/endtoend/endtoend_test.go @@ -50,9 +50,12 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { if err != nil { t.Fatal(err) } - if err := helpers.WaitForTextInFile(beaconLogFile, "Chain started within the last epoch"); err != nil { - t.Fatalf("failed to find chain start in logs, this means the chain did not start: %v", err) - } + + t.Run("chain started", func(t *testing.T) { + if err := helpers.WaitForTextInFile(beaconLogFile, "Chain started within the last epoch"); err != nil { + t.Fatalf("failed to find chain start in logs, this means the chain did not start: %v", err) + } + }) // Failing early in case chain doesn't start. if t.Failed() { @@ -132,8 +135,8 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { } conns = append(conns, syncConn) - // Sleep a second for every 4 blocks that need to be synced for the newly started node. - extraSecondsToSync := (config.EpochsToRun)*epochSeconds + (params.BeaconConfig().SlotsPerEpoch / 4 * config.EpochsToRun) + // Sleep a second for every 8 blocks that need to be synced for the newly started node. + extraSecondsToSync := (config.EpochsToRun)*epochSeconds + (params.BeaconConfig().SlotsPerEpoch / 8 * config.EpochsToRun) waitForSync := tickingStartTime.Add(time.Duration(extraSecondsToSync) * time.Second) time.Sleep(time.Until(waitForSync)) @@ -143,8 +146,13 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) { } defer helpers.LogErrorOutput(t, syncLogFile, "beacon chain node", index) defer helpers.KillProcesses(t, []int{processID}) - if err := helpers.WaitForTextInFile(syncLogFile, "Synced up to"); err != nil { - t.Fatalf("Failed to sync: %v", err) + t.Run("sync completed", func(t *testing.T) { + if err := helpers.WaitForTextInFile(syncLogFile, "Synced up to"); err != nil { + t.Errorf("Failed to sync: %v", err) + } + }) + if t.Failed() { + return } syncEvaluators := []types.Evaluator{ev.FinishedSyncing, ev.AllNodesHaveSameHead} diff --git a/endtoend/evaluators/metrics.go b/endtoend/evaluators/metrics.go index decb7e7ec6..1aae26c476 100644 --- a/endtoend/evaluators/metrics.go +++ b/endtoend/evaluators/metrics.go @@ -94,6 +94,7 @@ func metricsTest(conns ...*grpc.ClientConn) error { if err := response.Body.Close(); err != nil { return err } + time.Sleep(connTimeDelay) genesis, err := eth.NewNodeClient(conns[i]).GetGenesis(context.Background(), &ptypes.Empty{}) if err != nil { diff --git a/endtoend/evaluators/node.go b/endtoend/evaluators/node.go index af6495d0f0..61a79abe84 100644 --- a/endtoend/evaluators/node.go +++ b/endtoend/evaluators/node.go @@ -8,6 +8,7 @@ import ( "fmt" "io/ioutil" "net/http" + "time" ptypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" @@ -17,6 +18,9 @@ import ( "google.golang.org/grpc" ) +// Allow a very short delay after disconnecting to prevent connection refused issues. +var connTimeDelay = 50 * time.Millisecond + // PeersConnect checks all beacon nodes and returns whether they are connected to each other as peers. var PeersConnect = types.Evaluator{ Name: "peers_connect_epoch_%d", @@ -69,6 +73,7 @@ func healthzCheck(conns ...*grpc.ClientConn) error { if err := resp.Body.Close(); err != nil { return err } + time.Sleep(connTimeDelay) resp, err = http.Get(fmt.Sprintf("http://localhost:%d/healthz", e2e.TestParams.ValidatorMetricsPort+i)) if err != nil { @@ -84,6 +89,7 @@ func healthzCheck(conns ...*grpc.ClientConn) error { if err := resp.Body.Close(); err != nil { return err } + time.Sleep(connTimeDelay) } return nil } @@ -103,6 +109,7 @@ func peersConnect(conns ...*grpc.ClientConn) error { if expectedPeers != len(peersResp.Peers) { return fmt.Errorf("unexpected amount of peers, expected %d, received %d", expectedPeers, len(peersResp.Peers)) } + time.Sleep(connTimeDelay) } return nil } @@ -135,9 +142,7 @@ func allNodesHaveSameHead(conns ...*grpc.ClientConn) error { justifiedRoots[i] = chainHead.JustifiedBlockRoot prevJustifiedRoots[i] = chainHead.PreviousJustifiedBlockRoot finalizedRoots[i] = chainHead.FinalizedBlockRoot - if err := conn.Close(); err != nil { - return err - } + time.Sleep(connTimeDelay) } for i := 0; i < len(conns); i++ { diff --git a/endtoend/evaluators/validator.go b/endtoend/evaluators/validator.go index cf43be0ed8..53d127e4e3 100644 --- a/endtoend/evaluators/validator.go +++ b/endtoend/evaluators/validator.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc" ) -var expectedParticipation = 0.98 // 98% participation to make room for small fluctuations. +var expectedParticipation = 0.95 // 95% participation to make room for fluctuations. // ValidatorsAreActive ensures the expected amount of validators are active. var ValidatorsAreActive = types.Evaluator{ @@ -59,7 +59,6 @@ func validatorsAreActive(conns ...*grpc.ClientConn) error { } effBalanceLowCount := 0 - activeEpochWrongCount := 0 exitEpochWrongCount := 0 withdrawEpochWrongCount := 0 for _, item := range validators.ValidatorList { @@ -83,12 +82,10 @@ func validatorsAreActive(conns ...*grpc.ClientConn) error { effBalanceLowCount, params.BeaconConfig().MaxEffectiveBalance, ) - } else if activeEpochWrongCount > 0 { - return fmt.Errorf("%d validators did not have genesis validator epoch of 0", activeEpochWrongCount) } else if exitEpochWrongCount > 0 { return fmt.Errorf("%d validators did not have genesis validator exit epoch of far future epoch", exitEpochWrongCount) - } else if activeEpochWrongCount > 0 { - return fmt.Errorf("%d validators did not have genesis validator withdrawable epoch of far future epoch", activeEpochWrongCount) + } else if withdrawEpochWrongCount > 0 { + return fmt.Errorf("%d validators did not have genesis validator withdrawable epoch of far future epoch", withdrawEpochWrongCount) } return nil diff --git a/endtoend/minimal_e2e_genesis_test.go b/endtoend/minimal_e2e_genesis_test.go deleted file mode 100644 index 98938f9e5c..0000000000 --- a/endtoend/minimal_e2e_genesis_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package endtoend - -import ( - "testing" - - ev "github.com/prysmaticlabs/prysm/endtoend/evaluators" - e2eParams "github.com/prysmaticlabs/prysm/endtoend/params" - "github.com/prysmaticlabs/prysm/endtoend/types" - "github.com/prysmaticlabs/prysm/shared/params" - "github.com/prysmaticlabs/prysm/shared/testutil" -) - -func TestEndToEnd_Genesis_MinimalConfig(t *testing.T) { - testutil.ResetCache() - params.UseE2EConfig() - - minimalConfig := &types.E2EConfig{ - BeaconFlags: []string{}, - ValidatorFlags: []string{}, - EpochsToRun: 4, - TestSync: false, - TestSlasher: false, - Evaluators: []types.Evaluator{ - ev.PeersConnect, - ev.HealthzCheck, - ev.ValidatorsAreActive, - ev.ValidatorsParticipating, - ev.MetricsCheck, - }, - } - if err := e2eParams.Init(2); err != nil { - t.Fatal(err) - } - - runEndToEndTest(t, minimalConfig) -} diff --git a/endtoend/minimal_e2e_test.go b/endtoend/minimal_e2e_test.go index 959bfe8ebf..a9072e4053 100644 --- a/endtoend/minimal_e2e_test.go +++ b/endtoend/minimal_e2e_test.go @@ -17,9 +17,10 @@ func TestEndToEnd_MinimalConfig(t *testing.T) { minimalConfig := &types.E2EConfig{ BeaconFlags: []string{}, ValidatorFlags: []string{}, - EpochsToRun: 8, + EpochsToRun: 10, TestSync: true, TestSlasher: true, + TestDeposits: false, Evaluators: []types.Evaluator{ ev.PeersConnect, ev.HealthzCheck, diff --git a/endtoend/minimal_slashing_e2e_test.go b/endtoend/minimal_slashing_e2e_test.go index f29f64c333..cfbb2c75aa 100644 --- a/endtoend/minimal_slashing_e2e_test.go +++ b/endtoend/minimal_slashing_e2e_test.go @@ -20,6 +20,7 @@ func TestEndToEnd_Slashing_MinimalConfig(t *testing.T) { EpochsToRun: 3, TestSync: false, TestSlasher: true, + TestDeposits: false, Evaluators: []types.Evaluator{ ev.PeersConnect, ev.HealthzCheck,