Skip to content

Commit

Permalink
Responded to Doug's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Dec 14, 2021
1 parent 364b57d commit 7dbaec0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion balancer/rls/internal/builder.go
Expand Up @@ -24,7 +24,7 @@ import (
"google.golang.org/grpc/internal/grpcsync"
)

const rlsBalancerName = "rls"
const rlsBalancerName = "rls_experimental"

func init() {
balancer.Register(&rlsBB{})
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/clusterspecifier/rls/rls.go
Expand Up @@ -36,7 +36,7 @@ import (
_ "google.golang.org/grpc/balancer/rls"
)

const rlsBalancerName = "rls"
const rlsBalancerName = "rls_experimental"

func init() {
if envconfig.XDSRLS {
Expand Down
23 changes: 18 additions & 5 deletions xds/internal/clusterspecifier/rls/rls_test.go
Expand Up @@ -20,10 +20,11 @@ package rls

import (
"encoding/json"
"reflect"
"testing"

"github.com/golang/protobuf/proto"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
_ "google.golang.org/grpc/balancer/rls"
"google.golang.org/grpc/internal/grpctest"
"google.golang.org/grpc/internal/proto/grpc_lookup_v1"
Expand Down Expand Up @@ -75,19 +76,31 @@ func (s) TestParseClusterSpecifierConfig(t *testing.T) {
if (err != nil) != test.wantErr {
t.Fatalf("ParseClusterSpecifierConfig(%+v) returned err: %v, wantErr: %v", test.rlcs, err, test.wantErr)
}

if test.wantErr { // Successfully received an error.
return
}
// Marshal and then unmarshal into interface{} to get rid of
// nondeterministic protojson Marshaling.
lbCfgJSON, err := json.Marshal(lbCfg)
if err != nil {
t.Fatalf("json.Marshal(%+v) returned err %v", lbCfg, err)
}
var got interface{}
err = json.Unmarshal(lbCfgJSON, got)
if err != nil {
t.Fatalf("json.Unmarshal(%+v) returned err %v", lbCfgJSON, err)
}
wantCfgJSON, err := json.Marshal(test.wantConfig)
if err != nil {
t.Fatalf("json.Marshal(%+v) returned err %v", test.wantConfig, err)
}
if !reflect.DeepEqual(lbCfgJSON, wantCfgJSON) {
t.Fatalf("ParseClusterSpecifierConfig(%+v) = %v, want %v", test.rlcs, lbCfgJSON, wantCfgJSON)
var want interface{}
err = json.Unmarshal(wantCfgJSON, want)
if err != nil {
t.Fatalf("json.Unmarshal(%+v) returned err %v", lbCfgJSON, err)
}
if !cmp.Equal(want, got, cmpopts.EquateEmpty()) {
t.Fatalf("ParseClusterSpecifierConfig(%+v) returned expected, diff (-want +got):\\n%s", test.rlcs, cmp.Diff(want, got, cmpopts.EquateEmpty()))
}
}
}
Expand Down Expand Up @@ -144,7 +157,7 @@ var rlsClusterSpecifierConfigWithoutTransformations = testutils.MarshalAny(&grpc
},
})

var configWithoutTransformationsWant = clusterspecifier.BalancerConfig{{"rls": &lbConfigJSON{
var configWithoutTransformationsWant = clusterspecifier.BalancerConfig{{"rls_experimental": &lbConfigJSON{
RouteLookupConfig: []byte(`{"grpcKeybuilders":[{"names":[{"service":"service","method":"method"}],"headers":[{"key":"k1","names":["v1"]}]}],"lookupService":"target","lookupServiceTimeout":"100s","maxAge":"60s","staleAge":"50s","cacheSizeBytes":"1000","defaultTarget":"passthrough:///default"}`),
ChildPolicy: []map[string]json.RawMessage{
{
Expand Down

0 comments on commit 7dbaec0

Please sign in to comment.