make tests work

This commit is contained in:
Michael Hobbs
2014-12-14 14:45:49 -08:00
parent 3706392e65
commit 606bbda66c
15 changed files with 111 additions and 36 deletions

View File

@@ -25,10 +25,12 @@ ssl_session_timeout 10m;
ssl_ciphers EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
# this is already defined in the base nginx.conf and causes nginx reloads/starts to fail
# when its defined twice
# ssl_prefer_server_ciphers on;
#ssl_certificate $DOKKU_ROOT/tls/server.crt;
#ssl_certificate_key $DOKKU_ROOT/tls/server.key;
# ssl_certificate $DOKKU_ROOT/tls/server.crt;
# ssl_certificate_key $DOKKU_ROOT/tls/server.key;
EOF
fi

View File

@@ -11,9 +11,11 @@ endif
ci-dependencies: shellcheck bats
setup-deploy-tests:
# echo "-----> Enabling tracing"
# mkdir -p /home/dokku
# echo "export DOKKU_TRACE=1" >> /home/dokku/dokkurc
mkdir -p /home/dokku
ifdef ENABLE_DOKKU_TRACE
echo "-----> Enabling tracing"
echo "export DOKKU_TRACE=1" >> /home/dokku/dokkurc
endif
@echo "Setting dokku.me in /etc/hosts"
sudo /bin/bash -c "[[ `ping -c1 dokku.me > /dev/null 2>&1; echo $$?` -eq 0 ]] || echo \"127.0.0.1 dokku.me *.dokku.me\" >> /etc/hosts"
@@ -24,11 +26,9 @@ setup-deploy-tests:
chmod 600 /root/.ssh/dokku_test_rsa*
@echo "-----> Setting up ssh config..."
ifeq ($(shell ls /root/.ssh/config > /dev/null 2>&1 ; echo $$?),0)
ifeq ($(shell grep dokku.me /root/.ssh/config),)
ifneq ($(shell ls /root/.ssh/config > /dev/null 2>&1 ; echo $$?),0)
echo "Host dokku.me \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
endif
else
else ifeq ($(shell grep dokku.me /root/.ssh/config),)
echo "Host dokku.me \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config
endif
@@ -57,7 +57,6 @@ unit-tests:
deploy-tests:
@echo running deploy tests...
# @$(QUIET) bats tests/deploy
cd tests && ./test_deploy ./apps/go dokku.me
@$(QUIET) bats tests/deploy
test: lint setup-deploy-tests unit-tests deploy-tests
test: setup-deploy-tests lint unit-tests deploy-tests

View File

@@ -1,10 +1,6 @@
#!/bin/bash
set -e;
base_url="$1"
test_url / "config-test"
test_url /hello "Hello world"
test_url () {
path="$1"
expected_output="$2"
@@ -13,3 +9,7 @@ test_url () {
echo "$output"
test "$output" == "$expected_output"
}
base_url="$1"
test_url / "config-test"
test_url /hello "Hello world"

View File

@@ -4,5 +4,6 @@ set -ex;
REMOTE=$1
REPO=$2
ssh "$REMOTE" config:set "$REPO" CONFTEST=config-test HELLO=\"Hello world\"
# setting config variables with spaces is broken at the moment. ref: 820
# ssh "$REMOTE" config:set "$REPO" CONFTEST=config-test HELLO=\"Hello world\"
dokku config:set "$REPO" CONFTEST=config-test HELLO="Hello world"

View File

@@ -1,5 +1,2 @@
#!/bin/bash
set -ex
echo "curl -s $1"
curl -s -S $1
output="$(curl -s $1)"; echo $output; test "$output" == "Hello World!"
set -e; output="$(curl -s -S $1)"; echo $output; test "$output" == "Hello World!"

View File

@@ -3,7 +3,6 @@
load ../unit/test_helper
@test "deploy config app" {
skip "ssh is doing something odd with quoting... ref: #820"
run bash -c "cd tests && ./test_deploy ./apps/config dokku.me"
echo "output: "$output
echo "status: "$status

10
tests/deploy/go.bats Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy go app" {
run bash -c "cd tests && ./test_deploy ./apps/go dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

10
tests/deploy/java.bats Normal file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy java app" {
run bash -c "cd tests && ./test_deploy ./apps/java dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

11
tests/deploy/multi.bats Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy multi app" {
skip "fails on postinstall with Arguments to path.join must be strings"
run bash -c "cd tests && ./test_deploy ./apps/multi dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy nodejs-express app" {
run bash -c "cd tests && ./test_deploy ./apps/nodejs-express dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

11
tests/deploy/php.bats Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy php app" {
skip "fails with /root/bin/jq: No such file or directory"
run bash -c "cd tests && ./test_deploy ./apps/php dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy python-flask app" {
run bash -c "cd tests && ./test_deploy ./apps/python-flask dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

11
tests/deploy/static.bats Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bats
load ../unit/test_helper
@test "deploy static app" {
skip "fails on apt-get update..."
run bash -c "cd tests && ./test_deploy ./apps/static dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -exo pipefail
set -eo pipefail
SELF=$(which $0); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"
REMOTE="dokku@$TARGET"
@@ -10,8 +10,8 @@ destroy_app(){
}
failed(){
echo "************ $1 failed ************"
# destroy_app
echo "************ Deploying $1 failed ************"
destroy_app
exit 1
}
@@ -28,12 +28,12 @@ git add .
[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO
git commit -m 'initial commit'
git push target master
git push target master || failed git-push
if [[ -x post-deploy ]]; then
./post-deploy $REMOTE $REPO || failed post-deploy
fi
URL=$(ssh $REMOTE url $REPO)$FORWARDED_PORT
URL=$(dokku url $REPO)$FORWARDED_PORT
sleep 2
if (./check_deploy $URL); then
echo "-----> Deploy success!"

View File

@@ -1,5 +1,3 @@
# box: ruudk/ubuntu14.04@1.0.0
# box: jparyani/docker@1.0.1
box: wercker-labs/docker
build:
steps:
@@ -8,7 +6,6 @@ build:
code: |-
sudo apt-get update
sudo apt-get install -y make software-properties-common git wget man-db
docker version
- script:
name: ci dependencies
code: make -e ci-dependencies
@@ -16,7 +13,14 @@ build:
name: install dokku
code: sudo -E CI=true DOCKER_VERSION=1.4.0 make -e install
- script:
name: test dokku
code: |-
docker version
sudo -E make -e test
name: setup deploy tests
code: sudo -E make -e setup-deploy-tests
- script:
name: lint
code: sudo -E make -e lint
- script:
name: unit tests
code: sudo -E make -e unit-tests
- script:
name: deploy tests
code: sudo -E make -e deploy-tests