From 0b944c177025d986be34ed07e60890d3e9010984 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 11 Sep 2025 11:34:37 +0200 Subject: [PATCH 1/4] [chore][test] Add a comment in prw exporter tests to trigger scoped tests --- exporter/prometheusremotewriteexporter/exporter_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/exporter/prometheusremotewriteexporter/exporter_test.go b/exporter/prometheusremotewriteexporter/exporter_test.go index bed5888c0656d..1dfd73ea89752 100644 --- a/exporter/prometheusremotewriteexporter/exporter_test.go +++ b/exporter/prometheusremotewriteexporter/exporter_test.go @@ -390,6 +390,7 @@ func runExportPipeline(ts *prompb.TimeSeries, endpoint *url.URL) error { // Test_PushMetrics checks the number of TimeSeries received by server and the number of metrics dropped is the same as // expected +// This is a comment so that scoped tests are run. func Test_PushMetrics(t *testing.T) { invalidTypeBatch := testdata.GenerateMetricsMetricTypeInvalid() From 661ee348f5775d034633b497386baf1cd0454a94 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 11 Sep 2025 12:10:05 +0200 Subject: [PATCH 2/4] Try to create the temporary directory but not remove it --- exporter/prometheusremotewriteexporter/exporter_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exporter/prometheusremotewriteexporter/exporter_test.go b/exporter/prometheusremotewriteexporter/exporter_test.go index 1dfd73ea89752..b4f336eaee03d 100644 --- a/exporter/prometheusremotewriteexporter/exporter_test.go +++ b/exporter/prometheusremotewriteexporter/exporter_test.go @@ -11,6 +11,7 @@ import ( "net/http" "net/http/httptest" "net/url" + "os" "strconv" "strings" "sync" @@ -758,8 +759,10 @@ func Test_PushMetrics(t *testing.T) { } if useWAL { + dir, err := os.MkdirTemp("", tt.name) + require.NoError(t, err) cfg.WAL = configoptional.Some(WALConfig{ - Directory: t.TempDir(), + Directory: dir, }) } From 74aa9d7d82829a581c66e0680208ef3f05558266 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 11 Sep 2025 12:55:23 +0200 Subject: [PATCH 3/4] Add issue number and scope change to Windows --- .../prometheusremotewriteexporter/exporter_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/exporter/prometheusremotewriteexporter/exporter_test.go b/exporter/prometheusremotewriteexporter/exporter_test.go index b4f336eaee03d..594e29742f947 100644 --- a/exporter/prometheusremotewriteexporter/exporter_test.go +++ b/exporter/prometheusremotewriteexporter/exporter_test.go @@ -12,6 +12,7 @@ import ( "net/http/httptest" "net/url" "os" + "runtime" "strconv" "strings" "sync" @@ -759,8 +760,16 @@ func Test_PushMetrics(t *testing.T) { } if useWAL { - dir, err := os.MkdirTemp("", tt.name) - require.NoError(t, err) + var dir string + if runtime.GOOS == "windows" { + // On Windows, use os.MkdirTemp to create directory since t.TempDir results in an error during cleanup in scoped-tests. + // See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42639 + var err error + dir, err = os.MkdirTemp("", tt.name) //nolint:usetesting + require.NoError(t, err) + } else { + dir = t.TempDir() + } cfg.WAL = configoptional.Some(WALConfig{ Directory: dir, }) From 4a6875624f1338f61ba3e33203da25cc79b37283 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 11 Sep 2025 12:55:34 +0200 Subject: [PATCH 4/4] Revert "[chore][test] Add a comment in prw exporter tests to trigger scoped tests" This reverts commit 0b944c177025d986be34ed07e60890d3e9010984. --- exporter/prometheusremotewriteexporter/exporter_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/exporter/prometheusremotewriteexporter/exporter_test.go b/exporter/prometheusremotewriteexporter/exporter_test.go index 594e29742f947..c948056150367 100644 --- a/exporter/prometheusremotewriteexporter/exporter_test.go +++ b/exporter/prometheusremotewriteexporter/exporter_test.go @@ -392,7 +392,6 @@ func runExportPipeline(ts *prompb.TimeSeries, endpoint *url.URL) error { // Test_PushMetrics checks the number of TimeSeries received by server and the number of metrics dropped is the same as // expected -// This is a comment so that scoped tests are run. func Test_PushMetrics(t *testing.T) { invalidTypeBatch := testdata.GenerateMetricsMetricTypeInvalid()