tailcat: make interactive SSH tests hermetic and add netns idempotency regression test - #6
Merged
Merged
Conversation
…y regression test PR tailscale#8 fixed most of the PTY lifecycle, but TestSSHSuite/InteractiveShell still hung on this machine because the login shell sourced .bashrc, which auto-attaches tmux and never exits on 'exit'. Fix the embedded SSH server to honor the process HOME environment variable, and run the SSH test server with a clean temporary HOME so the test is hermetic. Also add TestNetNSDisabledOnce, a regression test for the fix that wraps netns.SetEnabled(false) in a sync.Once so multiple Server/Client lifetimes in the same process don't panic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR finishes the work PR tailscale#8 started on the SSH PTY lifecycle and adds a regression test for the netns.SetEnabled(false) idempotency fix.
Changes
tailcat_ssh.go: The embedded SSH server now honors the process HOME environment variable when configuring the session shell. This allows callers (and tests) to override the home directory used for the SSH session without changing /etc/passwd.
tailcat_ssh_test.go: setupSSHEnv now sets a clean, temporary HOME directory before starting the server, and restores the original HOME in t.Cleanup. This makes the SSH tests hermetic so the login shell started in the PTY doesn't source the real user's dotfiles (e.g. a .bashrc that auto-attaches tmux and ignores exit). The t.Skip on TestSSHSuite/InteractiveShell is removed.
tailcat_test.go: Adds TestNetNSDisabledOnce, a regression test that creates two sequential Server/Client pairs in the same process. This exercises the sync.Once wrapping netns.SetEnabled(false) so that the second engine creation does not panic.
Verification