From d9607c4f7246a375800c7cff4c48e3a3f1aa7695 Mon Sep 17 00:00:00 2001 From: Lujie Duan Date: Thu, 30 May 2024 18:46:52 +0000 Subject: [PATCH] Revert the nvmlreceiver fix --- receiver/nvmlreceiver/client_gpu_test.go | 2 +- receiver/nvmlreceiver/component_test.go | 3 --- receiver/nvmlreceiver/scraper_gpu_test.go | 14 ++++++-------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/receiver/nvmlreceiver/client_gpu_test.go b/receiver/nvmlreceiver/client_gpu_test.go index 877338431..cc3f74784 100644 --- a/receiver/nvmlreceiver/client_gpu_test.go +++ b/receiver/nvmlreceiver/client_gpu_test.go @@ -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) diff --git a/receiver/nvmlreceiver/component_test.go b/receiver/nvmlreceiver/component_test.go index 66f308d2a..5a7487aee 100644 --- a/receiver/nvmlreceiver/component_test.go +++ b/receiver/nvmlreceiver/component_test.go @@ -26,7 +26,6 @@ package nvmlreceiver import ( "context" - "sync" "testing" "github.com/stretchr/testify/require" @@ -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)) diff --git a/receiver/nvmlreceiver/scraper_gpu_test.go b/receiver/nvmlreceiver/scraper_gpu_test.go index 533f608b9..5faef49dd 100644 --- a/receiver/nvmlreceiver/scraper_gpu_test.go +++ b/receiver/nvmlreceiver/scraper_gpu_test.go @@ -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" @@ -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()) @@ -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()) @@ -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()) @@ -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()) @@ -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()) @@ -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