Add a test for e2e validator to run against prior release (#9042)

* Add a test for e2e validator to run against prior release

* gofmt

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
Preston Van Loon 2021-06-23 12:07:28 -05:00 committed by GitHub
parent 942472fc7e
commit 1f6a031630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 17 deletions

View File

@ -157,3 +157,9 @@ string_setting(
"libfuzzer",
],
)
sh_binary(
name = "prysm_sh",
srcs = ["prysm.sh"],
visibility = ["//visibility:public"],
)

View File

@ -13,6 +13,7 @@ go_test(
],
args = ["-test.v"],
data = [
"//:prysm_sh",
"//cmd/beacon-chain",
"//cmd/slasher",
"//cmd/validator",
@ -21,10 +22,10 @@ go_test(
],
shard_count = 2,
tags = [
"block-network",
"e2e",
"manual",
"minimal",
"requires-network",
],
deps = [
"//beacon-chain/core/state:go_default_library",

View File

@ -6,7 +6,9 @@ import (
"fmt"
"io/ioutil"
"math/big"
"os"
"os/exec"
"path"
"strings"
"github.com/bazelbuild/rules_go/go/tools/bazel"
@ -97,7 +99,15 @@ func NewValidatorNode(config *e2etypes.E2EConfig, validatorNum, index, offset in
// Start starts a validator client.
func (v *ValidatorNode) Start(ctx context.Context) error {
binaryPath, found := bazel.FindBinary("cmd/validator", "validator")
var pkg, target string
if v.config.UsePrysmShValidator {
pkg = ""
target = "prysm_sh"
} else {
pkg = "cmd/validator"
target = "validator"
}
binaryPath, found := bazel.FindBinary(pkg, target)
if !found {
return errors.New("validator binary not found")
}
@ -135,8 +145,34 @@ func (v *ValidatorNode) Start(ctx context.Context) error {
args = append(args, featureconfig.E2EValidatorFlags...)
args = append(args, config.ValidatorFlags...)
if v.config.UsePrysmShValidator {
args = append([]string{"validator"}, args...)
log.Warning("Using latest release validator via prysm.sh")
}
cmd := exec.CommandContext(ctx, binaryPath, args...)
log.Infof("Starting validator client %d with flags: %s", index, strings.Join(args[2:], " "))
// Write stdout and stderr to log files.
stdout, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("validator_%d_stdout.log", index)))
if err != nil {
return err
}
stderr, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("validator_%d_stderr.log", index)))
if err != nil {
return err
}
defer func() {
if err := stdout.Close(); err != nil {
log.WithError(err).Error("Failed to close stdout file")
}
if err := stderr.Close(); err != nil {
log.WithError(err).Error("Failed to close stderr file")
}
}()
cmd.Stdout = stdout
cmd.Stderr = stderr
log.Infof("Starting validator client %d with flags: %s %s", index, binaryPath, strings.Join(args, " "))
if err = cmd.Start(); err != nil {
return err
}

View File

@ -14,7 +14,15 @@ import (
)
func TestEndToEnd_MinimalConfig(t *testing.T) {
e2eMinimal(t, false /*usePrysmSh*/)
}
// Run minimal e2e config with the current release validator against latest beacon node.
func TestEndToEnd_MinimalConfig_ValidatorAtCurrentRelease(t *testing.T) {
e2eMinimal(t, true /*usePrysmSh*/)
}
func e2eMinimal(t *testing.T, usePrysmSh bool) {
params.UseE2EConfig()
require.NoError(t, e2eParams.Init(e2eParams.StandardBeaconCount))
@ -31,12 +39,13 @@ func TestEndToEnd_MinimalConfig(t *testing.T) {
BeaconFlags: []string{
fmt.Sprintf("--slots-per-archive-point=%d", params.BeaconConfig().SlotsPerEpoch*16),
},
ValidatorFlags: []string{},
EpochsToRun: uint64(epochsToRun),
TestSync: true,
TestDeposits: true,
TestSlasher: true,
UsePprof: !longRunning,
ValidatorFlags: []string{},
EpochsToRun: uint64(epochsToRun),
TestSync: true,
TestDeposits: true,
TestSlasher: true,
UsePrysmShValidator: usePrysmSh,
UsePprof: !longRunning,
Evaluators: []types.Evaluator{
ev.PeersConnect,
ev.HealthzCheck,

View File

@ -11,14 +11,15 @@ import (
// E2EConfig defines the struct for all configurations needed for E2E testing.
type E2EConfig struct {
BeaconFlags []string
ValidatorFlags []string
EpochsToRun uint64
TestSync bool
TestSlasher bool
TestDeposits bool
UsePprof bool
Evaluators []Evaluator
BeaconFlags []string
ValidatorFlags []string
EpochsToRun uint64
TestSync bool
TestSlasher bool
TestDeposits bool
UsePprof bool
UsePrysmShValidator bool
Evaluators []Evaluator
}
// Evaluator defines the structure of the evaluators used to