mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 04:55:18 +00:00
Partial fix for #5291. For details, see [README.md](https://github.com/tendermint/tendermint/blob/erik/e2e-tests/test/e2e/README.md) and [RFC-001](https://github.com/tendermint/tendermint/blob/master/docs/rfc/rfc-001-end-to-end-testing.md). This only includes a single test case under `test/e2e/tests/`, as a proof of concept - additional test cases will be submitted separately. A randomized testnet generator will also be submitted separately, there a currently just a handful of static testnets under `test/e2e/networks/`. This will eventually replace the current P2P tests and run in CI.
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
//nolint: gosec
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
osexec "os/exec"
|
|
"path/filepath"
|
|
)
|
|
|
|
// execute executes a shell command.
|
|
func exec(args ...string) error {
|
|
cmd := osexec.Command(args[0], args[1:]...)
|
|
out, err := cmd.CombinedOutput()
|
|
switch err := err.(type) {
|
|
case nil:
|
|
return nil
|
|
case *osexec.ExitError:
|
|
return fmt.Errorf("failed to run %q:\n%v", args, string(out))
|
|
default:
|
|
return err
|
|
}
|
|
}
|
|
|
|
// execVerbose executes a shell command while displaying its output.
|
|
func execVerbose(args ...string) error {
|
|
cmd := osexec.Command(args[0], args[1:]...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
return cmd.Run()
|
|
}
|
|
|
|
// execCompose runs a Docker Compose command for a testnet.
|
|
func execCompose(dir string, args ...string) error {
|
|
return exec(append(
|
|
[]string{"docker-compose", "-f", filepath.Join(dir, "docker-compose.yml")},
|
|
args...)...)
|
|
}
|
|
|
|
// execComposeVerbose runs a Docker Compose command for a testnet and displays its output.
|
|
func execComposeVerbose(dir string, args ...string) error {
|
|
return execVerbose(append(
|
|
[]string{"docker-compose", "-f", filepath.Join(dir, "docker-compose.yml")},
|
|
args...)...)
|
|
}
|
|
|
|
// execDocker runs a Docker command.
|
|
func execDocker(args ...string) error {
|
|
return exec(append([]string{"docker"}, args...)...)
|
|
}
|