mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-10 00:27:05 +02:00
Fixes #8826 From the QEMU VM: ```shell $ talosctl -n 172.20.0.5 get pcidevice NODE NAMESPACE TYPE ID VERSION CLASS SUBCLASS VENDOR PRODUCT 172.20.0.5 hardware PCIDevice 0000:00:00.0 1 Bridge Host bridge Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller 172.20.0.5 hardware PCIDevice 0000:00:01.0 1 Display controller VGA compatible controller 172.20.0.5 hardware PCIDevice 0000:00:02.0 1 Network controller Ethernet controller Red Hat, Inc. Virtio network device 172.20.0.5 hardware PCIDevice 0000:00:03.0 1 Unclassified device Red Hat, Inc. Virtio RNG 172.20.0.5 hardware PCIDevice 0000:00:04.0 1 Unclassified device Red Hat, Inc. Virtio memory balloon 172.20.0.5 hardware PCIDevice 0000:00:05.0 1 Communication controller Communication controller Red Hat, Inc. Virtio console 172.20.0.5 hardware PCIDevice 0000:00:06.0 1 Generic system peripheral System peripheral Intel Corporation 6300ESB Watchdog Timer 172.20.0.5 hardware PCIDevice 0000:00:07.0 1 Mass storage controller SCSI storage controller Red Hat, Inc. Virtio block device 172.20.0.5 hardware PCIDevice 0000:00:1f.0 1 Bridge ISA bridge Intel Corporation 82801IB (ICH9) LPC Interface Controller 172.20.0.5 hardware PCIDevice 0000:00:1f.2 1 Mass storage controller SATA controller Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA Controller [AHCI mode] 172.20.0.5 hardware PCIDevice 0000:00:1f.3 1 Serial bus controller SMBus Intel Corporation 82801I (ICH9 Family) SMBus Controller ``` ```yaml node: 172.20.0.5 metadata: namespace: hardware type: PCIDevices.hardware.talos.dev id: 0000:00:1f.3 version: 1 owner: hardware.PCIDevicesController phase: running created: 2024-05-30T12:09:05Z updated: 2024-05-30T12:09:05Z spec: class: Serial bus controller subclass: SMBus vendor: Intel Corporation product: 82801I (ICH9 Family) SMBus Controller class_id: "0x0c" subclass_id: "0x05" vendor_id: "0x8086" product_id: "0x2930" ``` Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
81 lines
2.3 KiB
Go
81 lines
2.3 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
//go:build integration_api
|
|
|
|
package api
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
"github.com/cosi-project/runtime/pkg/safe"
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/siderolabs/talos/internal/integration/base"
|
|
"github.com/siderolabs/talos/pkg/machinery/client"
|
|
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
|
|
)
|
|
|
|
// HardwareSuite ...
|
|
type HardwareSuite struct {
|
|
base.APISuite
|
|
|
|
ctx context.Context //nolint:containedctx
|
|
ctxCancel context.CancelFunc
|
|
}
|
|
|
|
// SuiteName ...
|
|
func (suite *HardwareSuite) SuiteName() string {
|
|
return "api.HardwareSuite"
|
|
}
|
|
|
|
// SetupTest ...
|
|
func (suite *HardwareSuite) SetupTest() {
|
|
if !suite.Capabilities().RunsTalosKernel {
|
|
suite.T().Skipf("doesn't run Talos kernel, skipping")
|
|
}
|
|
|
|
suite.ctx, suite.ctxCancel = context.WithTimeout(context.Background(), 15*time.Second)
|
|
}
|
|
|
|
// TearDownTest ...
|
|
func (suite *HardwareSuite) TearDownTest() {
|
|
if suite.ctxCancel != nil {
|
|
suite.ctxCancel()
|
|
}
|
|
}
|
|
|
|
// TestSystemInformation tests that SystemInformation is populated.
|
|
func (suite *HardwareSuite) TestSystemInformation() {
|
|
node := suite.RandomDiscoveredNodeInternalIP()
|
|
|
|
sysInfo, err := safe.StateGetByID[*hardware.SystemInformation](client.WithNode(suite.ctx, node), suite.Client.COSI, hardware.SystemInformationID)
|
|
suite.Require().NoError(err)
|
|
|
|
suite.Assert().NotEmpty(sysInfo.TypedSpec().UUID)
|
|
suite.Assert().NotEqual((uuid.UUID{}).String(), sysInfo.TypedSpec().UUID)
|
|
}
|
|
|
|
// TestHardwareInfo tests that hardware info is populated.
|
|
func (suite *HardwareSuite) TestHardwareInfo() {
|
|
node := suite.RandomDiscoveredNodeInternalIP()
|
|
|
|
for _, resourceType := range []resource.Type{
|
|
hardware.MemoryModuleType,
|
|
hardware.ProcessorType,
|
|
hardware.PCIDeviceType,
|
|
} {
|
|
items, err := suite.Client.COSI.List(client.WithNode(suite.ctx, node), resource.NewMetadata(hardware.NamespaceName, resourceType, "", resource.VersionUndefined))
|
|
suite.Require().NoError(err)
|
|
|
|
suite.Assert().NotEmpty(items.Items, "resource type %s is not populated", resourceType)
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
allSuites = append(allSuites, new(HardwareSuite))
|
|
}
|