tests: use github actions instead of circleci for test running
This commit is contained in:
@@ -9,27 +9,37 @@ install_dependencies() {
|
||||
mkdir -p "$ROOT_DIR/build/"
|
||||
HEROKUISH_VERSION=$(grep HEROKUISH_VERSION "${ROOT_DIR}/Makefile" | head -n1 | cut -d' ' -f3)
|
||||
HEROKUISH_PACKAGE_NAME="herokuish_${HEROKUISH_VERSION}_amd64.deb"
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/herokuish_${HEROKUISH_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${HEROKUISH_PACKAGE_NAME}"
|
||||
if [[ ! -f "$ROOT_DIR/build/${HEROKUISH_PACKAGE_NAME}" ]]; then
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/herokuish_${HEROKUISH_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${HEROKUISH_PACKAGE_NAME}"
|
||||
fi
|
||||
|
||||
PLUGN_VERSION=$(grep PLUGN_VERSION "${ROOT_DIR}/Makefile" | head -n1 | cut -d' ' -f3)
|
||||
PLUGN_PACKAGE_NAME="plugn_${PLUGN_VERSION}_amd64.deb"
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/plugn_${PLUGN_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${PLUGN_PACKAGE_NAME}"
|
||||
if [[ ! -f "$ROOT_DIR/build/${PLUGN_PACKAGE_NAME}" ]]; then
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/plugn_${PLUGN_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${PLUGN_PACKAGE_NAME}"
|
||||
fi
|
||||
|
||||
SSHCOMMAND_VERSION=$(grep SSHCOMMAND_VERSION "${ROOT_DIR}/Makefile" | head -n1 | cut -d' ' -f3)
|
||||
SSHCOMMAND_PACKAGE_NAME="sshcommand_${SSHCOMMAND_VERSION}_amd64.deb"
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/sshcommand_${SSHCOMMAND_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${SSHCOMMAND_PACKAGE_NAME}"
|
||||
if [[ ! -f "$ROOT_DIR/build/${SSHCOMMAND_PACKAGE_NAME}" ]]; then
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/sshcommand_${SSHCOMMAND_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${SSHCOMMAND_PACKAGE_NAME}"
|
||||
fi
|
||||
|
||||
SIGIL_VERSION=$(grep SIGIL_VERSION "${ROOT_DIR}/deb.mk" | head -n1 | cut -d' ' -f3)
|
||||
SIGIL_PACKAGE_NAME="gliderlabs-sigil_${SIGIL_VERSION}_amd64.deb"
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/gliderlabs-sigil_${SIGIL_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${SIGIL_PACKAGE_NAME}"
|
||||
if [[ ! -f "$ROOT_DIR/build/${SIGIL_PACKAGE_NAME}" ]]; then
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/gliderlabs-sigil_${SIGIL_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${SIGIL_PACKAGE_NAME}"
|
||||
fi
|
||||
|
||||
PROCFILE_VERSION=$(grep PROCFILE_VERSION "${ROOT_DIR}/Makefile" | head -n1 | cut -d' ' -f3)
|
||||
PROCFILE_UTIL_PACKAGE_NAME="procfile-util_${PROCFILE_VERSION}_amd64.deb"
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/procfile-util_${PROCFILE_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${PROCFILE_UTIL_PACKAGE_NAME}"
|
||||
if [[ ! -f "$ROOT_DIR/build/${PROCFILE_UTIL_PACKAGE_NAME}" ]]; then
|
||||
curl -L "https://packagecloud.io/dokku/dokku/packages/ubuntu/bionic/procfile-util_${PROCFILE_VERSION}_amd64.deb/download.deb" -o "$ROOT_DIR/build/${PROCFILE_UTIL_PACKAGE_NAME}"
|
||||
fi
|
||||
|
||||
sudo add-apt-repository -y ppa:nginx/stable
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get -qq -y --no-install-recommends install cgroupfs-mount dos2unix jq nginx
|
||||
sudo apt-get -qq -y --no-install-recommends install cgroupfs-mount dos2unix jq nginx debconf-utils
|
||||
sudo cp "${ROOT_DIR}/tests/dhparam.pem" /etc/nginx/dhparam.pem
|
||||
|
||||
sudo dpkg -i "${ROOT_DIR}/build/$HEROKUISH_PACKAGE_NAME" \
|
||||
@@ -58,13 +68,23 @@ install_dokku() {
|
||||
build_dokku
|
||||
fi
|
||||
|
||||
echo "dokku dokku/hostname string dokku.me" | sudo debconf-set-selections
|
||||
echo "dokku dokku/key_file string /root/.ssh/id_rsa.pub" | sudo debconf-set-selections
|
||||
echo "dokku dokku/nginx_enable boolean true" | sudo debconf-set-selections
|
||||
echo "dokku dokku/skip_key_file boolean true" | sudo debconf-set-selections
|
||||
echo "dokku dokku/vhost_enable boolean true" | sudo debconf-set-selections
|
||||
echo "dokku dokku/web_config boolean false" | sudo debconf-set-selections
|
||||
cat << EOF | sudo debconf-set-selections
|
||||
dokku dokku/hostname string dokku.me
|
||||
dokku dokku/key_file string /root/.ssh/id_rsa.pub
|
||||
dokku dokku/nginx_enable boolean true
|
||||
dokku dokku/skip_key_file boolean true
|
||||
dokku dokku/vhost_enable boolean true
|
||||
dokku dokku/web_config boolean false
|
||||
EOF
|
||||
|
||||
echo "-----> Start debconf selections"
|
||||
sudo debconf-get-selections | grep ^dokku
|
||||
echo "-----> End debconf selections"
|
||||
|
||||
sleep 5
|
||||
echo "-----> Start install $(cat "${ROOT_DIR}/build/deb-filename") via dpkg"
|
||||
sudo TRACE=1 dpkg -i "$(cat "${ROOT_DIR}/build/deb-filename")"
|
||||
echo "-----> End install $(cat "${ROOT_DIR}/build/deb-filename") via dpkg"
|
||||
}
|
||||
|
||||
build_dokku_docker_image() {
|
||||
@@ -94,7 +114,7 @@ check_container() {
|
||||
while true; do
|
||||
echo "$(date) [count: $cnt]: waiting for dokku startup"
|
||||
is_up=$(
|
||||
docker exec -ti dokku ps -ef | grep "/usr/sbin/sshd -D" >/dev/null 2>&1
|
||||
docker exec dokku ps -ef | grep "/usr/sbin/sshd -D" >/dev/null 2>&1
|
||||
echo $?
|
||||
)
|
||||
if [[ $is_up -eq 0 ]]; then
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
@@ -37,7 +36,7 @@ teardown() {
|
||||
CID=$(docker ps -a -q -f "ancestor=dokku/${TEST_APP}" -f "label=dokku_phase_script=postdeploy")
|
||||
DOCKER_COMMIT_LABEL_ARGS=("--change" "LABEL org.label-schema.schema-version=1.0" "--change" "LABEL org.label-schema.vendor=dokku" "--change" "LABEL com.dokku.app-name=$TEST_APP")
|
||||
IMAGE_ID=$(docker commit "${DOCKER_COMMIT_LABEL_ARGS[@]}" $CID dokku-test/${TEST_APP})
|
||||
run /bin/bash -c "docker run --rm -ti $IMAGE_ID ls /app/postdeploy.test"
|
||||
run /bin/bash -c "docker run --rm $IMAGE_ID ls /app/postdeploy.test"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
@@ -23,9 +23,13 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "(client) no args should print help" {
|
||||
run /bin/bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh | head -1 | grep -E 'Usage: dokku \[.+\] COMMAND <app>.*'"
|
||||
# dokku container is not run with a TTY on Github Actions so we don't get normal output
|
||||
# https://github.com/actions/runner/issues/241
|
||||
run /bin/bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output_contains "Manage apps"
|
||||
assert_output_contains "Manage buildpack settings for an app"
|
||||
assert_success
|
||||
}
|
||||
|
||||
|
||||
@@ -16,144 +16,6 @@ teardown() {
|
||||
global_teardown
|
||||
}
|
||||
|
||||
@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) access-log-format" {
|
||||
deploy_app
|
||||
|
||||
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-format combined"
|
||||
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 "-access.log combined;"
|
||||
|
||||
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-format"
|
||||
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 "-access.log;"
|
||||
}
|
||||
|
||||
@test "(nginx-vhosts) nginx:set proxy-read-timeout" {
|
||||
deploy_app
|
||||
|
||||
@@ -358,23 +220,3 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_output_contains "proxy_busy_buffers_size 10k;" 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"
|
||||
}
|
||||
|
||||
175
tests/unit/nginx-vhosts_9.bats
Normal file
175
tests/unit/nginx-vhosts_9.bats
Normal file
@@ -0,0 +1,175 @@
|
||||
#!/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) 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) access-log-format" {
|
||||
deploy_app
|
||||
|
||||
run /bin/bash -c "dokku nginx:set $TEST_APP access-log-format combined"
|
||||
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 "-access.log combined;"
|
||||
|
||||
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-format"
|
||||
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 "-access.log;"
|
||||
}
|
||||
|
||||
@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"
|
||||
}
|
||||
Reference in New Issue
Block a user