---
- name: Verify snapshot action fails if percent_space_required param negative
  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: "100%"
  tasks:
    - name: Run tests
      block:
        - name: Setup
          include_tasks: tasks/setup.yml

        - name: Test failure of creating snapshot that has negative space
          include_tasks: verify-role-failed.yml
          vars:
            __snapshot_failed_regex: >-
              percent_space_required must be greater than*
            __snapshot_failed_msg: >-
              Role did not fail percent_space_required error
            __snapshot_failed_params:
              snapshot_lvm_action: snapshot
              snapshot_lvm_verify_only: true
              __snapshot_lvm_set:
                name: snapset1
                volumes:
                  - name: snapshot VG1 LV1
                    vg: test_vg1
                    lv: lv1
                    percent_space_required: -20
            __snapshot_failed_changed: false
      always:
        - name: Cleanup
          include_tasks: tasks/cleanup.yml
          tags: tests::cleanup
