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 coverage for Client ops #641

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

cthulhu-rider
Copy link
Contributor

@cthulhu-rider cthulhu-rider commented Nov 27, 2024

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 73.04527% with 131 lines in your changes missing coverage. Please review.

Project coverage is 59.46%. Comparing base (2da6182) to head (b4c7efe).

Files with missing lines Patch % Lines
client/object_get.go 67.56% 18 Missing and 6 partials ⚠️
client/container.go 78.57% 14 Missing and 7 partials ⚠️
client/object_put.go 60.00% 16 Missing and 2 partials ⚠️
client/object_replicate.go 57.14% 8 Missing and 4 partials ⚠️
client/reputation.go 57.14% 8 Missing and 4 partials ⚠️
client/netmap.go 75.00% 6 Missing and 4 partials ⚠️
client/client.go 78.94% 5 Missing and 3 partials ⚠️
client/session.go 57.14% 4 Missing and 2 partials ⚠️
client/common.go 81.48% 5 Missing ⚠️
client/object_delete.go 66.66% 2 Missing and 2 partials ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #641      +/-   ##
==========================================
+ Coverage   57.47%   59.46%   +1.98%     
==========================================
  Files         164      165       +1     
  Lines       22503    22751     +248     
==========================================
+ Hits        12934    13529     +595     
+ Misses       9175     8810     -365     
- Partials      394      412      +18     

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

This:
 - groups with wrong length case;
 - mentions the correct version.

Signed-off-by: Leonard Lyubich <[email protected]>
Regression from b75db12. Since then, no
error were submitted to stat handler of following `Client` ops:
 - `NetmapSnapshot`;
 - `ObjectDelete`.

Now unit tests detect such things.

Signed-off-by: Leonard Lyubich <[email protected]>
Previously, client did not check split info from server responses to
`Head` / `Get` and `GetRange` requests. In addition to accepting a buggy
or malicious response, this also resulted in undefined data in the
method returns.

Now split info field is strictly controlled according to the protocol.

Signed-off-by: Leonard Lyubich <[email protected]>
Previously, `ObjectGetInit` and `ObjectHead` methods of the `Client` did
not check whether required response fields (object header, signature
and, for GET, ID) are set or not. This was incorrect since these fields
are required, missing any of them makes response inappropriate.

Now `Client` returns `MissingResponseFieldErr` in this case.
Corresponding unit tests PASS now.

Signed-off-by: Leonard Lyubich <[email protected]>
Previous 'empty attribute value K' text could confuse because K is not
empty.

For network info, 'attribute' is also renamed to 'parameter'.

Signed-off-by: Leonard Lyubich <[email protected]>
`Client` must not attempt to send obviously invalid requests. Moreover,
pre-check already existed for PUT, and these operations are similar in
this sense.

Signed-off-by: Leonard Lyubich <[email protected]>
`Client` signs not just payload but request parts. So, to be more
precise what's going on, it's worth to narrow generic 'calculate
signature' text. Moreover, PUT already results with 'calculate container
signature' in the same case.

Signed-off-by: Leonard Lyubich <[email protected]>
Previously, on the problem with the 1st GET stream message, `Client`
returned 'header: ...' error. Such an error led to the question: header
what?

Now 'read header: ...' is returned.

Signed-off-by: Leonard Lyubich <[email protected]>
@cthulhu-rider
Copy link
Contributor Author

that's it for now 😅

test code may look bulky, but now it's quite detective. The maintenance is expected to be easier in the future

testing allowed to revise many things. I've changed/fixed some of them right away. For less obvious and/or requiring more changes I opened several issues

@cthulhu-rider cthulhu-rider marked this pull request as ready for review December 10, 2024 17:32
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

I can't review test changes here, sorry. Functional ones are OK.

@@ -153,7 +153,8 @@ func (c *Client) ObjectHash(ctx context.Context, containerID cid.ID, objectID oi

resp, err := c.object.GetRangeHash(ctx, req.ToGRPCMessage().(*protoobject.GetRangeHashRequest))
if err != nil {
return nil, rpcErr(err)
err = rpcErr(err)
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't belong to 484bd6c.

@@ -155,7 +155,7 @@ func (x *Container) readFromV2(m container.Container, checkFieldPresence bool) e

val = attrs[i].GetValue()
if val == "" {
return fmt.Errorf("empty attribute value %s", key)
return fmt.Errorf("empty value of the attribute %s", key)
Copy link
Member

Choose a reason for hiding this comment

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

empty %q attribute value would be shorter.

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.

2 participants