mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
ci: judge tmpfs by filesystem type; an lsblk error voids its output
A tmpfs mounted under another source name (shm, a custom label) was refused because the check compared the source name. And an lsblk that printed an NVMe disk and then failed was accepted, since its status was discarded. The check now reads the filesystem type from df and treats any lsblk failure as "not a block device". Two stub cases pin both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ec8ec06e6
commit
a2419b2cec
2 files changed
+22
-14
No files matched your search
+12
-8
@@ -4,16 +4,18 @@ set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
t=$(mktemp -d)
|
||||
trap 'rm -rf "$t"' EXIT
|
||||
mkdir -p "$t/bin" "$t/nvme" "$t/sata" "$t/mem" "$t/raid" "$t/share"
|
||||
# df --output=source DIR: the stub answers by the directory's name.
|
||||
mkdir -p "$t/bin" "$t/nvme" "$t/sata" "$t/mem" "$t/raid" "$t/share" "$t/half"
|
||||
# df --output=source,fstype DIR: the stub answers by the directory's name.
|
||||
cat >"$t/bin/df" <<STUB
|
||||
#!/usr/bin/env bash
|
||||
printf 'Filesystem Type\n'
|
||||
case "\$2" in
|
||||
$t/nvme*) printf 'Filesystem\n/dev/nvme0n1p1\n' ;;
|
||||
$t/mem*) printf 'Filesystem\ntmpfs\n' ;;
|
||||
$t/raid*) printf 'Filesystem\n/dev/md0\n' ;;
|
||||
$t/share*) printf 'Filesystem\n//nas/work\n' ;;
|
||||
*) printf 'Filesystem\n/dev/sda2\n' ;;
|
||||
$t/nvme*) echo '/dev/nvme0n1p1 ext4' ;;
|
||||
$t/mem*) echo 'shm tmpfs' ;;
|
||||
$t/raid*) echo '/dev/md0 ext4' ;;
|
||||
$t/share*) echo '//nas/work cifs' ;;
|
||||
$t/half*) echo '/dev/nvme1n1p1 ext4' ;;
|
||||
*) echo '/dev/sda2 ext4' ;;
|
||||
esac
|
||||
STUB
|
||||
# lsblk -nrso TYPE,TRAN SOURCE: the source and the devices under it.
|
||||
@@ -23,6 +25,7 @@ case "$3" in
|
||||
/dev/nvme0n1p1) printf 'part \ndisk nvme\n' ;;
|
||||
/dev/sda2) printf 'part \ndisk sata\n' ;;
|
||||
/dev/md0) printf 'raid1 \npart \ndisk nvme\npart \ndisk sata\n' ;;
|
||||
/dev/nvme1n1p1) printf 'part \ndisk nvme\n'; echo "lsblk: read error" >&2; exit 32 ;;
|
||||
*) echo "lsblk: $3: not a block device" >&2; exit 32 ;;
|
||||
esac
|
||||
STUB
|
||||
@@ -30,7 +33,7 @@ chmod +x "$t/bin/df" "$t/bin/lsblk"
|
||||
run() { PATH="$t/bin:$PATH" RUNNER_NAME=r1 bash "$here/require-nvme.sh" "$@" >"$t/out" 2>&1; }
|
||||
fail() { echo "FAIL: $*"; cat "$t/out"; exit 1; }
|
||||
|
||||
run "$t/nvme" "$t/mem" "" || fail "nvme + tmpfs + empty arg must pass"
|
||||
run "$t/nvme" "$t/mem" "" || fail "nvme + tmpfs (any source name) + empty arg must pass"
|
||||
run "$t/nvme/not/made/yet" || fail "a missing dir is judged by its nearest existing parent"
|
||||
! run "$t/nvme" "$t/sata" || fail "a SATA dir must fail"
|
||||
grep -q "runner r1" "$t/out" || fail "the failure must name the runner"
|
||||
@@ -38,4 +41,5 @@ grep -q "FAIL $t/sata" "$t/out" || fail "the failure must name the directory"
|
||||
! run "$t/raid" || fail "an array with a SATA member must fail"
|
||||
! run "$t/share" || fail "a network share must fail"
|
||||
grep -q "not a block device" "$t/out" || fail "a network share must say why"
|
||||
! run "$t/half" || fail "an lsblk error after partial NVMe output must fail"
|
||||
echo "require-nvme tests: ok"
|
||||
+10
-6
@@ -11,14 +11,18 @@ for p in "$@"; do
|
||||
[ -n "$p" ] || continue
|
||||
d=$p
|
||||
while [ ! -e "$d" ]; do d=$(dirname "$d"); done
|
||||
src=$(df --output=source "$d" | tail -n 1)
|
||||
if [ "$src" = tmpfs ]; then
|
||||
echo "ok $p: tmpfs"
|
||||
read -r src fstype < <(df --output=source,fstype "$d" | tail -n 1)
|
||||
if [ "$fstype" = tmpfs ]; then
|
||||
echo "ok $p: $src (tmpfs)"
|
||||
continue
|
||||
fi
|
||||
# Every disk under the source (all members of an array) must be NVMe.
|
||||
disks=$({ lsblk -nrso TYPE,TRAN "$src" 2>/dev/null || true; } |
|
||||
awk '$1 == "disk" { print ($2 == "" ? "unknown" : $2) }' | sort -u | tr '\n' ' ')
|
||||
# Every disk under the source (all members of an array) must be NVMe; an
|
||||
# lsblk error voids whatever it printed.
|
||||
disks=
|
||||
if tree=$(lsblk -nrso TYPE,TRAN "$src" 2>/dev/null); then
|
||||
disks=$(printf '%s\n' "$tree" |
|
||||
awk '$1 == "disk" { print ($2 == "" ? "unknown" : $2) }' | sort -u | tr '\n' ' ')
|
||||
fi
|
||||
if [ "$disks" = "nvme " ]; then
|
||||
echo "ok $p: $src (nvme)"
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user