Skip to content

Commit

Permalink
Merge 1ddd358 into 1892f91
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Sep 22, 2023
2 parents 1892f91 + 1ddd358 commit daa77bb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 41 deletions.
5 changes: 2 additions & 3 deletions js/modules/k6/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ func (c *Client) parseInvokeParams(paramsVal goja.Value) (*invokeParams, error)
params := paramsVal.ToObject(rt)
for _, k := range params.Keys() {
switch k {
case "headers":
c.vu.State().Logger.Warn("The headers property is deprecated, replace it with the metadata property, please.")
fallthrough
case "metadata":
md, err := newMetadata(params.Get(k))
if err != nil {
Expand All @@ -467,6 +464,8 @@ func (c *Client) parseInvokeParams(paramsVal goja.Value) (*invokeParams, error)
if err != nil {
return result, fmt.Errorf("invalid timeout value: %w", err)
}
case "headers":
return result, errors.New("headers param is not supported anymore. Please, use metadata param instead")
default:
return result, fmt.Errorf("unknown param: %q", k)
}
Expand Down
38 changes: 0 additions & 38 deletions js/modules/k6/grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -1129,43 +1128,6 @@ func TestDebugStat(t *testing.T) {
}
}

func TestClientInvokeHeadersDeprecated(t *testing.T) {
t.Parallel()

ts := newTestState(t)
reflection.Register(ts.httpBin.ServerGRPC)

ts.httpBin.GRPCStub.EmptyCallFunc = func(_ context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) {
return &grpc_testing.Empty{}, nil
}

initString := codeBlock{
code: `var client = new grpc.Client();`,
}
vuString := codeBlock{
code: `
client.connect("GRPCBIN_ADDR", {reflect:true});
var resp = client.invoke("grpc.testing.TestService/EmptyCall", {}, { headers: { "X-Load-Tester": "k6" } })
if (resp.status !== grpc.StatusOK) {
throw new Error("failed to send a request")
}
`,
}

val, err := ts.Run(initString.code)
assertResponse(t, initString, err, val, ts)

ts.ToVUContext()

val, err = ts.Run(vuString.code)
assertResponse(t, vuString, err, val, ts)

entries := ts.loggerHook.Drain()

require.Len(t, entries, 1)
require.Contains(t, entries[0].Message, "headers property is deprecated")
}

func TestClientLoadProto(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit daa77bb

Please sign in to comment.