diff --git a/js/modules/k6/grpc/client.go b/js/modules/k6/grpc/client.go index f35cd9814141..5c350e6de090 100644 --- a/js/modules/k6/grpc/client.go +++ b/js/modules/k6/grpc/client.go @@ -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 { @@ -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) } diff --git a/js/modules/k6/grpc/client_test.go b/js/modules/k6/grpc/client_test.go index 90d4a02a43e0..f1212a3fbece 100644 --- a/js/modules/k6/grpc/client_test.go +++ b/js/modules/k6/grpc/client_test.go @@ -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" @@ -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()