-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix Subscribe panic and add a test which would have caught it #74
Conversation
2ae2cf5
to
6699895
Compare
Codecov Report
@@ Coverage Diff @@
## main #74 +/- ##
===========================================
+ Coverage 33.89% 50.00% +16.10%
===========================================
Files 3 3
Lines 413 422 +9
===========================================
+ Hits 140 211 +71
+ Misses 250 177 -73
- Partials 23 34 +11
Continue to review full report at Codecov.
|
6699895
to
f0ae94c
Compare
Thanks again to @mmlb for most of this test harness, and for the pointers for the further cleanup of the tests in https://github.com/tinkerbell/hegel/compare/669989512f74834d3a41cbcc271cf03cb152c630..f0ae94cd34199f0d1d1ce3c90e64dfb8ad9111a5 |
np. now that I look again the |
Good catch. I will clean that up. Edit: Cleaned up in https://github.com/tinkerbell/hegel/compare/f0ae94cd34199f0d1d1ce3c90e64dfb8ad9111a5..b149044946bc8f3de8db4607f3851b37e9e3d75a |
f0ae94c
to
b149044
Compare
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.
I read it over and think I understand what's happening and it looks fine to me. Thanks for adding this!
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.
just a few minor nits the only one I'd really like to see fixed is the comment on startServersAndConnectClient
grpc-server/grpc_server.go
Outdated
var m sync.RWMutex | ||
s := &Server{ | ||
log: l, | ||
hardwareClient: hc, | ||
subLock: &m, |
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.
var m sync.RWMutex | |
s := &Server{ | |
log: l, | |
hardwareClient: hc, | |
subLock: &m, | |
s := &Server{ | |
log: l, | |
hardwareClient: hc, | |
subLock: &sync.RWMutex{}, |
should work too and doesn't need a unnecessary variable.
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
grpc-server/grpc_helpers_test.go
Outdated
zt.mu.RUnlock() | ||
} | ||
|
||
// serveAndDial starts 2 grpc services. |
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.
should be startServersAndConnectClient
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.
And the rest of the comment updated too. 😄
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
grpc-server/subscribe_test.go
Outdated
}) | ||
|
||
t.Run("good", func(t *testing.T) { | ||
// id := uuid.Must(uuid.NewRandom()).String() |
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.
should be deleted
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
grpc-server/subscribe_test.go
Outdated
data := map[string]string{} | ||
value := fmt.Sprintf(`{"id": "%s", "ip": "%s"}`, id, id) | ||
payload := fmt.Sprintf(`%s=%s`, id, value) | ||
data[id] = value |
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.
could be:
data := map[string]string{} | |
value := fmt.Sprintf(`{"id": "%s", "ip": "%s"}`, id, id) | |
payload := fmt.Sprintf(`%s=%s`, id, value) | |
data[id] = value | |
value := fmt.Sprintf(`{"id": "%s", "ip": "%s"}`, id, id) | |
payload := fmt.Sprintf(`%s=%s`, id, value) | |
data := map[string]string{ | |
id: value, | |
} |
but not a big deal to change really
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
Fixes #69 Signed-off-by: Nahum Shalman <[email protected]>
This allows us to accept "bufconn" connections during testing without causing panics Signed-off-by: Nahum Shalman <[email protected]> Co-authored-by: Manuel Mendez <[email protected]>
b149044
to
0bd1af9
Compare
Signed-off-by: Nahum Shalman <[email protected]> Co-authored-by: Manuel Mendez <[email protected]>
0bd1af9
to
4b367ad
Compare
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.
Description
This PR creates a new test for the Subscribe endpoint as well as fixing a current bug which causes panics when that RPC is used.
Why is this needed
Fixes: #69
How Has This Been Tested?
How are existing users impacted? What migration steps/scripts do we need?
Checklist:
I have: