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

tests: fix status responses size and nil #14299

Merged
merged 1 commit into from
Aug 8, 2022
Merged

Conversation

clement2026
Copy link
Contributor

@clement2026 clement2026 commented Aug 2, 2022

As I migrate tests to common framework, I found 2 problems in the following code

  1. resp is filled with nil before it is appended
  2. --endpoints argument is redundant, as ctl.spawnJsonCmd() has already taken care of it. With this redundant--endpoints, status of one endpoint appears 2 times in epStatus

func (ctl *EtcdctlV3) Status() ([]*clientv3.StatusResponse, error) {
var epStatus []*struct {
Endpoint string
Status *clientv3.StatusResponse
}
err := ctl.spawnJsonCmd(&epStatus, "endpoint", "status", "--endpoints", strings.Join(ctl.endpoints, ","))
if err != nil {
return nil, err
}
resp := make([]*clientv3.StatusResponse, len(epStatus))
for _, e := range epStatus {
resp = append(resp, e.Status)
}
return resp, err
}

Copy link
Member

@spzala spzala left a comment

Choose a reason for hiding this comment

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

@clarkfw thanks for the PR. I would appreciate it if you could provide some details in the PR description for these changes and the issue(s) it solves.

@clement2026
Copy link
Contributor Author

@clarkfw thanks for the PR. I would appreciate it if you could provide some details in the PR description for these changes and the issue(s) it solves.

I've update the comment. By the way, is it better to open an issue before committing a PR like this(bug fix)?

@codecov-commenter
Copy link

Codecov Report

Merging #14299 (7fa88fb) into main (4f0e92d) will decrease coverage by 0.26%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main   #14299      +/-   ##
==========================================
- Coverage   75.58%   75.32%   -0.27%     
==========================================
  Files         456      456              
  Lines       37039    37039              
==========================================
- Hits        27997    27898      -99     
- Misses       7301     7389      +88     
- Partials     1741     1752      +11     
Flag Coverage Δ
all 75.32% <ø> (-0.27%) ⬇️

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

Impacted Files Coverage Δ
server/proxy/grpcproxy/register.go 69.76% <0.00%> (-20.94%) ⬇️
server/etcdserver/api/v3rpc/interceptor.go 73.43% <0.00%> (-9.38%) ⬇️
client/pkg/v3/fileutil/lock_linux.go 72.22% <0.00%> (-8.34%) ⬇️
client/pkg/v3/tlsutil/tlsutil.go 83.33% <0.00%> (-8.34%) ⬇️
server/storage/mvcc/watchable_store.go 85.14% <0.00%> (-4.72%) ⬇️
server/storage/wal/file_pipeline.go 90.69% <0.00%> (-4.66%) ⬇️
client/v3/concurrency/session.go 88.63% <0.00%> (-4.55%) ⬇️
client/v3/leasing/cache.go 87.77% <0.00%> (-3.89%) ⬇️
server/etcdserver/txn/util.go 75.47% <0.00%> (-3.78%) ⬇️
client/v3/watch.go 91.36% <0.00%> (-2.62%) ⬇️
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@spzala
Copy link
Member

spzala commented Aug 3, 2022

@clarkfw thanks for the PR. I would appreciate it if you could provide some details in the PR description for these changes and the issue(s) it solves.

I've update the comment. By the way, is it better to open an issue before committing a PR like this(bug fix)?

Thank you @clarkfw No, the issue is not required to open. But, when there is no issue related to the PR, the details provided in the PR description help reviewers to understand the context quickly for the proposed changes.

@clement2026
Copy link
Contributor Author

@clarkfw thanks for the PR. I would appreciate it if you could provide some details in the PR description for these changes and the issue(s) it solves.

I've update the comment. By the way, is it better to open an issue before committing a PR like this(bug fix)?

Thank you @clarkfw No, the issue is not required to open. But, when there is no issue related to the PR, the details provided in the PR description help reviewers to understand the context quickly for the proposed changes.

Thanks for the detailed explanation, which makes it easier for me to participate in contribution.

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you @clarkfw

@ahrtr
Copy link
Member

ahrtr commented Aug 8, 2022

I see that you made the same change in #14304, so you need to rebase that PR after this one is merged.

@ahrtr
Copy link
Member

ahrtr commented Aug 8, 2022

@spzala This is only test case change, the PR is fixing the golang slice length related issue. For example, the value 10 is actually added as the 3rd element (index: 2) instead of the first element (index: 0). It's a classic error when people handle golang slice.

s := make([]int, 2)
s = append(s, 10)

@ahrtr ahrtr merged commit eea4c10 into etcd-io:main Aug 8, 2022
@spzala
Copy link
Member

spzala commented Aug 8, 2022

@spzala This is only test case change, the PR is fixing the golang slice length related issue. For example, the value 10 is actually added as the 3rd element (index: 2) instead of the first element (index: 0). It's a classic error when people handle golang slice.

s := make([]int, 2)
s = append(s, 10)

Ok, lgtm! Thanks @ahrtr @clarkfw I meant to review it after my initial general comment on PR description but coming back to work today from couple of days vacation/long weekend :)

@clement2026 clement2026 deleted the fix-status branch August 9, 2022 03:35
@clement2026
Copy link
Contributor Author

clement2026 commented Aug 9, 2022

Thank you for taking the time to review🫰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants