Add in Separate Directories per Test (#10753)

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
Nishant Das
2022-05-25 23:57:13 +08:00
committed by GitHub
parent 61cbe3709b
commit ecb605814e
5 changed files with 19 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ import (
)
func TestWeb3RemoteSigner_StartsAndReturnsPublicKeys(t *testing.T) {
require.NoError(t, e2eparams.Init(0))
require.NoError(t, e2eparams.Init(t, 0))
wsc := components.NewWeb3RemoteSigner()

View File

@@ -17,7 +17,7 @@ import (
func e2eMinimal(t *testing.T, useWeb3RemoteSigner bool, extraEpochs uint64) *testRunner {
params.SetupTestConfigCleanup(t)
params.OverrideBeaconConfig(params.E2ETestConfig().Copy())
require.NoError(t, e2eParams.Init(e2eParams.StandardBeaconCount))
require.NoError(t, e2eParams.Init(t, e2eParams.StandardBeaconCount))
// Run for 12 epochs if not in long-running to confirm long-running has no issues.
var err error
@@ -89,9 +89,9 @@ func e2eMainnet(t *testing.T, usePrysmSh, useMultiClient bool) *testRunner {
params.SetupTestConfigCleanup(t)
params.OverrideBeaconConfig(params.E2EMainnetTestConfig())
if useMultiClient {
require.NoError(t, e2eParams.InitMultiClient(e2eParams.StandardBeaconCount, e2eParams.StandardLighthouseNodeCount))
require.NoError(t, e2eParams.InitMultiClient(t, e2eParams.StandardBeaconCount, e2eParams.StandardLighthouseNodeCount))
} else {
require.NoError(t, e2eParams.Init(e2eParams.StandardBeaconCount))
require.NoError(t, e2eParams.Init(t, e2eParams.StandardBeaconCount))
}
// Run for 10 epochs if not in long-running to confirm long-running has no issues.
var err error

View File

@@ -14,7 +14,7 @@ import (
func TestEndToEnd_Slasher_MinimalConfig(t *testing.T) {
params.SetupTestConfigCleanup(t)
params.OverrideBeaconConfig(params.E2ETestConfig().Copy())
require.NoError(t, e2eParams.Init(e2eParams.StandardBeaconCount))
require.NoError(t, e2eParams.Init(t, e2eParams.StandardBeaconCount))
tracingPort := e2eParams.TestParams.Ports.JaegerTracingPort
tracingEndpoint := fmt.Sprintf("127.0.0.1:%d", tracingPort)

View File

@@ -7,6 +7,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/testing/endtoend/params",
visibility = ["//testing/endtoend:__subpackages__"],
deps = [
"//io/file:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],

View File

@@ -6,11 +6,14 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strconv"
"testing"
"github.com/bazelbuild/rules_go/go/tools/bazel"
"github.com/ethereum/go-ethereum/common"
"github.com/prysmaticlabs/prysm/io/file"
)
// params struct defines the parameters needed for running E2E tests to properly handle test sharding.
@@ -105,12 +108,16 @@ const (
)
// Init initializes the E2E config, properly handling test sharding.
func Init(beaconNodeCount int) error {
func Init(t *testing.T, beaconNodeCount int) error {
testPath := bazel.TestTmpDir()
logPath, ok := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR")
if !ok {
return errors.New("expected TEST_UNDECLARED_OUTPUTS_DIR to be defined")
}
logPath = path.Join(logPath, t.Name())
if err := file.MkdirAll(logPath); err != nil {
return err
}
testTotalShardsStr, ok := os.LookupEnv("TEST_TOTAL_SHARDS")
if !ok {
testTotalShardsStr = "1"
@@ -146,12 +153,16 @@ func Init(beaconNodeCount int) error {
}
// InitMultiClient initializes the multiclient E2E config, properly handling test sharding.
func InitMultiClient(beaconNodeCount int, lighthouseNodeCount int) error {
func InitMultiClient(t *testing.T, beaconNodeCount int, lighthouseNodeCount int) error {
testPath := bazel.TestTmpDir()
logPath, ok := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR")
if !ok {
return errors.New("expected TEST_UNDECLARED_OUTPUTS_DIR to be defined")
}
logPath = path.Join(logPath, t.Name())
if err := file.MkdirAll(logPath); err != nil {
return err
}
testTotalShardsStr, ok := os.LookupEnv("TEST_TOTAL_SHARDS")
if !ok {
testTotalShardsStr = "1"