Skip to content

Commit

Permalink
Fix pip test to use setup_remote_tmp_dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclay committed Nov 4, 2021
1 parent a861cb5 commit 39509ff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
1 change: 1 addition & 0 deletions test/integration/targets/pip/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dependencies:
- prepare_tests
- setup_remote_tmp_dir
70 changes: 35 additions & 35 deletions test/integration/targets/pip/tasks/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,24 @@
- name: "make sure the test env doesn't exist"
file:
state: absent
name: "{{ output_dir }}/pipenv"
name: "{{ remote_tmp_dir }}/pipenv"

- name: install a working version of setuptools in the virtualenv
pip:
name: setuptools
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present
version: 33.1.1

- name: create a requirement file with an vcs url
copy:
dest: "{{ output_dir }}/pipreq.txt"
dest: "{{ remote_tmp_dir }}/pipreq.txt"
content: "-e git+https://github.com/dvarrazzo/pyiso8601#egg=iso8601"

- name: install the requirement file in a virtualenv
pip:
requirements: "{{ output_dir}}/pipreq.txt"
virtualenv: "{{ output_dir }}/pipenv"
requirements: "{{ remote_tmp_dir}}/pipreq.txt"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: req_installed

- name: check that a change occurred
Expand All @@ -115,8 +115,8 @@

- name: "repeat installation to check status didn't change"
pip:
requirements: "{{ output_dir}}/pipreq.txt"
virtualenv: "{{ output_dir }}/pipenv"
requirements: "{{ remote_tmp_dir}}/pipreq.txt"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: req_installed

- name: "check that a change didn't occurr this time (bug ansible#1705)"
Expand All @@ -127,7 +127,7 @@
- name: install the same module from url
pip:
name: "git+https://github.com/dvarrazzo/pyiso8601#egg=iso8601"
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
editable: True
register: url_installed

Expand All @@ -142,13 +142,13 @@
- name: check for pip package
pip:
name: pip
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present

- name: check for pip package in check_mode
pip:
name: pip
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present
check_mode: True
register: pip_check_mode
Expand All @@ -162,13 +162,13 @@
- name: check for setuptools package
pip:
name: setuptools
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present

- name: check for setuptools package in check_mode
pip:
name: setuptools
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present
check_mode: True
register: setuptools_check_mode
Expand All @@ -183,13 +183,13 @@
- name: check for q package
pip:
name: q
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present

- name: check for q package in check_mode
pip:
name: q
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present
check_mode: True
register: q_check_mode
Expand All @@ -204,13 +204,13 @@
- name: check for Junit-XML package
pip:
name: Junit-XML
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present

- name: check for Junit-XML package in check_mode
pip:
name: Junit-XML
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present
check_mode: True
register: diff_case_check_mode
Expand All @@ -224,12 +224,12 @@
- name: ensure is a fresh virtualenv
file:
state: absent
name: "{{ output_dir }}/pipenv"
name: "{{ remote_tmp_dir }}/pipenv"

- name: install pip throught pip into fresh virtualenv
pip:
name: pip
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: pip_install_venv

- name: make sure pip in fresh virtualenv report changed
Expand All @@ -242,7 +242,7 @@
- name: create chdir test directories
file:
state: directory
name: "{{ output_dir }}/{{ item }}"
name: "{{ remote_tmp_dir }}/{{ item }}"
loop:
- pip_module
- pip_root
Expand All @@ -251,16 +251,16 @@
- name: copy test module
copy:
src: "{{ item }}"
dest: "{{ output_dir }}/pip_module/{{ item }}"
dest: "{{ remote_tmp_dir }}/pip_module/{{ item }}"
loop:
- setup.py
- ansible_test_pip_chdir/__init__.py

- name: install test module
pip:
name: .
chdir: "{{ output_dir }}/pip_module"
extra_args: --user --upgrade --root {{ output_dir }}/pip_root
chdir: "{{ remote_tmp_dir }}/pip_module"
extra_args: --user --upgrade --root {{ remote_tmp_dir }}/pip_root

- name: register python_site_lib
command: '{{ ansible_python.executable }} -c "import site; print(site.USER_SITE)"'
Expand All @@ -271,7 +271,7 @@
register: pip_python_user_base

- name: run test module
shell: "PYTHONPATH=$(echo {{ output_dir }}/pip_root{{ pip_python_site_lib.stdout }}) {{ output_dir }}/pip_root{{ pip_python_user_base.stdout }}/bin/ansible_test_pip_chdir"
shell: "PYTHONPATH=$(echo {{ remote_tmp_dir }}/pip_root{{ pip_python_site_lib.stdout }}) {{ remote_tmp_dir }}/pip_root{{ pip_python_user_base.stdout }}/bin/ansible_test_pip_chdir"
register: pip_chdir_command

- name: make sure command ran
Expand All @@ -283,12 +283,12 @@
- name: ensure is a fresh virtualenv
file:
state: absent
name: "{{ output_dir }}/pipenv"
name: "{{ remote_tmp_dir }}/pipenv"

- name: install requirements file into virtual + chdir
pip:
name: q
chdir: "{{ output_dir }}/"
chdir: "{{ remote_tmp_dir }}/"
virtualenv: "pipenv"
state: present
register: venv_chdir
Expand All @@ -314,37 +314,37 @@
- name: Ensure previous virtualenv no longer exists
file:
state: absent
name: "{{ output_dir }}/pipenv"
name: "{{ remote_tmp_dir }}/pipenv"

- name: do not consider an empty string as a version
pip:
name: q
state: present
version: ""
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: pip_empty_version_string

- name: test idempotency with empty string
pip:
name: q
state: present
version: ""
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: pip_empty_version_string_idempotency

- name: test idempotency without empty string
pip:
name: q
state: present
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: pip_no_empty_version_string_idempotency

# 'present' and version=="" is analogous to latest when first installed
- name: ensure we installed the latest version
pip:
name: q
state: latest
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: pip_empty_version_idempotency

- name: ensure that installation worked and is idempotent
Expand Down Expand Up @@ -526,7 +526,7 @@
- name: make sure the virtualenv does not exist
file:
state: absent
name: "{{ output_dir }}/pipenv"
name: "{{ remote_tmp_dir }}/pipenv"

- name: install distribute in the virtualenv
pip:
Expand All @@ -535,14 +535,14 @@
name:
- distribute
- setuptools<45 # setuptools 45 and later require python 3.5 or later
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
state: present

- name: try to remove distribute
pip:
state: "absent"
name: "distribute"
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
ignore_errors: yes
register: remove_distribute

Expand All @@ -559,13 +559,13 @@
- name: make sure the virtualenv does not exist
file:
state: absent
name: "{{ output_dir }}/pipenv"
name: "{{ remote_tmp_dir }}/pipenv"

# ref: https://github.com/ansible/ansible/issues/52275
- name: install using virtualenv_command with arguments
pip:
name: "{{ pip_test_package }}"
virtualenv: "{{ output_dir }}/pipenv"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
virtualenv_command: "{{ command.stdout_lines[0] | basename }} --verbose"
state: present
register: version13
Expand Down

0 comments on commit 39509ff

Please sign in to comment.