storage SAT: split collect/self-test modes, add per-disk text reports

Check mode: read-only SMART/NVMe data collection, no self-test.
Load mode: same collection + short self-test (nvme device-self-test -s 1,
smartctl -t short). Card descriptions updated accordingly.

After each storage SAT run, a disk-N-devname-report.txt is written
per device into the runDir (auto-included in support bundles).
Web UI task page renders one card per disk directly below Task Report.

Also fixes pre-existing TestDashboardRendersRuntimeHealthTable failure:
test fixture used "inactive" status but code now treats inactive as OK
for completed oneshot services; updated to "failed" to match intent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-06-30 19:07:36 +03:00
parent ea68318744
commit 386c0738ee
7 changed files with 591 additions and 26 deletions
+34 -6
View File
@@ -14,14 +14,42 @@ import (
func TestStorageSATCommands(t *testing.T) {
t.Parallel()
nvme := storageSATCommands("/dev/nvme0n1", false)
if len(nvme) != 3 || nvme[2].cmd[0] != "nvme" {
t.Fatalf("unexpected nvme commands: %#v", nvme)
// Check mode (extended=false): read-only collection, no self-test.
nvmeCheck := storageSATCommands("/dev/nvme0n1", false)
if len(nvmeCheck) != 2 {
t.Fatalf("check nvme: want 2 commands, got %d: %#v", len(nvmeCheck), nvmeCheck)
}
if nvmeCheck[0].name != "nvme-id-ctrl" || nvmeCheck[1].name != "nvme-smart-log" {
t.Fatalf("check nvme: unexpected command names: %#v", nvmeCheck)
}
sata := storageSATCommands("/dev/sda", false)
if len(sata) != 2 || sata[0].cmd[0] != "smartctl" {
t.Fatalf("unexpected sata commands: %#v", sata)
sataCheck := storageSATCommands("/dev/sda", false)
if len(sataCheck) != 1 || sataCheck[0].cmd[0] != "smartctl" {
t.Fatalf("check sata: want 1 smartctl command, got %#v", sataCheck)
}
// Load mode (extended=true): collection + short self-test.
nvmeLoad := storageSATCommands("/dev/nvme0n1", true)
if len(nvmeLoad) != 3 || nvmeLoad[2].name != "nvme-device-self-test" {
t.Fatalf("load nvme: want 3 commands with self-test last, got %#v", nvmeLoad)
}
if got := nvmeLoad[2].cmd[len(nvmeLoad[2].cmd)-3]; got != "-s" {
t.Fatalf("load nvme: want -s flag, got %q", got)
}
if got := nvmeLoad[2].cmd[len(nvmeLoad[2].cmd)-2]; got != "1" {
t.Fatalf("load nvme: want self-test level 1, got %q", got)
}
sataLoad := storageSATCommands("/dev/sda", true)
if len(sataLoad) != 2 || sataLoad[1].name != "smartctl-self-test-short" {
t.Fatalf("load sata: want 2 commands with short self-test last, got %#v", sataLoad)
}
// cmd is: smartctl -t short /dev/sda
if got := sataLoad[1].cmd[1]; got != "-t" {
t.Fatalf("load sata: want -t flag at index 1, got %q", got)
}
if got := sataLoad[1].cmd[2]; got != "short" {
t.Fatalf("load sata: want short at index 2, got %q", got)
}
}