Merge branch 'master' into 1091_mh-switch-to-herokuish

This commit is contained in:
Michael Hobbs
2015-07-28 10:55:44 -07:00
42 changed files with 1024 additions and 390 deletions

View File

@@ -0,0 +1,2 @@
ATTEMPTS=2
/

View File

@@ -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);
});

View File

@@ -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"
}
}

View File

@@ -2,7 +2,9 @@ FROM ubuntu:trusty
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
EXPOSE 3000
EXPOSE 3001/udp
EXPOSE 3000/tcp
EXPOSE 3003
RUN apt-get install -y software-properties-common && add-apt-repository ppa:chris-lea/node.js && apt-get update
RUN apt-get install -y build-essential curl postgresql-client-9.3 nodejs git

View File

@@ -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

View File

@@ -3,13 +3,55 @@
load test_helper
setup() {
[[ -f $DOKKU_ROOT/ENV ]] && mv -f $DOKKU_ROOT/ENV $DOKKU_ROOT/ENV.bak
sudo -H -u dokku /bin/bash -c "echo 'export global_test=true' > $DOKKU_ROOT/ENV"
create_app
}
teardown() {
destroy_app
rm -f "$DOKKU_ROOT/ENV"
[[ -f $DOKKU_ROOT/ENV.bak ]] && mv -f $DOKKU_ROOT/ENV.bak $DOKKU_ROOT/ENV
}
@test "(config) config:set --global" {
run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "(config) config:get --global" {
run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\" test_var3=\"with\\nnewline\"
echo "output: "$output
echo "status: "$status
assert_success
run dokku config:get --global test_var2
echo "output: "$output
echo "status: "$status
assert_output 'hello world'
run dokku config:get --global test_var3
echo "output: "$output
echo "status: "$status
assert_output 'with\nnewline'
}
@test "(config) config:unset --global" {
run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
assert_success
run dokku config:get --global test_var
echo "output: "$output
echo "status: "$status
assert_success
run dokku config:unset --global test_var
echo "output: "$output
echo "status: "$status
assert_success
run dokku config:get --global test_var
echo "output: "$output
echo "status: "$status
assert_output ""
}
@test "(config) config:set" {

View File

@@ -5,6 +5,7 @@ load test_helper
setup() {
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -f "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
[[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -f "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak"
DOCKERFILE="$BATS_TMPDIR/Dockerfile"
}
teardown() {
@@ -162,3 +163,29 @@ check_urls() {
check_urls http://my-cool-guy-test-app.127.0.0.1.xip.io
}
@test "(core) port exposure (dockerfile raw port)" {
source "$PLUGIN_PATH/common/functions"
cat<<EOF > $DOCKERFILE
EXPOSE 3001/udp
EXPOSE 3003
EXPOSE 3000/tcp
EOF
run get_dockerfile_exposed_port $DOCKERFILE
echo "output: "$output
echo "status: "$status
assert_output 3003
}
@test "(core) port exposure (dockerfile tcp port)" {
source "$PLUGIN_PATH/common/functions"
cat<<EOF > $DOCKERFILE
EXPOSE 3001/udp
EXPOSE 3000/tcp
EXPOSE 3003
EOF
run get_dockerfile_exposed_port $DOCKERFILE
echo "output: "$output
echo "status: "$status
assert_output 3000
}

View File

@@ -2,6 +2,7 @@
# constants
DOKKU_ROOT=${DOKKU_ROOT:=~dokku}
PLUGIN_PATH=${PLUGIN_PATH:="/var/lib/dokku/plugins"}
TEST_APP=my-cool-guy-test-app
# test functions