From baefdabdfcfc39b1cffa917b4c3d383829ff867c Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Wed, 11 Dec 2013 21:41:05 +0000 Subject: [PATCH 1/2] Allow tests to have a setup phase. --- tests/test_deploy | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_deploy b/tests/test_deploy index 48626e035..4c680b199 100755 --- a/tests/test_deploy +++ b/tests/test_deploy @@ -1,6 +1,9 @@ #!/usr/bin/env bash -set -eo pipefail +set -exo pipefail SELF=`which $0`; APP="$1"; TARGET="$2"; FORWARDED_PORT="$3" +REMOTE="dokku@$TARGET" +REPO="test-$(basename $APP)-$RANDOM" + TMP=$(mktemp -d -t "$TARGET.XXXXX") trap "rm -rf $TMP" EXIT rmdir $TMP && cp -r $(dirname $SELF)/$APP $TMP @@ -8,14 +11,20 @@ cd $TMP git init git config user.email "robot@example.com" git config user.name "Test Robot" +git remote add target $REMOTE:$REPO + +[[ -f gitignore ]] && mv gitignore .gitignore git add . + +[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO git commit -m 'initial commit' -REPO="test-$(basename $APP)-$RANDOM" -git remote add target dokku@$TARGET:$REPO git push target master -URL=$(ssh dokku@$TARGET url $REPO)$FORWARDED_PORT +[[ -x post-deploy ]] && ./post-deploy $REMOTE $REPO + +URL=$(ssh $REMOTE url $REPO)$FORWARDED_PORT sleep 2 ./check_deploy $URL && echo "-----> Deploy success!" || { sleep 4 ./check_deploy $URL && echo "-----> Deploy success!" } + From 48b4e330a3ec3fe4f05f2f53ed721a56b0ddc31d Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Wed, 11 Dec 2013 21:41:16 +0000 Subject: [PATCH 2/2] Add a config test. --- tests/apps/config/Procfile | 1 + tests/apps/config/check_deploy | 3 +++ tests/apps/config/package.json | 11 +++++++++++ tests/apps/config/post-deploy | 8 ++++++++ tests/apps/config/web.js | 12 ++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 tests/apps/config/Procfile create mode 100755 tests/apps/config/check_deploy create mode 100644 tests/apps/config/package.json create mode 100755 tests/apps/config/post-deploy create mode 100644 tests/apps/config/web.js diff --git a/tests/apps/config/Procfile b/tests/apps/config/Procfile new file mode 100644 index 000000000..ae7366d41 --- /dev/null +++ b/tests/apps/config/Procfile @@ -0,0 +1 @@ +web: node web.js diff --git a/tests/apps/config/check_deploy b/tests/apps/config/check_deploy new file mode 100755 index 000000000..4047ea6b8 --- /dev/null +++ b/tests/apps/config/check_deploy @@ -0,0 +1,3 @@ +#!/bin/bash +set -e; output="$(curl -s $1)"; echo $output; test "$output" == "config-test" + diff --git a/tests/apps/config/package.json b/tests/apps/config/package.json new file mode 100644 index 000000000..7bdf8db0c --- /dev/null +++ b/tests/apps/config/package.json @@ -0,0 +1,11 @@ +{ + "name": "node-example", + "version": "0.0.1", + "dependencies": { + "express": "2.5.x" + }, + "engines": { + "node": "0.8.x", + "npm": "1.1.x" + } +} \ No newline at end of file diff --git a/tests/apps/config/post-deploy b/tests/apps/config/post-deploy new file mode 100755 index 000000000..d0080c7a9 --- /dev/null +++ b/tests/apps/config/post-deploy @@ -0,0 +1,8 @@ +#!/bin/bash +set -ex; + +REMOTE=$1 +REPO=$2 + +ssh $REMOTE config:set $REPO CONFTEST=config-test + diff --git a/tests/apps/config/web.js b/tests/apps/config/web.js new file mode 100644 index 000000000..3b5050b1f --- /dev/null +++ b/tests/apps/config/web.js @@ -0,0 +1,12 @@ +var express = require('express'); + +var app = express.createServer(express.logger()); + +app.get('/', function(request, response) { + response.send(process.env.CONFTEST); +}); + +var port = process.env.PORT || 5000; +app.listen(port, function() { + console.log("Listening on " + port); +});