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>
146 lines
5.6 KiB
Go
146 lines
5.6 KiB
Go
package topology
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/exporter"
|
|
"git.mchus.pro/reanimator/parser/v13/models"
|
|
)
|
|
|
|
func intp(v int) *int { return &v }
|
|
|
|
func TestBuildDistinguishesNUMAZeroFromUnknown(t *testing.T) {
|
|
snapshot := &exporter.ReanimatorExport{Hardware: exporter.ReanimatorHardware{
|
|
Board: exporter.ReanimatorBoard{SerialNumber: "SN1"},
|
|
CPUs: []exporter.ReanimatorCPU{{Socket: 0}, {Socket: 1}},
|
|
PCIeDevices: []exporter.ReanimatorPCIe{
|
|
{Slot: "0000:01:00.0", DeviceClass: "VideoController", Model: "GPU A", NUMANode: intp(0)},
|
|
{Slot: "0000:02:00.0", DeviceClass: "NetworkController", Model: "NIC A", NUMANode: nil},
|
|
},
|
|
}}
|
|
doc := Build(snapshot, nil)
|
|
var gpuAttached, nicAttached bool
|
|
for _, e := range doc.Edges {
|
|
gpuAttached = gpuAttached || (e.From == "cpu:0" && e.To == "gpu:0000:01:00.0")
|
|
nicAttached = nicAttached || strings.Contains(e.To, "nic:")
|
|
}
|
|
if !gpuAttached {
|
|
t.Fatal("NUMA node 0 GPU was not attached to CPU 0")
|
|
}
|
|
if nicAttached {
|
|
t.Fatal("unknown-affinity NIC must not be attached")
|
|
}
|
|
body, err := json.Marshal(doc)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(string(body), `"numa_node":0`) {
|
|
t.Fatalf("topology JSON lost NUMA zero: %s", body)
|
|
}
|
|
}
|
|
|
|
func TestBuildUsesBeeStaticEvidence(t *testing.T) {
|
|
snapshot := &exporter.ReanimatorExport{Hardware: exporter.ReanimatorHardware{
|
|
Board: exporter.ReanimatorBoard{SerialNumber: "SN1"},
|
|
CPUs: []exporter.ReanimatorCPU{{Socket: 0}, {Socket: 1}},
|
|
Memory: []exporter.ReanimatorMemory{{Slot: "DIMM000(A)", SerialNumber: "M1", Status: "OK"}},
|
|
Storage: []exporter.ReanimatorStorage{{Slot: "0:0:0:0", SerialNumber: "D1", Model: "Disk"}},
|
|
PCIeDevices: []exporter.ReanimatorPCIe{
|
|
{Slot: "0000:01:00.0", DeviceClass: "StorageController", NUMANode: intp(0)},
|
|
{Slot: "0000:31:00.0", DeviceClass: "VideoController", Model: "GPU 0", NUMANode: intp(0)},
|
|
{Slot: "0000:32:00.0", DeviceClass: "VideoController", Model: "GPU 1", NUMANode: intp(0)},
|
|
},
|
|
}}
|
|
e := &models.TopologyEvidence{
|
|
DIMMType17: "Memory Device\n Locator: DIMM000(A)\n Bank Locator: Node0_Channel0",
|
|
StorageMap: "sda hctl=0:0:0:0 ctrl=0000:01:00.0",
|
|
NVIDIAQueryCSV: "0, 0000:31:00.0\n1, 0000:32:00.0\n",
|
|
NVIDIATopology: " GPU0 GPU1\nGPU0 X NV4\nGPU1 NV4 X\n",
|
|
}
|
|
doc := Build(snapshot, e)
|
|
kinds := map[string]int{}
|
|
for _, edge := range doc.Edges {
|
|
kinds[edge.Kind]++
|
|
}
|
|
for _, kind := range []string{"memory", "storage", "nvlink"} {
|
|
if kinds[kind] == 0 {
|
|
t.Fatalf("missing %s edge: %+v", kind, doc.Edges)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRenderHTMLIsStaticAndEscapesLabels(t *testing.T) {
|
|
body := string(RenderHTML(&models.TopologyDocument{Version: ContractVersion, Title: `<script>x</script>`, Nodes: []models.TopologyNode{{ID: "cpu:0", Kind: "cpu", Label: "CPU 0", Socket: intp(0)}}}))
|
|
if strings.Contains(body, `<script>x</script>`) {
|
|
t.Fatal("title was not escaped")
|
|
}
|
|
for _, forbidden := range []string{"setInterval(", "fetch(", "nvidia-smi"} {
|
|
if strings.Contains(body, forbidden) {
|
|
t.Fatalf("rendered page contains live behavior %q", forbidden)
|
|
}
|
|
}
|
|
}
|
|
|
|
// HPE ProLiant DL380 Gen11 (BEE-SP v14.23): DIMM locators read "PROC 1 DIMM 10",
|
|
// the MegaRAID controller is not part of the Reanimator projection, and its
|
|
// physical drives carry storcli "EID:Slt" slots instead of an HCTL.
|
|
func TestBuildAttachesHPEMemoryAndRAIDMemberDisks(t *testing.T) {
|
|
snapshot := &exporter.ReanimatorExport{Hardware: exporter.ReanimatorHardware{
|
|
Board: exporter.ReanimatorBoard{SerialNumber: "SN1"},
|
|
CPUs: []exporter.ReanimatorCPU{{Socket: 1}},
|
|
Memory: []exporter.ReanimatorMemory{{Slot: "PROC 1 DIMM 10", SizeMB: 32768}},
|
|
Storage: []exporter.ReanimatorStorage{
|
|
{Slot: "252:1", Model: "Micron_7450"},
|
|
{Slot: "252:2", Model: "Micron_7450"},
|
|
{Slot: "252:3", Model: "Micron_7450"},
|
|
},
|
|
PCIeDevices: []exporter.ReanimatorPCIe{
|
|
{Slot: "0000:01:00.1", VendorID: 0x102b, DeviceClass: "VideoController", Model: "MGA G200eH3", NUMANode: intp(0)},
|
|
{Slot: "0000:6c:00.0", DeviceClass: "NetworkController", NUMANode: intp(0)},
|
|
},
|
|
}}
|
|
e := &models.TopologyEvidence{
|
|
StorageMap: "sda hctl=0:3:111:0 ctrl=0000:6d:00.0\nsdb hctl=1:0:0:0 ctrl=0000:00:14.0\n",
|
|
StorcliVDs: `{"Controllers":[{"Command Status":{"Controller":0},"Response Data":{
|
|
"/c0/v239":[{"DG/VD":"0/239","TYPE":"RAID1"}],
|
|
"PDs for VD 239":[{"EID:Slt":"252:1"},{"EID:Slt":"252:2"}],
|
|
"VD239 Properties":{"OS Drive Name":"/dev/sda"}}}]}`,
|
|
StorcliDrives: `{"Controllers":[{"Command Status":{"Controller":0},"Response Data":{
|
|
"Drive /c0/e252/s1":[{"EID:Slt":"252:1"}],
|
|
"Drive /c0/e252/s3":[{"EID:Slt":"252:3"}],
|
|
"Drive /c0/e252/s3 - Detailed Information":{}}}]}`,
|
|
}
|
|
controllers := []exporter.ReanimatorPCIe{
|
|
{Slot: "0000:6d:00.0", DeviceClass: "MassStorageController", Model: "MegaRAID", NUMANode: intp(0)},
|
|
{Slot: "0000:00:17.0", DeviceClass: "SATAController", Model: "AHCI", NUMANode: intp(0)},
|
|
}
|
|
doc := Build(snapshot, e, controllers...)
|
|
|
|
edges := map[string]string{}
|
|
for _, edge := range doc.Edges {
|
|
edges[edge.To] = edge.From
|
|
}
|
|
want := map[string]string{
|
|
"memory:PROC 1 DIMM 10": "cpu:1",
|
|
"raid:0000:6d:00.0": "cpu:1",
|
|
"storage:252:1": "raid:0000:6d:00.0",
|
|
"storage:252:2": "raid:0000:6d:00.0",
|
|
"storage:252:3": "raid:0000:6d:00.0",
|
|
}
|
|
for to, from := range want {
|
|
if edges[to] != from {
|
|
t.Errorf("edge to %s: got from %q, want %q", to, edges[to], from)
|
|
}
|
|
}
|
|
for _, n := range doc.Nodes {
|
|
if n.Kind == "gpu" {
|
|
t.Errorf("BMC VGA rendered as a GPU: %+v", n)
|
|
}
|
|
if n.BDF == "0000:00:17.0" {
|
|
t.Errorf("diskless onboard controller must stay hidden: %+v", n)
|
|
}
|
|
}
|
|
}
|