From 86b2a41e25e7fa254b7ea00ec927817922ce6725 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Tue, 3 Jun 2025 17:02:39 +0100 Subject: [PATCH] Initial Zuul config and testing migration --- .ansible-lint | 6 ++++++ lint-requirements.txt | 3 +++ tests/playbooks/post.yml | 11 +++++++++++ tests/playbooks/pre.yml | 13 +++++++++++++ tests/playbooks/run.yml | 18 ++++++++++++++++++ tox.ini | 31 +++++++++++++++++++++++++++++++ zuul.d/base.yaml | 9 +++++++++ zuul.d/jobs.yaml | 16 ++++++++++++++++ zuul.d/nodesets.yaml | 19 +++++++++++++++++++ zuul.d/project.yaml | 11 +++++++++++ 10 files changed, 137 insertions(+) create mode 100644 lint-requirements.txt create mode 100644 tests/playbooks/post.yml create mode 100644 tests/playbooks/pre.yml create mode 100644 tests/playbooks/run.yml create mode 100644 tox.ini create mode 100644 zuul.d/base.yaml create mode 100644 zuul.d/jobs.yaml create mode 100644 zuul.d/nodesets.yaml create mode 100644 zuul.d/project.yaml diff --git a/.ansible-lint b/.ansible-lint index 83ceea5..e3e77bc 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -5,6 +5,12 @@ exclude_paths: - changelogs/ - .github/ +mock_roles: + - ensure-docker + - ensure-pip + - ensure-podman + - ensure-output-dirs + skip_list: - var-naming[no-role-prefix] diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000..e50c1ee --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,3 @@ +ansible +ansible-lint<26 +antsibull-changelog diff --git a/tests/playbooks/post.yml b/tests/playbooks/post.yml new file mode 100644 index 0000000..7784117 --- /dev/null +++ b/tests/playbooks/post.yml @@ -0,0 +1,11 @@ +--- +- name: Prepare logs + hosts: all + vars: + zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" + tasks: + - name: Print all facts + copy: + content: "{{ hostvars[inventory_hostname] | to_nice_json }}" + dest: "{{ zuul_output_dir }}/facts.json" + mode: "0600" diff --git a/tests/playbooks/pre.yml b/tests/playbooks/pre.yml new file mode 100644 index 0000000..c7c9183 --- /dev/null +++ b/tests/playbooks/pre.yml @@ -0,0 +1,13 @@ +--- +- name: Prepare environment + hosts: all + any_errors_fatal: true + vars: + logs_dir: "/tmp/logs" + roles: + - ensure-output-dirs + - ensure-pip + - role: "ensure-docker" + when: cephadm_container_engine == "docker" + - role: "ensure-podman" + when: cephadm_container_engine == "podman" diff --git a/tests/playbooks/run.yml b/tests/playbooks/run.yml new file mode 100644 index 0000000..e4d2bef --- /dev/null +++ b/tests/playbooks/run.yml @@ -0,0 +1,18 @@ +--- +- name: Install catatonit package for Podman + hosts: all + any_errors_fatal: true + tasks: + - name: Install catatonit package for Podman + package: + name: catatonit + state: present + become: true + +- name: Run tests + hosts: all + any_errors_fatal: true + roles: + - role: cephadm + vars: + cephadm_public_interface: "{{ ansible_default_ipv4.interface }}" diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..79da0fd --- /dev/null +++ b/tox.ini @@ -0,0 +1,31 @@ +[tox] +minversion = 3.18 +envlist = py3,linters +ignore_basepython_conflict = True +skipsdist = True + +[testenv] +basepython = python3 +usedevelop = True +allowlist_externals = bash + find + rm +deps = -r{toxinidir}/test-requirements.txt +passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY, \ + OS_STDOUT_CAPTURE,OS_STDERR_CAPTURE,OS_LOG_CAPTURE,OS_TEST_TIMEOUT, \ + PYTHON,OS_TEST_PATH,LISTOPT,IDOPTION + +[testenv:linters] +deps = + -r{toxinidir}/lint-requirements.txt +allowlist_externals = bash + find +commands = + {[testenv:ansible-lint]commands} + +[testenv:ansible-lint] +setenv = {[testenv:linters]setenv} +deps = {[testenv:linters]deps} +commands = + ansible-lint -p --exclude zuul.d + antsibull-changelog lint diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml new file mode 100644 index 0000000..7e7e004 --- /dev/null +++ b/zuul.d/base.yaml @@ -0,0 +1,9 @@ +--- +- job: + parent: base + name: cephadm-base + pre-run: tests/playbooks/pre.yml + run: tests/playbooks/run.yml + post-run: tests/playbooks/post.yml + timeout: 7200 + post-timeout: 1800 diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 0000000..4c16727 --- /dev/null +++ b/zuul.d/jobs.yaml @@ -0,0 +1,16 @@ +--- +- job: + name: cephadm-jammy-singlenode-docker-reef + parent: cephadm-base + nodeset: cephadm-jammy-single + vars: + cephadm_ceph_release: reef + cephadm_container_engine: docker + +- job: + name: cephadm-jammy-singlenode-podman-reef + parent: cephadm-base + nodeset: cephadm-jammy-single + vars: + cephadm_ceph_release: reef + cephadm_container_engine: podman diff --git a/zuul.d/nodesets.yaml b/zuul.d/nodesets.yaml new file mode 100644 index 0000000..a9b8742 --- /dev/null +++ b/zuul.d/nodesets.yaml @@ -0,0 +1,19 @@ +--- +- nodeset: + name: cephadm-jammy-single + nodes: + - name: primary + label: ubuntu-jammy + groups: + - name: ceph + nodes: + - primary + - name: mons + nodes: + - primary + - name: mgrs + nodes: + - primary + - name: osds + nodes: + - primary diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml new file mode 100644 index 0000000..6f61ec2 --- /dev/null +++ b/zuul.d/project.yaml @@ -0,0 +1,11 @@ +--- +- project: + check: + jobs: + - cephadm-jammy-singlenode-docker-reef + - cephadm-jammy-singlenode-podman-reef + - tox-linters + gate: + jobs: + - cephadm-jammy-singlenode-docker-reef + - cephadm-jammy-singlenode-podman-reef