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>
139 lines
3.1 KiB
Go
139 lines
3.1 KiB
Go
package server
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"git.mchus.pro/reanimator/parser/v13/models"
|
|
)
|
|
|
|
func TestHandleGetSerials_WithGPUs(t *testing.T) {
|
|
// Create test server with GPU data
|
|
srv := &Server{}
|
|
|
|
testResult := &models.AnalysisResult{
|
|
Hardware: &models.HardwareConfig{
|
|
GPUs: []models.GPU{
|
|
{
|
|
Slot: "GPUSXM1",
|
|
Model: "NVIDIA Device 2335",
|
|
Manufacturer: "NVIDIA Corporation",
|
|
SerialNumber: "48:B0:2D:BB:8E:51:9E:E5",
|
|
Firmware: "96.00.D0.00.03",
|
|
BDF: "0000:3a:00.0",
|
|
},
|
|
{
|
|
Slot: "GPUSXM2",
|
|
Model: "NVIDIA Device 2335",
|
|
Manufacturer: "NVIDIA Corporation",
|
|
SerialNumber: "48:B0:2D:EE:DA:27:CF:78",
|
|
Firmware: "96.00.D0.00.03",
|
|
BDF: "0000:18:00.0",
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
srv.SetResult(testResult)
|
|
|
|
// Create request
|
|
req := httptest.NewRequest("GET", "/api/serials", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
// Call handler
|
|
srv.handleGetSerials(w, req)
|
|
|
|
// Check response
|
|
if w.Code != http.StatusOK {
|
|
t.Errorf("Expected status 200, got %d", w.Code)
|
|
}
|
|
|
|
// Parse response
|
|
var resp struct {
|
|
Items []struct {
|
|
Component string `json:"component"`
|
|
Location string `json:"location,omitempty"`
|
|
SerialNumber string `json:"serial_number"`
|
|
Manufacturer string `json:"manufacturer,omitempty"`
|
|
Category string `json:"category"`
|
|
} `json:"items"`
|
|
}
|
|
|
|
if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
|
|
t.Fatalf("Failed to decode response: %v", err)
|
|
}
|
|
serials := resp.Items
|
|
|
|
// Check that we have GPU entries
|
|
gpuCount := 0
|
|
for _, s := range serials {
|
|
if s.Category == "GPU" {
|
|
gpuCount++
|
|
t.Logf("Found GPU: %s (%s) S/N: %s", s.Component, s.Location, s.SerialNumber)
|
|
|
|
// Verify fields are set
|
|
if s.SerialNumber == "" {
|
|
t.Errorf("GPU serial number is empty")
|
|
}
|
|
if s.Location == "" {
|
|
t.Errorf("GPU location is empty")
|
|
}
|
|
if s.Manufacturer == "" {
|
|
t.Errorf("GPU manufacturer is empty")
|
|
}
|
|
}
|
|
}
|
|
|
|
if gpuCount != 2 {
|
|
t.Errorf("Expected 2 GPUs in serials, got %d", gpuCount)
|
|
}
|
|
}
|
|
|
|
func TestHandleGetSerials_WithoutGPUSerials(t *testing.T) {
|
|
// Create test server with GPUs but no serial numbers
|
|
srv := &Server{}
|
|
|
|
testResult := &models.AnalysisResult{
|
|
Hardware: &models.HardwareConfig{
|
|
GPUs: []models.GPU{
|
|
{
|
|
Slot: "GPU0",
|
|
Model: "Some GPU",
|
|
Manufacturer: "Vendor",
|
|
SerialNumber: "", // No serial number
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
srv.SetResult(testResult)
|
|
|
|
// Create request
|
|
req := httptest.NewRequest("GET", "/api/serials", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
// Call handler
|
|
srv.handleGetSerials(w, req)
|
|
|
|
// Parse response
|
|
var resp struct {
|
|
Items []struct {
|
|
Category string `json:"category"`
|
|
} `json:"items"`
|
|
}
|
|
|
|
if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
|
|
t.Fatalf("Failed to decode response: %v", err)
|
|
}
|
|
serials := resp.Items
|
|
|
|
// Check that GPUs without serial numbers are not included
|
|
for _, s := range serials {
|
|
if s.Category == "GPU" {
|
|
t.Error("GPU without serial number should not be included in serials list")
|
|
}
|
|
}
|
|
}
|