From c4b8bd8da9d512892397a4d5020b1c1c618398fc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 13 Mar 2020 12:42:42 -0400 Subject: [PATCH] test: ensure that the worker upstream exists --- tests/unit/40_nginx-vhosts_2.bats | 17 ++++++++++++++++- tests/unit/test_helper.bash | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/unit/40_nginx-vhosts_2.bats b/tests/unit/40_nginx-vhosts_2.bats index 30c96be01..6fbc2dd64 100644 --- a/tests/unit/40_nginx-vhosts_2.bats +++ b/tests/unit/40_nginx-vhosts_2.bats @@ -76,6 +76,7 @@ teardown() { add_domain "wildcard1.dokku.me" add_domain "wildcard2.dokku.me" deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_ssl_nginx_template + assert_ssl_domain "wildcard1.dokku.me" assert_ssl_domain "wildcard2.dokku.me" assert_http_redirect "http://${CUSTOM_TEMPLATE_SSL_DOMAIN}" "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}:443/" @@ -84,9 +85,23 @@ teardown() { @test "(nginx-vhosts) nginx:build-config (custom nginx template - no ssl)" { add_domain "www.test.app.dokku.me" - deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template + run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:scale $TEST_APP worker=1" + echo "output: $output" + echo "status: $status" + assert_success + assert_nonssl_domain "www.test.app.dokku.me" assert_http_success "customtemplate.dokku.me" + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "${TEST_APP}-worker-5000" } @test "(nginx-vhosts) nginx:build-config (failed validate_nginx)" { diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index aad460f86..b02ba0389 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -430,6 +430,14 @@ upstream {{ $.APP }}-{{ \$upstream_port }} { server {{ \$listener_ip }}:{{ \$upstream_port }};{{ end }} } {{ end }}{{ end }} +{{ if $.DOKKU_APP_WORKER_LISTENERS }} +{{ range \$upstream_port := $.PROXY_UPSTREAM_PORTS | split " " }} +upstream {{ $.APP }}-worker-{{ \$upstream_port }} { +{{ range \$listeners := $.DOKKU_APP_WORKER_LISTENERS | split " " }} + server {{ \$listeners }};{{ end }} +} +{{ end }}{{ end }} + EOF cat "$APP_REPO_DIR/nginx.conf.sigil" }