test(hardware): add comprehensive bus type inference testing#244
Closed
jra3 wants to merge 1 commit into
Closed
Conversation
Implement all 4 testing phases specified in issue #161 for hardware graph bus type inference validation. Tests cover device naming patterns, driver detection, relationship creation, and real-world cloud provider device patterns. Phase 1 (Core Disk Bus Type Patterns): - NVMe device patterns (nvme0n1, nvme1n2p1, etc) - SATA/SCSI device patterns (sda, sdb1, sdaa, etc) - IDE device patterns (hda, hdb, hdc, hdd) - VirtIO/Xen patterns (vda, xvda with partitions) - Unknown device patterns (loop, dm, md, mmcblk, etc) - Case sensitivity and substring matching edge cases Phase 2 (Network Driver Detection): - Virtual interface types (loopback, bridge, vlan, bond) - VirtIO network drivers (virtio_net, virtio_pci) - USB driver detection with documented limitations - PCI driver patterns for Intel, Broadcom, Realtek, Mellanox, AWS ENA, VMware vmxnet3, and wireless drivers Phase 3 (Bus Connection Relationships): - All bus type enum mappings (PCI, PCIe, USB, SATA, NVMe, SAS, IDE, SCSI, VirtIO, Unknown) - Bus address formatting validation - Relationship structure verification - Protobuf unmarshaling validation Phase 4 (Real-World Device Patterns): - AWS EC2 devices (NVMe EBS, instance store, Xen paravirtual) - GCP devices (persistent disks, local SSDs) - Azure devices (managed disks, NVMe) - VMware devices (SCSI, IDE) - Container environments (loop devices, device mapper) - Cloud provider network adapters (AWS ENA, GCP VirtIO, Azure Mellanox, VMware vmxnet3) - Physical server disk patterns (large arrays, mixed NVMe/SATA) Test implementation includes 17 test functions with 100+ individual test cases. Tests document current USB driver detection limitations and validate unknown device fallback behavior. Coverage improvement: 70.9% to 75.1% (+4.2%). Closes #161 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: John Allen <john@antimetal.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive testing for hardware bus type inference functions to address issue #161. The implementation follows a four-phase approach covering all device patterns, drivers, and real-world cloud provider scenarios.
What Changed
New Test File
internal/hardware/graph/bus_inference_test.go(715 lines)Test Coverage by Phase
Phase 1: Core Disk Bus Type Pattern Tests
Phase 2: Network Driver Detection Tests
Phase 3: Bus Connection Relationship Tests
Phase 4: Real-World Device Pattern Validation
Test Statistics
Test Results
Coverage Improvement:
All tests passing:
Key Findings
The tests document current implementation behavior:
Success Criteria Met
✅ Achieve comprehensive coverage for bus inference functions
✅ Test all documented device naming patterns
✅ Cover all supported bus types
✅ Validate unknown device fallback behavior
✅ Test relationship creation for all bus types
Testing
Closes #161
Related