diff options
author | Matt Clay <matt@mystile.com> | 2018-01-08 22:31:17 -0800 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2018-01-08 23:57:50 -0800 |
commit | 02b1d90cf3fc47bba8a1ec810bca6da528c63c0b (patch) | |
tree | 341fd9acd0933e1d27763d609c88f06fc916e42f | |
parent | e2fa2526ae20eb3f05e22e7b4e41ef63643f3b5c (diff) | |
download | ansible-02b1d90cf3fc47bba8a1ec810bca6da528c63c0b.tar.gz |
Make xattr test conditional on feature support.
(cherry picked from commit 77726b471f2fa610cb48a670126536c9583b23ff)
-rw-r--r-- | test/integration/targets/xattr/defaults/main.yml | 2 | ||||
-rw-r--r-- | test/integration/targets/xattr/tasks/main.yml | 73 | ||||
-rw-r--r-- | test/integration/targets/xattr/tasks/test.yml | 65 |
3 files changed, 74 insertions, 66 deletions
diff --git a/test/integration/targets/xattr/defaults/main.yml b/test/integration/targets/xattr/defaults/main.yml index 2ea8acbb4d..af18fb8474 100644 --- a/test/integration/targets/xattr/defaults/main.yml +++ b/test/integration/targets/xattr/defaults/main.yml @@ -1 +1 @@ -test_file: ~/foo.txt
\ No newline at end of file +test_file: "{{ output_dir }}/foo.txt" diff --git a/test/integration/targets/xattr/tasks/main.yml b/test/integration/targets/xattr/tasks/main.yml index 8514c444f7..563326b839 100644 --- a/test/integration/targets/xattr/tasks/main.yml +++ b/test/integration/targets/xattr/tasks/main.yml @@ -1,68 +1,11 @@ - name: Setup include: setup.yml -- name: Set attributes - xattr: - path: "{{ test_file }}" - key: user.foo - value: bar - register: xattr_set_result - -- name: Get attributes - xattr: - path: "{{ test_file }}" - register: xattr_get_all_result - -- name: Get specific attribute - xattr: - path: "{{ test_file }}" - key: user.foo - register: xattr_get_specific_result - -- assert: - that: - - "xattr_set_result.changed" - - "xattr_get_all_result['xattr']['user.foo'] == 'bar'" - - "not xattr_get_all_result.changed" - - "xattr_get_specific_result['xattr']['user.foo'] == 'bar'" - - "not xattr_get_specific_result.changed" - -- name: Set attribute again - xattr: - path: "{{ test_file }}" - key: user.foo - value: bar - register: xattr_set_again_result - -- assert: - that: - - "not xattr_set_again_result.changed" - -- name: Unset attribute - xattr: - path: "{{ test_file }}" - key: user.foo - state: absent - register: xattr_unset_result - -- name: get attributes - xattr: - path: "{{ test_file }}" - register: xattr_get_after_unset_result - -- assert: - that: - - "xattr_unset_result.changed" - - "xattr_get_after_unset_result['xattr'] == {}" - - "not xattr_get_after_unset_result.changed" - -- name: Unset attribute again - xattr: - path: "{{ test_file }}" - key: user.foo - state: absent - register: xattr_unset_result - -- assert: - that: - - "not xattr_set_again_result.changed"
\ No newline at end of file +- name: Check availability of xattr support + command: setfattr -n user.foo {{ test_file }} + ignore_errors: yes + register: xattr + +- name: Test + include: test.yml + when: xattr is not failed diff --git a/test/integration/targets/xattr/tasks/test.yml b/test/integration/targets/xattr/tasks/test.yml new file mode 100644 index 0000000000..4f4f35672c --- /dev/null +++ b/test/integration/targets/xattr/tasks/test.yml @@ -0,0 +1,65 @@ +- name: Set attributes + xattr: + path: "{{ test_file }}" + key: user.foo + value: bar + register: xattr_set_result + +- name: Get attributes + xattr: + path: "{{ test_file }}" + register: xattr_get_all_result + +- name: Get specific attribute + xattr: + path: "{{ test_file }}" + key: user.foo + register: xattr_get_specific_result + +- assert: + that: + - "xattr_set_result.changed" + - "xattr_get_all_result['xattr']['user.foo'] == 'bar'" + - "not xattr_get_all_result.changed" + - "xattr_get_specific_result['xattr']['user.foo'] == 'bar'" + - "not xattr_get_specific_result.changed" + +- name: Set attribute again + xattr: + path: "{{ test_file }}" + key: user.foo + value: bar + register: xattr_set_again_result + +- assert: + that: + - "not xattr_set_again_result.changed" + +- name: Unset attribute + xattr: + path: "{{ test_file }}" + key: user.foo + state: absent + register: xattr_unset_result + +- name: get attributes + xattr: + path: "{{ test_file }}" + register: xattr_get_after_unset_result + +- assert: + that: + - "xattr_unset_result.changed" + - "xattr_get_after_unset_result['xattr'] == {}" + - "not xattr_get_after_unset_result.changed" + +- name: Unset attribute again + xattr: + path: "{{ test_file }}" + key: user.foo + state: absent + register: xattr_unset_result + +- assert: + that: + - "not xattr_set_again_result.changed" |