mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
E2E Improvements (#6091)
* Some fixes * Merge branch 'master' into e2e-fixes * Add another small delay * Merge branch 'e2e-fixes' of github.com:prysmaticlabs/prysm into e2e-fixes * Remove genesis test, make normal e2e run longer * Gaz * more fixes * Merge branch 'master' into e2e-fixes * Merge refs/heads/master into e2e-fixes * Fix comment * Merge refs/heads/master into e2e-fixes
This commit is contained in:
parent
80539d9028
commit
4e96cbeae7
@ -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",
|
||||
|
@ -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}
|
||||
|
@ -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 {
|
||||
|
@ -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++ {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user