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 tests for cmd/jaeger/internal/extension/jaegerstorage #5096

Merged
merged 10 commits into from
Jan 18, 2024

Conversation

chirag-ghosh
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Add unit tests for jaegerstorage

How was this change tested?

Checklist

Signed-off-by: Chirag Ghosh <[email protected]>
@chirag-ghosh chirag-ghosh requested a review from a team as a code owner January 12, 2024 14:57
Copy link

github-actions bot commented Jan 12, 2024

Test Results

2 071 tests  +6   2 061 ✅ +6   1m 8s ⏱️ -1s
  216 suites ±0      10 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit fb1a3b4. ± Comparison against base commit 9997cce.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9997cce) 95.56% compared to head (fb1a3b4) 95.56%.

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           
Flag Coverage Δ
cassandra-3.x 25.58% <ø> (ø)
cassandra-4.x 25.58% <ø> (ø)
elasticsearch-5.x 19.87% <ø> (+0.01%) ⬆️
elasticsearch-6.x 19.85% <ø> (-0.02%) ⬇️
elasticsearch-7.x 20.00% <ø> (+0.01%) ⬆️
elasticsearch-8.x 20.08% <ø> (ø)
grpc-badger 19.51% <ø> (ø)
kafka 14.09% <ø> (ø)
opensearch-1.x 20.00% <ø> (ø)
opensearch-2.x 19.99% <ø> (ø)
unittests 93.24% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yurishkuro yurishkuro added the changelog:test Change that's adding missing tests or correcting existing tests label Jan 12, 2024
Copy link
Member

@yurishkuro yurishkuro left a 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).

@yurishkuro
Copy link
Member

yurishkuro commented Jan 12, 2024

btw very nice PR

@yurishkuro yurishkuro changed the title Add tests for jaegerstorage Add tests for cmd/jaeger/internal/extension/jaegerstorage Jan 12, 2024
@yurishkuro
Copy link
Member

Nit: be more specific in the PR title - use full package path

@chirag-ghosh
Copy link
Contributor Author

The config did not have any required fields. Memory seems to be a required field atleeast till other storages are supported. I have therefore made it required. Please check.

Signed-off-by: Chirag Ghosh <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a 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))
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@yurishkuro yurishkuro Jan 15, 2024

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.

Copy link
Member

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.

Copy link
Contributor Author

@chirag-ghosh chirag-ghosh Jan 15, 2024

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]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

  1. you can have a test for bad name passed to GetStorageFactory
  2. 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

@chirag-ghosh
Copy link
Contributor Author

chirag-ghosh commented Jan 16, 2024

  1. Done
  2. extension.factories isn't supposed to be accessible by public methods. The only place it is set is here

@yurishkuro
Copy link
Member

extension.factories isn't supposed to be accessible by public methods.

tests can be defined in the same package and have access to private members

@chirag-ghosh
Copy link
Contributor Author

Done. Please check

}

func (e errorFactory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
panic("implement me")
Copy link
Member

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

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. Maybe we should also change this then.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Thanks!

@yurishkuro yurishkuro enabled auto-merge (squash) January 18, 2024 05:02
@yurishkuro yurishkuro merged commit 1c0a6ca into jaegertracing:main Jan 18, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:test Change that's adding missing tests or correcting existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants