2021-08-18 11:41:51 +00:00
|
|
|
---
|
|
|
|
- name: "{{ test.name }} | install test packages"
|
|
|
|
dnf: name="{{ test.package }}-tests" state=installed
|
|
|
|
|
2021-08-23 18:25:13 +00:00
|
|
|
- name: "{{ test.name }} | define helper variables"
|
2021-08-18 11:41:51 +00:00
|
|
|
set_fact:
|
|
|
|
test_name_oneword: "{{ test.name | replace(' ','-') }}"
|
|
|
|
|
|
|
|
# UGH. This is necessary because our caller sets some environment variables
|
|
|
|
# and we need to set a few more based on other caller variables; then we
|
|
|
|
# need to combine the two dicts when running the test. This seems to be
|
|
|
|
# the only way to do it in ansible.
|
|
|
|
- name: "{{ test.name }} | define local environment"
|
|
|
|
set_fact:
|
|
|
|
local_environment:
|
|
|
|
TEST_NAME: "{{ test.name }}"
|
|
|
|
TEST_PACKAGE: "{{ test.package }}"
|
tests: Avoid running out of storage space
Toolbx's system tests download several images when setting up the test
suite, and cache them for later use by the tests [1]. This saves time
and avoids hitting rate limits imposed by OCI registries by not
downloading the same images repeatedly for several tests, but at the
cost of increased use of storage space to cache the images.
The images are cached under BATS_TMPDIR. It defaults to the TMPDIR
environment variable, and if that's not set then to /tmp [2]. Normally,
TMPDIR isn't set, and the images end up getting cached under /tmp. Now,
/tmp is typically on tmpfs backed by RAM or swap, which means that it
should be used for smaller size-bounded files only, and /var/tmp should
be used for everything else [3].
The images are big enough that a collection of them can't be described
as smaller and size-bounded, and it led to:
1..306
# test suite: Set up
# test suite: Tear down
not ok 1 setup_suite
# (from function `setup_suite' in test file ./setup_suite.bash, line
55)
# `_pull_and_cache_distro_image fedora "$((system_version-1))" ||
false' failed
# Failed to cache image registry.fedoraproject.org/fedora-toolbox:40
to /tmp/bats-run-IPz4Cn/image-cache/fedora-toolbox-40
# time="2024-02-19T11:41:43Z" level=fatal msg="copying system image
from manifest list: writing blob: write
/tmp/bats-run-IPz4Cn/image-cache/fedora-toolbox-40/dir-put-blob607392514:
no space left on device"
# bats warning: Executed 1 instead of expected 306 tests
So, change the default location of the BATS_TMPDIR environment variable
to /var/tmp by setting TMPDIR.
[1] Toolbx commit 50683c9d9a78adc9
https://github.com/containers/toolbox/commit/50683c9d9a78adc9
https://github.com/containers/toolbox/pull/375
[2] https://bats-core.readthedocs.io/en/stable/writing-tests.html
[3] https://systemd.io/TEMPORARY_DIRECTORIES/
Resolves: RHEL-61579
2024-10-04 19:44:04 +00:00
|
|
|
TMPDIR: "/var/tmp"
|
2021-08-18 11:41:51 +00:00
|
|
|
|
|
|
|
- name: "{{ test.name }} | setup/teardown helper | see if exists"
|
|
|
|
local_action: stat path={{ role_path }}/files/helper.{{ test_name_oneword }}.sh
|
|
|
|
register: helper
|
|
|
|
|
|
|
|
- name: "{{ test.name }} | setup/teardown helper | install"
|
|
|
|
copy: src=helper.{{ test_name_oneword }}.sh dest=/tmp/helper.sh
|
|
|
|
when: helper.stat.exists
|
|
|
|
|
|
|
|
- name: "{{ test.name }} | run test"
|
|
|
|
script: ./run_bats_tests.sh
|
|
|
|
args:
|
|
|
|
chdir: /usr/share/{{ test.package }}/test/system
|
|
|
|
become: "{{ true if test.become is defined else false }}"
|
|
|
|
become_user: testuser
|
2024-10-04 19:41:03 +00:00
|
|
|
environment: "{{ local_environment }}"
|
2021-08-18 11:41:51 +00:00
|
|
|
|
|
|
|
- name: "{{ test.name }} | pull logs"
|
|
|
|
fetch:
|
|
|
|
src: "/tmp/test.{{ item }}.log"
|
|
|
|
dest: "{{ artifacts }}/test.{{ test_name_oneword }}.{{ item }}.log"
|
|
|
|
flat: yes
|
|
|
|
with_items:
|
|
|
|
- bats
|
|
|
|
- debug
|
|
|
|
|
|
|
|
- name: "{{ test.name }} | remove remote logs and helpers"
|
|
|
|
file:
|
|
|
|
dest=/tmp/{{ item }}
|
|
|
|
state=absent
|
|
|
|
with_items:
|
|
|
|
- test.bats.log
|
|
|
|
- test.debug.log
|
|
|
|
- helper.sh
|