Skip to content

Commit

Permalink
Try waiting on the rdctl process if still running.
Browse files Browse the repository at this point in the history
- Explicit shutdown is needed on macos after running shells.

Signed-off-by: Eric Promislow <epromislow@suse.com>
  • Loading branch information
ericpromislow committed Jul 4, 2023
1 parent 473cb7a commit d9f3064
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions bats/tests/containers/allowed-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RD_USE_IMAGE_ALLOW_LIST=true
start_kubernetes
wait_for_container_engine
wait_for_apiserver
wait_for_rdctl_background_process
}

@test 'update the list of patterns first time' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/auto-start.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ load '../helpers/load'

@test 'Start up Rancher Desktop' {
start_application
wait_for_rdctl_background_process
}

@test 'Verify that initial Behavior is all set to false' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/catch-duplicate-api-patterns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RD_USE_IMAGE_ALLOW_LIST=true
run update_allowed_patterns true "$IMAGE_NGINX" "$IMAGE_BUSYBOX" "$IMAGE_RUBY" "$IMAGE_BUSYBOX"
assert_failure
assert_output --partial "field 'containerEngine.allowedImages.patterns' has duplicate entries: \"$IMAGE_BUSYBOX\""
wait_for_rdctl_background_process
}

@test 'catch attempts to add duplicate patterns via the API with enabled off' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/factory-reset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ refute=refute

@test 'Start up Rancher Desktop' {
start_application
wait_for_rdctl_background_process
}

@test 'Verify that the expected directories were created' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/host-connectivity.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ load '../helpers/load'
@test 'start container engine' {
start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

verify_host_connectivity() {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/platform.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load '../helpers/load'
@test 'start container engine' {
start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

check_uname() {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/run-rancher.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load '../helpers/load'
@test 'start container engine' {
start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

@test 'run rancher' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/containers/switch-engines.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pull_containers() {
start_container_engine
wait_for_container_engine
pull_containers
wait_for_rdctl_background_process
}

@test "switch to containerd" {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/extensions/allow-list.bats
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ check_extension_installed() { # refute, name
@test 'start container engine' {
RD_ENV_EXTENSIONS=1 start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

@test 'build extension testing image' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/extensions/containers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ encoded_id() { # variant
@test 'start container engine' {
RD_ENV_EXTENSIONS=1 start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

@test 'no extensions installed' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/extensions/install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ encoded_id() { # variant
@test 'start container engine' {
RD_ENV_EXTENSIONS=1 start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

@test 'no extensions installed' {
Expand Down
8 changes: 8 additions & 0 deletions bats/tests/helpers/vm.bash
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,17 @@ EOF
# Detach `rdctl start` because on Windows the process may not exit until
# Rancher Desktop itself quits.
RD_TEST=bats rdctl start "${args[@]}" "$@" &
RDCTL_PROCESS_ID=$!
fi
}

wait_for_rdctl_background_process() {
case "${RDCTL_PROCESS_ID:-no}" in
0 | no) ;;
[0-9][0-9]*) wait "$RDCTL_PROCESS_ID" || true ;;
esac
}

# shellcheck disable=SC2120
start_kubernetes() {
start_container_engine \
Expand Down
1 change: 1 addition & 0 deletions bats/tests/k8s/enable-disable-k8s.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ verify_k8s_is_running() {
start_kubernetes
wait_for_apiserver
verify_k8s_is_running
wait_for_rdctl_background_process
}

@test 'disable kubernetes' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/k8s/helm-install-rancher.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local_setup() {
@test 'start k8s' {
start_kubernetes
wait_for_apiserver
wait_for_rdctl_background_process
}

@test 'add helm repo' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/k8s/traefik.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local_setup() {
@test 'start k8s' {
start_kubernetes --kubernetes.options.traefik=true
wait_for_apiserver
wait_for_rdctl_background_process
}

get_host() {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/k8s/up-downgrade-k8s.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ARCH_FOR_KUBERLR=amd64
# the docker context "rancher-desktop" may not have been written
# even though the apiserver is already running
wait_for_container_engine
wait_for_rdctl_background_process
}

@test 'deploy nginx - always restart' {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/k8s/verify-cached-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ load '../helpers/load'
# Start first so we can use `rdctl set` in all the calls that change the k8s version
start_kubernetes
wait_for_apiserver
wait_for_rdctl_background_process
}

test_k8s_version_has_correct_cached_extension() {
Expand Down
1 change: 1 addition & 0 deletions bats/tests/k8s/wordpress.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local_setup() {
# the docker context "rancher-desktop" may not have been written
# even though the apiserver is already running
wait_for_container_engine
wait_for_rdctl_background_process
}

@test 'deploy wordpress' {
Expand Down
7 changes: 7 additions & 0 deletions bats/tests/preferences/verify-paths.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local_setup() {
@test 'start app' {
start_container_engine
wait_for_container_engine
wait_for_rdctl_background_process
}

# Running `bash -l -c` can cause bats to hang, so close the output file descriptor with '3>&-'
Expand Down Expand Up @@ -89,3 +90,9 @@ no_bashrc_path_manager() {
skip 'fish not found'
fi
}

@test 'shutdown on mac' {
if is_macos; then
rdctl shutdown
fi
}
1 change: 1 addition & 0 deletions bats/tests/registry/creds.bats
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ skip_for_insecure_registry() {
wait_for_shell
update_allowed_patterns true "$IMAGE_REGISTRY" "$REGISTRY"
fi
wait_for_rdctl_background_process
}

@test 'wait for container engine' {
Expand Down

0 comments on commit d9f3064

Please sign in to comment.