这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
34 changes: 34 additions & 0 deletions tests/unit/scheduler-k3s-1.bats
Original file line number Diff line number Diff line change
@@ -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
}
69 changes: 0 additions & 69 deletions tests/unit/scheduler-k3s.bats → tests/unit/scheduler-k3s-2.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
55 changes: 55 additions & 0 deletions tests/unit/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
}