Skip to content

Commit 310b452

Browse files
committed
use DryRun to validate the config
1 parent 0975ae1 commit 310b452

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

internal/pkg/otel/samples_test.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
package otel
66

77
import (
8-
"context"
98
"os"
109
"path/filepath"
1110
"runtime"
1211
"testing"
13-
"time"
1412

1513
"github.com/stretchr/testify/assert"
16-
"go.opentelemetry.io/collector/featuregate"
1714
"go.opentelemetry.io/collector/otelcol"
1815
"go.uber.org/zap"
1916
"go.uber.org/zap/zapcore"
@@ -31,12 +28,6 @@ func TestSamples(t *testing.T) {
3128
t.Setenv("AUTOOPS_TEMP_RESOURCE_ID", "temp")
3229
t.Setenv("AUTOOPS_OTEL_URL", "http://localhost:4318")
3330

34-
// Enable service.profilesSupport featuregate to test the profiling samples.
35-
assert.NoError(t, featuregate.GlobalRegistry().Set("service.profilesSupport", true))
36-
defer func() {
37-
assert.NoError(t, featuregate.GlobalRegistry().Set("service.profilesSupport", false))
38-
}()
39-
4031
err := filepath.WalkDir(filepath.Join(".", "samples", runtime.GOOS), func(path string, d os.DirEntry, err error) error {
4132
if err != nil {
4233
return err
@@ -60,13 +51,6 @@ func testSample(t *testing.T, configFile string) {
6051
collector, err := otelcol.NewCollector(*settings)
6152
assert.NoError(t, err)
6253
assert.NotNil(t, collector)
63-
64-
wg := startCollector(context.Background(), t, collector, "")
65-
66-
assert.Eventually(t, func() bool {
67-
return otelcol.StateRunning == collector.GetState()
68-
}, 20*time.Second, 200*time.Millisecond)
54+
assert.NoError(t, collector.DryRun(t.Context()))
6955
collector.Shutdown()
70-
wg.Wait()
71-
assert.Equal(t, otelcol.StateClosed, collector.GetState())
7256
}

0 commit comments

Comments
 (0)