From e249723cf08041f9004f2b71c7d3beb18802d804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 31 Dec 2024 13:15:32 -0500 Subject: [PATCH] github: Split testsuite to separate action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .github/actions/testsuite/action.yml | 231 +++++++++++++++++++++++++++ .github/workflows/tests.yml | 177 +------------------- 2 files changed, 236 insertions(+), 172 deletions(-) create mode 100644 .github/actions/testsuite/action.yml diff --git a/.github/actions/testsuite/action.yml b/.github/actions/testsuite/action.yml new file mode 100644 index 000000000..d9df654df --- /dev/null +++ b/.github/actions/testsuite/action.yml @@ -0,0 +1,231 @@ +name: Test suite +description: Runs the testsuite +inputs: + backend: + required: true + go: + required: true + suite: + required: true + +runs: + using: "composite" + steps: + - name: Install Go (${{ inputs.go }}) + uses: actions/setup-go@v5 + with: + go-version: ${{ inputs.go }} + if: inputs.go != 'tip' + + - name: Install Go (stable) + uses: actions/setup-go@v5 + with: + go-version: stable + if: inputs.go == 'tip' + + - name: Install Go (tip) + shell: bash + run: | + echo "::group::Install Go (tip)" + + go install golang.org/dl/gotip@latest + gotip download + ~/sdk/gotip/bin/go version + echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV + + echo "::endgroup::" + if: inputs.go == 'tip' + + - name: Install dependencies + shell: bash + run: | + echo "::group::Install dependencies" + + set -x + sudo add-apt-repository ppa:ubuntu-lxc/daily -y --no-update + sudo add-apt-repository ppa:cowsql/stable -y --no-update + sudo apt-get update + + sudo systemctl mask lxc.service lxc-net.service + + sudo apt-get install --no-install-recommends -y \ + apparmor \ + bsdextrautils \ + bzip2 \ + curl \ + dosfstools \ + git \ + libacl1-dev \ + libcap-dev \ + libdbus-1-dev \ + libcowsql-dev \ + liblxc-dev \ + libseccomp-dev \ + libselinux-dev \ + libsqlite3-dev \ + libtool \ + libudev-dev \ + make \ + pkg-config\ + acl \ + attr \ + bind9-dnsutils \ + btrfs-progs \ + busybox-static \ + dnsmasq-base \ + easy-rsa \ + gettext \ + jq \ + lxc-utils \ + lvm2 \ + nftables \ + quota \ + rsync \ + s3cmd \ + socat \ + sqlite3 \ + squashfs-tools \ + tar \ + tcl \ + thin-provisioning-tools \ + uuid-runtime \ + xfsprogs \ + xz-utils \ + zfsutils-linux + + # Make sure all AppArmor profiles are loaded. + sudo systemctl start apparmor + + # Reclaim some space + sudo apt-get clean + + # Download minio. + curl -sSfL https://dl.min.io/server/minio/release/linux-$(dpkg --print-architecture)/archive/minio_20240116160738.0.0_$(dpkg --print-architecture).deb --output /tmp/minio.deb + sudo apt-get install /tmp/minio.deb --yes + + # Download MinIO client + curl -sSfL https://dl.min.io/client/mc/release/linux-$(dpkg --print-architecture)/archive/mc.RELEASE.2024-01-16T16-06-34Z --output /tmp/mc + sudo mv /tmp/mc /usr/local/bin/ + sudo chmod +x /usr/local/bin/mc + + # Download latest release of openfga server. + mkdir -p "$(go env GOPATH)/bin/" + curl -sSfL https://api.github.com/repos/openfga/openfga/releases/latest | jq -r ".assets | .[] | .browser_download_url | select(. | test(\"_linux_$(dpkg --print-architecture).tar.gz$\"))" | xargs -I {} curl -sSfL {} -o openfga.tar.gz + tar -xzf openfga.tar.gz -C "$(go env GOPATH)/bin/" + + # Download latest release of openfga cli. + curl -sSfL https://api.github.com/repos/openfga/cli/releases/latest | jq -r ".assets | .[] | .browser_download_url | select(. | test(\"_linux_$(dpkg --print-architecture).tar.gz$\"))" | xargs -I {} curl -sSfL {} -o fga.tar.gz + tar -xzf fga.tar.gz -C "$(go env GOPATH)/bin/" + + echo "::endgroup::" + + - name: Download go dependencies + shell: bash + run: | + echo "::group::Download go dependencies" + + go mod download + + echo "::endgroup::" + + - name: Run Incus build + shell: bash + env: + CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" + run: | + echo "::group::Run Incus build" + + make + + echo "::endgroup::" + + - name: Setup MicroCeph + shell: bash + if: ${{ inputs.backend == 'ceph' }} + run: | + echo "::group::Setup MicroCeph" + + set -x + + # If the rootfs and the ephemeral part are on the same physical disk, giving the whole + # disk to microceph would wipe our rootfs. Since it is pretty rare for GitHub Action + # runners to have a single disk, we immediately bail rather than trying to gracefully + # handle it. Once snapd releases with https://github.com/snapcore/snapd/pull/13150, + # we will be able to stop worrying about that special case. + if [ "$(stat -c '%d' /)" = "$(stat -c '%d' /mnt)" ]; then + echo "FAIL: rootfs and ephemeral part on the same disk, aborting" + exit 1 + fi + + sudo apt-get install --no-install-recommends -y snapd + sudo snap install microceph --channel=quincy/stable + sudo apt-get install --no-install-recommends -y ceph-common + sudo microceph cluster bootstrap + sudo microceph.ceph config set global osd_pool_default_size 1 + sudo microceph.ceph config set global mon_allow_pool_delete true + sudo microceph.ceph config set global osd_memory_target 939524096 + sudo microceph.ceph osd crush rule rm replicated_rule + sudo microceph.ceph osd crush rule create-replicated replicated default osd + for flag in nosnaptrim noscrub nobackfill norebalance norecover noscrub nodeep-scrub; do + sudo microceph.ceph osd set $flag + done + # Repurpose the ephemeral disk for ceph OSD. + sudo swapoff /mnt/swapfile + ephemeral_disk="$(findmnt --noheadings --output SOURCE --target /mnt | sed 's/[0-9]\+$//')" + sudo umount /mnt + sudo microceph disk add --wipe "${ephemeral_disk}" + sudo rm -rf /etc/ceph + sudo ln -s /var/snap/microceph/current/conf/ /etc/ceph + sudo microceph enable rgw + sudo microceph.ceph osd pool create cephfs_meta 32 + sudo microceph.ceph osd pool create cephfs_data 32 + sudo microceph.ceph fs new cephfs cephfs_meta cephfs_data + sudo microceph.ceph fs ls + sleep 30 + sudo microceph.ceph status + # Wait until there are no more "unkowns" pgs + for _ in $(seq 60); do + if sudo microceph.ceph pg stat | grep -wF unknown; then + sleep 1 + else + break + fi + done + sudo microceph.ceph status + sudo rm -f /snap/bin/rbd + + echo "::endgroup::" + + - name: "Ensure offline mode (block image server)" + shell: bash + run: | + echo "::group::Ensure offline mode (block image server)" + + sudo nft add table inet filter + sudo nft add chain 'inet filter output { type filter hook output priority 10 ; }' + sudo nft add rule inet filter output ip daddr 45.45.148.8 reject + sudo nft add rule inet filter output ip6 daddr 2602:fc62:a:1::8 reject + + echo "::endgroup::" + + - name: "Run system tests (${{ inputs.go }}, ${{ inputs.suite }}, ${{ inputs.backend }})" + shell: bash + env: + CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" + INCUS_CEPH_CLUSTER: "ceph" + INCUS_CEPH_CEPHFS: "cephfs" + INCUS_CEPH_CEPHOBJECT_RADOSGW: "http://127.0.0.1" + INCUS_CONCURRENT: "1" + INCUS_VERBOSE: "1" + INCUS_OFFLINE: "1" + INCUS_TMPFS: "1" + INCUS_REQUIRED_TESTS: "test_storage_buckets" + run: | + echo "::group::Run system tests" + + chmod +x ~ + echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid + cd test + sudo --preserve-env=PATH,GOPATH,GITHUB_ACTIONS,INCUS_VERBOSE,INCUS_BACKEND,INCUS_CEPH_CLUSTER,INCUS_CEPH_CEPHFS,INCUS_CEPH_CEPHOBJECT_RADOSGW,INCUS_OFFLINE,INCUS_SKIP_TESTS,INCUS_REQUIRED_TESTS, INCUS_BACKEND=${{ inputs.backend }} ./main.sh ${{ inputs.suite }} + + echo "::endgroup::" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 087d2d6b5..d7183f05d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -113,16 +113,6 @@ jobs: sudo --preserve-env=CGO_CFLAGS,CGO_LDFLAGS,CGO_LDFLAGS_ALLOW,LD_LIBRARY_PATH LD_LIBRARY_PATH=${LD_LIBRARY_PATH} env "PATH=${PATH}" go test ./... system-tests: - env: - CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)" - INCUS_CEPH_CLUSTER: "ceph" - INCUS_CEPH_CEPHFS: "cephfs" - INCUS_CEPH_CEPHOBJECT_RADOSGW: "http://127.0.0.1" - INCUS_CONCURRENT: "1" - INCUS_VERBOSE: "1" - INCUS_OFFLINE: "1" - INCUS_TMPFS: "1" - INCUS_REQUIRED_TESTS: "test_storage_buckets" name: System runs-on: ubuntu-22.04 strategy: @@ -197,169 +187,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Install Go (${{ matrix.go }}) - uses: actions/setup-go@v5 + - name: Run the testsuite + uses: ./.github/actions/testsuite with: - go-version: ${{ matrix.go }} - if: matrix.go != 'tip' - - - name: Install Go (stable) - uses: actions/setup-go@v5 - with: - go-version: stable - if: matrix.go == 'tip' - - - name: Install Go (tip) - run: | - go install golang.org/dl/gotip@latest - gotip download - ~/sdk/gotip/bin/go version - echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - if: matrix.go == 'tip' - - - name: Install dependencies - run: | - set -x - sudo add-apt-repository ppa:ubuntu-lxc/daily -y --no-update - sudo add-apt-repository ppa:cowsql/stable -y --no-update - sudo apt-get update - - sudo systemctl mask lxc.service lxc-net.service - - sudo apt-get install --no-install-recommends -y \ - curl \ - git \ - libacl1-dev \ - libcap-dev \ - libdbus-1-dev \ - libcowsql-dev \ - liblxc-dev \ - libseccomp-dev \ - libselinux-dev \ - libsqlite3-dev \ - libtool \ - libudev-dev \ - make \ - pkg-config\ - acl \ - attr \ - bind9-dnsutils \ - btrfs-progs \ - busybox-static \ - dnsmasq-base \ - easy-rsa \ - gettext \ - jq \ - lxc-utils \ - lvm2 \ - nftables \ - quota \ - rsync \ - s3cmd \ - socat \ - sqlite3 \ - squashfs-tools \ - tar \ - tcl \ - thin-provisioning-tools \ - uuid-runtime \ - xfsprogs \ - xz-utils \ - zfsutils-linux - - # reclaim some space - sudo apt-get clean - - # Download minio. - curl -sSfL https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20240116160738.0.0_amd64.deb --output /tmp/minio.deb - sudo apt-get install /tmp/minio.deb --yes - - # Download MinIO client - curl -sSfL https://dl.min.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2024-01-16T16-06-34Z --output /tmp/mc - sudo mv /tmp/mc /usr/local/bin/ - sudo chmod +x /usr/local/bin/mc - - # Download latest release of openfga server. - mkdir -p "$(go env GOPATH)/bin/" - curl -sSfL https://api.github.com/repos/openfga/openfga/releases/latest | jq -r '.assets | .[] | .browser_download_url | select(. | test("_linux_amd64.tar.gz$"))' | xargs -I {} curl -sSfL {} -o openfga.tar.gz - tar -xzf openfga.tar.gz -C "$(go env GOPATH)/bin/" - - # Download latest release of openfga cli. - curl -sSfL https://api.github.com/repos/openfga/cli/releases/latest | jq -r '.assets | .[] | .browser_download_url | select(. | test("_linux_amd64.tar.gz$"))' | xargs -I {} curl -sSfL {} -o fga.tar.gz - tar -xzf fga.tar.gz -C "$(go env GOPATH)/bin/" - - - name: Download go dependencies - run: | - go mod download - - - name: Run Incus build - run: | - make - - - name: Setup MicroCeph - if: ${{ matrix.backend == 'ceph' }} - run: | - set -x - - # If the rootfs and the ephemeral part are on the same physical disk, giving the whole - # disk to microceph would wipe our rootfs. Since it is pretty rare for GitHub Action - # runners to have a single disk, we immediately bail rather than trying to gracefully - # handle it. Once snapd releases with https://github.com/snapcore/snapd/pull/13150, - # we will be able to stop worrying about that special case. - if [ "$(stat -c '%d' /)" = "$(stat -c '%d' /mnt)" ]; then - echo "FAIL: rootfs and ephemeral part on the same disk, aborting" - exit 1 - fi - - sudo snap install microceph --channel=quincy/stable - sudo apt-get install --no-install-recommends -y ceph-common - sudo microceph cluster bootstrap - sudo microceph.ceph config set global osd_pool_default_size 1 - sudo microceph.ceph config set global mon_allow_pool_delete true - sudo microceph.ceph config set global osd_memory_target 939524096 - sudo microceph.ceph osd crush rule rm replicated_rule - sudo microceph.ceph osd crush rule create-replicated replicated default osd - for flag in nosnaptrim noscrub nobackfill norebalance norecover noscrub nodeep-scrub; do - sudo microceph.ceph osd set $flag - done - # Repurpose the ephemeral disk for ceph OSD. - sudo swapoff /mnt/swapfile - ephemeral_disk="$(findmnt --noheadings --output SOURCE --target /mnt | sed 's/[0-9]\+$//')" - sudo umount /mnt - sudo microceph disk add --wipe "${ephemeral_disk}" - sudo rm -rf /etc/ceph - sudo ln -s /var/snap/microceph/current/conf/ /etc/ceph - sudo microceph enable rgw - sudo microceph.ceph osd pool create cephfs_meta 32 - sudo microceph.ceph osd pool create cephfs_data 32 - sudo microceph.ceph fs new cephfs cephfs_meta cephfs_data - sudo microceph.ceph fs ls - sleep 30 - sudo microceph.ceph status - # Wait until there are no more "unkowns" pgs - for _ in $(seq 60); do - if sudo microceph.ceph pg stat | grep -wF unknown; then - sleep 1 - else - break - fi - done - sudo microceph.ceph status - sudo rm -f /snap/bin/rbd - - - name: "Ensure offline mode (block image server)" - run: | - sudo nft add table inet filter - sudo nft add chain 'inet filter output { type filter hook output priority 10 ; }' - sudo nft add rule inet filter output ip daddr 45.45.148.8 reject - sudo nft add rule inet filter output ip6 daddr 2602:fc62:a:1::8 reject - - - name: "Run system tests (${{ matrix.go }}, ${{ matrix.suite }}, ${{ matrix.backend }})" - run: | - chmod +x ~ - echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid - cd test - sudo --preserve-env=PATH,GOPATH,GITHUB_ACTIONS,INCUS_VERBOSE,INCUS_BACKEND,INCUS_CEPH_CLUSTER,INCUS_CEPH_CEPHFS,INCUS_CEPH_CEPHOBJECT_RADOSGW,INCUS_OFFLINE,INCUS_SKIP_TESTS,INCUS_REQUIRED_TESTS, INCUS_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }} + backend: ${{ matrix.backend }} + go: ${{ matrix.go }} + suite: ${{ matrix.suite }} client: name: Client