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

test: Add unit test to protocol module #165

Merged
merged 2 commits into from
Feb 12, 2025
Merged

Conversation

tanmayv25
Copy link
Contributor

@tanmayv25 tanmayv25 commented Feb 11, 2025

What does the PR do?

Adds the unit testing to protocol.rs module.
Selected it for simplicity from the report shared in #144 (comment)

TODO : Add more coverage to the sections from report.

Test coverage after adding this test.

Filename                                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
component.rs                                       32                32     0.00%          24                24     0.00%          74                74     0.00%           0                 0         -
component/client.rs                                86                86     0.00%          17                17     0.00%         149               149     0.00%           0                 0         -
component/endpoint.rs                              43                43     0.00%           9                 9     0.00%          70                70     0.00%           0                 0         -
component/registry.rs                               2                 2     0.00%           2                 2     0.00%           8                 8     0.00%           0                 0         -
component/service.rs                               34                34     0.00%           8                 8     0.00%          45                45     0.00%           0                 0         -
config.rs                                          29                18    37.93%          10                 5    50.00%          54                23    57.41%           0                 0         -
discovery.rs                                        5                 5     0.00%           4                 4     0.00%          13                13     0.00%           0                 0         -
distributed.rs                                     53                53     0.00%          19                19     0.00%          88                88     0.00%           0                 0         -
engine.rs                                           7                 3    57.14%           7                 3    57.14%          29                14    51.72%           0                 0         -
pipeline.rs                                         3                 2    33.33%           3                 2    33.33%           9                 6    33.33%           0                 0         -
pipeline/context.rs                                85                34    60.00%          62                27    56.45%         261                89    65.90%           0                 0         -
pipeline/error.rs                                   5                 4    20.00%           2                 1    50.00%           8                 5    37.50%           0                 0         -
pipeline/network.rs                                54                35    35.19%          18                12    33.33%          73                50    31.51%           0                 0         -
pipeline/network/codec/two_part.rs                159                27    83.02%          38                 4    89.47%         721                31    95.70%           0                 0         -
pipeline/network/egress/push.rs                    52                52     0.00%           8                 8     0.00%          92                92     0.00%           0                 0         -
pipeline/network/ingress/push_endpoint.rs          35                35     0.00%           5                 5     0.00%          33                33     0.00%           0                 0         -
pipeline/network/ingress/push_handler.rs           62                62     0.00%           3                 3     0.00%          67                67     0.00%           0                 0         -
pipeline/network/tcp.rs                            27                 2    92.59%           5                 1    80.00%         174                 5    97.13%           0                 0         -
pipeline/network/tcp/client.rs                     83                43    48.19%          13                 5    61.54%         141                55    60.99%           0                 0         -
pipeline/network/tcp/server.rs                    213               105    50.70%          33                13    60.61%         329               125    62.01%           0                 0         -
pipeline/nodes.rs                                  61                15    75.41%          29                 6    79.31%         100                15    85.00%           0                 0         -
pipeline/nodes/sinks/base.rs                       13                 3    76.92%           5                 1    80.00%          20                 1    95.00%           0                 0         -
pipeline/nodes/sinks/pipeline.rs                   13                 1    92.31%           6                 0   100.00%          18                 0   100.00%           0                 0         -
pipeline/nodes/sinks/segment.rs                    19                 3    84.21%           9                 1    88.89%          32                 1    96.88%           0                 0         -
pipeline/nodes/sources/base.rs                     50                13    74.00%          15                 5    66.67%         105                11    89.52%           0                 0         -
pipeline/nodes/sources/common.rs                   24                 6    75.00%          10                 2    80.00%          49                 6    87.76%           0                 0         -
pipeline/registry.rs                               38                 6    84.21%          16                 4    75.00%          95                20    78.95%           0                 0         -
protocols.rs                                       21                 0   100.00%           7                 0   100.00%          61                 0   100.00%           0                 0         -
protocols/annotated.rs                             37                37     0.00%          14                14     0.00%          87                87     0.00%           0                 0         -
runtime.rs                                         36                25    30.56%          12                 7    41.67%          56                28    50.00%           0                 0         -
service.rs                                         32                25    21.88%          12                 8    33.33%         102                46    54.90%           0                 0         -
transports/etcd.rs                                 93                93     0.00%          27                27     0.00%         158               158     0.00%           0                 0         -
transports/etcd/lease.rs                           60                60     0.00%           6                 6     0.00%          69                69     0.00%           0                 0         -
transports/nats.rs                                112                78    30.36%          26                18    30.77%         152                79    48.03%           0                 0         -
transports/nats/slug.rs                            33                33     0.00%          15                15     0.00%          73                73     0.00%           0                 0         -
worker.rs                                          86                34    60.47%          15                 6    60.00%         114                33    71.05%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                            1797              1109    38.29%         514               292    43.19%        3729              1669    55.24%           0                 0         -

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

Check the conventional commit type
box here and add the label to the github PR.

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity - do you see the test coverage bump up compared to here after this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. See the protocol.rs is now 100%.
Updated in the PR description.

Copy link
Contributor

@rmccorm4 rmccorm4 Feb 12, 2025

Choose a reason for hiding this comment

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

TODO : Add more coverage to the sections from report.

Also FYI, there's an open PR adding some testing to component.rs - so no need to duplicate work there. Feel free to review that one: #127

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out!

@tanmayv25 tanmayv25 requested a review from rmccorm4 February 12, 2025 00:36
Copy link
Contributor

@rmccorm4 rmccorm4 left a comment

Choose a reason for hiding this comment

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

Rust developer 🚀

@tanmayv25 tanmayv25 merged commit a23f54f into main Feb 12, 2025
6 checks passed
@tanmayv25 tanmayv25 deleted the tanmayv-protocol-test branch February 12, 2025 01:29
@grahamking
Copy link
Contributor

@tanmayv25 @rmccorm4 Three of these tests don't do anything: test_component_creation, test_endpoint_creation, test_model_metadata_creation.

They would only fail if Rust was broken. They effectively do a = 42; assert(a == 42).

Do you intend to enhance them in a follow-up commit? Otherwise we should remove them.

@tanmayv25
Copy link
Contributor Author

@grahamking you mean the *_creation tests? Or do you think there are more(serialize/deserialize/defaults)? I don't have any extra tests in mind. I find tests as a good source of examples of creating and using the objects and hence added the *_creation.
I don't mind reverting them.

@grahamking
Copy link
Contributor

@grahamking you mean the *_creation tests? Or do you think there are more(serialize/deserialize/defaults)? I don't have any extra tests in mind. I find tests as a good source of examples of creating and using the objects and hence added the *_creation. I don't mind reverting them.

Yes the creation tests. They don't run any of our code. There is also only one way of creating an object in Rust, so there's no value in documenting how that's done.

Can you make a PR to remove them?

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