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

[tmpnet] Ensure tmpnet compatibility with windows #3002

Merged
merged 4 commits into from
May 20, 2024
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
6 changes: 0 additions & 6 deletions scripts/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ source "$AVALANCHE_PATH"/scripts/constants.sh

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 and antithesis tests (which depend on tmpnet) are not compatible with windows
EXCLUDED_TARGETS="${EXCLUDED_TARGETS} | grep -v tests/fixture | grep -v tests/antithesis"
fi

TEST_TARGETS="$(eval "go list ./... ${EXCLUDED_TARGETS}")"

# shellcheck disable=SC2086
Expand Down
17 changes: 17 additions & 0 deletions tests/fixture/tmpnet/detached_process_default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

//go:build linux || darwin

package tmpnet

import (
"os/exec"
"syscall"
)

func configureDetachedProcess(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
Setsid: true,
}
}
12 changes: 12 additions & 0 deletions tests/fixture/tmpnet/detached_process_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

//go:build windows

package tmpnet

import "os/exec"

func configureDetachedProcess(*exec.Cmd) {
panic("tmpnet deployment to windows is not supported")
}
5 changes: 1 addition & 4 deletions tests/fixture/tmpnet/node_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,8 @@ func (p *NodeProcess) Start(w io.Writer) error {

// 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,
}
configureDetachedProcess(cmd)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify - this PR is to make it so that this code can compile on windows, but there is no expectation for it to run on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.


if err := cmd.Start(); err != nil {
return err
Expand Down
Loading