From 5f03518ec8a9e0a86b516bea657d5b51290a27f5 Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Thu, 9 Jul 2015 19:13:27 +0200 Subject: [PATCH 1/4] Fix check-deploy skipping the root path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The root path, `/`, was treated as an invalid URL because it didn’t contain any characters after the slash. --- plugins/checks/check-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/checks/check-deploy b/plugins/checks/check-deploy index b6413ef14..26b15ea45 100755 --- a/plugins/checks/check-deploy +++ b/plugins/checks/check-deploy @@ -138,7 +138,7 @@ do [[ -z "$CHECK_URL" || "$CHECK_URL" =~ ^\# ]] && continue # Ignore if it's not a URL in a supported format # shellcheck disable=SC1001 - ! [[ "$CHECK_URL" =~ ^(http(s)?:)?\/.+ ]] && continue + ! [[ "$CHECK_URL" =~ ^(http(s)?:)?\/.* ]] && continue if [[ "$CHECK_URL" =~ ^https?: ]] ; then URL_PROTOCOL=${CHECK_URL%:*} From 3218e2b07659985ff0565e0460ab2e190b456b48 Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Sat, 11 Jul 2015 13:21:57 +0200 Subject: [PATCH 2/4] Allow for test apps that should fail deployment --- tests/test_deploy | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/test_deploy b/tests/test_deploy index 1f6cf4743..f1b46a0a6 100755 --- a/tests/test_deploy +++ b/tests/test_deploy @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -xeo pipefail -SELF=$(which $0); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3" +SELF=$(which $0); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"; SHOULD_FAIL="$4" REMOTE="dokku@$TARGET" REPO="test-$(basename $APP)-$RANDOM" @@ -15,6 +15,12 @@ failed(){ exit 1 } +succeeded(){ + echo "************ $1 succeeded but should have failed ************" + destroy_app + exit 1 +} + TMP=$(mktemp -d -t "$TARGET.XXXXX") rmdir $TMP && cp -r "$(dirname "$SELF")"/$APP $TMP cd $TMP @@ -28,11 +34,21 @@ git add . [[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO git commit -m 'initial commit' -git push target master || failed git-push +if [[ "$SHOULD_FAIL" == true ]]; then + git push target master && succeeded git-push +else + git push target master || failed git-push +fi if [[ -x post-deploy ]]; then ./post-deploy $REMOTE $REPO || failed post-deploy fi +if [[ "$SHOULD_FAIL" == true ]]; then + echo "-----> Deploy failed (as it should have)!" + destroy_app + exit 0 +fi + URL=$(dokku url $REPO)$FORWARDED_PORT sleep 2 if (./check_deploy $URL); then From 7c02c6d31ddd6bc85fac1b1beae625e53d6cdb96 Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Sat, 11 Jul 2015 13:40:09 +0200 Subject: [PATCH 3/4] Add test app checks-root --- tests/apps/checks-root/CHECKS | 2 ++ tests/apps/checks-root/index.js | 11 +++++++++++ tests/apps/checks-root/package.json | 14 ++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/apps/checks-root/CHECKS create mode 100644 tests/apps/checks-root/index.js create mode 100644 tests/apps/checks-root/package.json diff --git a/tests/apps/checks-root/CHECKS b/tests/apps/checks-root/CHECKS new file mode 100644 index 000000000..4bc292597 --- /dev/null +++ b/tests/apps/checks-root/CHECKS @@ -0,0 +1,2 @@ +ATTEMPTS=2 +/ diff --git a/tests/apps/checks-root/index.js b/tests/apps/checks-root/index.js new file mode 100644 index 000000000..67ba7ab2a --- /dev/null +++ b/tests/apps/checks-root/index.js @@ -0,0 +1,11 @@ +var express = require('express'); +var app = express(); + +app.get('/', function(req, res) { + res.sendStatus(404); +}); + +var port = process.env.PORT || 5000; +app.listen(port, function() { + console.log('Listening on port ' + port); +}); diff --git a/tests/apps/checks-root/package.json b/tests/apps/checks-root/package.json new file mode 100644 index 000000000..bcf229757 --- /dev/null +++ b/tests/apps/checks-root/package.json @@ -0,0 +1,14 @@ +{ + "name": "node-example", + "version": "0.0.1", + "dependencies": { + "express": "4.x" + }, + "engines": { + "node": "0.12.x", + "npm": "2.x" + }, + "scripts": { + "start": "node index.js" + } +} From 25c107b16419d8bd92f82cc71c775d3879b7d0cb Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Sat, 11 Jul 2015 13:50:53 +0200 Subject: [PATCH 4/4] Add checks-root test app to tests.mk --- tests.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests.mk b/tests.mk index 68f3e32fc..cfff53125 100644 --- a/tests.mk +++ b/tests.mk @@ -75,6 +75,10 @@ else @$(QUIET) ./tests/ci/unit_test_runner.sh $$UNIT_TEST_BATCH endif +deploy-test-checks-root: + @echo deploying checks-root app... + cd tests && ./test_deploy ./apps/checks-root dokku.me '' true + deploy-test-clojure: @echo deploying config app... cd tests && ./test_deploy ./apps/clojure dokku.me @@ -137,6 +141,7 @@ deploy-test-static: deploy-tests: @echo running deploy tests... + @$(QUIET) $(MAKE) deploy-test-checks-root @$(QUIET) $(MAKE) deploy-test-config @$(QUIET) $(MAKE) deploy-test-clojure @$(QUIET) $(MAKE) deploy-test-dockerfile