From d07a84cb66eb4d9bed4a5c70063af2ea89ff3946 Mon Sep 17 00:00:00 2001 From: ricolin Date: Wed, 17 Apr 2024 13:07:47 +0800 Subject: [PATCH] use zuul for molecule jobs --- .github/workflows/molecule.yml | 231 ---------------------- .gitignore | 2 + test-requirements.txt | 5 + tox.ini | 30 +++ zuul.d/jobs.yaml | 123 ++++++++++++ zuul.d/playbooks/molecule-upgrade/pre.yml | 20 ++ zuul.d/playbooks/molecule/post.yml | 29 +++ zuul.d/playbooks/molecule/pre.yml | 26 +++ zuul.d/playbooks/molecule/run.yml | 21 ++ zuul.d/project.yaml | 60 ++++++ 10 files changed, 316 insertions(+), 231 deletions(-) delete mode 100644 .github/workflows/molecule.yml create mode 100644 test-requirements.txt create mode 100644 tox.ini create mode 100644 zuul.d/jobs.yaml create mode 100644 zuul.d/playbooks/molecule-upgrade/pre.yml create mode 100644 zuul.d/playbooks/molecule/post.yml create mode 100644 zuul.d/playbooks/molecule/pre.yml create mode 100644 zuul.d/playbooks/molecule/run.yml create mode 100644 zuul.d/project.yaml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml deleted file mode 100644 index de7c0158..00000000 --- a/.github/workflows/molecule.yml +++ /dev/null @@ -1,231 +0,0 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -name: molecule - -on: - pull_request: - push: - branches: - - main - -jobs: - test-2204: - runs-on: v3-standard-8 - strategy: - fail-fast: false - matrix: - version: - - 18.2.1 - scenario: - - aio - - ha - distro: - - ubuntu2204 - steps: - - name: Checkout project - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: pip - - - name: Install Molecule - run: pip install -r requirements.txt - - # NOTE(mnaser): LVM commands take a long time if there are any existing - # loop devices created by "snapd", so we uninstall it. - - name: Uninstall "snapd" - run: sudo apt-get purge -y snapd - - - name: Generate random "fsid" using "uuidgen" - run: echo "MOLECULE_CEPH_FSID=$(uuidgen)" >> $GITHUB_ENV - - - name: Run Molecule - run: molecule test -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - test-2004: - runs-on: v3-standard-8 - strategy: - fail-fast: false - matrix: - version: - - 16.2.14 - - 17.2.7 - - 18.2.1 - scenario: - - aio - - ha - distro: - - ubuntu2004 - steps: - - name: Checkout project - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: pip - - - name: Install Molecule - run: pip install -r requirements.txt - - # NOTE(mnaser): LVM commands take a long time if there are any existing - # loop devices created by "snapd", so we uninstall it. - - name: Uninstall "snapd" - run: sudo apt-get purge -y snapd - - - name: Generate random "fsid" using "uuidgen" - run: echo "MOLECULE_CEPH_FSID=$(uuidgen)" >> $GITHUB_ENV - - - name: Run Molecule - run: molecule test -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - adopt: - runs-on: v3-standard-8 - strategy: - fail-fast: false - matrix: - version: - - 16.2.14 - - 17.2.7 - scenario: - - aio - - ha - distro: - - ubuntu2004 - steps: - - name: Checkout previous release - uses: actions/checkout@v3 - with: - ref: v2.2.0 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: pip - - - name: Install Molecule - run: pip install -r requirements.txt - - # NOTE(mnaser): LVM commands take a long time if there are any existing - # loop devices created by "snapd", so we uninstall it. - - name: Uninstall "snapd" - run: sudo apt-get purge -y snapd - - - name: Generate random "fsid" using "uuidgen" - run: echo "MOLECULE_CEPH_FSID=$(uuidgen)" >> $GITHUB_ENV - - - name: Run Molecule - run: molecule converge -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - - name: Run Molecule - run: molecule verify -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - - name: Checkout current release - uses: actions/checkout@v3 - - - name: Install Molecule - run: pip install -r requirements.txt - - - name: Run Molecule - run: molecule converge -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - - name: Run Molecule - run: molecule verify -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - upgrade: - runs-on: v3-standard-8 - strategy: - fail-fast: false - matrix: - version: - - 16.2.14 - - 17.2.7 - scenario: - - ha - distro: - - ubuntu2004 - steps: - - name: Checkout previous release - uses: actions/checkout@v3 - with: - ref: v2.2.0 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: pip - - - name: Install Molecule - run: pip install -r requirements.txt - - # NOTE(mnaser): LVM commands take a long time if there are any existing - # loop devices created by "snapd", so we uninstall it. - - name: Uninstall "snapd" - run: sudo apt-get purge -y snapd - - - name: Generate random "fsid" using "uuidgen" - run: echo "MOLECULE_CEPH_FSID=$(uuidgen)" >> $GITHUB_ENV - - - name: Run Molecule - run: molecule converge -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - - name: Run Molecule - run: molecule verify -s ${{ matrix.scenario }} - env: - MOLECULE_CEPH_VERSION: ${{ matrix.version }} - MOLECULE_DISTRO: ${{ matrix.distro }} - - - name: Checkout current release - uses: actions/checkout@v3 - - - name: Install Molecule - run: pip install -r requirements.txt - - - name: Run Molecule - run: molecule converge -s ${{ matrix.scenario }} - env: - MOLECULE_DISTRO: ${{ matrix.distro }} - - - name: Run Molecule - run: molecule verify -s ${{ matrix.scenario }} - env: - MOLECULE_DISTRO: ${{ matrix.distro }} diff --git a/.gitignore b/.gitignore index 1933d098..9c50e399 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ __pycache__ tests/output +.stestr +.tox diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..34b969f4 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +molecule +molecule-plugins[docker] +oslotest +stestr +testscenarios diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..e22fb6ab --- /dev/null +++ b/tox.ini @@ -0,0 +1,30 @@ +[tox] +minversion = 4 + +[testenv] +usedevelop = True +setenv = + VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE=1 +deps = + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt + +[testenv:venv] +passenv = + MOLECULE_CEPH_VERSION + MOLECULE_DISTRO +commands = + {posargs} + +[testenv:molecule-aio] +tetenv = + MOLECULE_CEPH_FSID = 1945b3ba-075d-4c35-9c60-315752d5f978 +commands = + molecule test -s aio + +[testenv:molecule-ha] +tetenv = + MOLECULE_CEPH_FSID = d8f45527-69bb-40fa-84da-52f4f292589b +commands = + molecule test -s ha diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 00000000..798cf16d --- /dev/null +++ b/zuul.d/jobs.yaml @@ -0,0 +1,123 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- job: + name: ceph-molecule + parent: tox + abstract: true + pre-run: zuul.d/playbooks/molecule/pre.yml + run: zuul.d/playbooks/molecule/run.yml + post-run: zuul.d/playbooks/molecule/post.yml + +# aio jobs +- job: + name: ceph-molecule-aio-base + abstract: true + parent: ceph-molecule + vars: + molecule_distro: ubuntu2204 + tox_envlist: molecule-aio + +- job: + name: ceph-molecule-aio-2004-base + abstract: true + parent: ceph-molecule-aio-base + vars: + molecule_distro: ubuntu2004 + +- job: + name: ceph-molecule-aio-18 + parent: ceph-molecule-aio-base + vars: + molecule_ceph_version: 18.2.1 + +- job: + name: ceph-molecule-aio-2004-18 + parent: ceph-molecule-aio-2004-base + vars: + molecule_ceph_version: 18.2.1 + +- job: + name: ceph-molecule-aio-2004-17 + parent: ceph-molecule-aio-2004-base + vars: + molecule_ceph_version: 17.2.7 + +- job: + name: ceph-molecule-aio-2004-16 + parent: ceph-molecule-aio-2004-base + vars: + molecule_ceph_version: 16.2.14 + +# ha jobs +- job: + name: ceph-molecule-ha-base + abstract: true + parent: ceph-molecule + vars: + molecule_distro: ubuntu2204 + tox_envlist: molecule-ha + +- job: + name: ceph-molecule-ha-2004-base + abstract: true + parent: ceph-molecule-ha-base + vars: + molecule_distro: ubuntu2004 + +- job: + name: ceph-molecule-ha-18 + parent: ceph-molecule-ha-base + vars: + molecule_ceph_version: 18.2.1 + +- job: + name: ceph-molecule-ha-2004-18 + parent: ceph-molecule-ha-2004-base + vars: + molecule_ceph_version: 18.2.1 + +- job: + name: ceph-molecule-ha-2004-17 + parent: ceph-molecule-ha-2004-base + vars: + molecule_ceph_version: 17.2.7 + +- job: + name: ceph-molecule-ha-2004-16 + parent: ceph-molecule-ha-2004-base + vars: + molecule_ceph_version: 16.2.14 + +# upgrade-adopt jobs +- job: + name: ceph-molecule-adopt-upgrade-16-18 + parent: ceph-molecule + pre-run: zuul.d/playbooks/molecule-upgrade/pre.yml + vars: + molecule_pre_ceph_version: 16.2.14 + molecule_ceph_version: 18.2.1 + molecule_distro: ubuntu2004 + tox_envlist: molecule-ha + timeout: 7200 + nodeset: + nodes: + - name: ubuntu-jammy + label: jammy-16c-64g + +- job: + name: ceph-molecule-adopt-upgrade-17-18 + parent: ceph-molecule-adopt-upgrade-16-18 + vars: + molecule_pre_ceph_version: 17.2.7 diff --git a/zuul.d/playbooks/molecule-upgrade/pre.yml b/zuul.d/playbooks/molecule-upgrade/pre.yml new file mode 100644 index 00000000..8527a95d --- /dev/null +++ b/zuul.d/playbooks/molecule-upgrade/pre.yml @@ -0,0 +1,20 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- hosts: all + become: true + roles: + - tox + environment: + MOLECULE_CEPH_VERSION: '{{ molecule_pre_ceph_version }}' diff --git a/zuul.d/playbooks/molecule/post.yml b/zuul.d/playbooks/molecule/post.yml new file mode 100644 index 00000000..0ededc5b --- /dev/null +++ b/zuul.d/playbooks/molecule/post.yml @@ -0,0 +1,29 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Finalize Molecule tests + hosts: all + tasks: + # NOTE(mnaser): Since we need to run Molecule using `sudo` because + # of a bug with the Kubernetes collection, we need to + # restore the permissions of the repository to the + # user that is running the tests. + - name: Fix permissions for repository + become: true + ansible.builtin.file: + path: "{{ zuul.project.src_dir }}" + state: directory + recurse: yes + owner: "{{ ansible_user }}" + group: "{{ ansible_user }}" diff --git a/zuul.d/playbooks/molecule/pre.yml b/zuul.d/playbooks/molecule/pre.yml new file mode 100644 index 00000000..34bb5a75 --- /dev/null +++ b/zuul.d/playbooks/molecule/pre.yml @@ -0,0 +1,26 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- name: Prepare host for Molecule tests + hosts: all + tasks: + - name: Uninstall "snapd" + ansible.builtin.command: sudo apt-get purge -y snapd + + - name: Generate random "fsid" using "uuidgen" + ansible.builtin.command: uuidgen + register: _fsid + + - name: Setup MOLECULE_CEPH_FSID environment variable + ansible.builtin.command: "export MOLECULE_CEPH_FSID={{ _fsid }}" diff --git a/zuul.d/playbooks/molecule/run.yml b/zuul.d/playbooks/molecule/run.yml new file mode 100644 index 00000000..a0c2ce05 --- /dev/null +++ b/zuul.d/playbooks/molecule/run.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- hosts: all + become: true + roles: + - tox + environment: + MOLECULE_CEPH_VERSION: '{{ molecule_ceph_version }}' + MOLECULE_DISTRO: '{{ molecule_distro }}' diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml new file mode 100644 index 00000000..8adfb25e --- /dev/null +++ b/zuul.d/project.yaml @@ -0,0 +1,60 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- project: + merge-mode: squash-merge + check: + jobs: + - ceph-molecule-aio-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-aio-2004-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-aio-2004-17: + dependencies: *molecule_check_dependencies + - ceph-molecule-aio-2004-16: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-2004-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-2004-17: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-2004-16: + dependencies: *molecule_check_dependencies + - ceph-molecule-adopt-upgrade-16-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-adopt-upgrade-16-18: + dependencies: *molecule_check_dependencies + gate: + jobs: + - ceph-molecule-aio-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-aio-2004-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-aio-2004-17: + dependencies: *molecule_check_dependencies + - ceph-molecule-aio-2004-16: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-2004-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-2004-17: + dependencies: *molecule_check_dependencies + - ceph-molecule-ha-2004-16: + dependencies: *molecule_check_dependencies + - ceph-molecule-adopt-upgrade-16-18: + dependencies: *molecule_check_dependencies + - ceph-molecule-adopt-upgrade-16-18: + dependencies: *molecule_check_dependencies