test(gitea_runner): pin the disk check and refused-input messages
Build / build (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 0s
Molecule / molecule (pull_request) Canceled after 0s

The weekly schedule and image age cases matched text the disk check
schedule message also holds; match each assert's own message. Add a
case at exactly the root's use so the strict comparison is pinned, and
check the below message so a df failure cannot pass for it.

Refs #319

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-23 18:35:53 +00:00
1 parent e91c074373
commit ee4cb160ea
1 file changed
+13 -9
+13 -9
View File
@@ -311,8 +311,8 @@
loop_control:
label: "{{ item.gitea_runner_test_case.name }}"
# The above case sets the threshold one below the root's use, read just before (df rounds up,
# so a used root is at least 1%); a tmpfs holding a few lock files is never above 50%.
# The above and at-use cases set the threshold one below and equal to the root's use, read
# just before (df rounds up, so a used root is at least 1%); /run/lock is never above 50%.
- name: Run each disk check case
ansible.builtin.shell:
cmd: |
@@ -320,13 +320,15 @@
{{ ('touch fail-' ~ gitea_runner_test_case.fail) if gitea_runner_test_case.fail else ':' }}
echo '{{ gitea_runner_test_case.root }}' > root
threshold={{ gitea_runner_test_case.threshold }}
if [ "$threshold" = below-use ]; then
df -P / > df-root && threshold=$(($(awk 'NR == 2 { sub(/%$/, "", $5); print $5 }' df-root) - 1))
fi
{% if gitea_runner_test_case.threshold in ['below-use', 'use'] %}
df -P / > df-root && use=$(awk 'NR == 2 { sub(/%$/, "", $5); print $5 }' df-root)
threshold=$((use - {{ 1 if gitea_runner_test_case.threshold == 'below-use' else 0 }}))
{% endif %}
/usr/local/sbin/gitea-runner-docker-prune-disk-check "$threshold"
loop:
- {name: above, root: /, threshold: below-use, fail: "", rc: 0}
- {name: below, root: /run/lock, threshold: 50, fail: "", rc: 1}
- {name: below, root: /run/lock, threshold: 50, fail: "", rc: 1, out: "% full, not above 50%: skipping the prune"}
- {name: at-use, root: /, threshold: use, fail: "", rc: 1, out: "not above"}
- {name: info-fails, root: /, threshold: below-use, fail: info, rc: 1}
- {name: root-missing, root: /nonexistent, threshold: 1, fail: "", rc: 1}
loop_control:
@@ -339,7 +341,9 @@
- name: The disk check let the pressure prune run only above the threshold
ansible.builtin.assert:
that: item.rc == item.gitea_runner_test_case.rc
that:
- item.rc == item.gitea_runner_test_case.rc
- item.gitea_runner_test_case.out | default('') in item.stdout
fail_msg: "case {{ item.gitea_runner_test_case.name }}: rc {{ item.rc }}, output {{ item.stdout }} {{ item.stderr }}"
quiet: true
loop: "{{ gitea_runner_test_pressure.results }}"
@@ -420,10 +424,10 @@
expect: gitea_runner_registration_scope must be empty
- name: prune schedule with a newline
vars: {gitea_runner_docker_prune_schedule: "daily\nExecStartPre=/bin/false"}
expect: plain OnCalendar value
expect: gitea_runner_docker_prune_schedule must be a plain OnCalendar value
- name: prune age without a unit
vars: {gitea_runner_docker_prune_image_age: "168"}
expect: plain OnCalendar value
expect: the two ages a number with s, m or h
- name: negative prune count
vars: {gitea_runner_docker_prune_keep_per_repository: -1}
expect: gitea_runner_docker_prune_keep_per_repository must be 0 (off) or more