Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Change-Id: I62576667da33589a32cb90e5417bac64a0192355
  • Loading branch information
pintohutch committed Jan 13, 2025
1 parent 17f7828 commit 9223be9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cmd/dcgm-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"log/slog"
"os"

_ "go.uber.org/automaxprocs"

"github.com/NVIDIA/dcgm-exporter/pkg/cmd"
)

Expand Down
22 changes: 16 additions & 6 deletions internal/pkg/transformation/kubernetes_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,10 @@ import (
"fmt"
"testing"

"testing"

"github.com/sirupsen/logrus"

mockdeviceinfo "github.com/NVIDIA/dcgm-exporter/internal/mocks/pkg/deviceinfo"

mocknvmlprovider "github.com/NVIDIA/dcgm-exporter/internal/mocks/pkg/nvmlprovider"
Expand All @@ -33,13 +37,15 @@ import (
"github.com/NVIDIA/dcgm-exporter/internal/pkg/appconfig"
"github.com/NVIDIA/dcgm-exporter/internal/pkg/collector"
"github.com/NVIDIA/dcgm-exporter/internal/pkg/counters"
"github.com/NVIDIA/dcgm-exporter/internal/pkg/dcgmprovider"
"github.com/NVIDIA/dcgm-exporter/internal/pkg/deviceinfo"
"github.com/NVIDIA/dcgm-exporter/internal/pkg/nvmlprovider"
"github.com/NVIDIA/dcgm-exporter/internal/pkg/testutils"
)

func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {
testutils.RequireLinux(t)
logrus.SetLevel(logrus.DebugLevel)

type TestCase struct {
KubernetesGPUIDType appconfig.KubernetesGPUIDType
Expand Down Expand Up @@ -275,13 +281,16 @@ func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {
defer cleanup()
socketPath := tmpDir + "/kubelet.sock"
server := grpc.NewServer()
config := &appconfig.Config{
UseRemoteHE: false,
}

cleanup, err := dcgm.Init(dcgm.Embedded)
require.NoError(t, err)
defer cleanup()
dcgmprovider.Initialize(config)
defer dcgmprovider.Client().Cleanup()

gpus := tc.PODGPUIDs
podresourcesapi.RegisterPodResourcesListerServer(server, testutils.NewMockPodResourcesServer(tc.ResourceName, gpus))
podresourcesapi.RegisterPodResourcesListerServer(server,
testutils.NewMockPodResourcesServer(tc.ResourceName, gpus))

cleanup = testutils.StartMockServer(t, server, socketPath)
defer cleanup()
Expand All @@ -291,6 +300,7 @@ func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {
GPUInstanceID: 3,
ComputeInstanceID: 0,
}

ctrl := gomock.NewController(t)
mockNVMLProvider := mocknvmlprovider.NewMockNVML(ctrl)
mockNVMLProvider.EXPECT().GetMIGDeviceInfoByID(gomock.Any()).Return(migDeviceInfo, nil).AnyTimes()
Expand Down Expand Up @@ -337,7 +347,7 @@ func TestProcessPodMapper_WithD_Different_Format_Of_DeviceID(t *testing.T) {
mockSystemInfo.EXPECT().GPUCount().Return(uint(1)).AnyTimes()
mockSystemInfo.EXPECT().GPU(uint(0)).Return(mockGPU).AnyTimes()

err = podMapper.Process(metrics, mockSystemInfo)
err := podMapper.Process(metrics, mockSystemInfo)
require.NoError(t, err)
assert.Len(t, metrics, 1)
if tc.KubernetesVirtualGPU {
Expand Down

0 comments on commit 9223be9

Please sign in to comment.