Documentation ¶
Overview ¶
Package testutil holds different utilities and stubs for testing
Index ¶
- Constants
- Variables
- func GetBasicNvmlMock() *nvmlmock.Interface
- func GetDeviceMock(deviceIdx int) *nvmlmock.Device
- func GetWorkloadMetaMock(t *testing.T) workloadmetamock.Mock
- func RequireDeviceListsEqual(t *testing.T, expected, actual []nvml.Device, msgAndArgs ...interface{})
- func RequireDevicesEqual(t *testing.T, expected, actual nvml.Device, msgAndArgs ...interface{})
Constants ¶
const DefaultGpuCores = 10
DefaultGpuCores is the default number of cores for a GPU device in the mock.
Variables ¶
var DefaultGpuUUID = GPUUUIDs[0]
DefaultGpuUUID is the UUID for the default device returned by the mock
var GPUCores = []int{DefaultGpuCores, 20, 30, 40, 50, 60, 70}
GPUCores is a list of number of cores for the devices returned by the mock, should be the same length as GPUUUIDs. If not, GetBasicNvmlMock will panic.
var GPUUUIDs = []string{
"GPU-00000000-1234-1234-1234-123456789012",
"GPU-11111111-1234-1234-1234-123456789013",
"GPU-22222222-1234-1234-1234-123456789014",
"GPU-33333333-1234-1234-1234-123456789015",
"GPU-44444444-1234-1234-1234-123456789016",
"GPU-55555555-1234-1234-1234-123456789017",
"GPU-66666666-1234-1234-1234-123456789018",
}
GPUUUIDs is a list of UUIDs for the devices returned by the mock
Functions ¶
func GetBasicNvmlMock ¶
GetBasicNvmlMock returns a mock of the nvml.Interface with a single device with 10 cores, useful for basic tests that need only the basic interaction with NVML to be working.
func GetDeviceMock ¶
GetDeviceMock returns a mock of the nvml.Device with the given UUID.
func GetWorkloadMetaMock ¶
func GetWorkloadMetaMock(t *testing.T) workloadmetamock.Mock
GetWorkloadMetaMock returns a mock of the workloadmeta.Component.
func RequireDeviceListsEqual ¶
func RequireDeviceListsEqual(t *testing.T, expected, actual []nvml.Device, msgAndArgs ...interface{})
RequireDeviceListsEqual checks that the two device lists are equal by comparing their UUIDs, which gives a better output than using require.ElementsMatch on the lists themselves
Types ¶
This section is empty.