mirror of https://github.com/grpc/grpc-go.git
client: consider service config invalid if loadBalancingConfig… (#3034)
This commit is contained in:
parent
a5e64ec425
commit
6b46f470d1
|
@ -310,6 +310,14 @@ func parseServiceConfig(js string) (*ServiceConfig, error) {
|
|||
}
|
||||
break
|
||||
}
|
||||
if sc.lbConfig == nil {
|
||||
// We had a loadBalancingConfig field but did not encounter a
|
||||
// supported policy. The config is considered invalid in this
|
||||
// case.
|
||||
err := fmt.Errorf("invalid loadBalancingConfig: no supported policies found")
|
||||
grpclog.Warningf(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if rsc.MethodConfig == nil {
|
||||
|
|
|
@ -92,6 +92,23 @@ func (s) TestParseLBConfig(t *testing.T) {
|
|||
runParseTests(t, testcases)
|
||||
}
|
||||
|
||||
func (s) TestParseNoLBConfigSupported(t *testing.T) {
|
||||
// We have a loadBalancingConfig field but will not encounter a supported
|
||||
// policy. The config will be considered invalid in this case.
|
||||
testcases := []parseTestCase{
|
||||
{
|
||||
scjs: `{
|
||||
"loadBalancingConfig": [{"not_a_balancer1": {} }, {"not_a_balancer2": {}}]
|
||||
}`,
|
||||
wantErr: true,
|
||||
}, {
|
||||
scjs: `{"loadBalancingConfig": []}`,
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
runParseTests(t, testcases)
|
||||
}
|
||||
|
||||
func (s) TestParseLoadBalancer(t *testing.T) {
|
||||
testcases := []parseTestCase{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue