Merge pull request #1082 from progrium/mh-test-updates

test cleanup with slight performance boost
This commit is contained in:
Jose Diaz-Gonzalez
2015-04-02 11:23:02 -04:00
16 changed files with 142 additions and 158 deletions

View File

@@ -5,7 +5,7 @@
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
"node": "0.10.x",
"npm": "2.7.x"
}
}
}

View File

@@ -6,6 +6,6 @@
},
"engines": {
"node": "0.10.x",
"npm": "1.3.x"
"npm": "2.7.x"
}
}
}

View File

@@ -5,8 +5,8 @@
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
"node": "0.10.x",
"npm": "2.7.x"
},
"scripts": {
"start": "node web.js"

View File

@@ -5,7 +5,7 @@
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
"node": "0.10.x",
"npm": "2.7.x"
}
}
}

36
tests/unit/apps.bats Executable file → Normal file
View File

@@ -2,24 +2,26 @@
load test_helper
APP=lifecycle-app
@test "(apps) apps" {
create_app
run bash -c "dokku apps | grep $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_output $TEST_APP
destroy_app
}
@test "apps:create" {
run dokku apps:create $APP
echo "output: "$output
echo "status: "$status
assert_success
}
@test "apps" {
run bash -c "dokku apps | grep $APP"
echo "output: "$output
echo "status: "$status
assert_output $APP
}
@test "apps:destroy" {
run bash -c "dokku --force apps:destroy $APP"
@test "(apps) apps:create" {
run dokku apps:create $TEST_APP
echo "output: "$output
echo "status: "$status
assert_success
destroy_app
}
@test "(apps) apps:destroy" {
create_app
run bash -c "dokku --force apps:destroy $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success

View File

@@ -12,7 +12,7 @@
# destroy_app
# }
# @test "backup:export" {
# @test "(backup) backup:export" {
# run dokku backup:export $backup_file
# echo "output: "$output
# echo "status: "$status

View File

@@ -10,7 +10,7 @@ teardown() {
destroy_app
}
@test "build-env with special chars" {
@test "(build-env) special characters" {
run dokku config:set $TEST_APP NEWRELIC_APP_NAME="$TEST_APP (Staging)"
echo "output: "$output
echo "status: "$status

View File

@@ -1,36 +0,0 @@
#!/usr/bin/env bats
load test_helper
setup() {
deploy_app
}
teardown() {
destroy_app
}
@test "remove exited containers" {
# make sure we have many exited containers of the same 'type'
run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_success
run dokku cleanup
echo "output: "$output
echo "status: "$status
assert_success
sleep 5 # wait for dokku cleanup to happen in the background
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_failure
run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false"
echo "output: "$output
echo "status: "$status
assert_output ""
}

View File

@@ -12,7 +12,7 @@ teardown() {
unset DOKKU_HOST
}
@test "dokku client (unconfigured DOKKU_HOST)" {
@test "(client) unconfigured DOKKU_HOST" {
unset DOKKU_HOST
run ./contrib/dokku_client.sh apps
echo "output: "$output
@@ -20,14 +20,14 @@ teardown() {
assert_exit_status 20
}
@test "dokku client (no args should print help)" {
@test "(client) no args should print help" {
run /bin/bash -c "./contrib/dokku_client.sh | head -1 | egrep -q '^Usage: dokku \[.+\] COMMAND <app>.*'"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "dokku client (apps:create AND apps:destroy)" {
@test "(client) apps:create AND apps:destroy" {
setup_client_repo
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh apps:create"
echo "output: "$output
@@ -39,7 +39,7 @@ teardown() {
assert_success
}
@test "dokku client (config:set)" {
@test "(client) config:set" {
run ./contrib/dokku_client.sh config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
@@ -50,7 +50,7 @@ teardown() {
assert_success
}
@test "dokku client (config:unset)" {
@test "(client) config:unset" {
run ./contrib/dokku_client.sh config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
@@ -69,14 +69,14 @@ teardown() {
assert_failure
}
@test "dokku client (domains)" {
@test "(client) domains" {
run bash -c "./contrib/dokku_client.sh domains $TEST_APP | grep -q ${TEST_APP}.dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "dokku client (domains:add)" {
@test "(client) domains:add" {
run ./contrib/dokku_client.sh domains:add $TEST_APP www.test.app.dokku.me
echo "output: "$output
echo "status: "$status
@@ -87,7 +87,7 @@ teardown() {
assert_success
}
@test "dokku client (domains:remove)" {
@test "(client) domains:remove" {
run ./contrib/dokku_client.sh domains:add $TEST_APP test.app.dokku.me
echo "output: "$output
echo "status: "$status
@@ -98,7 +98,7 @@ teardown() {
refute_line "test.app.dokku.me"
}
@test "dokku client (domains:clear)" {
@test "(client) domains:clear" {
run ./contrib/dokku_client.sh domains:add $TEST_APP test.app.dokku.me
echo "output: "$output
echo "status: "$status
@@ -109,7 +109,7 @@ teardown() {
assert_success
}
# @test "dokku client (ps)" {
# @test "(client) ps" {
# # CI support: 'Ah. I just spoke with our Docker expert --
# # looks like docker exec is built to work with docker-under-libcontainer,
# # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
@@ -121,7 +121,7 @@ teardown() {
# assert_success
# }
@test "dokku client (ps:start)" {
@test "(client) ps:start" {
deploy_app
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:stop $TEST_APP"
echo "output: "$output
@@ -137,7 +137,7 @@ teardown() {
assert_success
}
@test "dokku client (ps:stop)" {
@test "(client) ps:stop" {
deploy_app
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:stop $TEST_APP"
echo "output: "$output
@@ -149,7 +149,7 @@ teardown() {
assert_failure
}
@test "dokku client (ps:restart)" {
@test "(client) ps:restart" {
deploy_app
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:restart $TEST_APP"
echo "output: "$output

View File

@@ -12,14 +12,14 @@ teardown() {
rm -f "$DOKKU_ROOT/ENV"
}
@test "config:set" {
@test "(config) config:set" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "config:get" {
@test "(config) config:get" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
@@ -30,7 +30,7 @@ teardown() {
assert_output 'hello world'
}
@test "config:unset" {
@test "(config) config:unset" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
@@ -49,7 +49,7 @@ teardown() {
assert_output ""
}
@test "global config (buildstep)" {
@test "(config) global config (buildstep)" {
deploy_app
run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
echo "output: "$output
@@ -57,7 +57,7 @@ teardown() {
assert_success
}
@test "global config (dockerfile)" {
@test "(config) global config (dockerfile)" {
deploy_app dockerfile
run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
echo "output: "$output

View File

@@ -26,7 +26,33 @@ build_nginx_config() {
dokku nginx:build-config $TEST_APP
}
@test "run (with tty)" {
@test "(core) remove exited containers" {
deploy_app
# make sure we have many exited containers of the same 'type'
run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_success
run dokku cleanup
echo "output: "$output
echo "status: "$status
assert_success
sleep 5 # wait for dokku cleanup to happen in the background
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_failure
run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false"
echo "output: "$output
echo "status: "$status
assert_output ""
}
@test "(core) run (with tty)" {
deploy_app
run /bin/bash -c "dokku run $TEST_APP ls /app/package.json"
echo "output: "$output
@@ -34,7 +60,7 @@ build_nginx_config() {
assert_success
}
@test "run (without tty)" {
@test "(core) run (without tty)" {
deploy_app
run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json"
echo "output: "$output
@@ -42,7 +68,7 @@ build_nginx_config() {
assert_success
}
@test "run (with --options)" {
@test "(core) run (with --options)" {
deploy_app
run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version"
echo "output: "$output
@@ -50,7 +76,18 @@ build_nginx_config() {
assert_success
}
@test "urls (non-ssl)" {
@test "(core) unknown command" {
run /bin/bash -c "dokku fakecommand"
echo "output: "$output
echo "status: "$status
assert_failure
run /bin/bash -c "dokku fakecommand | grep -q 'is not a dokku command'"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "(core) urls (non-ssl)" {
assert_urls "http://dokku.me"
build_nginx_config
assert_urls "http://${TEST_APP}.dokku.me"
@@ -58,7 +95,7 @@ build_nginx_config() {
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
}
@test "urls (app ssl)" {
@test "(core) urls (app ssl)" {
setup_test_tls
assert_urls "https://dokku.me"
build_nginx_config
@@ -67,7 +104,7 @@ build_nginx_config() {
assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
}
@test "urls (wildcard ssl)" {
@test "(core) urls (wildcard ssl)" {
setup_test_tls_wildcard
assert_urls "https://dokku.me"
build_nginx_config
@@ -77,3 +114,4 @@ build_nginx_config() {
add_domain "dokku.example.com"
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://dokku.example.com"
}

View File

@@ -13,7 +13,7 @@ teardown() {
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME"
}
@test "port exposure (with global VHOST)" {
@test "(core) port exposure (with global VHOST)" {
echo "dokku.me" > "$DOKKU_ROOT/VHOST"
deploy_app
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }')
@@ -23,7 +23,7 @@ teardown() {
assert_failure
}
@test "port exposure (without global VHOST and real HOSTNAME)" {
@test "(core) port exposure (without global VHOST and real HOSTNAME)" {
rm "$DOKKU_ROOT/VHOST"
echo "dokku.me" > "$DOKKU_ROOT/HOSTNAME"
deploy_app
@@ -34,7 +34,7 @@ teardown() {
assert_success
}
@test "port exposure (with NO_VHOST set)" {
@test "(core) port exposure (with NO_VHOST set)" {
deploy_app
dokku config:set $TEST_APP NO_VHOST=1
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }')
@@ -44,7 +44,7 @@ teardown() {
assert_success
}
@test "port exposure (without global VHOST and IPv4 address as HOSTNAME)" {
@test "(core) port exposure (without global VHOST and IPv4 address as HOSTNAME)" {
rm "$DOKKU_ROOT/VHOST"
echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME"
deploy_app
@@ -55,7 +55,7 @@ teardown() {
assert_success
}
@test "port exposure (without global VHOST and IPv6 address as HOSTNAME)" {
@test "(core) port exposure (without global VHOST and IPv6 address as HOSTNAME)" {
rm "$DOKKU_ROOT/VHOST"
echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME"
deploy_app
@@ -66,7 +66,7 @@ teardown() {
assert_success
}
@test "port exposure (pre-deploy domains:add)" {
@test "(core) port exposure (pre-deploy domains:add)" {
create_app
run dokku domains:add $TEST_APP www.test.app.dokku.me
echo "output: "$output
@@ -88,7 +88,7 @@ teardown() {
assert_success
}
@test "port exposure (no global VHOST and domains:add post deploy)" {
@test "(core) port exposure (no global VHOST and domains:add post deploy)" {
rm "$DOKKU_ROOT/VHOST"
deploy_app
@@ -109,7 +109,7 @@ teardown() {
assert_success
}
@test "dockerfile port exposure" {
@test "(core) dockerfile port exposure" {
deploy_app dockerfile
run bash -c "grep upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep 3000"
echo "output: "$output
@@ -117,7 +117,7 @@ teardown() {
assert_success
}
@test "port exposure (xip.io style hostnames)" {
@test "(core) port exposure (xip.io style hostnames)" {
echo "127.0.0.1.xip.io" > "$DOKKU_ROOT/VHOST"
deploy_app

View File

@@ -10,14 +10,14 @@ teardown() {
destroy_app
}
@test "domains" {
@test "(domains) domains" {
run bash -c "dokku domains $TEST_APP | grep ${TEST_APP}.dokku.me"
echo "output: "$output
echo "status: "$status
assert_output "${TEST_APP}.dokku.me"
}
@test "domains:add" {
@test "(domains) domains:add" {
run dokku domains:add $TEST_APP www.test.app.dokku.me
echo "output: "$output
echo "status: "$status
@@ -28,7 +28,7 @@ teardown() {
assert_success
}
@test "domains:remove" {
@test "(domains) domains:remove" {
run dokku domains:add $TEST_APP test.app.dokku.me
echo "output: "$output
echo "status: "$status
@@ -39,7 +39,7 @@ teardown() {
refute_line "test.app.dokku.me"
}
@test "domains:clear" {
@test "(domains) domains:clear" {
run dokku domains:add $TEST_APP test.app.dokku.me
echo "output: "$output
echo "status: "$status

View File

@@ -53,7 +53,7 @@ assert_http_success() {
assert_output "200"
}
@test "nginx (no server tokens)" {
@test "(nginx-vhosts) nginx (no server tokens)" {
deploy_app
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | egrep '^Server' | egrep '[0-9]+'"
echo "output: "$output
@@ -61,7 +61,7 @@ assert_http_success() {
assert_failure
}
@test "nginx:build-config (wildcard SSL)" {
@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
setup_test_tls_wildcard
add_domain "wildcard1.dokku.me"
add_domain "wildcard2.dokku.me"
@@ -72,13 +72,13 @@ assert_http_success() {
assert_nonssl_domain "www.test.dokku.me"
}
@test "nginx:build-config (with SSL CN mismatch)" {
@test "(nginx-vhosts) nginx:build-config (with SSL CN mismatch)" {
setup_test_tls
deploy_app
assert_ssl_domain "node-js-app.dokku.me"
}
@test "nginx:build-config (with SSL and Multiple SANs)" {
@test "(nginx-vhosts) nginx:build-config (with SSL and Multiple SANs)" {
setup_test_tls_with_sans
deploy_app
assert_ssl_domain "test.dokku.me"
@@ -86,7 +86,7 @@ assert_http_success() {
assert_ssl_domain "www.test.app.dokku.me"
}
@test "nginx:build-config (no global VHOST and domains:add)" {
@test "(nginx-vhosts) nginx:build-config (no global VHOST and domains:add)" {
destroy_app
rm "$DOKKU_ROOT/VHOST"
create_app

View File

@@ -10,7 +10,7 @@ teardown() {
destroy_app
}
# @test "ps (buildstep)" {
# @test "(ps) buildstep" {
# # CI support: 'Ah. I just spoke with our Docker expert --
# # looks like docker exec is built to work with docker-under-libcontainer,
# # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
@@ -21,22 +21,7 @@ teardown() {
# assert_success
# }
@test "ps:start (buildstep)" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:start $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:stop (buildstep)" {
@test "(ps) buildstep" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -45,9 +30,16 @@ teardown() {
echo "output: "$output
echo "status: "$status
assert_failure
}
@test "ps:restart (buildstep)" {
run bash -c "dokku ps:start $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:restart $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -56,9 +48,7 @@ teardown() {
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:rebuild (buildstep)" {
run bash -c "dokku ps:rebuild $TEST_APP"
echo "output: "$output
echo "status: "$status

View File

@@ -10,33 +10,18 @@ teardown() {
destroy_app
}
@test "ps (dockerfile)" {
# CI support: 'Ah. I just spoke with our Docker expert --
# looks like docker exec is built to work with docker-under-libcontainer,
# but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
skip "circleci does not support docker exec at the moment."
run bash -c "dokku ps $TEST_APP | grep -q \"node web.js\""
echo "output: "$output
echo "status: "$status
assert_success
}
# @test "(ps) dockerfile" {
# # CI support: 'Ah. I just spoke with our Docker expert --
# # looks like docker exec is built to work with docker-under-libcontainer,
# # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
# skip "circleci does not support docker exec at the moment."
# run bash -c "dokku ps $TEST_APP | grep -q \"node web.js\""
# echo "output: "$output
# echo "status: "$status
# assert_success
# }
@test "ps:start (dockerfile)" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:start $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:stop (dockerfile)" {
@test "(ps) dockerfile" {
run bash -c "dokku ps:stop $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -45,9 +30,16 @@ teardown() {
echo "output: "$output
echo "status: "$status
assert_failure
}
@test "ps:restart (dockerfile)" {
run bash -c "dokku ps:start $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "dokku ps:restart $TEST_APP"
echo "output: "$output
echo "status: "$status
@@ -56,9 +48,7 @@ teardown() {
echo "output: "$output
echo "status: "$status
assert_success
}
@test "ps:rebuild (dockerfile)" {
run bash -c "dokku ps:rebuild $TEST_APP"
echo "output: "$output
echo "status: "$status