chore: enable and fix noctx issues - #3266
Conversation
717bd3a to
5d33adc
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3266 +/- ##
==========================================
- Coverage 14.73% 14.72% -0.02%
==========================================
Files 200 200
Lines 93077 93033 -44
==========================================
- Hits 13712 13696 -16
+ Misses 78019 77994 -25
+ Partials 1346 1343 -3 🚀 New features to boost your workflow:
|
ab4ad04 to
7b4aaea
Compare
| if t != nil { | ||
| ctx = t.Context() | ||
| } else { | ||
| ctx = context.Background() | ||
| } |
There was a problem hiding this comment.
I was curious why the nil-check was needed, but it looks because we also use the same utility for TestMain;
swarmkit/manager/state/raft/membership/cluster_test.go
Lines 32 to 37 in 2cd3a03
So, it's "ok" for now to do this, but perhaps we should look at;
- rewriting these utilities to return an error + a wrapper that's a
t.Helper(), which would change error ->t.Fail - OR; depending on how many tests require this; call the setup for each test individually. We'd have to look how costly it is (alternative could potentially be some
sync.Onceto prevent repeating it)
Last one is mostly to see if we need a TestMain (perhaps we still do, but I also notice an init func in that same file;
swarmkit/manager/state/raft/membership/cluster_test.go
Lines 27 to 30 in 2cd3a03
| @@ -352,7 +352,7 @@ func (t *Transport) dial(addr string) (*grpc.ClientConn, error) { | |||
| // TODO(anshul) Add an option to configure this. | |||
| grpcOptions = append(grpcOptions, | |||
| grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { | |||
There was a problem hiding this comment.
This one's deprecated, so we may as well do;
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "tcp", addr)
})There was a problem hiding this comment.
.. I think? (or would we lose the timeout?)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
- What I did
enable and fix noctx issues
- How I did it
Add noctx to noctx to enabled linters and fix raised issues
- How to test it
- Description for the changelog