diff options
author | dexpl <iamdexpl@gmail.com> | 2020-01-24 15:42:47 +0100 |
---|---|---|
committer | Sam Doran <sdoran@redhat.com> | 2020-01-24 15:42:47 +0100 |
commit | 1152774f923e441ec2e71c380cdb78e7f44f94ea (patch) | |
tree | 101693424726e4f4d5d24ec0c75e9334c4a4059a /test/integration/targets/git | |
parent | throttle: fix linear based strategies (#65422) (diff) | |
download | ansible-1152774f923e441ec2e71c380cdb78e7f44f94ea.tar.xz ansible-1152774f923e441ec2e71c380cdb78e7f44f94ea.zip |
git - add an 'archive_prefix' option (#66067)
Add integration tests for new option
Diffstat (limited to 'test/integration/targets/git')
-rw-r--r-- | test/integration/targets/git/handlers/main.yml | 2 | ||||
-rw-r--r-- | test/integration/targets/git/tasks/archive.yml | 59 | ||||
-rw-r--r-- | test/integration/targets/git/tasks/setup.yml | 3 | ||||
-rw-r--r-- | test/integration/targets/git/vars/main.yml | 18 |
4 files changed, 81 insertions, 1 deletions
diff --git a/test/integration/targets/git/handlers/main.yml b/test/integration/targets/git/handlers/main.yml index a96627adc9..592ea394d0 100644 --- a/test/integration/targets/git/handlers/main.yml +++ b/test/integration/targets/git/handlers/main.yml @@ -1,3 +1,5 @@ +# TODO remove everything we'd installed (see git_required_packages), not just git +# problem is that we should not remove what we hadn't installed - name: remove git package: name: git diff --git a/test/integration/targets/git/tasks/archive.yml b/test/integration/targets/git/tasks/archive.yml index c0d125cbeb..8c5e5ebcab 100644 --- a/test/integration/targets/git/tasks/archive.yml +++ b/test/integration/targets/git/tasks/archive.yml @@ -74,3 +74,62 @@ when: - "ansible_os_family == 'RedHat'" - ansible_distribution_major_version is version('7', '>=') + +- name: ARCHIVE | Inspect archive file + command: + cmd: "{{ git_list_commands[item] }} {{ checkout_dir }}/test_role.{{ item }}" + warn: no + register: archive_content + with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}" + +# Does not work on RedHat6 (jinja2 too old?) +- name: ARCHIVE | Ensure archive content is correct + assert: + that: + - item.stdout_lines | sort | first == 'defaults/' + with_items: "{{ archive_content.results }}" + when: + - ansible_os_family ~ ansible_distribution_major_version != 'RedHat6' + +- name: ARCHIVE | Clear checkout_dir + file: + state: absent + path: "{{ checkout_dir }}" + +- name: ARCHIVE | Generate an archive prefix + set_fact: + git_archive_prefix: '{{ range(2 ** 31, 2 ** 32) | random }}' # Generate some random archive prefix + +- name: ARCHIVE | Archive repo using various archival format and with an archive prefix + git: + repo: '{{ repo_format1 }}' + dest: '{{ checkout_dir }}' + archive: '{{ checkout_dir }}/test_role.{{ item }}' + archive_prefix: '{{ git_archive_prefix }}/' + register: git_archive + with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}" + +- name: ARCHIVE | Prepare the target for archive(s) extraction + file: + state: directory + path: '{{ checkout_dir }}/{{ git_archive_prefix }}.{{ item }}' + with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}" + +- name: ARCHIVE | Extract the archive(s) into that target + unarchive: + src: '{{ checkout_dir }}/test_role.{{ item }}' + dest: '{{ checkout_dir }}/{{ git_archive_prefix }}.{{ item }}' + with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}" + +- name: ARCHIVE | Check if prefix directory exists in what's extracted + find: + path: '{{ checkout_dir }}/{{ git_archive_prefix }}.{{ item }}' + patterns: '{{ git_archive_prefix }}' + file_type: directory + register: archive_check + with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}" + +- name: ARCHIVE | Assert that prefix directory is found + assert: + that: '{{ item.matched == 1 }}' + with_items: "{{ archive_check.results }}" diff --git a/test/integration/targets/git/tasks/setup.yml b/test/integration/targets/git/tasks/setup.yml index 0e56e8b017..109798e384 100644 --- a/test/integration/targets/git/tasks/setup.yml +++ b/test/integration/targets/git/tasks/setup.yml @@ -10,11 +10,12 @@ - name: SETUP | install git package: - name: git + name: '{{ item }}' when: ansible_distribution != "MacOSX" notify: - remove git - remove git from FreeBSD + with_items: "{{ git_required_packages[ansible_os_family | default('default') ] | default(git_required_packages.default) }}" - name: SETUP | verify that git is installed so this test can continue shell: which git diff --git a/test/integration/targets/git/vars/main.yml b/test/integration/targets/git/vars/main.yml index ea9dae268c..a5bae5ba7f 100644 --- a/test/integration/targets/git/vars/main.yml +++ b/test/integration/targets/git/vars/main.yml @@ -8,6 +8,24 @@ git_archive_extensions: - tar - zip +git_required_packages: + default: + - git + - gzip + - tar + - unzip + - zip + FreeBSD: + - git + - gzip + - unzip + - zip + +git_list_commands: + tar.gz: tar -tf + tar: tar -tf + tgz: tar -tf + zip: unzip -Z1 checkout_dir: '{{ output_dir }}/git' repo_dir: '{{ output_dir }}/local_repos' |