The bats coverage for plugin :report keys has been uneven since the raw/global/computed split landed in PR #8640. This commit adds a single combined triplet test per settable property across app-json, builder, builder-dockerfile, builder-herokuish, builder-lambda, builder-nixpacks, builder-pack, builder-railpack, buildpacks, cron (maintenance), git (keep-git-dir, rev-env-var, source-image), logs (vector-sink, vector-global-image, vector-global-networks), network (attach-post-create, attach-post-deploy, initial-network), proxy (per-app type), ps (stop-timeout-seconds), registry (image-repo, push-on-release, push-extra-tags), storage (build/deploy/run mounts), and adds a new tests/unit/scheduler.bats and tests/unit/nginx-vhosts_properties.bats. Brings ps `procfile-path` and `stop-timeout-seconds` global getters in line with the #8640 convention (raw global, default resolved in computed). Documents the read-only and internal properties that surface in `:report` (or are written by Dokku) but cannot be managed by `:set` in a new `## Internal properties` section appended to each affected plugin's docs page.
345 lines
9.9 KiB
Bash
345 lines
9.9 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup_file() {
|
|
install_pack
|
|
}
|
|
|
|
setup() {
|
|
global_setup
|
|
create_app
|
|
}
|
|
|
|
teardown() {
|
|
destroy_app
|
|
global_teardown
|
|
}
|
|
|
|
@test "(builder-pack:report) info-flag works before deploy" {
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-projecttoml-path"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path project.alt.toml"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-projecttoml-path"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output "project.alt.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-invalid-flag"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_failure
|
|
assert_output_contains "Invalid flag passed"
|
|
}
|
|
|
|
@test "(builder-pack:report) --global --builder-pack-global-projecttoml-path" {
|
|
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path project.alt.toml"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:report --global --builder-pack-global-projecttoml-path"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output "project.alt.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
}
|
|
|
|
@test "(builder-pack:report) projecttoml-path raw vs computed vs global" {
|
|
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-projecttoml-path"
|
|
assert_success
|
|
assert_output_not_exists
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-global-projecttoml-path"
|
|
assert_success
|
|
assert_output_not_exists
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-computed-projecttoml-path"
|
|
assert_success
|
|
assert_output "project.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path project.global.toml"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-global-projecttoml-path"
|
|
assert_success
|
|
assert_output "project.global.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-computed-projecttoml-path"
|
|
assert_success
|
|
assert_output "project.global.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path project.app.toml"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-projecttoml-path"
|
|
assert_success
|
|
assert_output "project.app.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-global-projecttoml-path"
|
|
assert_success
|
|
assert_output "project.global.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:report $TEST_APP --builder-pack-computed-projecttoml-path"
|
|
assert_success
|
|
assert_output "project.app.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder-pack:set --global projecttoml-path"
|
|
assert_success
|
|
}
|
|
|
|
@test "(builder-pack:set)" {
|
|
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder:set $TEST_APP selected pack"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku buildpacks:set-property $TEST_APP stack heroku/builder:24"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP add_requirements_txt_cnb
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'Building with buildpack 1' 0
|
|
assert_output_contains 'Installing dependencies using pip'
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path nonexistent.toml"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'Building with buildpack 1' 0
|
|
assert_output_contains 'Installing dependencies using pip'
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path project2.toml"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'Building with buildpack 1'
|
|
assert_output_contains 'Installing dependencies using pip' 0
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku ps:rebuild $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'Building with buildpack 1' 0
|
|
assert_output_contains 'Installing dependencies using pip'
|
|
}
|
|
|
|
@test "(builder-pack) run" {
|
|
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder:set $TEST_APP selected pack"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP add_requirements_txt_cnb
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'from cnb stack'
|
|
assert_output_contains 'Building with buildpack 1' 0
|
|
assert_output_contains 'Installing dependencies using pip'
|
|
|
|
run /bin/bash -c "dokku run $TEST_APP python3 task.py test"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output "['task.py', 'test']"
|
|
|
|
run /bin/bash -c "dokku --quiet run $TEST_APP task"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output "['task.py', 'test']"
|
|
|
|
run /bin/bash -c "dokku run $TEST_APP env"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains "SECRET_KEY=fjdkslafjdk"
|
|
}
|
|
|
|
@test "(builder-pack) git:from-image without a Procfile" {
|
|
run /bin/bash -c "dokku git:from-image $TEST_APP dokku/smoke-test-gradle-app:1"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
}
|
|
|
|
@test "(ps) cnb env vars" {
|
|
run /bin/bash -c "dokku config:set $TEST_APP APP_RESPECTS_ENV_VARS=1"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder:set $TEST_APP selected pack"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP add_requirements_txt_cnb
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "curl $(dokku url $TEST_APP)/env"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains '"APP_RESPECTS_ENV_VARS": "1"'
|
|
}
|
|
|
|
@test "(builder-pack) cron:run" {
|
|
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder:set $TEST_APP selected pack"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP cron_run_wrapper
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'from cnb stack'
|
|
assert_output_contains 'Building with buildpack 1' 0
|
|
assert_output_contains 'Installing dependencies using pip'
|
|
|
|
cron_id="$(dokku cron:list $TEST_APP --format json | jq -r '.[0].id')"
|
|
run /bin/bash -c "echo $cron_id"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_exists
|
|
|
|
run /bin/bash -c "dokku cron:run $TEST_APP $cron_id"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output "['task.py']"
|
|
}
|
|
|
|
@test "(builder-pack) cron:run with Procfile reference" {
|
|
run /bin/bash -c "dokku config:set $TEST_APP SECRET_KEY=fjdkslafjdk"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku builder:set $TEST_APP selected pack"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP cron_run_procfile_wrapper
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_contains 'from cnb stack'
|
|
assert_output_contains 'Building with buildpack 1' 0
|
|
assert_output_contains 'Installing dependencies using pip'
|
|
|
|
cron_id="$(dokku cron:list $TEST_APP --format json | jq -r '.[0].id')"
|
|
run /bin/bash -c "echo $cron_id"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output_exists
|
|
|
|
run /bin/bash -c "dokku --quiet cron:run $TEST_APP $cron_id"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
assert_output "['task.py', 'test']"
|
|
}
|
|
|
|
@test "(builder-pack) core-post-extract renames the configured project.toml" {
|
|
echo "" >"$BATS_TEST_TMPDIR/project2.toml"
|
|
|
|
run /bin/bash -c "dokku builder-pack:set $TEST_APP projecttoml-path project2.toml"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run_plugin_script builder-pack core-post-extract "$TEST_APP" "$BATS_TEST_TMPDIR" HEAD
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "test -f $BATS_TEST_TMPDIR/project.toml"
|
|
assert_success
|
|
|
|
run /bin/bash -c "test ! -e $BATS_TEST_TMPDIR/project2.toml"
|
|
assert_success
|
|
}
|
|
|
|
cron_run_wrapper() {
|
|
local APP="$1"
|
|
local APP_REPO_DIR="$2"
|
|
[[ -z "$APP" ]] && local APP="$TEST_APP"
|
|
APP_REPO_DIR="$(realpath "$APP_REPO_DIR")"
|
|
|
|
add_requirements_txt "$APP" "$APP_REPO_DIR"
|
|
ls -lah "$APP_REPO_DIR"
|
|
mv -f "$APP_REPO_DIR/app-cnb-cron.json" "$APP_REPO_DIR/app.json"
|
|
}
|
|
|
|
cron_run_procfile_wrapper() {
|
|
local APP="$1"
|
|
local APP_REPO_DIR="$2"
|
|
[[ -z "$APP" ]] && local APP="$TEST_APP"
|
|
APP_REPO_DIR="$(realpath "$APP_REPO_DIR")"
|
|
|
|
add_requirements_txt "$APP" "$APP_REPO_DIR"
|
|
ls -lah "$APP_REPO_DIR"
|
|
mv -f "$APP_REPO_DIR/app-cnb-cron-procfile.json" "$APP_REPO_DIR/app.json"
|
|
}
|