From edc9533832404681305b8b76b30715969174a8fd Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 12:36:47 -0400 Subject: [PATCH 1/9] tests/storage-vm: fix condition for testing volume.block.filesystem Signed-off-by: Simon Deziel --- tests/storage-vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/storage-vm b/tests/storage-vm index 8b7c31cef..7c72cc65a 100755 --- a/tests/storage-vm +++ b/tests/storage-vm @@ -408,7 +408,7 @@ for poolDriver in $poolDriverList; do lxc delete -f v1 lxc storage unset "${poolName}" volume.size - if [ "${poolDriver}" = "lvm" ] || [ "${poolDriver}" = "lvm-thin" ] | "${poolDriver}" = "ceph" ] || [ "${poolDriver}" = "powerflex" ]; then + if [ "${poolDriver}" = "lvm" ] || [ "${poolDriver}" = "lvm-thin" ] || [ "${poolDriver}" = "ceph" ] || [ "${poolDriver}" = "powerflex" ]; then echo "==> Change volume.block.filesystem on pool and create VM" lxc storage set "${poolName}" volume.block.filesystem xfs lxc init "${TEST_IMG:-ubuntu-minimal-daily:22.04}" v1 --vm -s "${poolName}" From 96d5369a2b29014fa7900d5c0e164f27a908336a Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 12:39:36 -0400 Subject: [PATCH 2/9] github: use non-shallow clones for differential shellcheck `actions/checkout@v4` moved to shallow clones by default: https://github.com/actions/checkout?tab=readme-ov-file#checkout-v4 This prevents the differential shellcheck action from finding the proper revs: ``` fatal: Invalid revision range 6034829bebd5755843be3ce8b8dee1e55afe1515..c31bb3595fab371d8e5d9265ceb9d210baf4c398 ``` Now why is the action not failing in those case is another story (https://github.com/redhat-plumbers-in-action/differential-shellcheck/issues/372). Signed-off-by: Simon Deziel --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 87667f5c6..325cb131b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,6 +43,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + # A non-shallow clone is needed for the Differential ShellCheck + fetch-depth: 0 - name: yamllint uses: ibiqlik/action-yamllint@v3 From 4360cd57a0986ccee0158723597f45801409ab5a Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:21:57 -0400 Subject: [PATCH 3/9] tests/cgroup: fix shellcheck warning about unknown variable Signed-off-by: Simon Deziel --- tests/cgroup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cgroup b/tests/cgroup index 9d8638122..1329b4a1b 100755 --- a/tests/cgroup +++ b/tests/cgroup @@ -180,7 +180,7 @@ else fi # limits.network.priority was dropped after 5.0 -if [ -e "/sys/fs/cgroup/net_prio" ] && echo "${lxd_snap_channel}" | grep -qE "^5\.0/"; then +if [ -e "/sys/fs/cgroup/net_prio" ] && echo "${LXD_SNAP_CHANNEL}" | grep -qE "^5\.0/"; then echo "==> Testing limits.network.priority" # NOTE: No such thing as net_prio under cgroup2 lxc config set c1 limits.network.priority=10 From 7b4d9edc5101d531f041dbfbf2a93172306c0301 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:32:58 -0400 Subject: [PATCH 4/9] github: be stricter with shellcheck Signed-off-by: Simon Deziel --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 325cb131b..c38d8f2d2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,6 +57,7 @@ jobs: uses: redhat-plumbers-in-action/differential-shellcheck@v5 with: token: ${{ secrets.GITHUB_TOKEN }} + strict-check-on-push: true if: github.event_name == 'pull_request' - name: Upload artifact with ShellCheck defects in SARIF format From 8fef1d4cac04b6505d70bd52f851719240d2fca2 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:33:18 -0400 Subject: [PATCH 5/9] tests/cpu-vm: use grep -c instead of piping to wc -l Signed-off-by: Simon Deziel --- tests/cpu-vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpu-vm b/tests/cpu-vm index d1a63f67d..9aa4de252 100755 --- a/tests/cpu-vm +++ b/tests/cpu-vm @@ -83,7 +83,7 @@ if journalctl --quiet --no-hostname --no-pager --boot=0 --unit=snap.lxd.daemon.s # pid 2898's current affinity list: 0-15 # pid 2899's current affinity list: 0-15 # 2894 and 2895 have affinity set, while others don't - PINNED_VCPU_NUM=$(taskset --cpu-list -a -p "${QEMU_PID}" | grep -E ':\s+[0-9]+$' | wc -l) + PINNED_VCPU_NUM=$(taskset --cpu-list -a -p "${QEMU_PID}" | grep -cE ':\s+[0-9]+$') [ "${PINNED_VCPU_NUM}" = "$(lxc config get v1 limits.cpu)" ] else # check that there is no pinning set From f7959318fd046bf5ed66869ae977ad02d83f975d Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:38:22 -0400 Subject: [PATCH 6/9] tests/cpu-vm: properly fail if there is pinning when none is expected Signed-off-by: Simon Deziel --- tests/cpu-vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpu-vm b/tests/cpu-vm index 9aa4de252..a5e982802 100755 --- a/tests/cpu-vm +++ b/tests/cpu-vm @@ -87,7 +87,7 @@ if journalctl --quiet --no-hostname --no-pager --boot=0 --unit=snap.lxd.daemon.s [ "${PINNED_VCPU_NUM}" = "$(lxc config get v1 limits.cpu)" ] else # check that there is no pinning set - ! taskset --cpu-list -a -p "${QEMU_PID}" | grep -E ':\s+[0-9]+$' + ! taskset --cpu-list -a -p "${QEMU_PID}" | grep -E ':\s+[0-9]+$' || false taskset --cpu-list -a -p "${QEMU_PID}" | grep "0-$((cpuCount-1))" fi From e888c9008bc7c897d1f7db3eb81d9469def77dc7 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:43:36 -0400 Subject: [PATCH 7/9] tests/interception: properly fail if insmod succedes when it should fail Signed-off-by: Simon Deziel --- tests/interception | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/interception b/tests/interception index 74b7b277e..5d95d694c 100755 --- a/tests/interception +++ b/tests/interception @@ -111,14 +111,14 @@ if hasNeededAPIExtension container_syscall_intercept_finit_module; then lxc file push "${MODULE_PATH}" "c1/root/" # negative case 1 (feature is not enabled) - ! lxc exec c1 -- insmod "/root/${MODULE_FILE_NAME}" + ! lxc exec c1 -- insmod "/root/${MODULE_FILE_NAME}" || false # turn on feature lxc config set c1 linux.kernel_modules.load=ondemand lxc restart c1 -f # negative case 2 (module is not in allow list) - ! lxc exec c1 -- insmod "/root/${MODULE_FILE_NAME}" + ! lxc exec c1 -- insmod "/root/${MODULE_FILE_NAME}" || talse # allow module lxc config set c1 linux.kernel_modules="${MODULE_TO_TRY}" From ea9a6b45c54a0170bd5e04fe782293039b1280d9 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:44:35 -0400 Subject: [PATCH 8/9] tests/storage-vm: add missing quotes Signed-off-by: Simon Deziel --- tests/storage-vm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/storage-vm b/tests/storage-vm index 7c72cc65a..a5fbb961e 100755 --- a/tests/storage-vm +++ b/tests/storage-vm @@ -27,19 +27,19 @@ for poolDriver in $poolDriverList; do lxc storage create "${poolName}" "${poolDriver}" size=59GiB lvm.use_thinpool=false lxc storage set "${poolName}" size=60GiB ! lxc storage set "${poolName}" size=58GiB || false - [ "$(lxc storage get ${poolName} size)" = "60GiB" ] + [ "$(lxc storage get "${poolName}" size)" = "60GiB" ] elif [ "${poolDriver}" = "lvm-thin" ]; then lxc storage create "${poolName}" lvm size=19GiB lxc storage set "${poolName}" size=20GiB ! lxc storage set "${poolName}" size=18GiB || false - [ "$(lxc storage get ${poolName} size)" = "20GiB" ] + [ "$(lxc storage get "${poolName}" size)" = "20GiB" ] elif [ "${poolDriver}" = "powerflex" ]; then createPowerFlexPool "${poolName}" else lxc storage create "${poolName}" "${poolDriver}" size=19GiB lxc storage set "${poolName}" size=20GiB ! lxc storage set "${poolName}" size=18GiB || false - [ "$(lxc storage get ${poolName} size)" = "20GiB" ] + [ "$(lxc storage get "${poolName}" size)" = "20GiB" ] fi if [ "${poolDriver}" != "powerflex" ]; then From 392987e36cb423c3328d01f8853a8654932598f1 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Fri, 19 Apr 2024 15:49:52 -0400 Subject: [PATCH 9/9] tests/storage-vm: silence shellcheck SC2016 Signed-off-by: Simon Deziel --- tests/storage-vm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/storage-vm b/tests/storage-vm index a5fbb961e..d5c94cb36 100755 --- a/tests/storage-vm +++ b/tests/storage-vm @@ -358,9 +358,11 @@ for poolDriver in $poolDriverList; do lxc storage volume delete "${poolName}" vol1 lxc config device add v1 block1 disk source="/tmp/lxd-test-${poolName}/lxd-test-block" readonly=true + # shellcheck disable=SC2016 lxc exec v1 -- sh -c 'for i in $(seq 10); do test -e /sys/block/sdb/ro && break; echo "Waiting for sys file to appear (${i}s)"; sleep 1; done' [ "$(lxc exec v1 -- cat /sys/block/sdb/ro)" -eq 1 ] lxc config device set v1 block1 readonly=false + # shellcheck disable=SC2016 lxc exec v1 -- sh -c 'for i in $(seq 10); do test -e /sys/block/sdb/ro && break; echo "Waiting for sys file to appear (${i}s)"; sleep 1; done' [ "$(lxc exec v1 -- cat /sys/block/sdb/ro)" -eq 0 ]