Skip to content

Commit

Permalink
Test for idempotence explicitly in all integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlehman committed Jul 3, 2019
1 parent 041c333 commit 36da735
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/tests_change_disk_fs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_volumes:
- name: test1
type: disk
mount_point: "{{ mount_location }}"
fs_type: "{{ fs_type_after }}"
disks: "{{ unused_disks }}"

- include_tasks: verify-role-results.yml

This comment has been minimized.

Copy link
@pcahyna

pcahyna Oct 15, 2019

Member

@dwlehman If you follow closely the test execution, you will see that it is not idempotent. The previous invocation has created a fstab entry which mounts the filesystem by block device path:

TASK [storage : manage mounts to match the specified state] ********************
changed: [/home/pcahyna/linux-system-roles-testing/local/rhel-guest-image-7.7-200.x86_64.qcow2] => (item={'path': '/opt/test', 'state': 'absent'}) => {"ansible_loop_var": "mount_info", "changed": true, "dump": "0", "fstab": "/etc/fstab", "mount_info": {"path": "/opt/test", "state": "absent"}, "name": "/opt/test", "opts": "defaults", "passno": "0"}
changed: [/home/pcahyna/linux-system-roles-testing/local/rhel-guest-image-7.7-200.x86_64.qcow2] => (item={'src': '/dev/vdc', 'dump': 0, 'passno': 0, 'fstype': 'ext4', 'state': 'mounted', 'path': '/opt/test', 'opts': 'defaults'}) => {"ansible_loop_var": "mount_info", "changed": true, "dump": "0", "fstab": "/etc/fstab", "fstype": "ext4", "mount_info": {"dump": 0, "fstype": "ext4", "opts": "defaults", "passno": 0, "path": "/opt/test", "src": "/dev/vdc", "state": "mounted"}, "name": "/opt/test", "opts": "defaults", "passno": "0", "src": "/dev/vdc"}

...

TASK [Read the /etc/fstab file for volume existence] ***************************
ok: [/home/pcahyna/linux-system-roles-testing/local/rhel-guest-image-7.7-200.x86_64.qcow2] => {"changed": false, "cmd": ["cat", "/etc/fstab"], "delta": "0:00:00.003845", "end": "2019-10-15 13:43:52.449118", "rc": 0, "start": "2019-10-15 13:43:52.445273", "stderr": "", "stderr_lines": [], "stdout_lines": ["/dev/vdc /opt/test ext4 defaults 0 0"]}

and this repeated invocation changes it to mount by UUID:

TASK [storage : manage mounts to match the specified state] ********************
changed: [/home/pcahyna/linux-system-roles-testing/local/rhel-guest-image-7.7-200.x86_64.qcow2] => (item={'src': 'UUID=26bddec8-c250-416c-b8f1-7d8bfc070d06', 'dump': 0, 'passno': 0, 'fstype': 'ext4', 'state': 'mounted', 'path': '/opt/test', 'opts': 'defaults'}) => {"ansible_loop_var": "mount_info", "changed": true, "dump": "0", "fstab": "/etc/fstab", "fstype": "ext4", "mount_info": {"dump": 0, "fstype": "ext4", "opts": "defaults", "passno": 0, "path": "/opt/test", "src": "UUID=26bddec8-c250-416c-b8f1-7d8bfc070d06", "state": "mounted"}, "name": "/opt/test", "opts": "defaults", "passno": "0", "src": "UUID=26bddec8-c250-416c-b8f1-7d8bfc070d06"}

...

TASK [Read the /etc/fstab file for volume existence] ***************************
ok: [/home/pcahyna/linux-system-roles-testing/local/rhel-guest-image-7.7-200.x86_64.qcow2] => {"changed": false, "cmd": ["cat", "/etc/fstab"], "delta": "0:00:00.004238", "end": "2019-10-15 13:45:30.693829", "rc": 0, "start": "2019-10-15 13:45:30.689591", "stderr": "", "stderr_lines": [], "stdout_lines": ["UUID=26bddec8-c250-416c-b8f1-7d8bfc070d06 /opt/test ext4 defaults 0 0"]}

