Improve Redfish recovery flow and raw export timing diagnostics
This commit is contained in:
46
internal/server/raw_export_test.go
Normal file
46
internal/server/raw_export_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCollectLogTimeBounds(t *testing.T) {
|
||||
lines := []string{
|
||||
"2026-02-28T13:10:13.7442032Z Задача поставлена в очередь",
|
||||
"not-a-timestamp line",
|
||||
"2026-02-28T13:31:00.5077486Z Сбор завершен",
|
||||
}
|
||||
|
||||
startedAt, finishedAt, ok := collectLogTimeBounds(lines)
|
||||
if !ok {
|
||||
t.Fatalf("expected bounds to be parsed")
|
||||
}
|
||||
if got := formatRawExportDuration(finishedAt.Sub(startedAt)); got != "20m47s" {
|
||||
t.Fatalf("unexpected duration: %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHumanReadableCollectionLog_IncludesDurationHeader(t *testing.T) {
|
||||
pkg := &RawExportPackage{
|
||||
Format: rawExportFormatV1,
|
||||
Source: RawExportSource{
|
||||
Kind: "live_redfish",
|
||||
CollectLogs: []string{
|
||||
"2026-02-28T13:10:13.7442032Z Redfish: подключение к BMC...",
|
||||
"2026-02-28T13:31:00.5077486Z Сбор завершен",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logText := buildHumanReadableCollectionLog(pkg, nil, "LOGPile test")
|
||||
for _, token := range []string{
|
||||
"Collection Started:",
|
||||
"Collection Finished:",
|
||||
"Collection Duration:",
|
||||
} {
|
||||
if !strings.Contains(logText, token) {
|
||||
t.Fatalf("expected %q in log header", token)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user