mirror of
https://github.com/dokku/dokku.git
synced 2025-12-16 12:07:45 +01:00
feat: split tests out even more and start deploy tests in parallel
This commit is contained in:
@@ -94,7 +94,7 @@ jobs:
|
|||||||
esac
|
esac
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: ./coverage.out
|
path: ./coverage.out
|
||||||
quick-test:
|
test:
|
||||||
executor: default
|
executor: default
|
||||||
parameters:
|
parameters:
|
||||||
index:
|
index:
|
||||||
@@ -103,26 +103,6 @@ jobs:
|
|||||||
- init-tests
|
- init-tests
|
||||||
- run-bats:
|
- run-bats:
|
||||||
index: << parameters.index >>
|
index: << parameters.index >>
|
||||||
medium-test:
|
|
||||||
executor: default
|
|
||||||
parallelism: 1
|
|
||||||
parameters:
|
|
||||||
index:
|
|
||||||
type: string
|
|
||||||
steps:
|
|
||||||
- init-tests
|
|
||||||
- run-bats:
|
|
||||||
index: << parameters.index >>
|
|
||||||
slow-test:
|
|
||||||
executor: default
|
|
||||||
parallelism: 1
|
|
||||||
parameters:
|
|
||||||
index:
|
|
||||||
type: string
|
|
||||||
steps:
|
|
||||||
- init-tests
|
|
||||||
- run-bats:
|
|
||||||
index: << parameters.index >>
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
workflow:
|
workflow:
|
||||||
@@ -131,68 +111,61 @@ workflows:
|
|||||||
- docker-deploy-tests:
|
- docker-deploy-tests:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- quick-test
|
|
||||||
- medium-test
|
|
||||||
- slow-test
|
|
||||||
- go-tests:
|
- go-tests:
|
||||||
matrix:
|
matrix:
|
||||||
parameters:
|
parameters:
|
||||||
index: [0, 1, 2, 3]
|
index: [0, 1, 2, 3]
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- quick-test
|
- test
|
||||||
- medium-test
|
- test:
|
||||||
- slow-test
|
|
||||||
- quick-test:
|
|
||||||
matrix:
|
matrix:
|
||||||
parameters:
|
parameters:
|
||||||
index:
|
index:
|
||||||
- app-json
|
- app-json
|
||||||
|
- apps_1
|
||||||
|
- apps_2
|
||||||
|
- build-env
|
||||||
- buildpacks
|
- buildpacks
|
||||||
- certs
|
- certs
|
||||||
- config
|
- checks
|
||||||
|
- client
|
||||||
- config-oddities
|
- config-oddities
|
||||||
|
- config
|
||||||
|
- core_1
|
||||||
|
- core_2
|
||||||
|
- core_3
|
||||||
- docker-options
|
- docker-options
|
||||||
- domains
|
- domains
|
||||||
- events
|
- events
|
||||||
|
- git_1
|
||||||
|
- git_2
|
||||||
- init
|
- init
|
||||||
|
- network
|
||||||
|
- nginx-vhosts_1
|
||||||
|
- nginx-vhosts_2
|
||||||
- nginx-vhosts_3
|
- nginx-vhosts_3
|
||||||
|
- nginx-vhosts_4
|
||||||
|
- nginx-vhosts_5
|
||||||
|
- nginx-vhosts_6
|
||||||
|
- nginx-vhosts_7
|
||||||
- plugin
|
- plugin
|
||||||
- proxy
|
- proxy
|
||||||
|
- ps-dockerfile-1
|
||||||
|
- ps-dockerfile-2
|
||||||
- ps-general
|
- ps-general
|
||||||
|
- ps-herokuish-1
|
||||||
|
- ps-herokuish-2
|
||||||
|
- repo
|
||||||
- report
|
- report
|
||||||
|
- resource_1
|
||||||
|
- resource_2
|
||||||
- scheduler-docker-local
|
- scheduler-docker-local
|
||||||
- ssh_keys
|
- ssh_keys
|
||||||
- storage
|
- storage
|
||||||
|
- tags
|
||||||
- tar
|
- tar
|
||||||
- trace
|
- trace
|
||||||
- version
|
- version
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- medium-test:
|
|
||||||
matrix:
|
|
||||||
parameters:
|
|
||||||
index:
|
|
||||||
- build-env
|
|
||||||
- checks
|
|
||||||
- client
|
|
||||||
- core_2
|
|
||||||
- network
|
|
||||||
- nginx-vhosts_1
|
|
||||||
- ps-herokuish
|
|
||||||
- repo
|
|
||||||
- tags
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- slow-test:
|
|
||||||
matrix:
|
|
||||||
parameters:
|
|
||||||
index:
|
|
||||||
- apps
|
|
||||||
- core_1
|
|
||||||
- git
|
|
||||||
- nginx-vhosts_2
|
|
||||||
- ps-dockerfile
|
|
||||||
- resource
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
|
|||||||
@@ -228,170 +228,6 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(apps) apps:clone" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku apps:list | grep $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output ""
|
|
||||||
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(apps) apps:clone (no app)" {
|
|
||||||
run /bin/bash -c "dokku apps:create $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/heroku/heroku-buildpack-ruby.git"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku git:set $TEST_APP deploy-branch SOME_BRANCH_NAME"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku network:set $TEST_APP attach-post-create test-network"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku resource:limit --memory 100 $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku scheduler-docker-local:set $TEST_APP disable-chown true"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku apps:list | grep $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku buildpacks:report great-test-name --buildpacks-list"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output "https://github.com/heroku/heroku-buildpack-ruby.git"
|
|
||||||
run /bin/bash -c "dokku git:report great-test-name --git-deploy-branch"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output "SOME_BRANCH_NAME"
|
|
||||||
run /bin/bash -c "dokku network:report great-test-name --network-attach-post-create"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output "test-network"
|
|
||||||
run /bin/bash -c "dokku nginx:report great-test-name --nginx-bind-address-ipv4"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output "127.0.0.1"
|
|
||||||
run /bin/bash -c "dokku resource:report great-test-name --resource-_default_.limit.memory"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output "100"
|
|
||||||
run /bin/bash -c "dokku scheduler-docker-local:report great-test-name --scheduler-docker-local-disable-chown"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output "true"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(apps) apps:clone ssl-app" {
|
|
||||||
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_PROXY_PORT_MAP=https:443:5000 DOKKU_PROXY_SSL_PORT=443"
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku apps:clone $TEST_APP app-without-ssl"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku --quiet proxy:ports app-without-ssl | xargs"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "http 80 5000"
|
|
||||||
run /bin/bash -c "dokku config:get app-without-ssl DOKKU_PROXY_SSL_PORT"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output ""
|
|
||||||
run /bin/bash -c "dokku --force apps:destroy app-without-ssl"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(apps) apps:clone --skip-deploy" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku apps:clone --skip-deploy $TEST_APP great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run [ -d /home/dokku/great-test-name/tls ]
|
|
||||||
assert_failure
|
|
||||||
run [ -f /home/dokku/great-test-name/URLS ]
|
|
||||||
assert_failure
|
|
||||||
run [ -f /home/dokku/great-test-name/VHOST ]
|
|
||||||
assert_failure
|
|
||||||
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(apps) apps:clone --ignore-existing" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku apps:create great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku apps:clone --ignore-existing $TEST_APP great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(apps) apps:exists" {
|
@test "(apps) apps:exists" {
|
||||||
run /bin/bash -c "dokku apps:exists $TEST_APP"
|
run /bin/bash -c "dokku apps:exists $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
175
tests/unit/apps_2.bats
Normal file
175
tests/unit/apps_2.bats
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(apps) apps:clone" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku apps:list | grep $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output ""
|
||||||
|
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(apps) apps:clone (no app)" {
|
||||||
|
run /bin/bash -c "dokku apps:create $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku git:set $TEST_APP deploy-branch SOME_BRANCH_NAME"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku network:set $TEST_APP attach-post-create test-network"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku resource:limit --memory 100 $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku scheduler-docker-local:set $TEST_APP disable-chown true"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku apps:list | grep $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku buildpacks:report great-test-name --buildpacks-list"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||||
|
run /bin/bash -c "dokku git:report great-test-name --git-deploy-branch"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "SOME_BRANCH_NAME"
|
||||||
|
run /bin/bash -c "dokku network:report great-test-name --network-attach-post-create"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "test-network"
|
||||||
|
run /bin/bash -c "dokku nginx:report great-test-name --nginx-bind-address-ipv4"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "127.0.0.1"
|
||||||
|
run /bin/bash -c "dokku resource:report great-test-name --resource-_default_.limit.memory"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "100"
|
||||||
|
run /bin/bash -c "dokku scheduler-docker-local:report great-test-name --scheduler-docker-local-disable-chown"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output "true"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(apps) apps:clone ssl-app" {
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_PROXY_PORT_MAP=https:443:5000 DOKKU_PROXY_SSL_PORT=443"
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku apps:clone $TEST_APP app-without-ssl"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku --quiet proxy:ports app-without-ssl | xargs"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "http 80 5000"
|
||||||
|
run /bin/bash -c "dokku config:get app-without-ssl DOKKU_PROXY_SSL_PORT"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output ""
|
||||||
|
run /bin/bash -c "dokku --force apps:destroy app-without-ssl"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(apps) apps:clone --skip-deploy" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku apps:clone --skip-deploy $TEST_APP great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run [ -d /home/dokku/great-test-name/tls ]
|
||||||
|
assert_failure
|
||||||
|
run [ -f /home/dokku/great-test-name/URLS ]
|
||||||
|
assert_failure
|
||||||
|
run [ -f /home/dokku/great-test-name/VHOST ]
|
||||||
|
assert_failure
|
||||||
|
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(apps) apps:clone --ignore-existing" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku apps:create great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku apps:clone --ignore-existing $TEST_APP great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku --force apps:destroy great-test-name"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
@@ -50,109 +50,6 @@ teardown() {
|
|||||||
docker rm $RANDOM_RUN_CID
|
docker rm $RANDOM_RUN_CID
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" {
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_RM_CONTAINER=1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:unset --no-restart $TEST_APP DOKKU_RM_CONTAINER"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:set --global DOKKU_RM_CONTAINER=1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:unset --global DOKKU_RM_CONTAINER"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) run (detached)" {
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
RANDOM_RUN_CID="$(dokku --label=com.dokku.test-label=value --detach run $TEST_APP sleep 300)"
|
|
||||||
run /bin/bash -c "docker inspect -f '{{ .State.Status }}' $RANDOM_RUN_CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "running"
|
|
||||||
|
|
||||||
run /bin/bash -c "docker inspect $RANDOM_RUN_CID --format '{{ index .Config.Labels \"com.dokku.test-label\" }}'"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "value"
|
|
||||||
|
|
||||||
run /bin/bash -c "docker stop $RANDOM_RUN_CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku cleanup"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
sleep 5 # wait for dokku cleanup to happen in the background
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) run (with tty)" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku run $TEST_APP ls /app/package.json"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) run (without tty)" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) run command from Procfile" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku run $TEST_APP custom 'hi dokku' | tail -n 1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
|
|
||||||
assert_success
|
|
||||||
assert_output 'hi dokku'
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(core) port exposure (dockerfile raw port)" {
|
@test "(core) port exposure (dockerfile raw port)" {
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
cat<<EOF > $DOCKERFILE
|
cat<<EOF > $DOCKERFILE
|
||||||
|
|||||||
120
tests/unit/core_3.bats
Normal file
120
tests/unit/core_3.bats
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
DOCKERFILE="$BATS_TMPDIR/Dockerfile"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
rm -rf /home/dokku/$TEST_APP/tls
|
||||||
|
destroy_app
|
||||||
|
dokku config:unset --global DOKKU_RM_CONTAINER
|
||||||
|
rm -f "$DOCKERFILE"
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" {
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_RM_CONTAINER=1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:unset --no-restart $TEST_APP DOKKU_RM_CONTAINER"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:set --global DOKKU_RM_CONTAINER=1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:unset --global DOKKU_RM_CONTAINER"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(core) run (detached)" {
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
RANDOM_RUN_CID="$(dokku --label=com.dokku.test-label=value --detach run $TEST_APP sleep 300)"
|
||||||
|
run /bin/bash -c "docker inspect -f '{{ .State.Status }}' $RANDOM_RUN_CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "running"
|
||||||
|
|
||||||
|
run /bin/bash -c "docker inspect $RANDOM_RUN_CID --format '{{ index .Config.Labels \"com.dokku.test-label\" }}'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "value"
|
||||||
|
|
||||||
|
run /bin/bash -c "docker stop $RANDOM_RUN_CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku cleanup"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
sleep 5 # wait for dokku cleanup to happen in the background
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(core) run (with tty)" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku run $TEST_APP ls /app/package.json"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(core) run (without tty)" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(core) run command from Procfile" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku run $TEST_APP custom 'hi dokku' | tail -n 1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output 'hi dokku'
|
||||||
|
}
|
||||||
73
tests/unit/git_1.bats
Normal file
73
tests/unit/git_1.bats
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(git) git:help" {
|
||||||
|
run /bin/bash -c "dokku git"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Manage app deploys via git"
|
||||||
|
help_output="$output"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku git:help"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "Manage app deploys via git"
|
||||||
|
assert_output "$help_output"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(git) ensure GIT_REV env var is set" {
|
||||||
|
deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:get $TEST_APP GIT_REV"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_exists
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(git) disable GIT_REV" {
|
||||||
|
run /bin/bash -c "dokku git:set $TEST_APP rev-env-var"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:get $TEST_APP GIT_REV"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output ""
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(git) customize the GIT_REV environment variable" {
|
||||||
|
run /bin/bash -c "dokku git:set $TEST_APP rev-env-var GIT_REV_ALT"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:get $TEST_APP GIT_REV_ALT"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_exists
|
||||||
|
}
|
||||||
@@ -12,20 +12,6 @@ teardown() {
|
|||||||
global_teardown
|
global_teardown
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(git) git:help" {
|
|
||||||
run /bin/bash -c "dokku git"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "Manage app deploys via git"
|
|
||||||
help_output="$output"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku git:help"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "Manage app deploys via git"
|
|
||||||
assert_output "$help_output"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(git) deploy specific branch" {
|
@test "(git) deploy specific branch" {
|
||||||
run /bin/bash -c "dokku git:set --global deploy-branch global-branch"
|
run /bin/bash -c "dokku git:set --global deploy-branch global-branch"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -62,52 +48,6 @@ teardown() {
|
|||||||
run /bin/bash -c "dokku git:set --global deploy-branch"
|
run /bin/bash -c "dokku git:set --global deploy-branch"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(git) ensure GIT_REV env var is set" {
|
|
||||||
deploy_app
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:get $TEST_APP GIT_REV"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_exists
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(git) disable GIT_REV" {
|
|
||||||
run /bin/bash -c "dokku git:set $TEST_APP rev-env-var"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
deploy_app
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:get $TEST_APP GIT_REV"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output ""
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(git) customize the GIT_REV environment variable" {
|
|
||||||
run /bin/bash -c "dokku git:set $TEST_APP rev-env-var GIT_REV_ALT"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
deploy_app
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:get $TEST_APP GIT_REV_ALT"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_exists
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(git) git:initialize" {
|
@test "(git) git:initialize" {
|
||||||
run /bin/bash -c "test -d $DOKKU_ROOT/$TEST_APP/refs"
|
run /bin/bash -c "test -d $DOKKU_ROOT/$TEST_APP/refs"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -69,100 +69,3 @@ teardown() {
|
|||||||
check_urls http://${TEST_APP}.dokku.me
|
check_urls http://${TEST_APP}.dokku.me
|
||||||
assert_http_success http://${TEST_APP}.dokku.me
|
assert_http_success http://${TEST_APP}.dokku.me
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST but real HOSTNAME)" {
|
|
||||||
rm "$DOKKU_ROOT/VHOST"
|
|
||||||
echo "${TEST_APP}.dokku.me" > "$DOKKU_ROOT/HOSTNAME"
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
|
|
||||||
check_urls http://${HOSTNAME}:[0-9]+
|
|
||||||
|
|
||||||
URLS=$(dokku --quiet urls "$TEST_APP")
|
|
||||||
for URL in $URLS; do
|
|
||||||
assert_http_success $URL
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv4 address set as HOSTNAME)" {
|
|
||||||
rm "$DOKKU_ROOT/VHOST"
|
|
||||||
echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME"
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
|
|
||||||
check_urls http://${HOSTNAME}:[0-9]+
|
|
||||||
|
|
||||||
URLS=$(dokku --quiet urls "$TEST_APP")
|
|
||||||
for URL in $URLS; do
|
|
||||||
assert_http_success $URL
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv6 address set as HOSTNAME)" {
|
|
||||||
rm "$DOKKU_ROOT/VHOST"
|
|
||||||
echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME"
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
|
|
||||||
check_urls http://${HOSTNAME}:[0-9]+
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add pre deploy)" {
|
|
||||||
rm "$DOKKU_ROOT/VHOST"
|
|
||||||
create_app
|
|
||||||
add_domain "www.test.app.dokku.me"
|
|
||||||
deploy_app
|
|
||||||
assert_nonssl_domain "www.test.app.dokku.me"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add post deploy)" {
|
|
||||||
rm "$DOKKU_ROOT/VHOST"
|
|
||||||
deploy_app
|
|
||||||
add_domain "www.test.app.dokku.me"
|
|
||||||
check_urls http://www.test.app.dokku.me
|
|
||||||
assert_http_success http://www.test.app.dokku.me
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (xip.io style hostnames)" {
|
|
||||||
echo "127.0.0.1.xip.io.dokku.me" > "$DOKKU_ROOT/VHOST"
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
check_urls http://${TEST_APP}.127.0.0.1.xip.io.dokku.me
|
|
||||||
assert_http_success http://${TEST_APP}.127.0.0.1.xip.io.dokku.me
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (dockerfile expose)" {
|
|
||||||
deploy_app dockerfile
|
|
||||||
|
|
||||||
add_domain "www.test.app.dokku.me"
|
|
||||||
check_urls http://${TEST_APP}.dokku.me:3000
|
|
||||||
check_urls http://${TEST_APP}.dokku.me:3003
|
|
||||||
check_urls http://www.test.app.dokku.me:3000
|
|
||||||
check_urls http://www.test.app.dokku.me:3003
|
|
||||||
assert_http_success http://${TEST_APP}.dokku.me:3000
|
|
||||||
assert_http_success http://${TEST_APP}.dokku.me:3003
|
|
||||||
assert_http_success http://www.test.app.dokku.me:3000
|
|
||||||
assert_http_success http://www.test.app.dokku.me:3003
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (multiple networks)" {
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
create_attach_network
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (global DOKKU_PROXY_PORT)" {
|
|
||||||
local GLOBAL_PORT=30999
|
|
||||||
run /bin/bash -c "dokku config:set --global DOKKU_PROXY_PORT=${GLOBAL_PORT}"
|
|
||||||
|
|
||||||
deploy_app
|
|
||||||
check_urls http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
|
|
||||||
assert_http_success http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku config:unset --global DOKKU_PROXY_PORT"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,102 +16,6 @@ teardown() {
|
|||||||
global_teardown
|
global_teardown
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx (no server tokens)" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | grep -E '^Server' | grep -E '[0-9]+'"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) logging" {
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
run [ -a "/var/log/nginx/$TEST_APP-access.log" ]
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run [ -a "/var/log/nginx/$TEST_APP-error.log" ]
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:access-logs $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:error-logs $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) log-path" {
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "off;"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "off;" 0
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "off;"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "off;" 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" {
|
@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" {
|
||||||
setup_test_tls
|
setup_test_tls
|
||||||
add_domain "node-js-app.dokku.me"
|
add_domain "node-js-app.dokku.me"
|
||||||
@@ -152,222 +56,3 @@ teardown() {
|
|||||||
assert_ssl_domain "www.test.dokku.me"
|
assert_ssl_domain "www.test.dokku.me"
|
||||||
assert_ssl_domain "www.test.app.dokku.me"
|
assert_ssl_domain "www.test.app.dokku.me"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (wildcard SSL and custom nginx template)" {
|
|
||||||
setup_test_tls wildcard
|
|
||||||
add_domain "wildcard1.dokku.me"
|
|
||||||
add_domain "wildcard2.dokku.me"
|
|
||||||
deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_ssl_nginx_template
|
|
||||||
|
|
||||||
assert_ssl_domain "wildcard1.dokku.me"
|
|
||||||
assert_ssl_domain "wildcard2.dokku.me"
|
|
||||||
assert_http_redirect "http://${CUSTOM_TEMPLATE_SSL_DOMAIN}" "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}:443/"
|
|
||||||
assert_http_success "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (custom nginx template - no ssl)" {
|
|
||||||
add_domain "www.test.app.dokku.me"
|
|
||||||
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP worker=1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
assert_nonssl_domain "www.test.app.dokku.me"
|
|
||||||
assert_http_success "customtemplate.dokku.me"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "${TEST_APP}-worker-5000"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:build-config (failed validate_nginx)" {
|
|
||||||
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP bad_custom_nginx_template
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:set hsts" {
|
|
||||||
setup_test_tls wildcard
|
|
||||||
local HSTS_CONF="/home/dokku/${TEST_APP}/nginx.conf.d/hsts.conf"
|
|
||||||
|
|
||||||
run deploy_app
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output_contains "Enabling HSTS"
|
|
||||||
|
|
||||||
run /bin/bash -c "test -f $HSTS_CONF"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=15724800'"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "cat $HSTS_CONF | grep preload"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP hsts-include-subdomains false"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP hsts-max-age 120"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=120'"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP hsts-preload true"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
run /bin/bash -c "cat $HSTS_CONF | grep preload"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP hsts false"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
assert_output_contains "Enabling HSTS" 0
|
|
||||||
|
|
||||||
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf.d/hsts.conf"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:set bind-address" {
|
|
||||||
run deploy_app
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6 ::1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "[::1]:80;"
|
|
||||||
assert_output_contains "127.0.0.1:80;"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "[::1]:80;" 0
|
|
||||||
assert_output_contains "127.0.0.1:80;" 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(nginx-vhosts) nginx:validate-config" {
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config --clean"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config $TEST_APP --clean"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku nginx:validate-config"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|||||||
71
tests/unit/nginx-vhosts_4.bats
Normal file
71
tests/unit/nginx-vhosts_4.bats
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
detach_delete_network
|
||||||
|
destroy_app
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (without global VHOST but real HOSTNAME)" {
|
||||||
|
rm "$DOKKU_ROOT/VHOST"
|
||||||
|
echo "${TEST_APP}.dokku.me" > "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
|
||||||
|
check_urls http://${HOSTNAME}:[0-9]+
|
||||||
|
|
||||||
|
URLS=$(dokku --quiet urls "$TEST_APP")
|
||||||
|
for URL in $URLS; do
|
||||||
|
assert_http_success $URL
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv4 address set as HOSTNAME)" {
|
||||||
|
rm "$DOKKU_ROOT/VHOST"
|
||||||
|
echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
|
||||||
|
check_urls http://${HOSTNAME}:[0-9]+
|
||||||
|
|
||||||
|
URLS=$(dokku --quiet urls "$TEST_APP")
|
||||||
|
for URL in $URLS; do
|
||||||
|
assert_http_success $URL
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv6 address set as HOSTNAME)" {
|
||||||
|
rm "$DOKKU_ROOT/VHOST"
|
||||||
|
echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
|
||||||
|
check_urls http://${HOSTNAME}:[0-9]+
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add pre deploy)" {
|
||||||
|
rm "$DOKKU_ROOT/VHOST"
|
||||||
|
create_app
|
||||||
|
add_domain "www.test.app.dokku.me"
|
||||||
|
deploy_app
|
||||||
|
assert_nonssl_domain "www.test.app.dokku.me"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add post deploy)" {
|
||||||
|
rm "$DOKKU_ROOT/VHOST"
|
||||||
|
deploy_app
|
||||||
|
add_domain "www.test.app.dokku.me"
|
||||||
|
check_urls http://www.test.app.dokku.me
|
||||||
|
assert_http_success http://www.test.app.dokku.me
|
||||||
|
}
|
||||||
62
tests/unit/nginx-vhosts_5.bats
Normal file
62
tests/unit/nginx-vhosts_5.bats
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
detach_delete_network
|
||||||
|
destroy_app
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (xip.io style hostnames)" {
|
||||||
|
echo "127.0.0.1.xip.io.dokku.me" > "$DOKKU_ROOT/VHOST"
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
check_urls http://${TEST_APP}.127.0.0.1.xip.io.dokku.me
|
||||||
|
assert_http_success http://${TEST_APP}.127.0.0.1.xip.io.dokku.me
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (dockerfile expose)" {
|
||||||
|
deploy_app dockerfile
|
||||||
|
|
||||||
|
add_domain "www.test.app.dokku.me"
|
||||||
|
check_urls http://${TEST_APP}.dokku.me:3000
|
||||||
|
check_urls http://${TEST_APP}.dokku.me:3003
|
||||||
|
check_urls http://www.test.app.dokku.me:3000
|
||||||
|
check_urls http://www.test.app.dokku.me:3003
|
||||||
|
assert_http_success http://${TEST_APP}.dokku.me:3000
|
||||||
|
assert_http_success http://${TEST_APP}.dokku.me:3003
|
||||||
|
assert_http_success http://www.test.app.dokku.me:3000
|
||||||
|
assert_http_success http://www.test.app.dokku.me:3003
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (multiple networks)" {
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
create_attach_network
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (global DOKKU_PROXY_PORT)" {
|
||||||
|
local GLOBAL_PORT=30999
|
||||||
|
run /bin/bash -c "dokku config:set --global DOKKU_PROXY_PORT=${GLOBAL_PORT}"
|
||||||
|
|
||||||
|
deploy_app
|
||||||
|
check_urls http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
|
||||||
|
assert_http_success http://${TEST_APP}.dokku.me:${GLOBAL_PORT}
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku config:unset --global DOKKU_PROXY_PORT"
|
||||||
|
}
|
||||||
312
tests/unit/nginx-vhosts_6.bats
Normal file
312
tests/unit/nginx-vhosts_6.bats
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak"
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app 0 $TEST_APP
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx (no server tokens)" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | grep -E '^Server' | grep -E '[0-9]+'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) logging" {
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
run [ -a "/var/log/nginx/$TEST_APP-access.log" ]
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run [ -a "/var/log/nginx/$TEST_APP-error.log" ]
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:access-logs $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:error-logs $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) log-path" {
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "off;"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "off;" 0
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "off;"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "off;" 0
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" {
|
||||||
|
setup_test_tls
|
||||||
|
add_domain "node-js-app.dokku.me"
|
||||||
|
add_domain "test.dokku.me"
|
||||||
|
deploy_app
|
||||||
|
dokku nginx:show-config $TEST_APP
|
||||||
|
assert_ssl_domain "node-js-app.dokku.me"
|
||||||
|
assert_http_redirect "http://test.dokku.me" "https://test.dokku.me:443/"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
|
||||||
|
setup_test_tls wildcard
|
||||||
|
add_domain "wildcard1.dokku.me"
|
||||||
|
add_domain "wildcard2.dokku.me"
|
||||||
|
deploy_app
|
||||||
|
dokku nginx:show-config $TEST_APP
|
||||||
|
assert_ssl_domain "wildcard1.dokku.me"
|
||||||
|
assert_ssl_domain "wildcard2.dokku.me"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:set hsts" {
|
||||||
|
setup_test_tls wildcard
|
||||||
|
local HSTS_CONF="/home/dokku/${TEST_APP}/nginx.conf.d/hsts.conf"
|
||||||
|
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "Enabling HSTS"
|
||||||
|
|
||||||
|
run /bin/bash -c "test -f $HSTS_CONF"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=15724800'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "cat $HSTS_CONF | grep preload"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP hsts-include-subdomains false"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP hsts-max-age 120"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=120'"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP hsts-preload true"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "cat $HSTS_CONF | grep preload"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP hsts false"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_contains "Enabling HSTS" 0
|
||||||
|
|
||||||
|
run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf.d/hsts.conf"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:set bind-address" {
|
||||||
|
run deploy_app
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6 ::1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "[::1]:80;"
|
||||||
|
assert_output_contains "127.0.0.1:80;"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:build-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "[::1]:80;" 0
|
||||||
|
assert_output_contains "127.0.0.1:80;" 0
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:validate-config" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config --clean"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config $TEST_APP --clean"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:validate-config"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
57
tests/unit/nginx-vhosts_7.bats
Normal file
57
tests/unit/nginx-vhosts_7.bats
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak"
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app 0 $TEST_APP
|
||||||
|
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
|
||||||
|
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME"
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (wildcard SSL and custom nginx template)" {
|
||||||
|
setup_test_tls wildcard
|
||||||
|
add_domain "wildcard1.dokku.me"
|
||||||
|
add_domain "wildcard2.dokku.me"
|
||||||
|
deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_ssl_nginx_template
|
||||||
|
|
||||||
|
assert_ssl_domain "wildcard1.dokku.me"
|
||||||
|
assert_ssl_domain "wildcard2.dokku.me"
|
||||||
|
assert_http_redirect "http://${CUSTOM_TEMPLATE_SSL_DOMAIN}" "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}:443/"
|
||||||
|
assert_http_success "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (custom nginx template - no ssl)" {
|
||||||
|
add_domain "www.test.app.dokku.me"
|
||||||
|
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP worker=1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_nonssl_domain "www.test.app.dokku.me"
|
||||||
|
assert_http_success "customtemplate.dokku.me"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "${TEST_APP}-worker-5000"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(nginx-vhosts) nginx:build-config (failed validate_nginx)" {
|
||||||
|
run deploy_app nodejs-express dokku@dokku.me:$TEST_APP bad_custom_nginx_template
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
124
tests/unit/ps-dockerfile-1.bats
Normal file
124
tests/unit/ps-dockerfile-1.bats
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps) dockerfile" {
|
||||||
|
deploy_app dockerfile
|
||||||
|
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:start $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:restart $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps:scale) dockerfile non-existent process" {
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
destroy_app
|
||||||
|
create_app
|
||||||
|
deploy_app dockerfile-procfile
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps:scale) dockerfile" {
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
deploy_app dockerfile
|
||||||
|
CIDS=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
CIDS=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=0"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
CIDS=""
|
||||||
|
shopt -s nullglob
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
run /bin/bash -c "[[ -z \"$CIDS\" ]]"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
@@ -9,12 +9,40 @@ setup() {
|
|||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
destroy_app
|
destroy_app
|
||||||
destroy_app 0 "$MYAPP" || true
|
|
||||||
global_teardown
|
global_teardown
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(ps) herokuish" {
|
@test "(ps:scale) dockerfile dokku-scale" {
|
||||||
deploy_app
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
deploy_app dockerfile-dokku-scale
|
||||||
|
CIDS=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:report $TEST_APP --ps-can-scale"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "false"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps) dockerfile with procfile" {
|
||||||
|
deploy_app dockerfile-procfile
|
||||||
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
@@ -60,24 +88,36 @@ teardown() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(ps:scale) herokuish" {
|
@test "(ps) dockerfile with bad procfile" {
|
||||||
|
run deploy_app dockerfile-procfile-bad
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
run create_app
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps:scale) dockerfile with procfile" {
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2"
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
deploy_app
|
deploy_app dockerfile-procfile
|
||||||
for PROC_TYPE in web worker; do
|
for PROC_TYPE in web worker; do
|
||||||
CIDS=""
|
run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc"
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2"
|
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
goodlines=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||||
|
cid=$(< $CID_FILE)
|
||||||
|
assert_output_contains "$cid"
|
||||||
|
goodlines+=$(echo "$output" | grep "$cid")
|
||||||
|
done
|
||||||
|
output="$goodlines"
|
||||||
|
assert_output_contains "node ${PROC_TYPE}.js" 2
|
||||||
done
|
done
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1"
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1"
|
||||||
@@ -85,23 +125,25 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
for PROC_TYPE in web worker; do
|
for PROC_TYPE in web worker; do
|
||||||
CIDS=""
|
run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc"
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
|
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
goodlines=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||||
|
cid=$(< $CID_FILE)
|
||||||
|
assert_output_contains "$cid"
|
||||||
|
goodlines+=$(echo "$output" | grep "$cid")
|
||||||
|
done
|
||||||
|
output="$goodlines"
|
||||||
|
assert_output_contains "node ${PROC_TYPE}.js"
|
||||||
done
|
done
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0 invalid-process=0"
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
for PROC_TYPE in web worker invalid-process; do
|
for PROC_TYPE in web worker; do
|
||||||
CIDS=""
|
CIDS=""
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||||
@@ -115,29 +157,3 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(ps:restore) herokuish" {
|
|
||||||
MYAPP="manual-randomtestapp-1"
|
|
||||||
create_app "$MYAPP"
|
|
||||||
deploy_app
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku apps:list"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:restore"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku --quiet ps:report $TEST_APP | grep -q exited"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
@@ -1,270 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
|
|
||||||
load test_helper
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
global_setup
|
|
||||||
create_app
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown() {
|
|
||||||
destroy_app
|
|
||||||
global_teardown
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps) dockerfile" {
|
|
||||||
deploy_app dockerfile
|
|
||||||
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:start $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:restart $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps:scale) dockerfile non-existent process" {
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
destroy_app
|
|
||||||
create_app
|
|
||||||
deploy_app dockerfile-procfile
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps:scale) dockerfile" {
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
deploy_app dockerfile
|
|
||||||
CIDS=""
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
CIDS=""
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=0"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
CIDS=""
|
|
||||||
shopt -s nullglob
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
run /bin/bash -c "[[ -z \"$CIDS\" ]]"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps:scale) dockerfile dokku-scale" {
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
deploy_app dockerfile-dokku-scale
|
|
||||||
CIDS=""
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:report $TEST_APP --ps-can-scale"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "false"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps) dockerfile with procfile" {
|
|
||||||
deploy_app dockerfile-procfile
|
|
||||||
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:start $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:restart $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
|
||||||
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps) dockerfile with bad procfile" {
|
|
||||||
run deploy_app dockerfile-procfile-bad
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
run create_app
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(ps:scale) dockerfile with procfile" {
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
deploy_app dockerfile-procfile
|
|
||||||
for PROC_TYPE in web worker; do
|
|
||||||
run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
goodlines=""
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
|
||||||
cid=$(< $CID_FILE)
|
|
||||||
assert_output_contains "$cid"
|
|
||||||
goodlines+=$(echo "$output" | grep "$cid")
|
|
||||||
done
|
|
||||||
output="$goodlines"
|
|
||||||
assert_output_contains "node ${PROC_TYPE}.js" 2
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for PROC_TYPE in web worker; do
|
|
||||||
run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
goodlines=""
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
|
||||||
cid=$(< $CID_FILE)
|
|
||||||
assert_output_contains "$cid"
|
|
||||||
goodlines+=$(echo "$output" | grep "$cid")
|
|
||||||
done
|
|
||||||
output="$goodlines"
|
|
||||||
assert_output_contains "node ${PROC_TYPE}.js"
|
|
||||||
done
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
for PROC_TYPE in web worker; do
|
|
||||||
CIDS=""
|
|
||||||
shopt -s nullglob
|
|
||||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
|
||||||
CIDS+=$(< $CID_FILE)
|
|
||||||
CIDS+=" "
|
|
||||||
done
|
|
||||||
shopt -u nullglob
|
|
||||||
run /bin/bash -c "[[ -z \"$CIDS\" ]]"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
done
|
|
||||||
}
|
|
||||||
61
tests/unit/ps-herokuish-1.bats
Normal file
61
tests/unit/ps-herokuish-1.bats
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
destroy_app 0 "$MYAPP" || true
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps) herokuish" {
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:start $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:restart $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
}
|
||||||
96
tests/unit/ps-herokuish-2.bats
Normal file
96
tests/unit/ps-herokuish-2.bats
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
destroy_app 0 "$MYAPP" || true
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps:scale) herokuish" {
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
deploy_app
|
||||||
|
for PROC_TYPE in web worker; do
|
||||||
|
CIDS=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for PROC_TYPE in web worker; do
|
||||||
|
CIDS=""
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g")
|
||||||
|
run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0 invalid-process=0"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
for PROC_TYPE in web worker invalid-process; do
|
||||||
|
CIDS=""
|
||||||
|
shopt -s nullglob
|
||||||
|
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do
|
||||||
|
CIDS+=$(< $CID_FILE)
|
||||||
|
CIDS+=" "
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
run /bin/bash -c "[[ -z \"$CIDS\" ]]"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ps:restore) herokuish" {
|
||||||
|
MYAPP="manual-randomtestapp-1"
|
||||||
|
create_app "$MYAPP"
|
||||||
|
deploy_app
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:stop $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku apps:list"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku ps:restore"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --quiet ps:report $TEST_APP | grep -q exited"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
@@ -100,85 +100,6 @@ teardown() {
|
|||||||
assert_output "0"
|
assert_output "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(resource) resource:reserve" {
|
|
||||||
run /bin/bash -c "dokku resource:reserve $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output_contains "resource reservation $TEST_APP information"
|
|
||||||
|
|
||||||
deploy_app
|
|
||||||
run /bin/bash -c "dokku resource:reserve --memory 512MB $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "0"
|
|
||||||
|
|
||||||
dokku ps:rebuild "$TEST_APP"
|
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "536870912"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve --memory 1024MB --process-type worker $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve --cpu 0.5 --process-type worker $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku ps:rebuild "$TEST_APP"
|
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "536870912"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku ps:rebuild "$TEST_APP"
|
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "536870912"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku ps:rebuild "$TEST_APP"
|
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "536870912"
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku ps:rebuild "$TEST_APP"
|
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_output "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "(resource) resource:limit-clear" {
|
@test "(resource) resource:limit-clear" {
|
||||||
run /bin/bash -c "dokku resource:limit-clear $TEST_APP"
|
run /bin/bash -c "dokku resource:limit-clear $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -190,15 +111,3 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "(resource) resource:reserve-clear" {
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP"
|
|
||||||
echo "output: $output"
|
|
||||||
echo "status: $status"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
104
tests/unit/resource_2.bats
Normal file
104
tests/unit/resource_2.bats
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(resource) resource:reserve" {
|
||||||
|
run /bin/bash -c "dokku resource:reserve $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output_contains "resource reservation $TEST_APP information"
|
||||||
|
|
||||||
|
deploy_app
|
||||||
|
run /bin/bash -c "dokku resource:reserve --memory 512MB $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "0"
|
||||||
|
|
||||||
|
dokku ps:rebuild "$TEST_APP"
|
||||||
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "536870912"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve --memory 1024MB --process-type worker $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve --cpu 0.5 --process-type worker $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
dokku ps:rebuild "$TEST_APP"
|
||||||
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "536870912"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
dokku ps:rebuild "$TEST_APP"
|
||||||
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "536870912"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
dokku ps:rebuild "$TEST_APP"
|
||||||
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "536870912"
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve-clear $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
dokku ps:rebuild "$TEST_APP"
|
||||||
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_output "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(resource) resource:reserve-clear" {
|
||||||
|
run /bin/bash -c "dokku resource:reserve-clear $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user