-
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
cleanup: replace dial with newclient #7975
base: master
Are you sure you want to change the base?
Conversation
…tification channel
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7975 +/- ##
==========================================
- Coverage 82.05% 81.95% -0.10%
==========================================
Files 381 381
Lines 38539 38539
==========================================
- Hits 31622 31585 -37
- Misses 5602 5627 +25
- Partials 1315 1327 +12 |
if err == nil || !strings.Contains(err.Error(), wantErr) { | ||
t.Fatalf("grpc.Dial(%q) returned %v, want: %s", target, err, wantErr) | ||
t.Fatalf("Expected error containing %q, got: %v", wantErr, err) |
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.
The log message should contain the function that was called.
t.Fatalf("Expected error containing %q, got: %v", wantErr, err) | |
t.Fatalf("EmptyCall(_, _) = _, %v; want _, %q", wantErr, err) |
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
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.
The order of wantErr
and err
is inverted. err
should come before wantErr
.
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
clientconn.go
Outdated
// validation for the google-c2p scheme. | ||
if cc.parsedTarget.URL.Scheme == "google-c2p" && cc.parsedTarget.URL.Host != "" { | ||
return nil, fmt.Errorf("google-c2p URI scheme does not support authorities") | ||
} | ||
|
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.
This is not how you get the test to pass :b. The validation is done by the resolver and not the gRPC channel. The gRPC channel is generic and doesn't care about the google-c2p
scheme.
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
@@ -315,15 +315,15 @@ func (s) TestBuildXDS(t *testing.T) { | |||
func (s) TestBuildFailsWhenCalledWithAuthority(t *testing.T) { | |||
useCleanUniverseDomain(t) | |||
uri := "google-c2p://an-authority/resource" | |||
cc, err := grpc.Dial(uri, grpc.WithTransportCredentials(insecure.NewCredentials())) | |||
cc, err := grpc.NewClient(uri, grpc.WithTransportCredentials(insecure.NewCredentials())) | |||
defer func() { | |||
if cc != nil { | |||
cc.Close() | |||
} | |||
}() | |||
wantErr := "google-c2p URI scheme does not support authorities" | |||
if err == nil || !strings.Contains(err.Error(), wantErr) { |
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.
NewClient
is lazy, so the the resolver will not be built until and rpc is made of cc.Connect
is called. You would need to create a test service client, call client.EmptyCall
and check for the error string in the returned error. This is very similar to the fix made in the federation 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.
done
test/end2end_test.go
Outdated
lis, err := net.Listen("tcp", "localhost:0") | ||
if err != nil { | ||
t.Fatalf("Failed to listen: %v", err) | ||
} | ||
defer lis.Close() |
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.
This seems unnecessary. You can just pass the target URI as "passthrough:///"
, no need to create a listener and get it's address.
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
test/balancer_switching_test.go
Outdated
} | ||
defer cc.Close() | ||
|
||
cc.Connect() |
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.
You can avoid using cc.Connect
here by replacing the r.UpdateState
below with r.InitialState
.
test/balancer_switching_test.go
Outdated
} | ||
defer cc.Close() | ||
|
||
cc.Connect() |
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.
You can avoid using cc.Connect
here by replacing the r.UpdateState
below with r.InitialState
.
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.
The resolver is getting as nil after updating to r.InitialState before creating a client conn.
test/balancer_switching_test.go
Outdated
} | ||
defer cc.Close() | ||
|
||
cc.Connect() |
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.
You can avoid using cc.Connect
here by replacing the r.UpdateState
below with r.InitialState
.
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.
@arjan-bal If we do like replacing r.UpdateState to r.InitialState, first we should ensure that the manual.Resolver.CC must be set grpc.NewClient before calling parseServiceConfig. So, we cannot update to r.InitialState before creating a NewClient.
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.
You can use internal.ParseConfig to avoid depending on manual.Resolver.CC
.
test/balancer_switching_test.go
Outdated
} | ||
defer cc.Close() | ||
|
||
cc.Connect() |
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.
You can avoid using cc.Connect
here by replacing the r.UpdateState
below with r.InitialState
. Please check other places where the same change can be made.
Partially address: #7049
RELEASE NOTES: None