Treat historical SMART failures as resolved
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -68,3 +69,37 @@ func TestApplyATAWearAndReason(t *testing.T) {
|
||||
t.Fatalf("причина предупреждения не добавлена: %+v", disk)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHistoricalATAFailureDoesNotRequireAttention(t *testing.T) {
|
||||
var smart smartctlJSON
|
||||
attribute := struct {
|
||||
Name string `json:"name"`
|
||||
Value int `json:"value"`
|
||||
Threshold int `json:"thresh"`
|
||||
WhenFailed string `json:"when_failed"`
|
||||
Raw struct {
|
||||
String string `json:"string"`
|
||||
Value int64 `json:"value"`
|
||||
} `json:"raw"`
|
||||
}{Name: "Airflow_Temperature_Cel", WhenFailed: "In_the_past"}
|
||||
attribute.Raw.String = "46 (Min/Max 26/47 #15)"
|
||||
smart.ATAAttributes.Table = append(smart.ATAAttributes.Table, attribute)
|
||||
disk := DiskMetrics{}
|
||||
applyATAAttributes(&disk, smart)
|
||||
applySMARTExitStatus(&disk, 32|64|128)
|
||||
if len(disk.AttentionReasons) != 0 {
|
||||
t.Fatalf("историческая ошибка стала активной: %+v", disk.AttentionReasons)
|
||||
}
|
||||
if len(disk.SMARTHistory) != 4 {
|
||||
t.Fatalf("история SMART потеряна: %+v", disk.SMARTHistory)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSMARTErrorLogGrowthRequiresAttention(t *testing.T) {
|
||||
old := DiskMetrics{SMARTErrorCount: 2}
|
||||
current := DiskMetrics{SMARTErrorCount: 3}
|
||||
changes := diskCounterChanges(old, current)
|
||||
if len(changes) != 1 || !strings.Contains(changes[0], "2 → 3") {
|
||||
t.Fatalf("рост журнала не обнаружен: %+v", changes)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user