---
- name: Verify the extend verify command fails when space too low
  hosts: all
  vars:
    test_disk_min_size: "1g"
    test_disk_count: 10
    test_storage_pools:
      - name: test_vg1
        disks: "{{ range(0, 3) | map('extract', unused_disks) | list }}"
        volumes:
          - name: lv1
            size: "50%"
    snapshot_test_set:
      name: snapset1
      volumes:
        - name: snapshot VG1 LV1
          vg: test_vg1
          lv: lv1
          percent_space_required: 10
    snapshot_test_verify_set:
      name: snapset1
      volumes:
        - name: snapshot VG1 LV1
          vg: test_vg1
          lv: lv1
          percent_space_required: 90
  tasks:
    - name: Run tests
      block:
        - name: Setup
          include_tasks: tasks/setup.yml

        - name: Run the snapshot role to create snapshot set of LVs
          include_role:
            name: linux-system-roles.snapshot
          vars:
            snapshot_lvm_action: snapshot
            snapshot_lvm_set: "{{ snapshot_test_set }}"

        - name: Run the snapshot role to verify the set of snapshots for the LVs
          include_role:
            name: linux-system-roles.snapshot
          vars:
            snapshot_lvm_action: check
            snapshot_lvm_set: "{{ snapshot_test_set }}"
            snapshot_lvm_verify_only: true

        - name: Test failure extend verify
          include_tasks: verify-role-failed.yml
          vars:
            __snapshot_failed_regex:
              "verify failed due to insufficient space for:*"
            __snapshot_failed_msg: Role did not fail with extend verify
            __snapshot_failed_params:
              snapshot_lvm_action: extend
              snapshot_lvm_verify_only: true
              __snapshot_lvm_set: "{{ snapshot_test_verify_set }}"
            __snapshot_failed_changed: false

      always:
        - name: Cleanup
          include_tasks: tasks/cleanup.yml
          tags: tests::cleanup
