Skip to content

Commit

Permalink
Add new integration test for invalid client api version.
Browse files Browse the repository at this point in the history
Signed-off-by: James Blair <mail@jamesblair.net>
  • Loading branch information
jmhbnz committed Mar 20, 2023
1 parent 30abf17 commit 19a9995
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/integration/clientv3/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

"go.etcd.io/etcd/api/v3/mvccpb"
Expand Down Expand Up @@ -896,3 +897,25 @@ func TestBalancerSupportLearner(t *testing.T) {
t.Errorf("expect no error (balancer should retry when request to learner fails), got error: %v", err)
}
}

func TestInvalidUTF8ClientVersionOverwrite(t *testing.T) {

// Initialize integration test framework
integration2.BeforeTest(t)

// Create a new single node cluster
clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 1})
defer clus.Terminate(t)

// Create a client request with an invalid client api version
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
ctx = metadata.NewIncomingContext(ctx, metadata.New(map[string]string{rpctypes.MetadataClientAPIVersionKey: "hello\xff\xfe\xfdworld"}))
resp, err := clus.Members[0].Client.Put(ctx, "/foo", "bar")

// We should see no error because downstream call stack for clientv3
// should overwrite the invalid version created here.
if err != nil {
t.Errorf("Expected no error (clienv3 should be overwriting invalid clientapiversion): %v", err)
}
}

0 comments on commit 19a9995

Please sign in to comment.