Skip to content

Commit

Permalink
Revert the nvmlreceiver fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LujieDuan committed May 30, 2024
1 parent 60c9786 commit d9607c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion receiver/nvmlreceiver/client_gpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestCollectGpuProcessesAccounting(t *testing.T) {
assert.LessOrEqual(t, metric.lifetimeGpuMaxMemory, uint64(10995116277760))

assert.GreaterOrEqual(t, metric.processPid, int(0))
assert.LessOrEqual(t, metric.processPid, int(4194304))
assert.LessOrEqual(t, metric.processPid, int(32768))
assert.Greater(t, len(metric.processName), 0)
assert.Greater(t, len(metric.command), 0)
assert.Greater(t, len(metric.commandLine), 0)
Expand Down
3 changes: 0 additions & 3 deletions receiver/nvmlreceiver/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package nvmlreceiver

import (
"context"
"sync"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -80,11 +79,9 @@ func TestComponentLifecycle(t *testing.T) {
firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
host := componenttest.NewNopHost()
once = sync.Once{}
require.NoError(t, err)
require.NoError(t, firstRcvr.Start(context.Background(), host))
require.NoError(t, firstRcvr.Shutdown(context.Background()))
once = sync.Once{}
secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg)
require.NoError(t, err)
require.NoError(t, secondRcvr.Start(context.Background(), host))
Expand Down
14 changes: 6 additions & 8 deletions receiver/nvmlreceiver/scraper_gpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/receivertest"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest"
Expand All @@ -37,7 +36,7 @@ import (
)

func TestScrapeWithGpuPresent(t *testing.T) {
scraper := newNvmlScraper(createDefaultConfig().(*Config), receivertest.NewNopCreateSettings())
scraper := newNvmlScraper(createDefaultConfig().(*Config), receiver.CreateSettings{})
require.NotNil(t, scraper)

err := scraper.start(context.Background(), componenttest.NewNopHost())
Expand All @@ -55,7 +54,7 @@ func TestScrapeOnGpuUtilizationUnsupported(t *testing.T) {
return nvml.VALUE_TYPE_SIGNED_LONG_LONG, nil, nvml.ERROR_NOT_SUPPORTED
}

scraper := newNvmlScraper(createDefaultConfig().(*Config), receivertest.NewNopCreateSettings())
scraper := newNvmlScraper(createDefaultConfig().(*Config), receiver.CreateSettings{})
require.NotNil(t, scraper)

err := scraper.start(context.Background(), componenttest.NewNopHost())
Expand All @@ -72,7 +71,7 @@ func TestScrapeOnGpuMemoryInfoUnsupported(t *testing.T) {
return nvml.Memory{}, nvml.ERROR_NOT_SUPPORTED
}

scraper := newNvmlScraper(createDefaultConfig().(*Config), receivertest.NewNopCreateSettings())
scraper := newNvmlScraper(createDefaultConfig().(*Config), receiver.CreateSettings{})
require.NotNil(t, scraper)

err := scraper.start(context.Background(), componenttest.NewNopHost())
Expand All @@ -86,7 +85,7 @@ func TestScrapeWithGpuProcessAccounting(t *testing.T) {
logger := zaptest.NewLogger(t)
logger.Sugar().Warnf("This test requires superuser privileges.")

scraper := newNvmlScraper(createDefaultConfig().(*Config), receivertest.NewNopCreateSettings())
scraper := newNvmlScraper(createDefaultConfig().(*Config), receiver.CreateSettings{})
require.NotNil(t, scraper)

err := scraper.start(context.Background(), componenttest.NewNopHost())
Expand All @@ -110,7 +109,7 @@ func TestScrapeWithGpuProcessAccountingError(t *testing.T) {
return nil, nvml.ERROR_UNKNOWN
}

scraper := newNvmlScraper(createDefaultConfig().(*Config), receivertest.NewNopCreateSettings())
scraper := newNvmlScraper(createDefaultConfig().(*Config), receiver.CreateSettings{})
require.NotNil(t, scraper)

err := scraper.start(context.Background(), componenttest.NewNopHost())
Expand All @@ -136,8 +135,7 @@ func TestScrapeEmitsWarningsUptoThreshold(t *testing.T) {
warnings := 0
var settings receiver.CreateSettings
settings.Logger = zaptest.NewLogger(t, zaptest.WrapOptions(zap.Hooks(func(e zapcore.Entry) error {
if e.Level == zap.WarnLevel && strings.Contains(e.Message, "Unable to query") &&
!strings.Contains(e.Message, "Unable to query MIG mode for Nvidia device") {
if e.Level == zap.WarnLevel && strings.Contains(e.Message, "Unable to query") {
warnings = warnings + 1
}
return nil
Expand Down

0 comments on commit d9607c4

Please sign in to comment.