summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorreuben olinsky <reubeno@users.noreply.github.com>2022-11-11 21:10:42 -0800
committerMing Lei <tom.leiming@gmail.com>2022-11-15 08:13:11 +0800
commit17f652d5196ef1e599a99546537fa8ec7d9f6ab1 (patch)
tree9d545554778de82709271e0e750f1c403eca52b9
parent9f29847ae1fe1242edd23873e6434a77ccdeb2ab (diff)
Add basic GitHub-hosted CI workflowv1.0-rc5
* Add build job that compiles the project in Ubuntu 22.04. Future changes could add steps here for more static analysis. * Add test job that, in parallel: - Uses systemd/mkosi to build a custom Fedora image that has a 6.0+ kernel and ublk et al. built + installed into it. Conveniently, the Fedora 6.0+ kernel images have CONFIG_BLK_DEV_UBLK set to 'm'. - Launches the image under QEMU (in software emulation mode because GitHub-hosted runners don't support using KVM) - Runs generic ublk tests (but doesn't yet deeply inspect the results); for now, tests that require newer kernel facilities--say, for recovery--will not work as expected in this environment. * Tweak build_with_liburing_src to support: - building outside the source tree - building with parallelism * Add a few more error checks to run_tests.sh Signed-off-by: reuben olinsky <reubeno.dev@gmail.com>
-rw-r--r--.github/workflows/ci.yml126
-rw-r--r--.gitignore1
-rwxr-xr-xbuild_with_liburing_src12
-rw-r--r--ci/.gitignore3
-rwxr-xr-xci/mkosi.build29
-rw-r--r--ci/mkosi.conf2
-rw-r--r--ci/mkosi.default.d/10-ubdsrv.conf28
-rw-r--r--ci/mkosi.default.d/fedora/10-fedora.conf22
-rw-r--r--ci/mkosi.extra/etc/modules-load.d/ublk-drv.conf1
-rw-r--r--lib/ublksrv.c5
-rwxr-xr-xtests/run_test.sh28
11 files changed, 252 insertions, 5 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..a49f27b
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,126 @@
+name: CI
+
+on:
+ workflow_dispatch:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+env:
+ URING_VER: "2.3"
+
+jobs:
+ build:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: "install: prerequisites"
+ shell: bash
+ run: |
+ sudo apt update
+ sudo apt install -y autoconf-archive
+
+ - name: "acquire: ubdsrv"
+ uses: actions/checkout@v3
+ with:
+ path: ubdsrv
+
+ - name: "acquire: liburing"
+ run: |
+ wget https://brick.kernel.dk/snaps/liburing-$URING_VER.tar.gz
+ tar xzvf liburing-$URING_VER.tar.gz
+
+ - name: "build: liburing"
+ working-directory: liburing-${{ env.URING_VER }}
+ shell: bash
+ run: |
+ ./configure
+ make -j$(nproc)
+ sudo make install
+
+ - name: "build: ubdsrv"
+ working-directory: ubdsrv
+ run: |
+ LIBURING_DIR=${{ github.workspace }}/liburing-$URING_VER ./build_with_liburing_src
+
+ - name: "build: installable artifacts"
+ working-directory: ubdsrv
+ shell: bash
+ run: |
+ mkdir -p ${{ github.workspace }}/files
+ make DESTDIR=${{ github.workspace }}/files install
+
+ - name: "publish: installable artifacts"
+ uses: actions/upload-artifact@v3
+ with:
+ name: ubdsrv
+ if-no-files-found: error
+ path: ${{ github.workspace }}/files/**
+
+ - name: "publish: logs"
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: build-logs
+ if-no-files-found: ignore
+ path: ubdsrv/*.log
+
+ test:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: "install: mkosi + dependencies"
+ shell: bash
+ run: |
+ sudo apt update
+ sudo apt install -y dnf rpm systemd-container qemu-system-x86 ovmf e2fsprogs
+ python3 -m pip install --user git+https://github.com/systemd/mkosi.git
+
+ # Required for ssh'ing into VM
+ - name: "setup: environment"
+ run: |
+ sudo systemctl enable --now systemd-networkd
+
+ - name: "cache: os packages"
+ uses: actions/cache@v3
+ with:
+ path: mkosi.cache
+ key: fedora-cache-v1
+
+ - name: "acquire: ubdsrv"
+ uses: actions/checkout@v3
+
+ - name: "build: fedora image"
+ working-directory: ci
+ run: |
+ sudo $(which mkosi) build
+
+ - name: "start: boot fedora in qemu"
+ working-directory: ci
+ run: |
+ RUNNER_TRACKING_ID="" && sudo $(which mkosi) qemu -serial none -monitor none -display none &
+
+ - name: "connect: check ssh connection"
+ shell: bash
+ timeout-minutes: 10
+ working-directory: ci
+ run: |
+ until mkosi ssh uname -a; do
+ echo "Retrying..."
+ sleep 0.25
+ done
+
+ - name: "test: run ublk"
+ working-directory: ci
+ run: |
+ mkosi ssh ublk list
+
+ - name: "test: run tests"
+ working-directory: ci
+ run: |
+ mkosi ssh UBLK=ublk /usr/share/tests/run_test.sh all 10 tests/tmp/
+
+ - name: "cleanup"
+ if: always()
+ continue-on-error: true
+ run: |
+ sudo pkill -f qemu
diff --git a/.gitignore b/.gitignore
index 93f4234..f1d723e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
.deps
.libs
+.dirstamp
Makefile
Makefile.in
diff --git a/build_with_liburing_src b/build_with_liburing_src
index 06056e0..4e24a32 100755
--- a/build_with_liburing_src
+++ b/build_with_liburing_src
@@ -5,15 +5,19 @@
# cd $LIBURING_DIR
# ./configure && make install
-autoreconf -i
+set -eo pipefail
+
+script_dir="$(dirname ${BASH_SOURCE[0]})"
+
+autoreconf -i "${script_dir}"
OPTS="-g -O0"
-: "${LIBURING_DIR:=/root/git/liburing}" #replace with your own liburing path
+: "${LIBURING_DIR:=/root/git/liburing}" #replace with your own liburing path
PKG_CONFIG_PATH=${LIBURING_DIR} \
-./configure \
+${script_dir}/configure \
--enable-gcc-warnings \
CFLAGS="-I${LIBURING_DIR}/src/include $OPTS" \
CXXFLAGS="-I${LIBURING_DIR}/src/include $OPTS" \
LDFLAGS="-L${LIBURING_DIR}/src"
-make
+make -j$(nproc)
diff --git a/ci/.gitignore b/ci/.gitignore
new file mode 100644
index 0000000..d0b02ac
--- /dev/null
+++ b/ci/.gitignore
@@ -0,0 +1,3 @@
+mkosi.builddir/
+mkosi.output/
+mkosi.cache/
diff --git a/ci/mkosi.build b/ci/mkosi.build
new file mode 100755
index 0000000..4c7cf50
--- /dev/null
+++ b/ci/mkosi.build
@@ -0,0 +1,29 @@
+#!/usr/bin/bash
+
+#
+# This is a build script file for OS image generation using mkosi (https://github.com/systemd/mkosi).
+# It is invoked in a build environment, with the following set well-known variables:
+#
+# $SRCDIR
+# $DESTDIR
+# $BUILDDIR
+#
+
+set -eo pipefail
+
+# Build newer version of liburing
+cd $SRCDIR
+git clone git://git.kernel.dk/liburing.git
+cd liburing
+./configure
+make -j$(nproc)
+make DESTDIR= install
+
+# Build in BUILDDIR and install to DESTDIR
+mkdir -p $BUILDDIR/ubdsrv
+LIBURING_DIR=$SRCDIR/liburing $SRCDIR/build_with_liburing_src
+make install
+
+# Copy tests into the dest
+mkdir -p $DESTDIR/usr/share
+cp -r $SRCDIR/tests $DESTDIR/usr/share/
diff --git a/ci/mkosi.conf b/ci/mkosi.conf
new file mode 100644
index 0000000..5197b11
--- /dev/null
+++ b/ci/mkosi.conf
@@ -0,0 +1,2 @@
+[Distribution]
+Distribution=fedora
diff --git a/ci/mkosi.default.d/10-ubdsrv.conf b/ci/mkosi.default.d/10-ubdsrv.conf
new file mode 100644
index 0000000..3ba3e50
--- /dev/null
+++ b/ci/mkosi.default.d/10-ubdsrv.conf
@@ -0,0 +1,28 @@
+# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
+
+[Output]
+Format=gpt_btrfs
+Bootable=yes
+HostonlyInitrd=yes
+OutputDirectory=mkosi.output
+QCow2=yes
+
+[Content]
+BuildDirectory=mkosi.builddir
+BuildSources=..
+Cache=mkosi.cache
+SourceFileTransfer=copy-git-cached
+WithNetwork=yes
+
+[Host]
+QemuHeadless=yes
+Netdev=yes
+Ssh=yes
+SshTimeout=300
+
+[Validation]
+Password=
+Autologin=yes
+
+[Partitions]
+RootSize=6G
diff --git a/ci/mkosi.default.d/fedora/10-fedora.conf b/ci/mkosi.default.d/fedora/10-fedora.conf
new file mode 100644
index 0000000..3f7b388
--- /dev/null
+++ b/ci/mkosi.default.d/fedora/10-fedora.conf
@@ -0,0 +1,22 @@
+# This is a settings file for OS image generation using mkosi (https://github.com/systemd/mkosi).
+
+[Distribution]
+Distribution=fedora
+
+[Content]
+BuildPackages=
+ autoconf
+ autoconf-archive
+ automake
+ diffutils
+ gcc
+ gcc-g++
+ git
+ libtool
+ make
+Packages=
+ fio
+ fio-engine-libaio
+ qemu-img
+ util-linux
+ which
diff --git a/ci/mkosi.extra/etc/modules-load.d/ublk-drv.conf b/ci/mkosi.extra/etc/modules-load.d/ublk-drv.conf
new file mode 100644
index 0000000..866965f
--- /dev/null
+++ b/ci/mkosi.extra/etc/modules-load.d/ublk-drv.conf
@@ -0,0 +1 @@
+ublk_drv
diff --git a/lib/ublksrv.c b/lib/ublksrv.c
index 6a2780e..daf9446 100644
--- a/lib/ublksrv.c
+++ b/lib/ublksrv.c
@@ -633,9 +633,14 @@ struct ublksrv_queue *ublksrv_queue_init(struct ublksrv_dev *dev,
ublksrv_dev_init_io_cmds(dev, q);
+ /*
+ * N.B. PR_SET_IO_FLUSHER was added with Linux 5.6+.
+ */
+#if defined(PR_SET_IO_FLUSHER)
if (prctl(PR_SET_IO_FLUSHER, 0, 0, 0, 0) != 0)
syslog(LOG_INFO, "ublk dev %d queue %d set_io_flusher failed",
q->dev->ctrl_dev->dev_info.dev_id, q->q_id);
+#endif
ublksrv_queue_adjust_uring_io_wq_workers(q);
diff --git a/tests/run_test.sh b/tests/run_test.sh
index 082b058..4e85987 100755
--- a/tests/run_test.sh
+++ b/tests/run_test.sh
@@ -2,10 +2,17 @@
# SPDX-License-Identifier: MIT or GPL-2.0-only
DIR=$(cd "$(dirname "$0")";pwd)
+cd $DIR
#. $DIR/common/fio_common
-export UBLK=${DIR}/../ublk
+: ${UBLK:=${DIR}/../ublk}
+if ! command -v "${UBLK}" &> /dev/null; then
+ echo "error: ublk command could not be found: ${UBLK}"
+ exit -1
+fi
+
+export UBLK
export TEST_DIR=$DIR
export UBLK_TMP=`mktemp /tmp/ublk_tmp_XXXXX`
@@ -38,11 +45,27 @@ run_test_all() {
done
}
+display_usage() {
+ echo 'usage:'
+ echo ' run_test.sh <test> <test_running_time> <temp_dir>'
+}
+
TEST=$1
+if [ -z "$TEST" ]; then
+ echo 'error: no test specified'
+ display_usage
+ exit -1
+fi
[ ! -c /dev/ublk-control ] && echo 'please run "modprobe ublk_drv" first' && exit -1
TDIR=$3
+if [ -z "$TDIR" ]; then
+ echo 'error: no temp dir specified'
+ display_usage
+ exit -1
+fi
+
if [ "${TDIR:0:1}" != "/" ]; then
TDIR=`dirname $PWD`/${TDIR}
fi
@@ -62,6 +85,9 @@ for _ITEM in "${_ITEMS[@]}"; do
run_test ${_ITEM}
elif [ `basename ${_ITEM}` = "all" ]; then
run_test_all `dirname ${_ITEM}`
+ else
+ echo "error: test suite not found: ${_ITEM}"
+ exit -1
fi
done