ci: run tests in containers
authorVincent Fu <vincent.fu@samsung.com>
Wed, 7 Aug 2024 21:17:29 +0000 (21:17 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 21 Aug 2024 19:18:42 +0000 (19:18 +0000)
This patch adds GitHub Actions tests that run in containers to support
running tests on Debian and Fedora. Ubuntu tests are also run in
containers.

The io_uring (t0018) and command priority (in latency_percentiles.py)
tests are not supported in containers, so the Ubuntu container tests
cannot replace the tests running directly on GitHub Actions Ubuntu
runners.

This is a single uncomfortably large patch because all of these changes
are required for the tests to pass.

Here is a list of changes:

ci.yml:
  add GitHub Actions jobs for the different containers
actions-build.sh:
  use bash found in PATH to pick up bash 4 installed on macOS because
    bash 4 is required to match multiple patterns in a case statement
  only enable cuda when running on Ubuntu because Debian does not have
    the cuda package by default
actions-full-test.sh:
  skip io_uring and cmdprio tests when running on containers because
    these features are not supported
actions-install.sh:
  install nvidia-cuda-dev only on Ubuntu because this is not available
    for Debian by default
  install additional packages when running on Debian and Ubuntu
    containers. These are already installed in the GHA image.
  install packages for Fedora
  install bash via homebrew on macOS to get bash v4

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
.github/workflows/ci.yml
ci/actions-build.sh
ci/actions-full-test.sh
ci/actions-install.sh

index e53082c302ecf6ffe41f94292265ab39c00a47b2..1601aa9ebbe1ae35b2eedf4904389c2403135ab1 100644 (file)
@@ -5,6 +5,38 @@ on:
   pull_request:
 
 jobs:
+  build-containers:
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        container:
+        - {os: 'debian', dh: 'debian', ver: 'bookworm', target_arch: 'x86_64'}
+        - {os: 'fedora', dh: 'fedora', ver: '40', target_arch: 'x86_64'}
+        - {os: 'ubuntu', dh: 'ubuntu', ver: 'noble', target_arch: 'i686'}
+        - {os: 'ubuntu', dh: 'ubuntu', ver: 'noble', target_arch: 'x86_64'}
+
+    container:
+      image: ${{ matrix.container.dh }}:${{ matrix.container.ver }}
+      env:
+        CI_TARGET_BUILD: Linux
+        CI_TARGET_ARCH: ${{ matrix.container.target_arch }}
+        CI_TARGET_OS: ${{ matrix.container.os }}
+        CI_TARGET_OS_VER: ${{ matrix.container.ver }}
+
+    steps:
+    - name: Checkout repo
+      uses: actions/checkout@v4
+    - name: Install dependencies
+      run:  ./ci/actions-install.sh
+    - name: Build
+      run:  ./ci/actions-build.sh
+    - name: Smoke test
+      run:  ./ci/actions-smoke-test.sh
+    - name: Full test
+      run:  ./ci/actions-full-test.sh
+
   build:
     runs-on: ${{ matrix.os }}
     strategy:
index 47d4f044ecc49b7cd3efa6ae061c8a06cb9260c0..de444a220306d32eef0196a9746833038fd5bdf7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # This script expects to be invoked from the base fio directory.
 set -eu
 
@@ -29,7 +29,16 @@ main() {
                 return 1
             fi
             ;;
-        */linux)
+        */linux | */ubuntu)
+            case "${CI_TARGET_ARCH}" in
+                "x86_64")
+                    configure_flags+=(
+                        "--enable-cuda"
+                    )
+                    ;;
+           esac
+           ;;&
+        */linux | */ubuntu | */debian | */fedora)
             case "${CI_TARGET_ARCH}" in
                 "i686")
                     extra_cflags="${extra_cflags} -m32"
@@ -37,7 +46,6 @@ main() {
                     ;;
                 "x86_64")
                     configure_flags+=(
-                        "--enable-cuda"
                         "--enable-libiscsi"
                         "--enable-libnbd"
                     )
