sync file-type support across upload/convert and fix collected_at timezone handling

This commit is contained in:
2026-02-28 23:27:49 +03:00
parent 736b77f055
commit 4940cd9645
20 changed files with 931 additions and 49 deletions
+47
View File
@@ -8,6 +8,7 @@ import (
"net/http/httptest"
"strings"
"testing"
"time"
"git.mchus.pro/mchus/logpile/internal/models"
)
@@ -305,6 +306,52 @@ func TestReplayRedfishFromRawPayloads_FallbackCollectionMembersByPrefix(t *testi
}
}
func TestReplayRedfishFromRawPayloads_PreservesSourceTimezoneAndUTCCollectedAt(t *testing.T) {
raw := map[string]any{
"redfish_tree": map[string]interface{}{
"/redfish/v1": map[string]interface{}{
"Systems": map[string]interface{}{"@odata.id": "/redfish/v1/Systems"},
"Chassis": map[string]interface{}{"@odata.id": "/redfish/v1/Chassis"},
"Managers": map[string]interface{}{"@odata.id": "/redfish/v1/Managers"},
},
"/redfish/v1/Systems": map[string]interface{}{
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1"}},
},
"/redfish/v1/Systems/1": map[string]interface{}{
"Manufacturer": "Inspur",
"Model": "NF5688M7",
"SerialNumber": "23E100051",
},
"/redfish/v1/Chassis": map[string]interface{}{
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1"}},
},
"/redfish/v1/Chassis/1": map[string]interface{}{"Id": "1"},
"/redfish/v1/Managers": map[string]interface{}{
"Members": []interface{}{map[string]interface{}{"@odata.id": "/redfish/v1/Managers/1"}},
},
"/redfish/v1/Managers/1": map[string]interface{}{
"DateTime": "2026-02-28T04:18:18+08:00",
"DateTimeLocalOffset": "+08:00",
},
},
}
got, err := ReplayRedfishFromRawPayloads(raw, nil)
if err != nil {
t.Fatalf("replay failed: %v", err)
}
if got.SourceTimezone != "+08:00" {
t.Fatalf("expected source_timezone +08:00, got %q", got.SourceTimezone)
}
wantCollectedAt := time.Date(2026, 2, 27, 20, 18, 18, 0, time.UTC)
if !got.CollectedAt.Equal(wantCollectedAt) {
t.Fatalf("expected collected_at %s, got %s", wantCollectedAt, got.CollectedAt)
}
if got.RawPayloads["source_timezone"] != "+08:00" {
t.Fatalf("expected source_timezone in raw payloads, got %#v", got.RawPayloads["source_timezone"])
}
}
func TestReplayRedfishFromRawPayloads_ParsesInlineThresholdAndDiscreteSensors(t *testing.T) {
raw := map[string]any{
"redfish_tree": map[string]interface{}{