From 18a8a3a9c348ad8598deb73e52eb5be30bac743b Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Tue, 28 May 2024 10:45:47 +0200 Subject: [PATCH] tests: Check version of Blivet when running Stratis tests Some Stratis features are not available with older versions of Blivet. Related: RHEL-31854 --- tests/tests_stratis.yml | 127 ++++++++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 51 deletions(-) diff --git a/tests/tests_stratis.yml b/tests/tests_stratis.yml index 139d1b21..c41498ad 100644 --- a/tests/tests_stratis.yml +++ b/tests/tests_stratis.yml @@ -110,64 +110,89 @@ - name: Verify role results include_tasks: verify-role-results.yml - - name: Create encrypted Stratis pool - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - encryption: true - encryption_password: yabbadabbadoo - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" + - name: Gather package facts + package_facts: - - name: Verify role results - include_tasks: verify-role-results.yml + - name: Set blivet package name + set_fact: + blivet_pkg_name: "{{ ansible_facts.packages | + select('search', 'blivet') | select('search', 'python') | list }}" - - name: Repeat the previous invocation to verify idempotence - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - encryption: true - encryption_password: yabbadabbadoo - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" + - name: Set blivet package version + set_fact: + blivet_pkg_version: "{{ + ansible_facts.packages[blivet_pkg_name[0]][0]['version'] + + '-' + ansible_facts.packages[blivet_pkg_name[0]][0]['release'] }}" - - name: Verify role results - include_tasks: verify-role-results.yml + - name: Set distribution version + set_fact: + is_rhel9: "{{ (ansible_facts.distribution == 'CentOS' or + ansible_facts.distribution == 'RedHat') and + ansible_facts.distribution_major_version == '9' }}" + is_rhel10: "{{ (ansible_facts.distribution == 'CentOS' or + ansible_facts.distribution == 'RedHat') and + ansible_facts.distribution_major_version == '10' }}" + is_fedora: "{{ ansible_facts.distribution == 'Fedora' }}" - - name: Clean up - include_role: - name: linux-system-roles.storage - vars: - storage_pools: - - name: foo - disks: "{{ unused_disks }}" - type: stratis - state: absent - volumes: - - name: test1 - size: "{{ volume_size }}" - mount_point: "{{ mount_location }}" + - name: Run test only if blivet supports this functionality + when: ((is_fedora and blivet_pkg_version is version("3.10.0-1", ">=")) or + (is_rhel10 and blivet_pkg_version is version("3.10.0-1", ">=")) or + (is_rhel9 and blivet_pkg_version is version("3.6.0-15", ">="))) + block: + - name: Create encrypted Stratis pool + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis + encryption: true + encryption_password: yabbadabbadoo + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Repeat the previous invocation to verify idempotence + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis + encryption: true + encryption_password: yabbadabbadoo + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Clean up + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: stratis state: absent + volumes: + - name: test1 + size: "{{ volume_size }}" + mount_point: "{{ mount_location }}" + state: absent - - name: Verify role results - include_tasks: verify-role-results.yml + - name: Verify role results + include_tasks: verify-role-results.yml - # XXX blivet supporting this is not yet released - - name: Run test only if blivet supports this functionality - when: false - block: - name: Create one Stratis pool on one disk include_role: name: linux-system-roles.storage