index 126891333292cb9baf7696f5095866cdb82cff92..23bdd219820fc0fdb872d81783111fe630a38a3c 100755 (executable)
@@ -10,7 +10,31 @@ main() {
 
     echo "Running long running tests..."
     export PYTHONUNBUFFERED="TRUE"
-    python3 t/run-fio-tests.py --skip 6 1007 1008 --debug
+    skip=(
+        6
+       1007
+       1008
+    )
+    args=(
+        --debug
+    )
+    if [ "${GITHUB_JOB}" == "build-containers" ]; then
+        # io_uring is disabled in containers
+        # so skip the io_uring test
+        skip+=(
+            18
+        )
+       # cmd priority does not work in containers
+       # so skip the related latency test cases
+       args+=(
+           -p
+            "1010:--skip 15 16 17 18 19 20 21 22"
+        )
+
+    fi
+
+    echo python3 t/run-fio-tests.py --skip "${skip[@]}" "${args[@]}"
+    python3 t/run-fio-tests.py --skip "${skip[@]}" "${args[@]}"
     make -C doc html
 }
 
index 6eb2d795e7d1d93b0327c3bbd3a3fbcb4b295129..1796ee47187c54287685ba6bcfd12c6e8084eccb 100755 (executable)
@@ -9,6 +9,12 @@ SCRIPT_DIR=$(dirname "$0")
 install_ubuntu() {
     local pkgs
 
+    if [ "${GITHUB_JOB}" == "build-containers" ]; then
+        # containers run as root and do not have sudo
+        apt update
+        apt -y install sudo
+    fi
+
     cat <<DPKGCFG | sudo tee /etc/dpkg/dpkg.cfg.d/dpkg-speedup > /dev/null
 # Skip fsync
 force-unsafe-io
@@ -17,6 +23,7 @@ path-exclude=/usr/share/man/*
 path-exclude=/usr/share/locale/*/LC_MESSAGES/*.mo
 path-exclude=/usr/share/doc/*
 DPKGCFG
+
     # Packages available on i686 and x86_64
     pkgs=(
         libaio-dev
@@ -50,12 +57,18 @@ DPKGCFG
                 libprotobuf-c-dev
                 librbd-dev
                 libtcmalloc-minimal4
-                nvidia-cuda-dev
                 libibverbs-dev
                 librdmacm-dev
+               pkg-config
             )
            echo "Removing libunwind-14-dev because of conflicts with libunwind-dev"
            sudo apt remove -y libunwind-14-dev
+           if [ "${CI_TARGET_OS}" == "linux" ] || [ "${CI_TARGET_OS}" == "ubuntu" ]; then
+               # Only for Ubuntu
+               pkgs+=(
+                  nvidia-cuda-dev
+               )
+           fi
             ;;
     esac
 
@@ -66,6 +79,17 @@ DPKGCFG
        python3-sphinx
        python3-statsmodels
     )
+    if [ "${GITHUB_JOB}" == "build-containers" ]; then
+        pkgs+=(
+            bison
+            build-essential
+            cmake
+            flex
+            unzip
+            wget
+            zlib1g-dev
+        )
+    fi
 
     echo "Updating APT..."
     sudo apt-get -qq update
@@ -77,6 +101,39 @@ DPKGCFG
     fi
 }
 
+install_fedora() {
+    dnf install -y \
+        bison-devel \
+        cmake \
+        cunit-devel \
+        flex-devel \
+        kernel-devel \
+        libaio-devel \
+        libgfapi-devel \
+        libibverbs-devel \
+        libiscsi-devel \
+        libnbd-devel \
+        libnfs-devel \
+        libpmem-devel \
+        libpmem2-devel \
+        librbd-devel \
+        numactl-devel \
+        protobuf-c-devel \
+        python3-scipy \
+        python3-sphinx \
+        python3-statsmodels \
+        unzip \
+        valgrind-devel \
+        wget \
+
+    # install librpma from sources
+    ci/actions-install-librpma.sh
+}
+
+install_debian() {
+    install_ubuntu
+}
+
 install_linux() {
     install_ubuntu
 }
@@ -86,7 +143,7 @@ install_macos() {
     #echo "Updating homebrew..."
     #brew update >/dev/null 2>&1
     echo "Installing packages..."
-    HOMEBREW_NO_AUTO_UPDATE=1 brew install cunit libnfs
+    HOMEBREW_NO_AUTO_UPDATE=1 brew install cunit libnfs bash
     pip3 install scipy six statsmodels sphinx
 }