diff --git a/tests/unit/scheduler-k3s-1.bats b/tests/unit/scheduler-k3s-1.bats new file mode 100644 index 00000000000..b8a62e8d876 --- /dev/null +++ b/tests/unit/scheduler-k3s-1.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats + +load test_helper + +TEST_APP="rdmtestapp" + +setup() { + uninstall_k3s || true + global_setup + dokku nginx:stop + export KUBECONFIG="/etc/rancher/k3s/k3s.yaml" +} + +teardown_() { + global_teardown + dokku nginx:start + uninstall_k3s || true +} + +@test "(scheduler-k3s) install traefik with taint" { + if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then + skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN" + fi + + TAINT_SCHEDULING=true install_k3s +} + +@test "(scheduler-k3s) install nginx with taint" { + if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then + skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN" + fi + + INGRESS_CLASS=nginx TAINT_SCHEDULING=true install_k3s +} diff --git a/tests/unit/scheduler-k3s.bats b/tests/unit/scheduler-k3s-2.bats similarity index 80% rename from tests/unit/scheduler-k3s.bats rename to tests/unit/scheduler-k3s-2.bats index c2a4ffc4145..385fb503476 100644 --- a/tests/unit/scheduler-k3s.bats +++ b/tests/unit/scheduler-k3s-2.bats @@ -17,75 +17,6 @@ teardown_() { uninstall_k3s || true } -install_k3s() { - run /bin/bash -c "dokku proxy:set --global k3s" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku registry:set --global server hub.docker.com" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku registry:set --global image-repo-template '$DOCKERHUB_USERNAME/{{ .AppName }}'" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku registry:set --global push-on-release true" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku scheduler:set --global selected k3s" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku registry:login docker.io $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN" - echo "output: $output" - echo "status: $status" - assert_success - assert_output_contains "Login Succeeded" - - INGRESS_CLASS="${INGRESS_CLASS:-traefik}" - if [[ "$TAINT_SCHEDULING" == "true" ]]; then - run /bin/bash -c "dokku scheduler-k3s:initialize --ingress-class $INGRESS_CLASS --taint-scheduling" - echo "output: $output" - echo "status: $status" - assert_success - else - run /bin/bash -c "dokku scheduler-k3s:initialize --ingress-class $INGRESS_CLASS" - echo "output: $output" - echo "status: $status" - assert_success - fi -} - -uninstall_k3s() { - run /bin/bash -c "dokku scheduler-k3s:uninstall" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(scheduler-k3s) install traefik with taint" { - if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then - skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN" - fi - - TAINT_SCHEDULING=true install_k3s -} - -@test "(scheduler-k3s) install nginx with taint" { - if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then - skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN" - fi - - INGRESS_CLASS=nginx TAINT_SCHEDULING=true install_k3s -} - @test "(scheduler-k3s) deploy traefik [resource] [autoscaling]" { if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN" diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 0ea1a45edbd..b141fd43704 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -621,3 +621,58 @@ install_nixpacks() { curl -sSL https://nixpacks.com/install.sh | FORCE=1 bash fi } + +install_k3s() { + run /bin/bash -c "dokku proxy:set --global k3s" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku registry:set --global server hub.docker.com" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku registry:set --global image-repo-template '$DOCKERHUB_USERNAME/{{ .AppName }}'" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku registry:set --global push-on-release true" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku scheduler:set --global selected k3s" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku registry:login docker.io $DOCKERHUB_USERNAME $DOCKERHUB_TOKEN" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "Login Succeeded" + + INGRESS_CLASS="${INGRESS_CLASS:-traefik}" + if [[ "$TAINT_SCHEDULING" == "true" ]]; then + run /bin/bash -c "dokku scheduler-k3s:initialize --ingress-class $INGRESS_CLASS --taint-scheduling" + echo "output: $output" + echo "status: $status" + assert_success + else + run /bin/bash -c "dokku scheduler-k3s:initialize --ingress-class $INGRESS_CLASS" + echo "output: $output" + echo "status: $status" + assert_success + fi + + sleep 20 +} + +uninstall_k3s() { + run /bin/bash -c "dokku scheduler-k3s:uninstall" + echo "output: $output" + echo "status: $status" + assert_success +}