Skip to content

Add test that executes tsh with no env vars#49255

Merged
ravicious merged 4 commits intomasterfrom
r7s/tsh-no-env-vars
Nov 21, 2024
Merged

Add test that executes tsh with no env vars#49255
ravicious merged 4 commits intomasterfrom
r7s/tsh-no-env-vars

Conversation

@ravicious
Copy link
Copy Markdown
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
Comment thread tool/tsh/common/tsh_test.go Outdated
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
Copy Markdown
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
Comment thread tool/tsh/common/tsh_test.go Outdated
@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
@ravicious ravicious deleted the r7s/tsh-no-env-vars branch November 21, 2024 08:21
@public-teleport-github-review-bot
Copy link
Copy Markdown

@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/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