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

Add test that executes tsh with no env vars #49255

Merged
merged 4 commits into from
Nov 21, 2024
Merged

Conversation

ravicious
Copy link
Member

@ravicious ravicious commented Nov 20, 2024

Recently we introduced a regression in VNet where the tsh auto-updater would assume that $HOME is present when running tsh (#47815 (comment)). It turns out that when launchd starts VNet's launch daemon and executes tsh vnet-daemon, it does so without providing any of the "regular" env variables.

This has been fixed in #49159. This PR adds a test which hopefully catches similar regressions in the future.

This test fails on the parent commit of #49159 with:

=== RUN   TestNoEnvVars
    tsh_test.go:426: running command /var/folders/kz/2d_vhlks21l3g0s4g5yytlwr0000gn/T/go-build927609993/b001/common.test version --client
    tsh_test.go:428: executable output: ERROR: $HOME is not defined

    tsh_test.go:429:
        	Error Trace:	/Users/rav/src/teleport/tool/tsh/common/tsh_test.go:429
        	Error:      	Received unexpected error:
        	            	exit status 1
        	Test:       	TestNoEnvVars
--- FAIL: TestNoEnvVars (2.54s)
FAIL
FAIL	github.com/gravitational/teleport/tool/tsh/common	8.264s
FAIL

@ravicious ravicious added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v16 backport/branch/v17 labels Nov 20, 2024
@github-actions github-actions bot added size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Nov 20, 2024
testExecutable, err := os.Executable()
require.NoError(t, err)
// Execute an actual command and not jut `tsh help` which goes through a different code path.
cmd := exec.Command(testExecutable, "version", "--client")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we use CommandContext and provide a context with a 5-10s deadline?

@ravicious ravicious requested a review from zmb3 November 20, 2024 16:46
tool/tsh/common/tsh_test.go Outdated Show resolved Hide resolved
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from smallinsky November 20, 2024 18:16
Co-authored-by: Bernard Kim <bernard@goteleport.com>
@ravicious ravicious enabled auto-merge November 21, 2024 07:46
@ravicious ravicious added this pull request to the merge queue Nov 21, 2024
Merged via the queue into master with commit 7029b0c Nov 21, 2024
39 checks passed
@ravicious ravicious deleted the r7s/tsh-no-env-vars branch November 21, 2024 08:21
@public-teleport-github-review-bot

@ravicious See the table below for backport results.

Branch Result
branch/v16 Create PR
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/sm tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants