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

try() is not a variant of run() #5094

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions bats/scripts/bats-lint.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
undef $run;
$problems++;
}
# Matches any line starting with "run " or "try "
if (/^\s*(run|try)\s/) {
# Matches any line starting with "run "
if (/^\s*(run)\s/) {
$run = $_;
}
# Reset $. line counter for next input file
Expand Down
1 change: 0 additions & 1 deletion bats/tests/containers/allowed-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ verify_no_nginx() {

@test 'but fails to stand up a pod for forbidden image' {
try --max 18 --delay 10 verify_no_nginx
assert_success
}

@test 'set patterns with the allowed list disabled' {
Expand Down
2 changes: 1 addition & 1 deletion bats/tests/containers/run-rancher.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load '../helpers/load'
}

@test 'verify rancher' {
try --max 9 --delay 10 curl --insecure --silent --show-error "https://localhost:8443/dashboard/auth/login"
run try --max 9 --delay 10 curl --insecure --silent --show-error "https://localhost:8443/dashboard/auth/login"
assert_success
assert_output --partial "Rancher Dashboard"
run ctrctl logs rancher
Expand Down
1 change: 0 additions & 1 deletion bats/tests/containers/switch-engines.bats
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ switch_back_verify_post_switch_containers() {
local name=$1
switch_container_engine "${name}"
try --max 12 --delay 5 verify_post_switch_containers
assert_success
}

@test 'switch back to moby and verify containers' {
Expand Down
2 changes: 0 additions & 2 deletions bats/tests/helpers/vm.bash
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
wait_for_shell() {
if is_unix; then
try --max 24 --delay 5 rdctl shell test -f /var/run/lima-boot-done
assert_success
# wait until sshfs mounts are done
try --max 12 --delay 5 rdctl shell test -d "$HOME/.rd"
assert_success
fi
rdctl shell sync
}
Expand Down
2 changes: 1 addition & 1 deletion bats/tests/k8s/helm-install-rancher.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ get_host() {
}

@test 'verify rancher' {
try --max 9 --delay 10 curl --insecure --silent --show-error "https://$(get_host)/dashboard/auth/login"
run try --max 9 --delay 10 curl --insecure --silent --show-error "https://$(get_host)/dashboard/auth/login"
assert_success
assert_output --partial "Rancher Dashboard"
run kubectl get secret --namespace cattle-system bootstrap-secret -o json
Expand Down
7 changes: 2 additions & 5 deletions bats/tests/k8s/traefik.bats
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ assert_traefik_pods_are_up() {
@test 'disable traefik' {
# First check whether the traefik pods are up from the first launch
try --max 30 --delay 10 assert_traefik_pods_are_up
assert_success
# Disable traefik
rdctl set --kubernetes.options.traefik=FALSE
wait_for_apiserver
# Check if the traefik pods go down
try --max 30 --delay 10 assert_traefik_pods_are_down
assert_success
}

@test 'enable traefik' {
Expand All @@ -77,11 +75,10 @@ assert_traefik_pods_are_up() {
wait_for_apiserver
# Check if the traefik pods come up
try --max 30 --delay 10 assert_traefik_pods_are_up
assert_success
try --max 30 --delay 10 curl --head "http://$(get_host):80"
run try --max 30 --delay 10 curl --head "http://$(get_host):80"
assert_success
assert_output --regexp 'HTTP/[0-9.]* 404'
try --max 30 --delay 10 curl --head --insecure "https://$(get_host):443"
run try --max 30 --delay 10 curl --head --insecure "https://$(get_host):443"
assert_success
assert_output --regexp 'HTTP/[0-9.]* 404'
}
7 changes: 0 additions & 7 deletions bats/tests/k8s/up-downgrade-k8s.bats
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ verify_nginx() {

@test 'verify nginx before upgrade' {
try verify_nginx
assert_success
}

verify_busybox() {
Expand All @@ -51,7 +50,6 @@ verify_busybox() {

@test 'verify busybox before upgrade' {
try verify_busybox
assert_success
}

verify_images() {
Expand Down Expand Up @@ -104,12 +102,10 @@ verify_nginx_after_change_k8s() {

@test 'verify nginx after upgrade' {
try verify_nginx_after_change_k8s
assert_success
}

@test 'verify busybox after upgrade' {
try verify_busybox
assert_success
}

@test 'verify images after upgrade' {
Expand All @@ -127,10 +123,8 @@ verify_nginx_after_change_k8s() {
# See https://github.com/containerd/nerdctl/issues/665#issuecomment-1372862742
# BUG BUG BUG
try nerdctl start nginx-no-restart
assert_success
fi
try verify_nginx
assert_success
}

@test 'downgrade kubernetes' {
Expand All @@ -146,7 +140,6 @@ verify_nginx_after_change_k8s() {
@test 'verify nginx after downgrade' {
# nginx should still be running because it is not managed by kubernetes
try verify_nginx_after_change_k8s
assert_success
}

@test 'verify busybox is gone after downgrade' {
Expand Down
2 changes: 1 addition & 1 deletion bats/tests/k8s/wordpress.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local_setup() {
assert_success

# Load the homepage; that can take a while because all the pods are still restarting
try --max 9 --delay 10 curl --silent --show-error "http://localhost:$output"
run try --max 9 --delay 10 curl --silent --show-error "http://localhost:$output"
assert_success
assert_output --regexp "(Just another WordPress site|<title>User&#039;s Blog!</title>)"
}
Expand Down
1 change: 0 additions & 1 deletion bats/tests/preferences/verify-paths.bats
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ no_bashrc_path_manager() {
@test 'move to manual path-management' {
rdctl set --application.path-management-strategy=manual
try --max 5 --delay 2 no_bashrc_path_manager
assert_success
}

@test 'bash unmanaged' {
Expand Down
1 change: 0 additions & 1 deletion bats/tests/registry/creds.bats
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ create_registry() {
wait_for_registry() {
# registry port is forwarded to host
try --max 10 --delay 5 curl -k --silent --show-error "https://localhost:$REGISTRY_PORT/v2/_catalog"
assert_success
}

using_insecure_registry() {
Expand Down