-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 tests for cmd/jaeger/internal/extension/jaegerstorage #5096
Add tests for cmd/jaeger/internal/extension/jaegerstorage #5096
Conversation
Signed-off-by: Chirag Ghosh <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5096 +/- ##
=======================================
Coverage 95.56% 95.56%
=======================================
Files 317 320 +3
Lines 18283 18347 +64
=======================================
+ Hits 17472 17534 +62
- Misses 651 653 +2
Partials 160 160
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another suggestion: the config does not have a Validate function like the other components have, can you add it? And then you can add a test calling getDefaultConfig and checking that Validate returns an error (because I don't think empty config is valid for this extension).
btw very nice PR |
Nit: be more specific in the PR title - use full package path |
Signed-off-by: Chirag Ghosh <[email protected]>
…tion. add test Signed-off-by: Chirag Ghosh <[email protected]>
The config did not have any required fields. |
Signed-off-by: Chirag Ghosh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Signed-off-by: Chirag Ghosh <[email protected]>
host := componenttest.NewNopHost() | ||
err := storageExtension.Start(ctx, host) | ||
require.Error(t, err) | ||
require.EqualError(t, err, fmt.Sprintf("duplicate memory storage name %s", memstoreName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the error in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are starting the storageExtension again. This will lead to an error. Ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the error message doesn't seem to be about extension starting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're testing specifically the dual entry condition, it would be better to test it explicitly, not via a side-effect of starting extension twice. I assume it's possible to create dual entry in the config if using a different type of storage and then giving it the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently only Memory type storage is supported. So I was unable to recreate this using config. Have changed the function name for now.
Signed-off-by: Chirag Ghosh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- you can have a test for bad name passed to GetStorageFactory
- you can have a test for error path in Shutdown by manually inserting a mock Factory into
extension.factories
which throws an error on Close
Signed-off-by: Chirag Ghosh <[email protected]>
|
tests can be defined in the same package and have access to private members |
Signed-off-by: Chirag Ghosh <[email protected]>
Done. Please check |
} | ||
|
||
func (e errorFactory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error { | ||
panic("implement me") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: change to "not implemented", otherwise it reads as if these need to be implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Maybe we should also change this then.
Signed-off-by: Chirag Ghosh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test