-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: Add unit test for channel state waiting for first resolver update #7768
base: master
Are you sure you want to change the base?
Changes from 7 commits
49329cf
f314b62
6ad9713
7d8ed8f
b74dcd2
2061c46
f3c6931
7829dd6
69c8a63
3b33b19
a6d2b49
9a85a50
bc03ad2
cd4f22e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
"google.golang.org/grpc/internal/balancer/stub" | ||
"google.golang.org/grpc/internal/envconfig" | ||
"google.golang.org/grpc/internal/grpcsync" | ||
"google.golang.org/grpc/internal/stubserver" | ||
"google.golang.org/grpc/internal/testutils" | ||
"google.golang.org/grpc/resolver" | ||
"google.golang.org/grpc/resolver/manual" | ||
|
@@ -616,3 +617,38 @@ func (s) TestConnectivityStateSubscriber(t *testing.T) { | |
} | ||
} | ||
} | ||
|
||
// TestChannelStateWaitingForFirstResolverUpdate verifies the initial | ||
// state of the channel when a manual name resolver doesn't provide any updates. | ||
func (s) TestChannelStateWaitingForFirstResolverUpdate(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("Skipping test in short mode.") | ||
} | ||
|
||
backend := stubserver.StartTestService(t, nil) | ||
defer backend.Stop() | ||
dfawley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
mr := manual.NewBuilderWithScheme("e2e-test") | ||
defer mr.Close() | ||
|
||
cc, err := grpc.NewClient(mr.Scheme()+":///", grpc.WithResolvers(mr), grpc.WithTransportCredentials(insecure.NewCredentials())) | ||
if err != nil { | ||
t.Fatalf("Failed to create new client: %v", err) | ||
} | ||
defer cc.Close() | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | ||
defer cancel() | ||
|
||
cc.Connect() | ||
|
||
testutils.AwaitState(ctx, t, cc, connectivity.Idle) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has to be before Connect or else it will race.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should go above the context creation and just be an assertion that |
||
|
||
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mr.UpdateState(resolver.State{ | ||
Addresses: []resolver.Address{{Addr: backend.Address}}, | ||
}) | ||
|
||
testutils.AwaitState(ctx, t, cc, connectivity.Connecting) | ||
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
arjan-bal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testutils.AwaitState(ctx, t, cc, connectivity.Ready) | ||
} |
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.
What is this and why?
I think we have a bug, which this test doesn't actually appear to be testing, but which is described in the issue that asked for this test. IF there is a bug, we need to always skip the test.
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.
Yes, we have a bug that's why we added this test to skip.
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.
@janardhanvissa you can skip the test unconditionally, i.e. remote the
if testing.Short()
. Also add more details in the skip message.