diff --git a/scripts/build_test.sh b/scripts/build_test.sh index 2251cc64f6ba..1b9302b693cc 100755 --- a/scripts/build_test.sh +++ b/scripts/build_test.sh @@ -7,6 +7,15 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) # Load the constants source "$AVALANCHE_PATH"/scripts/constants.sh -# Ensure execution of fixture unit tests under tests/ but exclude ginkgo tests in tests/e2e and tests/upgrade -# shellcheck disable=SC2046 -go test -shuffle=on -race -timeout="${TIMEOUT:-120s}" -coverprofile="coverage.out" -covermode="atomic" $(go list ./... | grep -v /mocks | grep -v proto | grep -v tests/e2e | grep -v tests/upgrade) +EXCLUDED_TARGETS="| grep -v /mocks | grep -v proto | grep -v tests/e2e | grep -v tests/upgrade" + +GOOS=$(go env GOOS) +if [[ "$GOOS" == "windows" ]]; then + # tmpnet is not compatible with windows + EXCLUDED_TARGETS="${EXCLUDED_TARGETS} | grep -v tests/fixture" +fi + +TEST_TARGETS="$(eval "go list ./... ${EXCLUDED_TARGETS}")" + +# shellcheck disable=SC2086 +go test -shuffle=on -race -timeout="${TIMEOUT:-120s}" -coverprofile="coverage.out" -covermode="atomic" ${TEST_TARGETS} diff --git a/tests/fixture/tmpnet/defaults.go b/tests/fixture/tmpnet/defaults.go index aac7a1fee912..958dd414a420 100644 --- a/tests/fixture/tmpnet/defaults.go +++ b/tests/fixture/tmpnet/defaults.go @@ -7,6 +7,7 @@ import ( "time" "github.com/ava-labs/avalanchego/config" + "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/vms/platformvm/txs/executor" ) @@ -46,8 +47,8 @@ func DefaultFlags() FlagsMap { config.HealthCheckFreqKey: "2s", config.AdminAPIEnabledKey: true, config.IndexEnabledKey: true, - config.LogDisplayLevelKey: "INFO", - config.LogLevelKey: "DEBUG", + config.LogDisplayLevelKey: logging.Off.String(), // Display logging not needed since nodes run headless + config.LogLevelKey: logging.Debug.String(), config.MinStakeDurationKey: DefaultMinStakeDuration.String(), } } diff --git a/tests/fixture/tmpnet/node_process.go b/tests/fixture/tmpnet/node_process.go index dc5c5bfebf16..4ce0997eb60f 100644 --- a/tests/fixture/tmpnet/node_process.go +++ b/tests/fixture/tmpnet/node_process.go @@ -112,7 +112,14 @@ func (p *NodeProcess) Start(w io.Writer) error { return fmt.Errorf("failed to remove stale process context file: %w", err) } + // All arguments are provided in the flags file cmd := exec.Command(p.node.RuntimeConfig.AvalancheGoPath, "--config-file", p.node.getFlagsPath()) // #nosec G204 + + // Ensure process is detached from the parent process so that an error in the parent will not affect the child + cmd.SysProcAttr = &syscall.SysProcAttr{ + Setsid: true, + } + if err := cmd.Start(); err != nil { return err } @@ -129,15 +136,6 @@ func (p *NodeProcess) Start(w io.Writer) error { nodeDescription = fmt.Sprintf("%s with path: %s", nodeDescription, dataDir) } - go func() { - if err := cmd.Wait(); err != nil { - if err.Error() != "signal: killed" { - _, _ = fmt.Fprintf(w, "%s finished with error: %v\n", nodeDescription, err) - } - } - _, _ = fmt.Fprintf(w, "%s exited\n", nodeDescription) - }() - // A node writes a process context file on start. If the file is not // found in a reasonable amount of time, the node is unlikely to have // started successfully.