Skip to content

Commit

Permalink
[chore] move solace receiver to generated lifecycle tests (#30413)
Browse files Browse the repository at this point in the history
Relates to #27849
  • Loading branch information
atoulme authored Jan 22, 2024
1 parent ff3023c commit 82484a2
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 4 deletions.
9 changes: 6 additions & 3 deletions receiver/solacereceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ func TestCreateTracesReceiver(t *testing.T) {
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))

set := receivertest.NewNopCreateSettings()
set.ID = component.NewIDWithName("solace", "factory")
receiver, err := factory.CreateTracesReceiver(
context.Background(),
receivertest.NewNopCreateSettings(),
set,
cfg,
consumertest.NewNop(),
)
Expand Down Expand Up @@ -92,10 +94,11 @@ func TestCreateTracesReceiverBadMetrics(t *testing.T) {
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "primary").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))

set := receivertest.NewNopCreateSettings()
set.ID = component.NewIDWithName("solace", "factory")
receiver, err := factory.CreateTracesReceiver(
context.Background(),
receivertest.NewNopCreateSettings(),
set,
cfg,
consumertest.NewNop(),
)
Expand Down
89 changes: 89 additions & 0 deletions receiver/solacereceiver/generated_component_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions receiver/solacereceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ status:
distributions: [contrib, sumo, splunk]
codeowners:
active: [djaglowski, mcardy]

tests:
config:
auth:
sasl_plain:
username: username
password: passwd
skip_lifecycle: true
5 changes: 4 additions & 1 deletion receiver/solacereceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ func (s *solaceTracesReceiver) Start(_ context.Context, _ component.Host) error

// Shutdown implements component.Receiver::Shutdown
func (s *solaceTracesReceiver) Shutdown(_ context.Context) error {
if s.cancel == nil {
return nil
}
s.terminating.Store(true)
s.metrics.recordReceiverStatus(receiverStateTerminating)
s.settings.Logger.Info("Shutdown waiting for all components to complete")
s.cancel() // cancels the context passed to the reconneciton loop
s.cancel() // cancels the context passed to the reconnection loop
s.shutdownWaitGroup.Wait()
s.settings.Logger.Info("Receiver shutdown successfully")
s.metrics.recordReceiverStatus(receiverStateTerminated)
Expand Down

0 comments on commit 82484a2

Please sign in to comment.