Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lifecycle tests to all default components #2741

Merged

Conversation

pjanotti
Copy link
Contributor

Why

Add lifetime tests to remaining default components in line with #2679. This allows changing the components without restarting the process.

What

Description:
Separate the default components test per type of component and also allow to run the test for a single component. Some receivers are not being tested for lifecycle in this PR:

  • Zipkin and OTLP receiver (I will have PRs to fix these soon)
  • Kafka receiver: requires access to the internals of the receiver to perform a successful Start call
  • OpenCensus: can't be properly stopped due to usage CMux (the CMux listener Accept calls block forever)

@pjanotti pjanotti requested a review from a team March 19, 2021 21:12
@codecov
Copy link

codecov bot commented Mar 19, 2021

Codecov Report

Merging #2741 (b651d96) into main (76237c7) will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2741      +/-   ##
==========================================
+ Coverage   91.77%   91.81%   +0.04%     
==========================================
  Files         291      291              
  Lines       15535    15535              
==========================================
+ Hits        14257    14264       +7     
+ Misses        877      870       -7     
  Partials      401      401              
Impacted Files Coverage Δ
...babilisticsamplerprocessor/probabilisticsampler.go 98.98% <0.00%> (+2.02%) ⬆️
receiver/prometheusreceiver/factory.go 81.81% <0.00%> (+3.03%) ⬆️
exporter/fileexporter/file_exporter.go 84.61% <0.00%> (+7.69%) ⬆️
exporter/fileexporter/factory.go 100.00% <0.00%> (+11.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76237c7...b651d96. Read the comment docs.

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. So this uncovered some bugs.

service/defaultcomponents/default_receivers_test.go Outdated Show resolved Hide resolved
@bogdandrutu
Copy link
Member

@tigrannajaryan bugs based on? I think we need first to document the requirements before claiming that something is a bug :)

@tigrannajaryan
Copy link
Member

@tigrannajaryan bugs based on? I think we need first to document the requirements before claiming that something is a bug :)

@bogdandrutu My understanding from the skipped tests is that some components fail the Create/Start/Shutdown/Create/Start/Shutdown sequence (did I misunderstand it?).

I think we can consider that a bug, given our discussions about how we should be able to restart the Collector with a new config. Sure, let's document the requirement clearly.

@bogdandrutu
Copy link
Member

Not sure if I would call missunderstand but the sequence that is tested is Create/Start/Create/Shutdown/Start/Shutdown so let's document exactly what is the expectations so I can ensure that we test what is expected.

I understand the need to be able to restart the collector, but let's document that and then we can push all these PRs

@tigrannajaryan
Copy link
Member

Not sure if I would call missunderstand but the sequence that is tested is Create/Start/Create/Shutdown/Start/Shutdown so let's document exactly what is the expectations so I can ensure that we test what is expected.

I understand the need to be able to restart the collector, but let's document that and then we can push all these PRs

@pjanotti I think @bogdandrutu is right, the test verifies the sequence where we create the second instance before we shutdown the first. I think the actual sequence we need is Create/Start/Shutdown/Create/Start/Shutdown, right? It should be easy to change the test to do this instead.

@bogdandrutu
Copy link
Member

Please update tests accordingly to #2757


secondExp, err := createFn(ctx, expCreateParams, getConfigFn())
require.NoError(t, err)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 174 to 176
if err == configerror.ErrDataTypeIsNotSupported {
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if errors.Is(err, configerror.ErrDataTypeIsNotSupported)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


secondExt, err := factory.CreateExtension(ctx, extCreateParams, getConfigFn())
assert.NoError(t, err)
require.NoError(t, err)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove new line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


for _, createFn := range createFns {
firstExp, err := createFn(ctx, processorCreateParams, getConfigFn())
if err == configerror.ErrDataTypeIsNotSupported {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same use errors.Is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


secondExp, err := createFn(ctx, processorCreateParams, getConfigFn())
require.NoError(t, err)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, remove new line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 175 to 177
func castProcessor(p component.Processor, err error) (component.Processor, error) {
return p, err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this func. Is this necessary? If yes please comment why.

Copy link
Contributor Author

@pjanotti pjanotti Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, not needed anymore


for _, createFn := range createFns {
firstRcvr, err := createFn(ctx, receiverCreateParams, getConfigFn())
if err == configerror.ErrDataTypeIsNotSupported {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


secondRcvr, err := createFn(ctx, receiverCreateParams, getConfigFn())
require.NoError(t, err)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

func castReceiver(p component.Receiver, err error) (component.Receiver, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, not needed anymore.

}
}

func castExporter(exp component.Exporter, err error) (component.Exporter, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary? please comment why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not necessary anymore, perhaps it was needed on the initial version definitely not anymore, removed.

@bogdandrutu
Copy link
Member

Please consider to update description if necessary.

@bogdandrutu bogdandrutu merged commit 3660f5c into open-telemetry:main Mar 22, 2021
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
…etry#2741)

Bumps [pygithub](https://github.com/pygithub/pygithub) from 1.58.0 to 1.58.1.
- [Release notes](https://github.com/pygithub/pygithub/releases)
- [Changelog](https://github.com/PyGithub/PyGithub/blob/v1.58.1/doc/changes.rst)
- [Commits](PyGithub/PyGithub@v1.58.0...v1.58.1)

---
updated-dependencies:
- dependency-name: pygithub
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants