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

Unit tests fail when sudo is not available #630

Closed
twz123 opened this issue Jan 10, 2024 · 2 comments · Fixed by #631
Closed

Unit tests fail when sudo is not available #630

twz123 opened this issue Jan 10, 2024 · 2 comments · Fixed by #631

Comments

@twz123
Copy link
Member

twz123 commented Jan 10, 2024

Since 0.17.2, the unit tests fail if there's no sudo available on the host machine. I think this has been introduced in #620.

=== RUN TestK0sInstallCommand
DEBUG [local] localhost: executing uname | grep -q Linux
DEBUG [local] localhost: executing cat /etc/os-release || cat /usr/lib/os-release
DEBUG [local] localhost: NAME="Alpine Linux"
DEBUG [local] localhost: ID=alpine
DEBUG [local] localhost: VERSION_ID=3.20.0_alpha20231219
DEBUG [local] localhost: PRETTY_NAME="Alpine Linux edge"
DEBUG [local] localhost: HOME_URL="https://alpinelinux.org/"
DEBUG [local] localhost: BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
DEBUG [local] localhost: executing [ "$(id -u)" = 0 ]
DEBUG [local] localhost: executing sudo -n true
DEBUG [local] localhost: (stderr) sh: sudo: not found
DEBUG [local] localhost: executing doas -n -- "${SHELL-sh}" -c true
host_test.go:82:
Error Trace: github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host_test.go:82
Error: Should be true
Test: TestK0sInstallCommand
--- FAIL: TestK0sInstallCommand (0.01s)

@twz123
Copy link
Member Author

twz123 commented Jan 10, 2024

@kke
Copy link
Contributor

kke commented Jan 10, 2024

Actually it's probably because the doasifier wraps the command in quotes and escapes ".

	require.True(t, strings.HasSuffix(cmd, `k0s install worker --data-dir=/tmp/k0s --token-file "from-configurer"`))
func sudoDoas(cmd string) string {
	return `doas -n -- "${SHELL-sh}" -c ` + shellescape.Quote(cmd)
}

@kke kke mentioned this issue Jan 10, 2024
@kke kke closed this as completed in #631 Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants