-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from wtsi-hgi/feature/testing
Adds tests
- Loading branch information
Showing
18 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
sudo: required | ||
|
||
services: | ||
- docker | ||
|
||
install: | ||
- docker build -t test-runner -f Dockerfile.test . | ||
|
||
script: | ||
- docker run --rm -t -v $PWD:/ansible-conda test-runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM ubuntu | ||
|
||
ENV DATA_DIRECTORY=/ansible-conda | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
python \ | ||
python-pip \ | ||
python-apt \ | ||
python-dev \ | ||
build-essential \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install setuptools wheel | ||
RUN pip install ansible==2.3.2.0 | ||
|
||
ADD tests/requirements.yml /tmp/requirements.yml | ||
RUN ansible-galaxy install -r /tmp/requirements.yml | ||
|
||
ADD tests/requirements.txt /tmp/requirements.txt | ||
RUN pip install -r /tmp/requirements.txt | ||
|
||
VOLUME "${DATA_DIRECTORY}" | ||
|
||
CMD ansible-galaxy install -r "${DATA_DIRECTORY}/tests/requirements.yml" \ | ||
&& pip install -r "${DATA_DIRECTORY}/tests/requirements.txt" \ | ||
&& ansible-playbook -vvv -e ansible_python_interpreter=$(which python) -c local "${DATA_DIRECTORY}/tests/site.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
conda_tests_python_version: 2 | ||
conda_tests_anaconda_version: 4.4.0 | ||
conda_tests_anaconda_installation_location: /tmp/install/anaconda | ||
conda_tests_conda_executable: "{{ conda_tests_anaconda_installation_location }}/bin/conda" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../conda.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
dependencies: | ||
- role: anaconda | ||
vars: | ||
anaconda_python_ver: "{{ conda_tests_python_version }}" | ||
anaconda_ver: "{{ conda_tests_anaconda_version }}" | ||
anaconda_pkg_update: no | ||
anaconda_parent_dir: "{{ conda_tests_anaconda_installation_location | dirname }}" | ||
anaconda_link_subdir: "{{ conda_tests_anaconda_installation_location | basename }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jmespath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
- name: anaconda | ||
src: https://github.com/wtsi-hgi/ansible-anaconda.git | ||
version: 60ac57016facaf8658437ca4700f4037b60be42e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
- hosts: localhost | ||
roles: | ||
- ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: install apt prerequisites | ||
apt: | ||
name: python-pip | ||
|
||
- name: install Python prerequisites | ||
pip: | ||
name: jmespath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
|
||
- include: install.yml | ||
- include: tear-down.yml | ||
|
||
- block: | ||
- include: test-install-latest.yml | ||
always: | ||
- include: tear-down.yml | ||
|
||
- block: | ||
- include: test-install-fixed-version.yml | ||
always: | ||
- include: tear-down.yml | ||
|
||
- block: | ||
- include: test-upgrade.yml | ||
always: | ||
- include: tear-down.yml | ||
|
||
- block: | ||
- include: test-downgrade.yml | ||
always: | ||
- include: tear-down.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
|
||
- name: find installed Conda matching packages | ||
shell: "{{ conda_tests_conda_executable }} search --json ^{{ conda_tests_install_example }}$" | ||
no_log: True | ||
register: installed_raw | ||
|
||
- name: filter output | ||
set_fact: | ||
installed: "{{ (installed_raw.stdout | from_json | json_query('%s[?installed]' % conda_tests_install_example)) }}" | ||
|
||
- name: ensure expected environment | ||
assert: | ||
that: installed | length <= 1 | ||
|
||
- name: set install facts | ||
set_fact: | ||
example_package: | ||
installed: "{{ installed | length != 0 }}" | ||
version: "{{ installed[0].version if installed | length > 0 else False }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
|
||
- name: uninstall package via Conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
state: absent | ||
executable: "{{ conda_tests_conda_executable }}" | ||
|
||
- include: set-install-facts.yml | ||
|
||
- name: verify package not installed | ||
assert: | ||
that: not example_package.installed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
- name: install latest package via conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
state: latest | ||
executable: "{{ conda_tests_conda_executable }}" | ||
|
||
- name: install old package via conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
version: "{{ conda_tests_old_version }}" | ||
state: present | ||
executable: "{{ conda_tests_conda_executable }}" | ||
register: second_install | ||
|
||
- include: set-install-facts.yml | ||
|
||
- name: verify installed | ||
assert: | ||
that: second_install.changed | ||
that: example_package.installed | ||
that: example_package.version | version_compare(conda_tests_old_version, '=') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
|
||
- name: install package via conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
version: "{{ conda_tests_old_version }}" | ||
state: present | ||
executable: "{{ conda_tests_conda_executable }}" | ||
register: first_install | ||
|
||
- include: set-install-facts.yml | ||
|
||
- name: verify installed | ||
assert: | ||
that: first_install.changed | ||
that: example_package.installed | ||
that: example_package.version | version_compare(conda_tests_old_version, '=') | ||
|
||
- name: install package via conda (again) | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
version: "{{ conda_tests_old_version }}" | ||
state: present | ||
executable: "{{ conda_tests_conda_executable }}" | ||
register: second_install | ||
|
||
- name: verify idempotence | ||
assert: | ||
that: not second_install.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
|
||
- name: install package via conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
state: latest | ||
executable: "{{ conda_tests_conda_executable }}" | ||
register: first_install | ||
|
||
- include: set-install-facts.yml | ||
|
||
- name: verify installed | ||
assert: | ||
that: first_install.changed | ||
that: example_package.installed | ||
that: example_package.version | version_compare(conda_tests_minimum_latest_version, '>=') | ||
|
||
- name: install package via conda (again) | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
state: latest | ||
executable: "{{ conda_tests_conda_executable }}" | ||
register: second_install | ||
|
||
- name: verify idempotence | ||
assert: | ||
that: not second_install.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
- name: install old package via conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
version: "{{ conda_tests_old_version }}" | ||
state: present | ||
executable: "{{ conda_tests_conda_executable }}" | ||
|
||
- name: install latest package via conda | ||
conda: | ||
name: "{{ conda_tests_install_example }}" | ||
state: latest | ||
executable: "{{ conda_tests_conda_executable }}" | ||
register: second_install | ||
|
||
- include: set-install-facts.yml | ||
|
||
- name: verify installed | ||
assert: | ||
that: second_install.changed | ||
that: example_package.installed | ||
that: example_package.version | version_compare(conda_tests_minimum_latest_version, '>=') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
# XXX: better to hit local package repository with dummy package | ||
conda_tests_install_example: translationstring | ||
conda_tests_minimum_latest_version: "1.3" | ||
conda_tests_old_version: "1.1" |