(using the current code from PR #43 if this makes any difference).
Also the commit message is misleading. There is apparently nothing to actually check for idempotence, i.e. that the second invocation has not changed anything.

This comment has been minimized.

Copy link
@pcahyna

pcahyna Oct 18, 2019

Member

PR #50 created to add a crude test for this (but not a fix).

- name: Clean up
include_role:
name: storage
Expand Down
12 changes: 12 additions & 0 deletions tests/tests_change_disk_mount.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_volumes:
- name: test1
type: disk
mount_point: "{{ mount_location_after }}"
disks: "{{ unused_disks }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
15 changes: 15 additions & 0 deletions tests/tests_change_fs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
fs_type: "{{ fs_after }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
15 changes: 15 additions & 0 deletions tests/tests_change_fs_use_partitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: bar
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
fs_type: "{{ fs_type_after }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
14 changes: 14 additions & 0 deletions tests/tests_change_mount.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
mount_point: "{{ mount_location_after }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
12 changes: 12 additions & 0 deletions tests/tests_create_disk_then_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_volumes:
- name: test1
type: disk
disks: "{{ unused_disks }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Remove the disk device created above
include_role:
name: storage
Expand Down
37 changes: 37 additions & 0 deletions tests/tests_create_lvm_pool_then_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,43 @@

- include_tasks: verify-role-results.yml

- name: Remove one of the LVM logical volumes in 'foo' created above
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
state: "present"
volumes:
- name: test1
size: "{{ volume1_size }}"
mount_point: "{{ mount_location1 }}"
- name: test2
size: "{{ volume2_size }}"
mount_point: "{{ mount_location2 }}"
state: absent

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume1_size }}"
mount_point: "{{ mount_location1 }}"
- name: test2
size: "{{ volume2_size }}"
mount_point: "{{ mount_location2 }}"
state: absent

- include_tasks: verify-role-results.yml

- name: Remove both of the LVM logical volumes in 'foo' created above
include_role:
name: storage
Expand Down
32 changes: 32 additions & 0 deletions tests/tests_create_partition_volume_then_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: "{{ unused_disks[0] }}"
type: disk
disks: "{{ unused_disks }}"
volumes:
- name: test1
type: partition
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Remove the partition created above
include_role:
name: storage
Expand All @@ -43,3 +58,20 @@
state: absent

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: "{{ unused_disks[0] }}"
type: disk
disks: "{{ unused_disks }}"
state: absent
volumes:
- name: "{{ unused_disks[0] }}1"
type: partition
mount_point: "{{ mount_location }}"
state: absent

- include_tasks: verify-role-results.yml
12 changes: 12 additions & 0 deletions tests/tests_filesystem_one_disk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_volumes:
- name: test1
type: disk
mount_point: "{{ mount_location }}"
disks: "{{ unused_disks }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
17 changes: 17 additions & 0 deletions tests/tests_lvm_multiple_disks_multiple_volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: phi
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
mount_point: "{{ mount_location1 }}"
- name: test2
size: "{{ volume_size }}"
mount_point: "{{ mount_location2 }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
20 changes: 20 additions & 0 deletions tests/tests_lvm_one_disk_multiple_volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
mount_point: '/opt/test1'
- name: test2
size: "{{ volume_size }}"
mount_point: '/opt/test2'
- name: test3
size: "{{ volume_size }}"
mount_point: '/opt/test3'

- include_tasks: verify-role-results.yml

- name: Remove two of the LVs
include_role:
name: storage
Expand Down
14 changes: 14 additions & 0 deletions tests/tests_lvm_one_disk_one_volume.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down
14 changes: 14 additions & 0 deletions tests/tests_remove_mount.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@

- include_tasks: verify-role-results.yml

- name: Repeat the previous invocation to verify idempotence
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
volumes:
- name: test1
size: "{{ volume_size }}"
mount_point: "{{ mount_location_after }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
Expand Down

0 comments on commit 36da735

Please sign in to comment.