MCPcopy
hub / github.com/NVIDIA/k8s-device-plugin / TestGPUModeLabeler

Function TestGPUModeLabeler

internal/lm/nvml_test.go:208–292  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func TestGPUModeLabeler(t *testing.T) {
209 testCases := []struct {
210 description string
211 devices []resource.Device
212 expectedError bool
213 expectedLabels map[string]string
214 }{
215 {
216 description: "single device with compute PCI class",
217 devices: []resource.Device{
218 rt.NewDeviceWithPCIClassMock(0x030000),
219 },
220 expectedLabels: map[string]string{
221 "nvidia.com/gpu.mode": "graphics",
222 },
223 },
224 {
225 description: "single device with graphics PCI class",
226 devices: []resource.Device{
227 rt.NewDeviceWithPCIClassMock(0x030200),
228 },
229 expectedLabels: map[string]string{
230 "nvidia.com/gpu.mode": "compute",
231 },
232 },
233 {
234 description: "single device with switch PCI class",
235 devices: []resource.Device{
236 rt.NewDeviceWithPCIClassMock(0x068000),
237 },
238 expectedLabels: map[string]string{
239 "nvidia.com/gpu.mode": "unknown",
240 },
241 },
242 {
243 description: "multiple device have same graphics PCI class",
244 devices: []resource.Device{
245 rt.NewDeviceWithPCIClassMock(0x030200),
246 rt.NewDeviceWithPCIClassMock(0x030200),
247 rt.NewDeviceWithPCIClassMock(0x030200),
248 },
249 expectedLabels: map[string]string{
250 "nvidia.com/gpu.mode": "compute",
251 },
252 },
253 {
254 description: "multiple device have same compute PCI class",
255 devices: []resource.Device{
256 rt.NewDeviceWithPCIClassMock(0x030000),
257 rt.NewDeviceWithPCIClassMock(0x030000),
258 rt.NewDeviceWithPCIClassMock(0x030000),
259 },
260 expectedLabels: map[string]string{
261 "nvidia.com/gpu.mode": "graphics",
262 },
263 },
264 {
265 description: "multiple device with some with graphics and others with compute PCI class",

Callers

nothing calls this directly

Calls 3

newGPUModeLabelerFunction · 0.85
ErrorMethod · 0.80
LabelsMethod · 0.65

Tested by

no test coverage detected