From 2e0685b1b2b38c702fa801347a7a75297bfd64d8 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 19 Dec 2023 15:54:28 +0100 Subject: [PATCH] Revert "[chore] move sshcheck receiver to generated lifecycle tests" (#30081) Reverts open-telemetry/opentelemetry-collector-contrib#29978. Windows receiver tests are broken after this PR, since the receiver is not supported on Windows --- .../generated_component_test.go | 89 ------------------- receiver/sshcheckreceiver/metadata.yaml | 4 - 2 files changed, 93 deletions(-) delete mode 100644 receiver/sshcheckreceiver/generated_component_test.go diff --git a/receiver/sshcheckreceiver/generated_component_test.go b/receiver/sshcheckreceiver/generated_component_test.go deleted file mode 100644 index 5f20f4cb44db..000000000000 --- a/receiver/sshcheckreceiver/generated_component_test.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by mdatagen. DO NOT EDIT. - -package sshcheckreceiver - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/component/componenttest" - - "go.opentelemetry.io/collector/consumer/consumertest" - "go.opentelemetry.io/collector/receiver" - "go.opentelemetry.io/collector/receiver/receivertest" - - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -// assertNoErrorHost implements a component.Host that asserts that there were no errors. -type assertNoErrorHost struct { - component.Host - *testing.T -} - -var _ component.Host = (*assertNoErrorHost)(nil) - -// newAssertNoErrorHost returns a new instance of assertNoErrorHost. -func newAssertNoErrorHost(t *testing.T) component.Host { - return &assertNoErrorHost{ - componenttest.NewNopHost(), - t, - } -} - -func (aneh *assertNoErrorHost) ReportFatalError(err error) { - assert.NoError(aneh, err) -} - -func Test_ComponentLifecycle(t *testing.T) { - factory := NewFactory() - - tests := []struct { - name string - createFn func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) - }{ - - { - name: "metrics", - createFn: func(ctx context.Context, set receiver.CreateSettings, cfg component.Config) (component.Component, error) { - return factory.CreateMetricsReceiver(ctx, set, cfg, consumertest.NewNop()) - }, - }, - } - - cm, err := confmaptest.LoadConf("metadata.yaml") - require.NoError(t, err) - cfg := factory.CreateDefaultConfig() - sub, err := cm.Sub("tests::config") - require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) - - for _, test := range tests { - t.Run(test.name+"-shutdown", func(t *testing.T) { - c, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) - require.NoError(t, err) - err = c.Shutdown(context.Background()) - require.NoError(t, err) - }) - - t.Run(test.name+"-lifecycle", func(t *testing.T) { - - // TODO support lifecycle - t.SkipNow() - - firstRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) - require.NoError(t, err) - host := newAssertNoErrorHost(t) - require.NoError(t, err) - require.NoError(t, firstRcvr.Start(context.Background(), host)) - require.NoError(t, firstRcvr.Shutdown(context.Background())) - secondRcvr, err := test.createFn(context.Background(), receivertest.NewNopCreateSettings(), cfg) - require.NoError(t, err) - require.NoError(t, secondRcvr.Start(context.Background(), host)) - require.NoError(t, secondRcvr.Shutdown(context.Background())) - }) - } -} diff --git a/receiver/sshcheckreceiver/metadata.yaml b/receiver/sshcheckreceiver/metadata.yaml index 5c510dc5591a..ee1a963698b0 100644 --- a/receiver/sshcheckreceiver/metadata.yaml +++ b/receiver/sshcheckreceiver/metadata.yaml @@ -65,7 +65,3 @@ metrics: monotonic: false unit: "{error}" attributes: [error.message] - -tests: - config: - skip_lifecycle: true \ No newline at end of file