logpile no longer carries its own archive/vendor parsers or Redfish raw-payload replay/analysis engine. Both now live in git.mchus.pro/reanimator/parser/v13 (already used by the sibling `core` project), reached through parser.NewService().AnalyzeArchivePayload / AnalyzeRedfishRawPayloads. logpile keeps live BMC/Redfish collection, the DB, exporter, server and UI. - Deleted internal/parser/ (interface, registry, archive extraction, all vendor packages), internal/collector/redfish_replay*.go (replay engine, confirmed near-identical to the module's redfish/ package), internal/ingest/ (pure duplicate of the module's Service), internal/models/ (repointed every import to the module's models package instead), and internal/rar5 (only used by the deleted archive extractor). Removed the now-unused third_party/pciids submodule. - internal/collector/redfish.go: Collect() now calls parser.NewService().AnalyzeRedfishRawPayloads(...) at the one place it used to call the local ReplayRedfishFromRawPayloads (an existing "unified tunnel" between live collection and raw import). A deadcode-driven pass then removed ~150 doc-to-model conversion helpers in redfish.go that duplicated the module's redfish/ package and were already unreachable before this change; kept the small generic dedup/scoring helpers the live crawler still calls. - internal/collector/redfishprofile/ stays whole: Collect() depends on it directly for acquisition-time tuning. Its analysis-only methods (ApplyAnalysisProfiles/PostAnalyze) are now dead but left in place rather than splitting the package's single Profile interface. - pciids moved with the module (now a public package there); logpile's live collector and exporter import it from there instead of keeping a local copy. - go.mod: new require on git.mchus.pro/reanimator/parser/v13 v13.0.0 (plain module dependency, not a submodule like reanimator/chart, since this module is independently versioned and shared with core). - bible-local docs rewritten for the new boundary; see ADL-080. See also the companion change in git.mchus.pro/reanimator/parser (tagged v13.0.0): new top-level exports (IsSupportedArchiveFilename/SupportedArchiveExtensions/ ParseInDefaultArchiveLocation/PrivacyScanEnabled) and pciids moved to a public package, both needed to complete this migration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
62 lines
2.8 KiB
Go
62 lines
2.8 KiB
Go
package exporter
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"git.mchus.pro/reanimator/parser/v13/models"
|
|
)
|
|
|
|
func TestConvertEventLogs_UndatedEventHasNoEventTime(t *testing.T) {
|
|
logs := convertEventLogs([]models.Event{{Source: "BMC", Description: "FAN3 reports Critical"}})
|
|
if len(logs) != 1 {
|
|
t.Fatalf("expected 1 log, got %d", len(logs))
|
|
}
|
|
if logs[0].EventTime != "" {
|
|
t.Fatalf("event without source time must not get collection time, got %q", logs[0].EventTime)
|
|
}
|
|
}
|
|
|
|
func TestConvertEventLogs_IsActive(t *testing.T) {
|
|
t0 := time.Date(2026, 8, 12, 10, 0, 0, 0, time.UTC)
|
|
yes := true
|
|
events := []models.Event{
|
|
// 0..2: condition with lifecycle, latest Assert still open.
|
|
{Timestamp: t0, Source: "BMC", SensorType: "memory", SensorName: "CPU0_C2D1", ID: "0C090401", EventType: "Assert", Description: "disabled"},
|
|
{Timestamp: t0.Add(time.Minute), Source: "BMC", SensorType: "memory", SensorName: "CPU0_C2D1", ID: "0C090401", EventType: "Deassert", Description: "disabled"},
|
|
{Timestamp: t0.Add(2 * time.Minute), Source: "BMC", SensorType: "memory", SensorName: "CPU0_C2D1", ID: "0C090401", EventType: "Assert", Description: "disabled"},
|
|
// 3: one-shot Assert without lifecycle.
|
|
{Timestamp: t0, Source: "BMC", SensorType: "sys restart", SensorName: "SYS RESTART", ID: "1D020000", EventType: "Assert", Description: "restart"},
|
|
// 4: explicit snapshot state.
|
|
{Source: "BMC", SensorType: "fan", SensorName: "FAN3", EventType: "Fan Status", Description: "FAN3 reports Critical", Active: &yes},
|
|
// 5: SEL-style record: condition in EventType, phase in RawData.
|
|
{Timestamp: t0, Source: "SEL", SensorType: "power supply", SensorName: "PSU0_Status", ID: "10", EventType: "Predictive failure", RawData: "Asserted", Description: "Predictive failure"},
|
|
{Timestamp: t0.Add(time.Minute), Source: "SEL", SensorType: "power supply", SensorName: "PSU0_Status", ID: "15", EventType: "Predictive failure", RawData: "Deasserted", Description: "Predictive failure"},
|
|
}
|
|
|
|
logs := convertEventLogs(events)
|
|
want := []*bool{ptrBool(false), ptrBool(false), nil, nil, ptrBool(true), ptrBool(false), ptrBool(false)}
|
|
for i, w := range want {
|
|
got := logs[i].IsActive
|
|
switch {
|
|
case w == nil && got != nil:
|
|
t.Fatalf("log %d: expected is_active unset, got %v", i, *got)
|
|
case w != nil && (got == nil || *got != *w):
|
|
t.Fatalf("log %d: expected is_active=%v, got %v", i, *w, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func ptrBool(v bool) *bool { return &v }
|
|
|
|
func TestConvertEventLogs_EasyBeeSources(t *testing.T) {
|
|
logs := convertEventLogs([]models.Event{
|
|
{Source: "ipmi-sel", Description: "Transition to Non-critical from OK"},
|
|
{Source: "dmesg", Description: "usb 1-1: device not accepting address 3, error -71"},
|
|
{Source: "Bee Runtime", Description: "Bee runtime status: PARTIAL"},
|
|
})
|
|
if len(logs) != 2 || logs[0].Source != "bmc" || logs[1].Source != "host" {
|
|
t.Fatalf("unexpected event_logs: %+v", logs)
|
|
}
|
|
}
|