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>
156 lines
4.8 KiB
Go
156 lines
4.8 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/exporter"
|
|
"git.mchus.pro/reanimator/parser/v13/models"
|
|
)
|
|
|
|
func TestIsAuditCandidate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
path string
|
|
includePlain bool
|
|
want bool
|
|
}{
|
|
{name: "tar gzip", path: "dump.tar.gz", want: true},
|
|
{name: "zip", path: "dump.zip", want: true},
|
|
{name: "plain log excluded", path: "component.log", want: false},
|
|
{name: "plain log requested", path: "nvidia-bug-report.log", includePlain: true, want: true},
|
|
{name: "JSON report excluded", path: "report.json", want: false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := isAuditCandidate(tt.path, tt.includePlain); got != tt.want {
|
|
t.Fatalf("isAuditCandidate(%q, %v) = %v, want %v", tt.path, tt.includePlain, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCPUOnlyReanimatorPayloadPreservesRequiredFields(t *testing.T) {
|
|
payload := &exporter.ReanimatorExport{
|
|
Filename: "dump.tar.gz",
|
|
CollectedAt: "2026-07-27T10:34:40Z",
|
|
Hardware: exporter.ReanimatorHardware{
|
|
Board: exporter.ReanimatorBoard{SerialNumber: "23E102624"},
|
|
CPUs: []exporter.ReanimatorCPU{{Socket: 0, SerialNumber: "D46E5D6B1D3E40E1"}},
|
|
Firmware: []exporter.ReanimatorFirmware{{DeviceName: "BIOS", Version: "1.0"}},
|
|
},
|
|
}
|
|
|
|
got := cpuOnlyReanimatorPayload(payload)
|
|
if got.CollectedAt == "" || got.Hardware.Board.SerialNumber == "" || len(got.Hardware.CPUs) != 1 {
|
|
t.Fatalf("required ingest fields were lost: %+v", got)
|
|
}
|
|
if len(got.Hardware.Firmware) != 0 {
|
|
t.Fatalf("expected non-CPU hardware to be removed: %+v", got.Hardware.Firmware)
|
|
}
|
|
}
|
|
|
|
func TestFlatReanimatorName(t *testing.T) {
|
|
got := flatReanimatorName("v1", "NL/example/dump.tar.gz")
|
|
if got != "v1__dump.tar.gz.reanimator.json" {
|
|
t.Fatalf("unexpected flat name %q", got)
|
|
}
|
|
}
|
|
|
|
func TestBuildCPUAudit(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
cpu models.CPU
|
|
finding string
|
|
promoted bool
|
|
expectedSer string
|
|
}{
|
|
{
|
|
name: "PPIN promoted",
|
|
cpu: models.CPU{Socket: 0, PPIN: "D46E5D6B1D3E40E1", SerialNumber: "D46E5D6B1D3E40E1"},
|
|
finding: "ppin_used_as_serial",
|
|
promoted: true,
|
|
expectedSer: "D46E5D6B1D3E40E1",
|
|
},
|
|
{
|
|
name: "regression detected",
|
|
cpu: models.CPU{Socket: 1, PPIN: "D44F8D6B9155EE0E"},
|
|
finding: "missing_serial_with_ppin",
|
|
expectedSer: "D44F8D6B9155EE0E",
|
|
},
|
|
{
|
|
name: "placeholder serial with PPIN",
|
|
cpu: models.CPU{Socket: 1, PPIN: "D44F8D6B9155EE0E", SerialNumber: "Unknown"},
|
|
finding: "missing_serial_with_ppin",
|
|
expectedSer: "D44F8D6B9155EE0E",
|
|
},
|
|
{
|
|
name: "native serial",
|
|
cpu: models.CPU{Socket: 0, SerialNumber: "CPU-SERIAL"},
|
|
finding: "source_serial_present",
|
|
expectedSer: "CPU-SERIAL",
|
|
},
|
|
{
|
|
name: "placeholder PPIN",
|
|
cpu: models.CPU{Socket: 0, PPIN: "N/A"},
|
|
finding: "cpu_identity_missing",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := buildCPUAudit(tt.cpu)
|
|
if got.Finding != tt.finding || got.PPINPromoted != tt.promoted || got.ExpectedSerialNumber != tt.expectedSer {
|
|
t.Fatalf("unexpected audit: %+v", got)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRunAuditWritesFailureReportAndSummary(t *testing.T) {
|
|
input := t.TempDir()
|
|
output := t.TempDir()
|
|
badArchive := filepath.Join(input, "bad.zip")
|
|
if err := os.WriteFile(badArchive, []byte("not a zip"), 0o644); err != nil {
|
|
t.Fatalf("write fixture: %v", err)
|
|
}
|
|
|
|
summary, err := runAudit(input, output, 1, false)
|
|
if err != nil {
|
|
t.Fatalf("runAudit failed: %v", err)
|
|
}
|
|
if summary.FilesFound != 1 || summary.FilesFailed != 1 || summary.FilesParsed != 0 {
|
|
t.Fatalf("unexpected summary: %+v", summary)
|
|
}
|
|
for _, name := range []string{"bad.zip.cpu-audit.json", "_summary.json"} {
|
|
if _, err := os.Stat(filepath.Join(output, name)); err != nil {
|
|
t.Fatalf("expected %s: %v", name, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCollectAuditJobsAndReanimatorNoCPU(t *testing.T) {
|
|
input := t.TempDir()
|
|
output := filepath.Join(input, "output")
|
|
plain := filepath.Join(input, "nvidia-bug-report.log")
|
|
if err := os.WriteFile(plain, []byte("NVIDIA bug report log file\nnvidia-bug-report.sh\n"), 0o644); err != nil {
|
|
t.Fatalf("write fixture: %v", err)
|
|
}
|
|
|
|
jobs, err := collectAuditJobs(input, output, true, true)
|
|
if err != nil {
|
|
t.Fatalf("collectAuditJobs: %v", err)
|
|
}
|
|
if len(jobs) != 1 || jobs[0].relative != "nvidia-bug-report.log" {
|
|
t.Fatalf("unexpected jobs: %+v", jobs)
|
|
}
|
|
|
|
summary, err := runReanimatorExport(input, output, "v1", 1, true)
|
|
if err != nil {
|
|
t.Fatalf("runReanimatorExport: %v", err)
|
|
}
|
|
if summary.FilesFound != 1 || summary.FilesParsed != 1 || summary.FilesNoCPU != 1 || summary.FilesWithCPU != 0 {
|
|
t.Fatalf("unexpected summary: %+v", summary)
|
|
}
|
|
}
|