Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Single Log File in E2E #11810

Merged
merged 5 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions testing/endtoend/components/beacon_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,16 @@ func (node *BeaconNode) Start(ctx context.Context) error {
args = append(args, config.BeaconFlags...)

cmd := exec.CommandContext(ctx, binaryPath, args...) // #nosec G204 -- Safe
// Write stdout and stderr to log files.
stdout, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("beacon_node_%d_stdout.log", index)))
if err != nil {
return err
}
// Write stderr to log files.
stderr, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("beacon_node_%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 beacon chain %d with flags: %s", index, strings.Join(args[2:], " "))
if err = cmd.Start(); err != nil {
Expand Down
18 changes: 7 additions & 11 deletions testing/endtoend/components/boot_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,27 @@ func (node *BootNode) Start(ctx context.Context) error {
return errors.New("boot node binary not found")
}

stdOutFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, e2e.BootNodeLogFileName)
if err != nil {
return err
}

args := []string{
fmt.Sprintf("--log-file=%s", stdOutFile.Name()),
fmt.Sprintf("--discv5-port=%d", e2e.TestParams.Ports.BootNodePort),
fmt.Sprintf("--metrics-port=%d", e2e.TestParams.Ports.BootNodeMetricsPort),
"--debug",
}

cmd := exec.CommandContext(ctx, binaryPath, args...) // #nosec G204 -- Safe
cmd.Stdout = stdOutFile
cmd.Stderr = stdOutFile
stdErrFile, err := helpers.DeleteAndCreateFile(e2e.TestParams.LogPath, e2e.BootNodeLogFileName)
if err != nil {
return err
}
cmd.Stderr = stdErrFile
log.Infof("Starting boot node with flags: %s", strings.Join(args[1:], " "))
if err = cmd.Start(); err != nil {
return fmt.Errorf("failed to start beacon node: %w", err)
}

if err = helpers.WaitForTextInFile(stdOutFile, "Running bootnode"); err != nil {
if err = helpers.WaitForTextInFile(stdErrFile, "Running bootnode"); err != nil {
return fmt.Errorf("could not find enr for bootnode, this means the bootnode had issues starting: %w", err)
}

node.enr, err = enrFromLogFile(stdOutFile.Name())
node.enr, err = enrFromLogFile(stdErrFile.Name())
if err != nil {
return fmt.Errorf("could not get enr for bootnode: %w", err)
}
Expand Down
10 changes: 1 addition & 9 deletions testing/endtoend/components/lighthouse_beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,16 @@ func (node *LighthouseBeaconNode) Start(ctx context.Context) error {
fmt.Sprintf("--trusted-peers=%s", flagVal))
}
cmd := exec.CommandContext(ctx, binaryPath, args...) /* #nosec G204 */
// Write stdout and stderr to log files.
stdout, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("lighthouse_beacon_node_%d_stdout.log", index)))
if err != nil {
return err
}
// Write stderr to log files.
stderr, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("lighthouse_beacon_node_%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 lighthouse beacon chain %d with flags: %s", index, strings.Join(args[2:], " "))
if err = cmd.Start(); err != nil {
Expand Down
10 changes: 1 addition & 9 deletions testing/endtoend/components/lighthouse_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,24 +198,16 @@ func (v *LighthouseValidatorNode) Start(ctx context.Context) error {

cmd := exec.CommandContext(ctx, binaryPath, args...) // #nosec G204 -- Safe

// Write stdout and stderr to log files.
stdout, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("lighthouse_validator_%d_stdout.log", index)))
if err != nil {
return err
}
// Write stderr to log files.
stderr, err := os.Create(path.Join(e2e.TestParams.LogPath, fmt.Sprintf("lighthouse_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 lighthouse validator client %d with flags: %s %s", index, binaryPath, strings.Join(args, " "))
Expand Down
10 changes: 1 addition & 9 deletions testing/endtoend/components/web3remotesigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,16 @@ func (w *Web3RemoteSigner) Start(ctx context.Context) error {

cmd := exec.CommandContext(ctx, binaryPath, args...) // #nosec G204 -- Test code is safe to do this.
w.cmd = cmd
// Write stdout and stderr to log files.
stdout, err := os.Create(path.Join(e2e.TestParams.LogPath, "web3signer.stdout.log"))
if err != nil {
return err
}
// Write stderr to log files.
stderr, err := os.Create(path.Join(e2e.TestParams.LogPath, "web3signer.stderr.log"))
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 web3signer with flags: %s %s", binaryPath, strings.Join(args, " "))
Expand Down