From 53d20e5abcfff299b6b1a025dbdfcccb71fc681e Mon Sep 17 00:00:00 2001 From: Kinga Stefaniuk Date: Tue, 1 Oct 2024 15:19:49 +0200 Subject: [PATCH] CI: use self-hosted runner to run tests Use prepared VM machine in GitHub actions to run mdadm tests on it. Signed-off-by: Kinga Stefaniuk --- .github/tools/run_mdadm_tests.sh | 9 ++++++ .github/workflows/tests.yml | 41 +++++++++++++++++++++++++ Detail.c | 2 +- test | 7 +++++ tests/07layouts.broken | 1 + tests/14imsm-r5_3d-migrate-r4_3d.broken | 1 + util.c | 2 -- 7 files changed, 60 insertions(+), 3 deletions(-) create mode 100755 .github/tools/run_mdadm_tests.sh create mode 100644 .github/workflows/tests.yml create mode 100644 tests/07layouts.broken create mode 100644 tests/14imsm-r5_3d-migrate-r4_3d.broken diff --git a/.github/tools/run_mdadm_tests.sh b/.github/tools/run_mdadm_tests.sh new file mode 100755 index 00000000..a4513a46 --- /dev/null +++ b/.github/tools/run_mdadm_tests.sh @@ -0,0 +1,9 @@ +#!/usr/bin/bash + +sudo make clean +sudo make -j$(nproc) +sudo make install +sudo mdadm -Ss +sudo ./test setup +sudo ./test --skip-broken --no-error --disable-integrity --disable-multipath --disable-linear --keep-going +sudo ./test cleanup \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..59601947 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +name: review +on: + pull_request: + paths: + - '*.c' + - '*.h' +jobs: + upstream_tests: + if: ${{ github.repository == 'md-raid-utilities/mdadm' }} + runs-on: self-hosted + timeout-minutes: 90 + name: upstream tests + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: 'Prepare machine' + run: | + cd .. + vagrant halt + vagrant status + vagrant up + - name: 'Run tests' + run: | + cd .. + vagrant ssh -c "cd /home/vagrant/host/mdadm && .github/tools/run_mdadm_tests.sh" + - uses: actions/download-artifact@v4 + with: + name: /var/tmp/*.log + cleanup: + runs-on: self-hosted + steps: + - name: Restore clean VM + run: | + cd .. + vagrant halt + - name: Stop md devices + run: sudo mdadm -Ss + - name: Clean logs + run: rm -rf /var/tmp/*.log diff --git a/Detail.c b/Detail.c index 5819ced9..3d1957b8 100644 --- a/Detail.c +++ b/Detail.c @@ -275,7 +275,7 @@ int Detail(char *dev, struct context *c) array.major_version, array.minor_version); } - + //test if (info && memcmp(info->uuid, uuid_zero, sizeof(int[4])) != 0) mp = map_by_uuid(&map, info->uuid); if (!mp) diff --git a/test b/test index 3a05bc9b..6f3b45ac 100755 --- a/test +++ b/test @@ -102,6 +102,9 @@ do_test() { if [ -f "$_script" ] then + if [ "${_basename:0:2}" == "$skip_prefix" ]; then + return + fi if [ -f "${_script}.broken" ]; then _broken=1 _broken_msg=$(head -n1 "${_script}.broken" | tr -d '\n') @@ -162,6 +165,7 @@ do_help() { --loop=N Run tests N times (0 to run forever) --skip-broken Skip tests that are known to be broken --skip-always-broken Skip tests that are known to always fail + --skip=prefix Skip group of tests starting with --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk --disks= Provide a bunch of physical devices for test --volgroup=name LVM volume group for LVM test @@ -265,6 +269,9 @@ parse_args() { --skip-always-broken ) skipbroken=always ;; + --skip=* ) + skip_prefix="${i##*=}" + ;; --disable-multipath ) unset MULTIPATH ;; diff --git a/tests/07layouts.broken b/tests/07layouts.broken new file mode 100644 index 00000000..f6d69773 --- /dev/null +++ b/tests/07layouts.broken @@ -0,0 +1 @@ +always fails \ No newline at end of file diff --git a/tests/14imsm-r5_3d-migrate-r4_3d.broken b/tests/14imsm-r5_3d-migrate-r4_3d.broken new file mode 100644 index 00000000..f6d69773 --- /dev/null +++ b/tests/14imsm-r5_3d-migrate-r4_3d.broken @@ -0,0 +1 @@ +always fails \ No newline at end of file diff --git a/util.c b/util.c index 4dfe757d..ee97ac83 100644 --- a/util.c +++ b/util.c @@ -1159,8 +1159,6 @@ int open_dev_excl(char *devnm) flags = O_RDONLY; continue; } - if (errno != EBUSY) - return fd; sleep_for(0, MSEC_TO_NSEC(delay), true); if (delay < 200) delay *= 2;