From 09b1805e5fddb0ea90e7ee5a97b4b172397df323 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 27 Jun 2019 17:09:39 -0500 Subject: [PATCH] Convert tox to native zuul This change converts the TripleO-Ansible test process to using native zuul. After a long discussion about the current test process [0] it has been determined that most folks using tox do so on a local workstation and would not expect the local system to be modified when envoked. To ensure we're not creating a situation where a developer runs tox with a job that may require modifications of the system the current test structure has been replaced with a native zuul `base` job. > This change opens the door for us to add tox jobs later which may be added in support of the native jobs we're running now. > The test_json_error role was updated to set required configuration for that specific role, which was being passed in via tox before. Documentation has been added to the contributing section to highlight the role development process and how folks can test things locally using a script which will mimic the zuul job runtime. [0] - http://eavesdrop.openstack.org/irclogs/%23tripleo/latest.log.html#t2019-06-27T14:01:13 Change-Id: Ia1f3d479f3ac447d125169d08c78aaccfeacea3a Signed-off-by: Kevin Carter --- doc/source/contributing.rst | 38 +----- role-addition.yml | 18 +-- scripts/run-local-test | 11 +- tests/hosts.ini | 2 +- tox.ini | 216 +-------------------------------- zuul.d/base.yaml | 24 ++-- zuul.d/molecule.yaml | 63 +++++----- zuul.d/playbooks/pre.yml | 28 +++++ zuul.d/playbooks/run-local.yml | 14 +++ zuul.d/playbooks/run.yml | 18 +++ 10 files changed, 117 insertions(+), 315 deletions(-) create mode 100644 zuul.d/playbooks/pre.yml create mode 100644 zuul.d/playbooks/run-local.yml create mode 100644 zuul.d/playbooks/run.yml diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst index 46704c36f..519e0fd24 100644 --- a/doc/source/contributing.rst +++ b/doc/source/contributing.rst @@ -14,34 +14,8 @@ From with the project root, creating a skeleton for the new role. $ ansible-galaxy init --role-skeleton=_skeleton_role_ --init-path=tripleo_ansible/roles ${NEWROLENAME} - -Once the new role has been created, and is ready for testing add the role into -the `tox.ini` file as an test scenario. - -.. code-block:: ini - - [testenv:mol-${NEWROLENAME}] - basepython={[testenv:mol]basepython} - deps={[testenv:mol]deps} - changedir = {toxinidir}/tripleo_ansible/roles/${NEWROLENAME} - envdir = {toxworkdir}/mol - commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - - -If a given role has more than one scenario to test, the `--scenario` argument -can be used to set the scenario accordingly. - -.. code-block:: ini - - [testenv:mol-${NEWROLENAME}-${SCENARIO_2}] - basepython={[testenv:mol-${NEWROLENAME}]basepython} - deps={[testenv:mol-${NEWROLENAME}]deps} - changedir = {[testenv:mol-${NEWROLENAME}]changedir} - envdir = {[testenv:mol-${NEWROLENAME}]envdir} - commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=${SCENARIO_2} - - -When the role is ready for CI, add a **job** entry into the `zuul.d/molecule.yaml`. +When the role is ready for CI, add a **job** entry into the +`zuul.d/molecule.yaml`. .. code-block:: yaml @@ -54,8 +28,8 @@ When the role is ready for CI, add a **job** entry into the `zuul.d/molecule.yam tox_envlist: mol-${NEWROLENAME} -Make sure to add the **job** name into the check and gate section at the top of -the `molecule.yaml` file. +Make sure to add the **job** name into the check and gate section at the top +of the `molecule.yaml` file. .. code-block:: yaml @@ -88,8 +62,8 @@ will perform the basic tasks noted above. $ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME} -If this playbook is being executed from a virtual-environment be sure to activate -the virtual environment before running the playbook. +If this playbook is being executed from a virtual-environment be sure to +activate the virtual environment before running the playbook. .. code-block:: console diff --git a/role-addition.yml b/role-addition.yml index d256f2be1..b50bbd9e0 100644 --- a/role-addition.yml +++ b/role-addition.yml @@ -34,22 +34,6 @@ args: creates: "tripleo_ansible/roles/{{ role_name }}" - - name: Add tox config - ini_file: - path: tox.ini - section: "testenv:mol-{{ role_name }}" - option: "{{ item.key }}" - value: "{{ item.value }}" - with_items: - - key: "basepython" - value: "{[testenv:mol]basepython}" - - key: "deps" - value: "{[testenv:mol]deps}" - - key: "changedir" - value: "{toxinidir}/tripleo_ansible/roles/{{ role_name }}" - - key: "commands" - value: "python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py" - - name: Read zuul molecule file slurp: src: zuul.d/molecule.yaml @@ -86,7 +70,7 @@ "^tripleo_ansible/roles/" ~ role_name ~ "/.*" ], "vars": { - "tox_envlist": "mol-" ~ role_name + "tripleo_role_name": role_name } } %} diff --git a/scripts/run-local-test b/scripts/run-local-test index 862f36b58..08d120e52 100755 --- a/scripts/run-local-test +++ b/scripts/run-local-test @@ -54,12 +54,11 @@ PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate" # Run local test source "${PROJECT_DIR}/ansible-test-env.rc" +export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles" ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \ + -e "tripleo_src=$(realpath --relative-to="${HOME}" "${PROJECT_DIR}")" \ + -e "tripleo_role_name=${ROLE_NAME}" \ -e "ansible_user=${USER}" \ -e "ansible_user_dir=${HOME}" \ - "${PROJECT_DIR}/tripleo_ansible/playbooks/prepare-test-host.yml" - -# Run test -pushd "${PROJECT_DIR}/tripleo_ansible/roles/${ROLE_NAME}" - molecule test --all -popd + "${PROJECT_DIR}/tripleo_ansible/playbooks/prepare-test-host.yml" \ + "${PROJECT_DIR}/zuul.d/playbooks/run-local.yml" diff --git a/tests/hosts.ini b/tests/hosts.ini index b6a3f656c..28280524b 100644 --- a/tests/hosts.ini +++ b/tests/hosts.ini @@ -1 +1 @@ -test ansible_connection=local +test ansible_connection=local ansible_host=localhost diff --git a/tox.ini b/tox.ini index 9643e16d1..65262ede9 100644 --- a/tox.ini +++ b/tox.ini @@ -44,7 +44,8 @@ commands = [testenv:ansible-lint] envdir = {toxworkdir}/linters -deps = {[testenv:linters]deps} +deps = + {[testenv:linters]deps} commands = bash -c "ansible-galaxy install -fr {toxinidir}/tripleo_ansible/ansible-role-requirements.yml" python -m pre_commit run ansible-lint -a @@ -75,9 +76,9 @@ commands = [testenv:linters] deps = - {[testenv:mol]deps} - -r {toxinidir}/test-requirements.txt -r {toxinidir}/requirements.txt + -r {toxinidir}/test-requirements.txt + -r {toxinidir}/molecule-requirements.txt commands = {[testenv:pep8]commands} {[testenv:ansible-lint]commands} @@ -108,218 +109,9 @@ ignore = D001 commands = {posargs} [testenv:role-addition] -basepython={[testenv:mol]basepython} deps= - {[testenv:mol]deps} {[testenv:linters]deps} commands = bash -c "ansible-playbook -i localhost, role-addition.yml -e role_name=skeleton_test" bash -c "pushd {toxinidir}/tripleo_ansible/roles/skeleton_test; molecule test --all; popd" {[testenv:linters]commands} - -[testenv:mol] # environment naming scheme "mol-$ROLE_NAME" -# basepython forces tox to use system python and avoid other -# python versions like pyenv ones -basepython=python -deps = - -r {toxinidir}/molecule-requirements.txt - -[testenv:mol-aide] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/aide -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-test_deps] -basepython={[testenv:mol]basepython} -deps={[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/test_deps -envdir = {toxworkdir}/mol -commands = - python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-test_json_error_callback] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/test_json_error_callback -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-test_package_action] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/test_package_action -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-test_package_action-default] -basepython = {[testenv:mol-test_package_action]basepython} -deps = {[testenv:mol-test_package_action]deps} -changedir = {[testenv:mol-test_package_action]changedir} -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-test_package_action-negative] -basepython = {[testenv:mol-test_package_action]basepython} -deps = {[testenv:mol-test_package_action]deps} -changedir = {[testenv:mol-test_package_action]changedir} -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=negative - -[testenv:mol-test_package_action-positive] -basepython = {[testenv:mol-test_package_action]basepython} -deps = {[testenv:mol-test_package_action]deps} -changedir = {[testenv:mol-test_package_action]changedir} -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=positive - -[testenv:mol-tuned] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tuned -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-bootstrap] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-bootstrap -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-create-admin] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-create-admin -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-create-admin-default] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-create-admin -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-tripleo-create-admin-keyadd] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-create-admin -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=keyadd - -[testenv:mol-tripleo-create-admin-keygen] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-create-admin -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=keygen - -[testenv:mol-tripleo-module-load] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-module-load -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-module-load-default] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-module-load -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-tripleo-module-load-remove_module] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-module-load -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=remove_module - -[testenv:mol-tripleo-module-load-legacy_vars] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-module-load -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars - -[testenv:mol-tripleo-ssh-known-hosts] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-ssh-known-hosts -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-ssh-known-hosts-default] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-ssh-known-hosts -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-tripleo-ssh-known-hosts-legacy_vars] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-ssh-known-hosts -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars - -[testenv:mol-tripleo-container-tag] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-tag -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-container-tag-default] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-tag -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-tripleo-container-tag-podman] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-tag -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=podman - -[testenv:mol-tripleo-container-tag-legacy_vars] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-tag -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars - -[testenv:mol-tripleo-container-rm] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-container-rm-default] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-tripleo-container-rm-docker] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=docker - -[testenv:mol-tripleo-container-rm-docker_rm] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=docker_rm - -[testenv:mol-tripleo-container-rm-legacy_vars] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars - -[testenv:mol-tripleo-image-serve] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-image-serve -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py - -[testenv:mol-tripleo-image-serve-default] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-image-serve -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default - -[testenv:mol-tripleo-image-serve-legacy_vars] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-image-serve -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars - -[testenv:mol-tripleo-transfer] -basepython = {[testenv:mol]basepython} -deps = {[testenv:mol]deps} -changedir = {toxinidir}/tripleo_ansible/roles/tripleo-transfer -commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml index d7ae6cef1..64dd840d8 100644 --- a/zuul.d/base.yaml +++ b/zuul.d/base.yaml @@ -1,21 +1,19 @@ --- - job: - name: tripleo-ansible-centos - parent: tox-molecule - description: Basic tripleo-ansible tox job - timeout: 900 + description: Base tripleo-ansible job + name: tripleo-ansible-centos-7-base nodeset: centos-7 + parent: base + pre-run: + - tripleo_ansible/playbooks/prepare-test-host.yml + - zuul.d/playbooks/pre.yml + run: + - zuul.d/playbooks/run.yml + timeout: 1800 voting: true - job: - name: tripleo-ansible-centos-sudo - parent: openstack-tox-with-sudo - description: Basic tripleo-ansible tox job with sudo - timeout: 900 - nodeset: centos-7 - voting: true -- job: - name: tripleo-ansible-docs - parent: openstack-tox-docs files: - ^doc/.* - ^README.rst + name: tripleo-ansible-docs + parent: openstack-tox-docs diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index 7096bf16e..1a90b3166 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -37,106 +37,101 @@ files: - ^tripleo_ansible/roles/aide/.* name: tripleo-ansible-centos-7-molecule-aide - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-aide + tripleo_role_name: aide - job: files: - ^tripleo_ansible/roles/test_deps/.* name: tripleo-ansible-centos-7-molecule-test_deps - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-test_deps + tripleo_role_name: test_deps - job: files: - ^tripleo_ansible/roles/test_json_error_callback/.* name: tripleo-ansible-centos-7-molecule-test_json_error_callback - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-test_json_error_callback + tripleo_role_name: test_json_error_callback - job: files: - ^tripleo_ansible/ansible_plugins/action/package.py - ^tripleo_ansible/roles/test_package_action/.* name: tripleo-ansible-centos-7-molecule-test_package_action - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-test_package_action + tripleo_role_name: test_package_action - job: files: - ^tripleo_ansible/roles/tripleo-bootstrap/.* name: tripleo-ansible-centos-7-molecule-tripleo-bootstrap - parent: tripleo-ansible-centos - timeout: 1800 + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-bootstrap + tripleo_role_name: tripleo-bootstrap - job: files: - ^tripleo_ansible/roles/tuned/.* name: tripleo-ansible-centos-7-molecule-tuned - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tuned + tripleo_role_name: tuned - job: files: - ^_skeleton_role_/.* - ^role-addition.yml name: tripleo-ansible-centos-7-role-addition - parent: tripleo-ansible-centos + nodeset: centos-7 + parent: openstack-tox + timeout: 1800 vars: tox_envlist: role-addition - job: files: - ^tripleo_ansible/roles/tripleo-create-admin/.* name: tripleo-ansible-centos-7-molecule-tripleo-create-admin - parent: tripleo-ansible-centos - timeout: 1800 + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-create-admin + tripleo_role_name: tripleo-create-admin - job: files: - ^tripleo_ansible/roles/tripleo-module-load/.* name: tripleo-ansible-centos-7-molecule-tripleo-module-load - parent: tripleo-ansible-centos - timeout: 1800 + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-module-load + tripleo_role_name: tripleo-module-load - job: files: - ^tripleo_ansible/roles/tripleo-ssh-known-hosts/.* name: tripleo-ansible-centos-7-molecule-tripleo-ssh-known-hosts - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-ssh-known-hosts + tripleo_role_name: tripleo-ssh-known-hosts - job: files: - ^tripleo_ansible/roles/tripleo-container-tag/.* name: tripleo-ansible-centos-7-molecule-tripleo-container-tag - parent: tripleo-ansible-centos-sudo - pre-run: - - tripleo_ansible/playbooks/prepare-test-host.yml + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-container-tag + tripleo_role_name: tripleo-container-tag - job: files: - ^tripleo_ansible/roles/tripleo-container-rm/.* name: tripleo-ansible-centos-7-molecule-tripleo-container-rm - parent: tripleo-ansible-centos-sudo - pre-run: - - tripleo_ansible/playbooks/prepare-test-host.yml + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-container-rm + tripleo_role_name: tripleo-container-rm - job: files: - ^tripleo_ansible/roles/tripleo-image-serve/.* name: tripleo-ansible-centos-7-molecule-tripleo-image-serve - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-image-serve + tripleo_role_name: tripleo-image-serve - job: files: - ^tripleo_ansible/roles/tripleo-transfer/.* name: tripleo-ansible-centos-7-molecule-tripleo-transfer - parent: tripleo-ansible-centos + parent: tripleo-ansible-centos-7-base vars: - tox_envlist: mol-tripleo-transfer + tripleo_role_name: tripleo-transfer diff --git a/zuul.d/playbooks/pre.yml b/zuul.d/playbooks/pre.yml new file mode 100644 index 000000000..27874d985 --- /dev/null +++ b/zuul.d/playbooks/pre.yml @@ -0,0 +1,28 @@ +--- + +- hosts: all + pre_tasks: + - name: Ensure output dirs + file: + path: "{{ ansible_user_dir }}/zuul-output/logs" + state: directory + + - name: Setup bindep + pip: + name: "bindep" + virtualenv: "{{ ansible_user_dir }}/test-python" + virtualenv_site_packages: true + + - name: Run bindep + shell: |- + . {{ ansible_user_dir }}/test-python/bin/activate + {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/scripts/bindep-install + become: true + + - name: Setup test-python + pip: + requirements: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/molecule-requirements.txt" + virtualenv: "{{ ansible_user_dir }}/test-python" + virtualenv_site_packages: true + roles: + - role: install-docker diff --git a/zuul.d/playbooks/run-local.yml b/zuul.d/playbooks/run-local.yml new file mode 100644 index 000000000..65d4d5e12 --- /dev/null +++ b/zuul.d/playbooks/run-local.yml @@ -0,0 +1,14 @@ +--- + +- hosts: all + tasks: + - name: set basic zuul fact + set_fact: + zuul: + project: + src_dir: "{{ tripleo_src }}" + ansible_connection: ssh + +- import_playbook: pre.yml + +- import_playbook: run.yml diff --git a/zuul.d/playbooks/run.yml b/zuul.d/playbooks/run.yml new file mode 100644 index 000000000..bd264dd21 --- /dev/null +++ b/zuul.d/playbooks/run.yml @@ -0,0 +1,18 @@ +--- + +- hosts: all + environment: + ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/zuul-output/logs/ansible-execution.log" + tasks: + - name: Run role test job + shell: |- + . {{ ansible_user_dir }}/test-python/bin/activate + . {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/ansible-test-env.rc + pytest --color=no \ + --html={{ ansible_user_dir }}/zuul-output/logs/reports.html \ + --self-contained-html \ + -s \ + {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py + args: + chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tripleo_ansible/roles/{{ tripleo_role_name }}" + executable: /bin/bash