Add test for cron concurrency policy
This commit is contained in:
1 parent
b8f32f6ea4
commit
983115c827
4 files changed
+45
-4
No files matched your search
@@ -23,7 +23,7 @@
|
|||||||
- `command`: (string, required)
|
- `command`: (string, required)
|
||||||
- `maintenance`: (boolean, optional)
|
- `maintenance`: (boolean, optional)
|
||||||
- `schedule`: (string, required)
|
- `schedule`: (string, required)
|
||||||
- `concurrency_policy`: (string, optional, default: `allow`, options: `allow`, `deny`, `replace`)
|
- `concurrency_policy`: (string, optional, default: `allow`, options: `allow`, `forbid`, `replace`)
|
||||||
|
|
||||||
## Formation
|
## Formation
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func CommandList(appName string, format string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if format == "stdout" {
|
if format == "stdout" {
|
||||||
output := []string{"ID | Schedule | Maintenance | Command"}
|
output := []string{"ID | Schedule | Concurrency | Maintenance | Command"}
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
maintenance := "false"
|
maintenance := "false"
|
||||||
if task.Maintenance {
|
if task.Maintenance {
|
||||||
@@ -52,7 +52,7 @@ func CommandList(appName string, format string) error {
|
|||||||
maintenance = "true (app)"
|
maintenance = "true (app)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output = append(output, fmt.Sprintf("%s | %s | %s | %s", task.ID, task.Schedule, maintenance, task.Command))
|
output = append(output, fmt.Sprintf("%s | %s | %s | %t | %s", task.ID, task.Schedule, task.ConcurrencyPolicy, maintenance, task.Command))
|
||||||
}
|
}
|
||||||
|
|
||||||
result := columnize.SimpleFormat(output)
|
result := columnize.SimpleFormat(output)
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ trigger-scheduler-docker-local-scheduler-run() {
|
|||||||
if [[ -n "$DOKKU_CONCURRENCY_POLICY" ]]; then
|
if [[ -n "$DOKKU_CONCURRENCY_POLICY" ]]; then
|
||||||
concurrency_policy="$DOKKU_CONCURRENCY_POLICY"
|
concurrency_policy="$DOKKU_CONCURRENCY_POLICY"
|
||||||
fi
|
fi
|
||||||
concurrency_policy="$DOKKU_CONCURRENCY_POLICY"
|
|
||||||
DOCKER_ARGS+=" --label=com.dokku.concurrency-policy=$concurrency_policy"
|
DOCKER_ARGS+=" --label=com.dokku.concurrency-policy=$concurrency_policy"
|
||||||
|
|
||||||
if [[ "$concurrency_policy" == "forbid" ]]; then
|
if [[ "$concurrency_policy" == "forbid" ]]; then
|
||||||
|
|||||||
@@ -235,6 +235,30 @@ teardown() {
|
|||||||
assert_output "['task.py', 'schedule', 'now']"
|
assert_output "['task.py', 'schedule', 'now']"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(cron) cron:run concurrency_policy forbid" {
|
||||||
|
run deploy_app dockerfile dokku@$DOKKU_DOMAIN:$TEST_APP template_cron_file_concurrency_forbid
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
cron_id="$(dokku cron:list $TEST_APP --format json | jq -r '.[0].id')"
|
||||||
|
run /bin/bash -c "echo cron $cron_id"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
assert_output_exists
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku cron:run $TEST_APP $cron_id --detach"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku cron:run $TEST_APP $cron_id"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
@test "(cron) cron:suspend cron:resume" {
|
@test "(cron) cron:suspend cron:resume" {
|
||||||
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP template_cron_file_valid_multiple
|
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP template_cron_file_valid_multiple
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -427,3 +451,21 @@ template_cron_file_valid_multiple() {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template_cron_file_concurrency_forbid() {
|
||||||
|
local APP="$1"
|
||||||
|
local APP_REPO_DIR="$2"
|
||||||
|
[[ -z "$APP" ]] && local APP="$TEST_APP"
|
||||||
|
echo "injecting valid cron app.json -> $APP_REPO_DIR/app.json"
|
||||||
|
cat <<EOF >"$APP_REPO_DIR/app.json"
|
||||||
|
{
|
||||||
|
"cron": [
|
||||||
|
{
|
||||||
|
"command": "sleep 5",
|
||||||
|
"schedule": "0 0 * * *",
|
||||||
|
"concurrency_policy": "forbid"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
Reference in new issue
Block a user