From 9d84a07807bec9dde916df8a24ec27a9fa226148 Mon Sep 17 00:00:00 2001 From: "Gael Chamoulaud (Strider)" Date: Fri, 18 Sep 2020 14:39:08 +0200 Subject: [PATCH] Add molecule tests runs back in the CI This patch reverts files which have been deleted with [1]. It also adds back the openstack-tox-linters job in the check queue. [1] https://opendev.org/openstack/validations-common/commit/b706d7c7c92eecd0aac5664288e43fb347eae782 Change-Id: Idd3bdb4aecf59ba20992e9c499efd8767e9d06be --- .zuul.yaml | 132 +++++++++++++++++++++++++++++++ playbooks/molecule/pre.yml | 82 +++++++++++++++++++ playbooks/molecule/run-local.yml | 13 +++ playbooks/molecule/run.yml | 19 +++++ scripts/run-local-test | 2 +- 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 playbooks/molecule/pre.yml create mode 100644 playbooks/molecule/run-local.yml create mode 100644 playbooks/molecule/run.yml diff --git a/.zuul.yaml b/.zuul.yaml index 047ca7e..812f613 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -16,15 +16,147 @@ - ^doc/.*$ - ^releasenotes/.*$ +- job: + description: Base validations-common job + name: validations-common-centos-8-base + nodeset: centos-8 + parent: base + success-url: "reports.html" + failure-url: "reports.html" + pre-run: + - tests/prepare-test-host.yml + - playbooks/molecule/pre.yml + run: + - playbooks/molecule/run.yml + timeout: 1800 + voting: true + - project: templates: - check-requirements - openstack-lower-constraints-jobs - openstack-python3-victoria-jobs + - validations-common-molecule-jobs check: jobs: + - openstack-tox-linters - validations-common-functional gate: jobs: - openstack-tox-linters - validations-common-functional + +- project-template: + check: + jobs: + - validations-common-centos-8-molecule-advanced_format_512e_support + - validations-common-centos-8-molecule-check_latest_packages_version + - validations-common-centos-8-molecule-dns + - validations-common-centos-8-molecule-haproxy + - validations-common-centos-8-molecule-ntp + - validations-common-centos-8-molecule-service_status + - validations-common-centos-8-molecule-check_cpu + - validations-common-centos-8-molecule-check_disk_space + - validations-common-centos-8-molecule-check_ram + - validations-common-centos-8-molecule-check_selinux_mode + - validations-common-centos-8-molecule-validate_selinux + - validations-common-centos-8-molecule-xfs_check_ftype + gate: + jobs: + - validations-common-centos-8-molecule-check_latest_packages_version + - validations-common-centos-8-molecule-dns + - validations-common-centos-8-molecule-haproxy + - validations-common-centos-8-molecule-check_cpu + - validations-common-centos-8-molecule-check_disk_space + - validations-common-centos-8-molecule-check_ram + - validations-common-centos-8-molecule-validate_selinux + name: validations-common-molecule-jobs +- job: + files: + - ^validations_common/roles/check_selinux_mode/.* + name: validations-common-centos-8-molecule-check_selinux_mode + parent: validations-common-centos-8-base + vars: + validations_common_role_name: check_selinux_mode + voting: false +- job: + files: + - ^validations_common/roles/ntp/.* + name: validations-common-centos-8-molecule-ntp + parent: validations-common-centos-8-base + vars: + validations_common_role_name: ntp + voting: false +- job: + files: + - ^validations_common/roles/service_status/.* + name: validations-common-centos-8-molecule-service_status + parent: validations-common-centos-8-base + vars: + validations_common_role_name: service_status + voting: false +- job: + files: + - ^validations_common/roles/advanced_format_512e_support/.* + name: validations-common-centos-8-molecule-advanced_format_512e_support + parent: validations-common-centos-8-base + vars: + validations_common_role_name: advanced_format_512e_support + voting: false +- job: + files: + - ^validations_common/roles/dns/.* + name: validations-common-centos-8-molecule-dns + parent: validations-common-centos-8-base + vars: + validations_common_role_name: dns +- job: + files: + - ^validations_common/roles/haproxy/.* + name: validations-common-centos-8-molecule-haproxy + parent: validations-common-centos-8-base + vars: + validations_common_role_name: haproxy +- job: + files: + - ^validations_common/roles/check_cpu/.* + name: validations-common-centos-8-molecule-check_cpu + parent: validations-common-centos-8-base + vars: + validations_common_role_name: check_cpu +- job: + files: + - ^validations_common/roles/check_ram/.* + name: validations-common-centos-8-molecule-check_ram + parent: validations-common-centos-8-base + vars: + validations_common_role_name: check_ram +- job: + files: + - ^validations_common/roles/check_disk_space/.* + name: validations-common-centos-8-molecule-check_disk_space + parent: validations-common-centos-8-base + vars: + validations_common_role_name: check_disk_space +- job: + files: + - ^validations_common/roles/xfs_check_ftype/.* + name: validations-common-centos-8-molecule-xfs_check_ftype + parent: validations-common-centos-8-base + vars: + validations_common_role_name: xfs_check_ftype + voting: false +- job: + files: + - ^validations_common/roles/check_latest_packages_version/.* + name: validations-common-centos-8-molecule-check_latest_packages_version + parent: validations-common-centos-8-base + vars: + validations_common_role_name: check_latest_packages_version +- job: + files: + - ^validations_common/roles/validate_selinux/.* + name: validations-common-centos-8-molecule-validate_selinux + parent: validations-common-centos-8-base + vars: + validations_common_role_name: validate_selinux diff --git a/playbooks/molecule/pre.yml b/playbooks/molecule/pre.yml new file mode 100644 index 0000000..2721d4c --- /dev/null +++ b/playbooks/molecule/pre.yml @@ -0,0 +1,82 @@ +--- +- hosts: all + pre_tasks: + - name: Ensure output dirs + file: + path: "{{ ansible_user_dir }}/zuul-output/logs" + state: directory + + - name: Ensure pip is available + include_role: + name: ensure-pip + + - name: Ensure virtualenv is available + include_role: + name: ensure-virtualenv + + - 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 + changed_when: false + + - name: Setup test-python + pip: + requirements: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/molecule-requirements.txt" + virtualenv: "{{ ansible_user_dir }}/test-python" + virtualenv_command: "{{ ensure_pip_virtualenv_command }}" + virtualenv_site_packages: true + + - name: Display test-python virtualenv package versions + shell: |- + . {{ ansible_user_dir }}/test-python/bin/activate + pip freeze + + - name: Basic ci setup + become: true + block: + - name: Ensure ci directories + file: + path: "/etc/ci" + state: "directory" + + - name: Ensure ci mirror file + file: + path: "/etc/ci/mirror_info.sh" + state: "touch" + + - name: Set an appropriate fs.file-max + sysctl: + name: fs.file-max + value: 2048000 + sysctl_set: true + state: present + reload: true + + - name: Set container_manage_cgroup boolean + seboolean: + name: container_manage_cgroup + state: true + persistent: true + failed_when: false + + - name: Create limits file for containers + copy: + content: | + * soft nofile 102400 + * hard nofile 204800 + * soft nproc 2048 + * hard nproc 4096 + dest: /etc/security/limits.d/containers.conf + + - name: Reset ssh connection + meta: reset_connection + roles: + - role: ensure-docker diff --git a/playbooks/molecule/run-local.yml b/playbooks/molecule/run-local.yml new file mode 100644 index 0000000..cd0f83e --- /dev/null +++ b/playbooks/molecule/run-local.yml @@ -0,0 +1,13 @@ +--- +- 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/playbooks/molecule/run.yml b/playbooks/molecule/run.yml new file mode 100644 index 0000000..fe0fcd0 --- /dev/null +++ b/playbooks/molecule/run.yml @@ -0,0 +1,19 @@ +--- +- 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 \ + --ansible-args='{{ tripleo_job_ansible_args | default("") }}' \ + {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py + args: + chdir: + "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/validations_common/roles/{{ validations_common_role_name }}" + executable: /bin/bash + changed_when: false diff --git a/scripts/run-local-test b/scripts/run-local-test index 5bba19d..c2e7258 100755 --- a/scripts/run-local-test +++ b/scripts/run-local-test @@ -67,4 +67,4 @@ ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \ -e "ansible_user=${USER}" \ -e "ansible_user_dir=${HOME}" \ "${PROJECT_DIR}/tests/prepare-test-host.yml" \ - "${PROJECT_DIR}/zuul.d/playbooks/run-local.yml" + "${PROJECT_DIR}/playbooks/molecule/run-local.yml"