tests: add unit tests and support multiple routers/services in traefik
This commit is contained in:
@@ -91,6 +91,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
|||||||
|
|
||||||
output="$output --label traefik.http.services.$APP-$PROC_TYPE.loadbalancer.server.port=$proxy_container_http_port"
|
output="$output --label traefik.http.services.$APP-$PROC_TYPE.loadbalancer.server.port=$proxy_container_http_port"
|
||||||
output="$output --label traefik.http.routers.$APP-$PROC_TYPE.entrypoints=http"
|
output="$output --label traefik.http.routers.$APP-$PROC_TYPE.entrypoints=http"
|
||||||
|
output="$output --label traefik.http.routers.$APP-$PROC_TYPE.service=$APP-$PROC_TYPE"
|
||||||
if [[ -n "$traefik_domains" ]]; then
|
if [[ -n "$traefik_domains" ]]; then
|
||||||
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE.rule=Host(\\\`$traefik_domains\\\`)\""
|
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE.rule=Host(\\\`$traefik_domains\\\`)\""
|
||||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
||||||
@@ -107,6 +108,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
|
|||||||
|
|
||||||
output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port"
|
output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port"
|
||||||
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https"
|
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https"
|
||||||
|
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.service=$APP-$PROC_TYPE-https"
|
||||||
if [[ -n "$traefik_domains" ]]; then
|
if [[ -n "$traefik_domains" ]]; then
|
||||||
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-https.rule=Host(\\\`$traefik_domains\\\`)\""
|
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-https.rule=Host(\\\`$traefik_domains\\\`)\""
|
||||||
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
echo "# THIS FILE IS GENERATED BY DOKKU - DO NOT EDIT, YOUR CHANGES WILL BE OVERWRITTEN" >"$app_urls_path"
|
||||||
|
|||||||
83
tests/unit/traefik.bats
Normal file
83
tests/unit/traefik.bats
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
dokku nginx:stop
|
||||||
|
dokku traefik:start
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
global_teardown
|
||||||
|
destroy_app
|
||||||
|
dokku traefik:stop
|
||||||
|
dokku nginx:start
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(traefik) traefik:help" {
|
||||||
|
run /bin/bash -c "dokku traefik"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Manage the traefik proxy integration"
|
||||||
|
help_output="$output"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku traefik:help"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Manage the traefik proxy integration"
|
||||||
|
assert_output "$help_output"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(traefik) single domain" {
|
||||||
|
run /bin/bash -c "dokku proxy:set $TEST_APP traefik"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "curl --silent $(dokku url $TEST_APP)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "python/http.server"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(traefik) multiple domains" {
|
||||||
|
run /bin/bash -c "dokku proxy:set $TEST_APP traefik"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku domains:add $TEST_APP $TEST_APP.dokku.me"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku domains:add $TEST_APP $TEST_APP-2.dokku.me"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "curl --silent $TEST_APP.dokku.me"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "python/http.server"
|
||||||
|
|
||||||
|
run /bin/bash -c "curl --silent $TEST_APP-2.dokku.me"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "python/http.server"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user