From 15ea787ab91dd7f2f1cdea129e387dfc2b6dd1a7 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Thu, 26 Jun 2025 15:10:33 +0000 Subject: [PATCH] tests: Adds common setup steps There are 2 types of tests being run: single node, and multi node. Adds GitHub actions for these 2 types of scenarios, with the common steps for those scenarios. This should make future tests easier to write and review. Signed-off-by: Claudiu Belu --- .../actions/test-multi-node-setup/action.yml | 98 ++++ .../actions/test-single-node-setup/action.yml | 46 ++ .github/workflows/tests.yml | 477 +++--------------- 3 files changed, 213 insertions(+), 408 deletions(-) create mode 100644 .github/actions/test-multi-node-setup/action.yml create mode 100644 .github/actions/test-single-node-setup/action.yml diff --git a/.github/actions/test-multi-node-setup/action.yml b/.github/actions/test-multi-node-setup/action.yml new file mode 100644 index 000000000..359eb2b97 --- /dev/null +++ b/.github/actions/test-multi-node-setup/action.yml @@ -0,0 +1,98 @@ +name: MicroCeph Test Multi Node Setup +description: Common setup steps for MicroCeph multi node testing + +inputs: + container-network-name: + description: Container network name for create_containers. + required: false + default: "public" + + ceph-release: + description: | + Ceph release to be installed from the store. If empty, the local + microceph snap will be installed instead. + required: false + default: "" + + bootstrap-parameters: + description: | + Space-separated parameters to be used for the "Bootstrap" step. + Skipped if empty. + required: false + default: bootstrap_head public + + setup-cluster-parameters: + description: | + Space-separated parameters to be used for the "Setup cluster" step. + Skipped if empty. + required: false + default: cluster_nodes public + + osd-count: + description: Number of OSDs to add. Skipped if 0. + required: false + default: 0 + +runs: + using: "composite" + steps: + - name: Download snap + uses: actions/download-artifact@v4 + with: + name: snaps + path: /home/runner + + - name: Copy utils + shell: bash + run: cp tests/scripts/actionutils.sh $HOME + + - name: Clear FORWARD firewall rules + shell: bash + run: ~/actionutils.sh cleaript + + - name: Free disk + shell: bash + run: ~/actionutils.sh free_runner_disk + + - name: Install dependencies + shell: bash + run: | + ~/actionutils.sh install_tools + ~/actionutils.sh setup_lxd + + - name: Create containers with loopback devices + shell: bash + run: ~/actionutils.sh create_containers ${{ inputs.container-network-name }} + + - name: Install ceph release from store + if: "${{ inputs.ceph-release != '' }}" + shell: bash + run: ~/actionutils.sh install_store ${{ inputs.ceph-release }} + + - name: Install local microceph snap + if: "${{ inputs.ceph-release == '' }}" + shell: bash + run: ~/actionutils.sh install_multinode + + - name: Bootstrap + if: "${{ inputs.bootstrap-parameters != '' }}" + shell: bash + run: ~/actionutils.sh ${{ inputs.bootstrap-parameters }} + + - name: Setup cluster + if: "${{ inputs.setup-cluster-parameters != '' }}" + shell: bash + run: ~/actionutils.sh ${{ inputs.setup-cluster-parameters }} + + - name: Add and wait for OSDs + if: ${{ inputs.osd-count != 0 }} + shell: bash + run: | + set -uex + for i in $(seq 0 $[${{ inputs.osd-count }} - 1]) ; do + ~/actionutils.sh add_osd_to_node "node-wrk$i" + done + + ~/actionutils.sh headexec wait_for_osds ${{ inputs.osd-count }} + + lxc exec node-wrk0 -- sh -c "microceph.ceph -s" diff --git a/.github/actions/test-single-node-setup/action.yml b/.github/actions/test-single-node-setup/action.yml new file mode 100644 index 000000000..d88882c41 --- /dev/null +++ b/.github/actions/test-single-node-setup/action.yml @@ -0,0 +1,46 @@ +name: MicroCeph Test Single Node Setup +description: Common setup steps for MicroCeph single node testing + +inputs: + osd-count: + description: Number of OSDs to add. Skipped if 0. + required: false + default: 0 + +runs: + using: "composite" + steps: + - name: Download snap + uses: actions/download-artifact@v4 + with: + name: snaps + path: /home/runner + + - name: Copy utils + shell: bash + run: cp tests/scripts/actionutils.sh $HOME + + - name: Clear FORWARD firewall rules + shell: bash + run: ~/actionutils.sh cleaript + + - name: Free disk + shell: bash + run: ~/actionutils.sh free_runner_disk + + - name: Install local microceph snap and setup + shell: bash + run: | + ~/actionutils.sh install_tools + ~/actionutils.sh install_microceph + + - name: Add loopback file OSDs + if: ${{ inputs.osd-count != 0 }} + shell: bash + run: | + set -uex + + sudo microceph disk add loop,1G,${{ inputs.osd-count }} + ~/actionutils.sh wait_for_osds ${{ inputs.osd-count }} + + sudo microceph.ceph -s diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 529f707e8..c881cd966 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,28 +69,16 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Free disk - run: ~/actionutils.sh free_runner_disk + - name: MicroCeph test common single node setup + uses: ./.github/actions/test-single-node-setup - - name: Install and setup + - name: Verify metadata run: | - ~/actionutils.sh install_tools - ~/actionutils.sh install_microceph - set -uex # Verify metadata.yaml meta=/var/snap/microceph/current/conf/metadata.yaml @@ -277,40 +265,13 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head public - - - name: Setup cluster - run: ~/actionutils.sh cluster_nodes public + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup - name: Verify config run: ~/actionutils.sh test_ceph_conf @@ -406,46 +367,18 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers internal - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head internal - - - name: Setup cluster - run: ~/actionutils.sh cluster_nodes internal - - - name: Add 3 OSDs - run: | - for c in node-wrk0 node-wrk1 node-wrk2 ; do - ~/actionutils.sh add_osd_to_node $c - done + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + container-network-name: internal + bootstrap-parameters: bootstrap_head internal + setup-cluster-parameters: cluster_nodes internal + osd-count: 3 - name: Test 3 osds present run: | @@ -463,48 +396,18 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: ~/actionutils.sh setup_lxd - - - name: Create 4 containers with loopback devices - run: ~/actionutils.sh create_containers internal - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head internal - - - name: Setup cluster - run: ~/actionutils.sh cluster_nodes internal - - - name: Add and wait for OSDs - run: | - set -uex - for i in 0 1 2 3 ; do - ~/actionutils.sh add_osd_to_node "node-wrk$i" - done - ~/actionutils.sh headexec wait_for_osds 4 + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + container-network-name: internal + bootstrap-parameters: bootstrap_head internal + setup-cluster-parameters: cluster_nodes internal + osd-count: 4 - name: Wait for ceph cluster to settle run: | @@ -563,37 +466,15 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install and setup - run: | - ~/actionutils.sh install_tools - ~/actionutils.sh install_microceph - - - name: Add loopback file OSDs - run: | - set -uex - sudo microceph disk add loop,1G,4 - ~/actionutils.sh wait_for_osds 4 - sudo microceph.ceph -s + - name: MicroCeph test common single node setup + uses: ./.github/actions/test-single-node-setup + with: + osd-count: 4 - name: Enable RGW run: ~/actionutils.sh enable_rgw @@ -618,37 +499,15 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install and setup - run: | - ~/actionutils.sh install_tools - ~/actionutils.sh install_microceph - - - name: Add loopback file OSDs - run: | - set -uex - sudo microceph disk add loop,1G,3 - ~/actionutils.sh wait_for_osds 3 - sudo microceph.ceph -s + - name: MicroCeph test common single node setup + uses: ./.github/actions/test-single-node-setup + with: + osd-count: 3 - name: Add WAL/DB enabled OSD run: | @@ -686,49 +545,18 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: | - ~/actionutils.sh install_tools - ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install quincy stable from store - run: ~/actionutils.sh install_store quincy/stable - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head - - - name: Setup cluster - run: ~/actionutils.sh cluster_nodes - - - name: Add 3 OSDs - run: | - for c in node-wrk0 node-wrk1 node-wrk2 ; do - ~/actionutils.sh add_osd_to_node $c - done - ~/actionutils.sh headexec wait_for_osds 3 + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + ceph-release: "quincy/stable" + bootstrap-parameters: "bootstrap_head" + setup-cluster-parameters: "cluster_nodes" + osd-count: 3 - name: Enable RGW run: ~/actionutils.sh headexec enable_rgw @@ -759,49 +587,18 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: | - ~/actionutils.sh install_tools - ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install reef stable from store - run: ~/actionutils.sh install_store reef/stable - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head - - - name: Setup cluster - run: ~/actionutils.sh cluster_nodes - - - name: Add 3 OSDs - run: | - for c in node-wrk0 node-wrk1 node-wrk2 ; do - ~/actionutils.sh add_osd_to_node $c - done - ~/actionutils.sh headexec wait_for_osds 3 + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + ceph-release: "reef/stable" + bootstrap-parameters: "bootstrap_head" + setup-cluster-parameters: "cluster_nodes" + osd-count: 3 - name: Enable RGW run: ~/actionutils.sh headexec enable_rgw @@ -835,37 +632,15 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install and setup - run: | - ~/actionutils.sh install_tools - ~/actionutils.sh install_microceph - - - name: Add loopback file OSDs - run: | - set -uex - sudo microceph disk add loop,1G,3 - ~/actionutils.sh wait_for_osds 3 - sudo microceph.ceph -s + - name: MicroCeph test common single node setup + uses: ./.github/actions/test-single-node-setup + with: + osd-count: 3 - name: Enable RGW run: ~/actionutils.sh enable_rgw @@ -884,39 +659,16 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: | - ~/actionutils.sh install_tools - ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - - name: Bootstrap - run: ~/actionutils.sh remote_simple_bootstrap_two_sites + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + bootstrap-parameters: "remote_simple_bootstrap_two_sites" + setup-cluster-parameters: "" - name: Exchange Cluster tokens run: ~/actionutils.sh remote_exchange_site_tokens @@ -953,35 +705,16 @@ jobs: runs-on: ubuntu-24.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - name: Bootstrap - run: ~/actionutils.sh remote_simple_bootstrap_two_sites + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + bootstrap-parameters: "remote_simple_bootstrap_two_sites" + setup-cluster-parameters: "" - name: Exchange Cluster tokens run: ~/actionutils.sh remote_exchange_site_tokens @@ -1015,35 +748,15 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install and setup - run: ~/actionutils.sh install_microceph - - - name: Add loopback file OSDs - run: | - set -uex - sudo microceph disk add loop,1G,3 - ~/actionutils.sh wait_for_osds 3 - sudo microceph.ceph -s + - name: MicroCeph test common single node setup + uses: ./.github/actions/test-single-node-setup + with: + osd-count: 3 - name: Enable NFS run: ~/actionutils.sh enable_nfs foo @@ -1080,46 +793,15 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head public - - - name: Setup cluster - run: ~/actionutils.sh cluster_nodes public - - - name: Add 3 OSDs - run: | - for c in node-wrk0 node-wrk1 node-wrk2 ; do - ~/actionutils.sh add_osd_to_node $c - done + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + osd-count: 3 - name: Enable NFS run: ~/actionutils.sh enable_nfs_in_nodes foo node-wrk0 node-wrk1 node-wrk2 @@ -1154,37 +836,16 @@ jobs: runs-on: ubuntu-22.04 needs: build-microceph steps: - - name: Download snap - uses: actions/download-artifact@v4 - with: - name: snaps - path: /home/runner - - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Copy utils - run: cp tests/scripts/actionutils.sh $HOME - - - name: Clear FORWARD firewall rules - run: ~/actionutils.sh cleaript - - - name: Free disk - run: ~/actionutils.sh free_runner_disk - - - name: Install dependencies - run: ~/actionutils.sh setup_lxd - - - name: Create containers with loopback devices - run: ~/actionutils.sh create_containers public - - - name: Install local microceph snap - run: ~/actionutils.sh install_multinode - - - name: Bootstrap - run: ~/actionutils.sh bootstrap_head public --v2-only + - name: MicroCeph test common multi node setup + uses: ./.github/actions/test-multi-node-setup + with: + bootstrap-parameters: bootstrap_head public --v2-only + setup-cluster-parameters: "" - name: Verify messenger v2 on head node run: ~/actionutils.sh test_v2_single_node