generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: centralize test setup/cleanup - add cleanup debugging
We are getting some test flakes which I believe are related to incomplete cleanup. Rather than add the same code to every test, I created a tasks/cleanup.yml to do this, and variables for the storage pools and other parameters to cleanup. Then, it made sense to do the same for setup - tasks/setup.yml Signed-off-by: Rich Megginson <[email protected]>
- Loading branch information
Showing
33 changed files
with
871 additions
and
1,841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-License-Identifier: MIT | ||
# Input: | ||
# - test_disk_min_size e.g. "1g" | ||
# - test_disk_count e.g. 10 | ||
# - test_storage_pools - the list of pools & volumes to create | ||
--- | ||
- name: Remove storage volumes | ||
include_role: | ||
name: fedora.linux_system_roles.storage | ||
vars: | ||
storage_safe_mode: false | ||
storage_pools: | | ||
{% set cleanup_pools = [] %} | ||
{% for pool in test_storage_pools %} | ||
{% set clean_pool = {"name": pool["name"], | ||
"disks": pool["disks"], "state": "absent"} %} | ||
{% set vols = [] %} | ||
{% for vol in pool.get("volumes", []) %} | ||
{% set clean_vol = {"name": vol["name"], "state": "absent"} %} | ||
{% set _ = vols.append(clean_vol) %} | ||
{% endfor %} | ||
{% if vols %} | ||
{% set _ = clean_pool.__setitem__("volumes", vols) %} | ||
{% endif %} | ||
{% set _ = cleanup_pools.append(clean_pool) %} | ||
{% endfor %} | ||
{{ cleanup_pools }} | ||
- name: Save unused_disk_return before verify | ||
set_fact: | ||
unused_disks_before: "{{ unused_disks }}" | ||
|
||
- name: Verify that pools/volumes used in test are removed | ||
include_tasks: get_unused_disk.yml | ||
vars: | ||
min_size: "{{ test_disk_min_size }}" | ||
min_return: "{{ test_disk_count }}" | ||
|
||
- name: Debug why list of unused disks has changed | ||
shell: | | ||
set -euxo pipefail | ||
exec 1>&2 | ||
mount -f -l | ||
df -H | ||
lvs --all | ||
pvs --all | ||
vgs --all | ||
cat /tmp/snapshot_role.log || : | ||
changed_when: false | ||
when: unused_disks_before != unused_disks_return.disks | ||
failed_when: unused_disks_before != unused_disks_return.disks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# SPDX-License-Identifier: MIT | ||
# Input: | ||
# - test_disk_min_size e.g. "1g" | ||
# - test_disk_count e.g. 10 | ||
# - test_storage_pools - the list of pools & volumes to create | ||
# Output: | ||
# - unused_disks e.g. ["sda", "sdb", ..] | ||
# - test_mnt_parent e.g. /mnt or /var/mnt | ||
--- | ||
- name: Check if system is ostree | ||
stat: | ||
path: /run/ostree-booted | ||
register: __ostree_booted_stat | ||
|
||
- name: Set mount parent | ||
set_fact: | ||
test_mnt_parent: "{{ __ostree_booted_stat.stat.exists | | ||
ternary('/var/mnt', '/mnt') }}" | ||
|
||
- name: Run the storage role install base packages | ||
include_role: | ||
name: fedora.linux_system_roles.storage | ||
|
||
- name: Get unused disks | ||
include_tasks: get_unused_disk.yml | ||
vars: | ||
min_size: "{{ test_disk_min_size }}" | ||
min_return: "{{ test_disk_count }}" | ||
|
||
- name: Create LVM logical volumes under volume groups | ||
include_role: | ||
name: fedora.linux_system_roles.storage | ||
vars: | ||
storage_pools: "{{ test_storage_pools }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.