Skip to content

Conversation

@twz123
Copy link
Contributor

@twz123 twz123 commented Dec 22, 2025

This will properly pass on cancellation requests, and reduce usage of a deprecated method.

See:

RELEASE NOTES: none

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.28%. Comparing base (0381eb6) to head (6398f6e).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8788      +/-   ##
==========================================
- Coverage   83.48%   83.28%   -0.21%     
==========================================
  Files         414      414              
  Lines       32720    32723       +3     
==========================================
- Hits        27315    27252      -63     
- Misses       4025     4069      +44     
- Partials     1380     1402      +22     
Files with missing lines Coverage Δ
internal/testutils/pipe_listener.go 84.61% <100.00%> (+0.83%) ⬆️
test/rawConnWrapper.go 66.10% <100.00%> (+0.28%) ⬆️

... and 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@twz123 twz123 force-pushed the test-withcontextdialer branch from debddcb to e5d0794 Compare December 22, 2025 14:43
@mbissa mbissa assigned mbissa and eshitachandwani and unassigned mbissa Dec 24, 2025
dl := pl.Dialer()
conn, err := dl("", time.Duration(0))
dl := pl.ContextDialer()
conn, err := dl(t.Context(), "")
Copy link
Member

Choose a reason for hiding this comment

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

We do not use t.Context() rather we do something like this :

ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()

where defaultTestTimeout = 10 * time.Second

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

case <-p.done:
return nil, errClosed
case <-ctx.Done():
return nil, context.Cause(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Can you change this to return ctx.Err()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@eshitachandwani eshitachandwani added this to the 1.79 Release milestone Jan 2, 2026
@twz123 twz123 force-pushed the test-withcontextdialer branch from e5d0794 to 7965ceb Compare January 5, 2026 10:41
opts, scheme := te.configDial()
dw := &dialerWrapper{}
// overwrite the dialer before
opts = append(opts, grpc.WithDialer(dw.dialer))
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep some tests that also check the behaviour of grpc.WithDialer since we say it will be supported throughout 1.x

Copy link
Contributor Author

@twz123 twz123 Jan 21, 2026

Choose a reason for hiding this comment

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

Hmm, we could add a bool to the test struct, so that tests can select which implementation to use, and then pick some tests to explicitly use the old behavior. However, I'm a bit concerned that this might clash with #8666, which actually prompted me to change the e2e tests to respect the context. Without it, there will probably be test failures, because some goroutines will hang around for 10 secs when closing the connection. But I'd need to verify that, to be sure.

Looking at the implementation of grpc.WithDialer, it simply delegates to grpc.WithContextDialer. Maybe adding a unit test that asserts that WithDialer properly forwards to WithContextDialer might already be sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regardless of the decision regarding the e2e tests, I figured a simple unit test would be useful nonetheless, so I added one in 6398f6e.


func (te *test) withServerTester(fn func(st *serverTester)) {
c, err := te.e.dialer(te.srvAddr, 10*time.Second)
ctx, cancel := context.WithTimeout(te.ctx, 10*time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

please use defaultTestTimeout instead of 10*time.Second

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

This will properly pass on cancellation requests, and reduce usage of a
deprecated method.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 force-pushed the test-withcontextdialer branch from 7965ceb to 0471bbf Compare January 21, 2026 07:57
After replacing all usages of grpc.WithDialer in the tests, there was no
longer any test coverage for it. Since WithContextDialer is used behind
the scenes and has proper coverage, we just need to ensure that the
timeouts passed to the callback function are derived properly from the
connect deadline.

Signed-off-by: Tom Wieczorek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants