Skip to content

Commit

Permalink
Merge pull request #156 from simondeziel/fix-test-scripts
Browse files Browse the repository at this point in the history
Fix test scripts
  • Loading branch information
tomponline authored Apr 20, 2024
2 parents 6e31185 + 392987e commit bff86f4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -54,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
Expand Down
2 changes: 1 addition & 1 deletion tests/cgroup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/cpu-vm
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ 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
! 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

Expand Down
4 changes: 2 additions & 2 deletions tests/interception
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
10 changes: 6 additions & 4 deletions tests/storage-vm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ]

Expand Down Expand Up @@ -408,7 +410,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}"
Expand Down

0 comments on commit bff86f4

Please sign in to comment.