From 3ea6bfe888369013a7f9f62a28ddf6b8554d5db1 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:04:56 +0300 Subject: [PATCH] Change to using sobek instead of goja (#297) We are moving to a fork of goja under grafana org called sobek. More info in: - https://github.com/grafana/k6/issues/3772 - https://github.com/grafana/k6/issues/3773 --- go.mod | 23 +++++++------ go.sum | 75 +++++++++++++---------------------------- jks.go | 10 +++--- jks_test.go | 6 ++-- kafka_helpers_test.go | 6 ++-- module.go | 6 ++-- reader.go | 10 +++--- reader_test.go | 16 ++++----- schema_registry.go | 14 ++++---- schema_registry_test.go | 38 ++++++++++----------- serdes_test.go | 4 +-- topic.go | 18 +++++----- topic_test.go | 28 +++++++-------- utils.go | 6 ++-- writer.go | 12 +++---- writer_test.go | 16 ++++----- 16 files changed, 130 insertions(+), 158 deletions(-) diff --git a/go.mod b/go.mod index d97d9ce..f473a85 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/mostafa/xk6-kafka -go 1.22 +go 1.20 require ( github.com/aws/aws-sdk-go-v2/config v1.18.39 - github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 + github.com/grafana/sobek v0.0.0-20240607083612-4f0cd64f4e78 github.com/linkedin/goavro/v2 v2.12.0 github.com/pavlo-v-chernykh/keystore-go/v4 v4.5.0 github.com/riferrei/srclient v0.6.0 @@ -13,12 +13,11 @@ require ( github.com/segmentio/kafka-go/sasl/aws_msk_iam_v2 v0.1.0 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.9.0 - go.k6.io/k6 v0.50.0 + go.k6.io/k6 v0.51.1-0.20240610082146-1f01a9bc2365 gopkg.in/guregu/null.v3 v3.5.0 ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.37 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect @@ -33,11 +32,12 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect + github.com/dop251/goja v0.0.0-20240516125602-ccbae20bcec2 // indirect + github.com/evanw/esbuild v0.21.2 // indirect github.com/fatih/color v1.16.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/pprof v0.0.0-20240402174815-29b9bb013b0f // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect @@ -47,6 +47,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect + github.com/mstoykov/k6-taskqueue-lib v0.1.0 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.20.2 // indirect github.com/pierrec/lz4/v4 v4.1.19 // indirect @@ -64,15 +65,15 @@ require ( go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.24.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/grpc v1.62.1 // indirect + google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 070a66e..5a5cbfb 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,4 @@ github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/aws/aws-sdk-go-v2 v1.16.12/go.mod h1:C+Ym0ag2LIghJbXhfXZ0YEEp49rBWowxKzJLUoob0ts= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2 v1.24.0 h1:890+mqQ+hTpNuw0gGP6/4akolQkSToDJgHfQE7AwGuk= @@ -40,34 +39,25 @@ github.com/aws/smithy-go v1.19.0 h1:KWFKQV80DpP3vJrrA9sVAHQ5gc2z8i4EzrLhLlWXcBM= github.com/aws/smithy-go v1.19.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= -github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= -github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 h1:O7I1iuzEA7SG+dK8ocOBSlYAA9jBUmCYl/Qa7ey7JAM= -github.com/dop251/goja v0.0.0-20240220182346-e401ed450204/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= -github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= -github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= +github.com/dop251/goja v0.0.0-20240516125602-ccbae20bcec2 h1:OFTHt+yJDo/uaIKMGjEKzc3DGhrpQZoqvMUIloZv6ZY= +github.com/dop251/goja v0.0.0-20240516125602-ccbae20bcec2/go.mod h1:o31y53rb/qiIAONF7w3FHJZRqqP3fzHUr1HqanthByw= +github.com/evanw/esbuild v0.21.2 h1:CLplcGi794CfHLVmUbvVfTMKkykm+nyIHU8SU60KUTA= +github.com/evanw/esbuild v0.21.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sourcemap/sourcemap v2.1.4+incompatible h1:a+iTbH5auLKxaNwQFg0B+TCYl6lbukKPc7b5x0n1s6Q= github.com/go-sourcemap/sourcemap v2.1.4+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -78,8 +68,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -88,16 +76,14 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= github.com/google/pprof v0.0.0-20240402174815-29b9bb013b0f h1:f00RU+zOX+B3rLAmMMkzHUF2h1z4DeYR9tTCvEq2REY= github.com/google/pprof v0.0.0-20240402174815-29b9bb013b0f/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/grafana/sobek v0.0.0-20240607083612-4f0cd64f4e78 h1:rVCZdB+13G+aQoGm3CBVaDGl0uxZxfjvQgEJy4IeHTA= +github.com/grafana/sobek v0.0.0-20240607083612-4f0cd64f4e78/go.mod h1:6ZH0b0iOxyigeTh+/IlGoL0Hd3lVXA94xoXf0ldNgCM= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= @@ -106,15 +92,8 @@ github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHU github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linkedin/goavro/v2 v2.11.1/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA= github.com/linkedin/goavro/v2 v2.12.0 h1:rIQQSj8jdAUlKQh6DttK8wCRv4t4QO09g1C4aBWXslg= github.com/linkedin/goavro/v2 v2.12.0/go.mod h1:KXx+erlq+RPlGSPmLF7xGo6SAbh8sCQ53x064+ioxhk= @@ -126,11 +105,11 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa h1:lx8ZnNPwjkXSzOROz0cg69RlErRXs+L3eDkggASWKLo= -github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa/go.mod h1:fhpOYavp5g2K74XDl/ao2y4KvhqVtKlkg1e+0UaQv7I= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd h1:AC3N94irbx2kWGA8f/2Ks7EQl2LxKIRQYuT9IJDwgiI= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 h1:94EkGmhXrVUEal+uLwFUf4fMXPhZpM5tYxuIsxrCCbI= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1/go.mod h1:vk/d9jpexY2Z9Bb0uB4Ndesss1Sr0Z9ZiGUrg5o9VGk= +github.com/mstoykov/envconfig v1.5.0 h1:E2FgWf73BQt0ddgn7aoITkQHmgwAcHup1s//MsS5/f8= +github.com/mstoykov/k6-taskqueue-lib v0.1.0 h1:M3eww1HSOLEN6rIkbNOJHhOVhlqnqkhYj7GTieiMBz4= +github.com/mstoykov/k6-taskqueue-lib v0.1.0/go.mod h1:PXdINulapvmzF545Auw++SCD69942FeNvUztaa9dVe4= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -151,9 +130,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/riferrei/srclient v0.6.0 h1:60LWpQW66AAL5TtWuMPZEplwgWLUdCK3OBUbag/JWFg= github.com/riferrei/srclient v0.6.0/go.mod h1:e3nZcDdaOSsaYqiO18INPBK4qnJTjEEyL2rlJcsTtrA= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/santhosh-tekuri/jsonschema/v5 v5.0.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= @@ -187,8 +164,8 @@ github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49 github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.k6.io/k6 v0.50.0 h1:2AMTXJ37QTmfUZ4ykitWNyIzVJTBQ7mBvlTbzHSmYoU= -go.k6.io/k6 v0.50.0/go.mod h1:hg9WY+HJvyMQo5anhVzz/Gu4lSSm6jpjV+Kk2ts4W9c= +go.k6.io/k6 v0.51.1-0.20240610082146-1f01a9bc2365 h1:ZXlJs5hXt1hbY4k3jHVJS8xrgypgTZAwbMBVH1EMCgY= +go.k6.io/k6 v0.51.1-0.20240610082146-1f01a9bc2365/go.mod h1:LJKmFwUODAYoxitsJ3Xk+wsyVJDpyQiLyJAVn+oGyVQ= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= @@ -206,15 +183,14 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -230,16 +206,16 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -252,7 +228,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -261,8 +236,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -276,8 +251,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -293,8 +268,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1: google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -304,10 +279,7 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/guregu/null.v3 v3.5.0 h1:xTcasT8ETfMcUHn0zTvIYtQud/9Mx5dJqD554SZct0o= gopkg.in/guregu/null.v3 v3.5.0/go.mod h1:E4tX2Qe3h7QdL+uZ3a0vqvYwKQsRSQKM5V4YltdgH9Y= @@ -318,7 +290,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/jks.go b/jks.go index 72aecbb..4c88ecc 100644 --- a/jks.go +++ b/jks.go @@ -7,7 +7,7 @@ import ( "log" "os" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/pavlo-v-chernykh/keystore-go/v4" "go.k6.io/k6/js/common" ) @@ -117,7 +117,7 @@ func (*Kafka) loadJKS(jksConfig *JKSConfig) (*JKS, *Xk6KafkaError) { }, nil } -func (k *Kafka) loadJKSFunction(call goja.FunctionCall) goja.Value { +func (k *Kafka) loadJKSFunction(call sobek.FunctionCall) sobek.Value { runtime := k.vu.Runtime() var jksConfig *JKSConfig @@ -171,7 +171,7 @@ func saveServerCaFile(filename string, cert *keystore.TrustedCertificateEntry) * Bytes: cert.Certificate.Content, }) - if err := os.WriteFile(filename, certPem, 0644); err != nil { + if err := os.WriteFile(filename, certPem, 0o644); err != nil { return NewXk6KafkaError( failedWriteServerCaFile, "Failed to write CA file", err) } @@ -186,7 +186,7 @@ func saveClientKeyFile(filename string, key *keystore.PrivateKeyEntry) *Xk6Kafka Bytes: key.PrivateKey, }) - if err := os.WriteFile(filename, keyPem, 0644); err != nil { + if err := os.WriteFile(filename, keyPem, 0o644); err != nil { return NewXk6KafkaError( failedWriteKeyFile, "Failed to write key file", err) } @@ -200,7 +200,7 @@ func saveClientCertFile(filename string, cert *keystore.Certificate) *Xk6KafkaEr Type: "CERTIFICATE", Bytes: cert.Content, }) - if err := os.WriteFile(filename, clientCertPem, 0644); err != nil { + if err := os.WriteFile(filename, clientCertPem, 0o644); err != nil { return NewXk6KafkaError( failedWriteCertFile, "Failed to write cert file", err) } diff --git a/jks_test.go b/jks_test.go index 45d68a2..1cc7ba5 100644 --- a/jks_test.go +++ b/jks_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/stretchr/testify/assert" ) @@ -118,8 +118,8 @@ func TestJKS(t *testing.T) { func TestLoadJKS_Function(t *testing.T) { test := getTestModuleInstance(t) - jks := test.module.Kafka.loadJKSFunction(goja.FunctionCall{ - Arguments: []goja.Value{ + jks := test.module.Kafka.loadJKSFunction(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "path": "fixtures/kafka-keystore.jks", diff --git a/kafka_helpers_test.go b/kafka_helpers_test.go index ea17231..4e36ea0 100644 --- a/kafka_helpers_test.go +++ b/kafka_helpers_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/dop251/goja" + "github.com/grafana/sobek" kafkago "github.com/segmentio/kafka-go" "github.com/stretchr/testify/require" "go.k6.io/k6/js/common" @@ -20,7 +20,7 @@ const ( // struct to keep all the things test need in one place. type kafkaTest struct { - rt *goja.Runtime + rt *sobek.Runtime module *Module vu *modulestest.VU samples chan metrics.SampleContainer @@ -31,7 +31,7 @@ type kafkaTest struct { // nolint: golint,revive func getTestModuleInstance(tb testing.TB) *kafkaTest { tb.Helper() - runtime := goja.New() + runtime := sobek.New() runtime.SetFieldNameMapper(common.FieldNameMapper{}) ctx, cancel := context.WithCancel(context.Background()) diff --git a/module.go b/module.go index 91f1ee7..1758275 100644 --- a/module.go +++ b/module.go @@ -4,7 +4,7 @@ import ( "crypto/tls" "time" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/riferrei/srclient" kafkago "github.com/segmentio/kafka-go" "github.com/segmentio/kafka-go/compress" @@ -74,7 +74,7 @@ type ( Kafka struct { vu modules.VU metrics kafkaMetrics - exports *goja.Object + exports *sobek.Object schemaCache map[string]*Schema } RootModule struct{} @@ -151,7 +151,7 @@ func (m *Module) defineConstants() { runtime := m.vu.Runtime() mustAddProp := func(name string, val interface{}) { err := m.exports.DefineDataProperty( - name, runtime.ToValue(val), goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_TRUE, + name, runtime.ToValue(val), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE, ) if err != nil { common.Throw(runtime, err) diff --git a/reader.go b/reader.go index 3c04fd0..c885dde 100644 --- a/reader.go +++ b/reader.go @@ -7,7 +7,7 @@ import ( "io" "time" - "github.com/dop251/goja" + "github.com/grafana/sobek" kafkago "github.com/segmentio/kafka-go" "go.k6.io/k6/js/common" "go.k6.io/k6/metrics" @@ -109,7 +109,7 @@ func (d *Duration) UnmarshalJSON(b []byte) error { // readerClass is a wrapper around kafkago.reader and acts as a JS constructor // for this extension, thus it must be called with new operator, e.g. new Reader(...). // nolint: funlen -func (k *Kafka) readerClass(call goja.ConstructorCall) *goja.Object { +func (k *Kafka) readerClass(call sobek.ConstructorCall) *sobek.Object { runtime := k.vu.Runtime() var readerConfig *ReaderConfig if len(call.Arguments) == 0 { @@ -134,7 +134,7 @@ func (k *Kafka) readerClass(call goja.ConstructorCall) *goja.Object { common.Throw(runtime, err) } - err := readerObject.Set("consume", func(call goja.FunctionCall) goja.Value { + err := readerObject.Set("consume", func(call sobek.FunctionCall) sobek.Value { var consumeConfig *ConsumeConfig if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) @@ -157,12 +157,12 @@ func (k *Kafka) readerClass(call goja.ConstructorCall) *goja.Object { } // This is unnecessary, but it's here for reference purposes - err = readerObject.Set("close", func(call goja.FunctionCall) goja.Value { + err = readerObject.Set("close", func(call sobek.FunctionCall) sobek.Value { if err := reader.Close(); err != nil { common.Throw(runtime, err) } - return goja.Undefined() + return sobek.Undefined() }) if err != nil { common.Throw(runtime, err) diff --git a/reader_test.go b/reader_test.go index 655d8ea..483c082 100644 --- a/reader_test.go +++ b/reader_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/riferrei/srclient" kafkago "github.com/segmentio/kafka-go" "github.com/stretchr/testify/assert" @@ -329,8 +329,8 @@ func TestReaderClass(t *testing.T) { }) assert.NotPanics(t, func() { - reader := test.module.readerClass(goja.ConstructorCall{ - Arguments: []goja.Value{ + reader := test.module.readerClass(sobek.ConstructorCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "brokers": []string{"localhost:9092"}, @@ -347,9 +347,9 @@ func TestReaderClass(t *testing.T) { assert.Equal(t, this.Config().Topic, "test-reader-class") assert.Equal(t, this.Config().MaxWait, time.Second*3) - consume := reader.Get("consume").Export().(func(goja.FunctionCall) goja.Value) - messages := consume(goja.FunctionCall{ - Arguments: []goja.Value{ + consume := reader.Get("consume").Export().(func(sobek.FunctionCall) sobek.Value) + messages := consume(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "limit": 1, @@ -370,9 +370,9 @@ func TestReaderClass(t *testing.T) { assert.Equal(t, "value", deserializedValue) // Close the reader. - close := reader.Get("close").Export().(func(goja.FunctionCall) goja.Value) + close := reader.Get("close").Export().(func(sobek.FunctionCall) sobek.Value) assert.NotNil(t, close) - result := close(goja.FunctionCall{}).Export() + result := close(sobek.FunctionCall{}).Export() assert.Nil(t, result) // Check if one message was consumed. diff --git a/schema_registry.go b/schema_registry.go index 1e607a4..379470d 100644 --- a/schema_registry.go +++ b/schema_registry.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/linkedin/goavro/v2" "github.com/riferrei/srclient" "github.com/santhosh-tekuri/jsonschema/v5" @@ -92,7 +92,7 @@ func (s *Schema) JsonSchema() *jsonschema.Schema { return s.jsonSchema } -func (k *Kafka) schemaRegistryClientClass(call goja.ConstructorCall) *goja.Object { +func (k *Kafka) schemaRegistryClientClass(call sobek.ConstructorCall) *sobek.Object { runtime := k.vu.Runtime() var configuration *SchemaRegistryConfig var schemaRegistryClient *srclient.SchemaRegistryClient @@ -117,7 +117,7 @@ func (k *Kafka) schemaRegistryClientClass(call goja.ConstructorCall) *goja.Objec common.Throw(runtime, err) } - err := schemaRegistryClientObject.Set("getSchema", func(call goja.FunctionCall) goja.Value { + err := schemaRegistryClientObject.Set("getSchema", func(call sobek.FunctionCall) sobek.Value { if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) } @@ -143,7 +143,7 @@ func (k *Kafka) schemaRegistryClientClass(call goja.ConstructorCall) *goja.Objec common.Throw(runtime, err) } - err = schemaRegistryClientObject.Set("createSchema", func(call goja.FunctionCall) goja.Value { + err = schemaRegistryClientObject.Set("createSchema", func(call sobek.FunctionCall) sobek.Value { if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) } @@ -170,7 +170,7 @@ func (k *Kafka) schemaRegistryClientClass(call goja.ConstructorCall) *goja.Objec } var subjectNameConfig *SubjectNameConfig - err = schemaRegistryClientObject.Set("getSubjectName", func(call goja.FunctionCall) goja.Value { + err = schemaRegistryClientObject.Set("getSubjectName", func(call sobek.FunctionCall) sobek.Value { if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) } @@ -191,7 +191,7 @@ func (k *Kafka) schemaRegistryClientClass(call goja.ConstructorCall) *goja.Objec common.Throw(runtime, err) } - err = schemaRegistryClientObject.Set("serialize", func(call goja.FunctionCall) goja.Value { + err = schemaRegistryClientObject.Set("serialize", func(call sobek.FunctionCall) sobek.Value { if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) } @@ -213,7 +213,7 @@ func (k *Kafka) schemaRegistryClientClass(call goja.ConstructorCall) *goja.Objec common.Throw(runtime, err) } - err = schemaRegistryClientObject.Set("deserialize", func(call goja.FunctionCall) goja.Value { + err = schemaRegistryClientObject.Set("deserialize", func(call sobek.FunctionCall) sobek.Value { if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) } diff --git a/schema_registry_test.go b/schema_registry_test.go index 181796a..c2ddea3 100644 --- a/schema_registry_test.go +++ b/schema_registry_test.go @@ -3,7 +3,7 @@ package kafka import ( "testing" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/riferrei/srclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -32,7 +32,7 @@ func TestDecodeWireFormatFails(t *testing.T) { defer func() { err := recover() assert.Equal(t, - err.(*goja.Object).ToString().String(), + err.(*sobek.Object).ToString().String(), GoErrorPrefix+"Invalid message: message too short to contain schema id.") }() @@ -276,8 +276,8 @@ func TestSchemaRegistryClientClass(t *testing.T) { require.NoError(t, test.moveToVUCode()) assert.NotPanics(t, func() { // Create a schema registry client. - client := test.module.schemaRegistryClientClass(goja.ConstructorCall{ - Arguments: []goja.Value{ + client := test.module.schemaRegistryClientClass(sobek.ConstructorCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "url": "http://localhost:8081", @@ -288,9 +288,9 @@ func TestSchemaRegistryClientClass(t *testing.T) { assert.NotNil(t, client) // Create a schema and send it to the registry. - createSchema := client.Get("createSchema").Export().(func(goja.FunctionCall) goja.Value) - newSchema := createSchema(goja.FunctionCall{ - Arguments: []goja.Value{ + createSchema := client.Get("createSchema").Export().(func(sobek.FunctionCall) sobek.Value) + newSchema := createSchema(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "subject": "test-subject", @@ -304,9 +304,9 @@ func TestSchemaRegistryClientClass(t *testing.T) { assert.Equal(t, 0, newSchema.Version) // Get the latest version of the schema from the registry. - getSchema := client.Get("getSchema").Export().(func(goja.FunctionCall) goja.Value) - currentSchema := getSchema(goja.FunctionCall{ - Arguments: []goja.Value{ + getSchema := client.Get("getSchema").Export().(func(sobek.FunctionCall) sobek.Value) + currentSchema := getSchema(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "subject": "test-subject", @@ -320,9 +320,9 @@ func TestSchemaRegistryClientClass(t *testing.T) { assert.Equal(t, avroSchema, currentSchema.Schema) // Get the subject name based on the given subject name config. - getSubjectName := client.Get("getSubjectName").Export().(func(goja.FunctionCall) goja.Value) - subjectName := getSubjectName(goja.FunctionCall{ - Arguments: []goja.Value{ + getSubjectName := client.Get("getSubjectName").Export().(func(sobek.FunctionCall) sobek.Value) + subjectName := getSubjectName(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "schema": avroSchema, @@ -336,9 +336,9 @@ func TestSchemaRegistryClientClass(t *testing.T) { assert.Equal(t, "test-topic-com.example.person.Schema", subjectName) // Serialize the given value to byte array. - serialize := client.Get("serialize").Export().(func(goja.FunctionCall) goja.Value) - serialized := serialize(goja.FunctionCall{ - Arguments: []goja.Value{ + serialize := client.Get("serialize").Export().(func(sobek.FunctionCall) sobek.Value) + serialized := serialize(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "data": map[string]interface{}{"field": "value"}, @@ -351,9 +351,9 @@ func TestSchemaRegistryClientClass(t *testing.T) { assert.NotNil(t, serialized) // Deserialize the given byte array to the actual value. - deserialize := client.Get("deserialize").Export().(func(goja.FunctionCall) goja.Value) - deserialized := deserialize(goja.FunctionCall{ - Arguments: []goja.Value{ + deserialize := client.Get("deserialize").Export().(func(sobek.FunctionCall) sobek.Value) + deserialized := deserialize(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "data": serialized, diff --git a/serdes_test.go b/serdes_test.go index dd541b2..050f863 100644 --- a/serdes_test.go +++ b/serdes_test.go @@ -5,7 +5,7 @@ import ( "testing" "unsafe" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/riferrei/srclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -233,7 +233,7 @@ func TestSerializeFails(t *testing.T) { defer func(t *testing.T) { err := recover() assert.Equal(t, - err.(*goja.Object).ToString().String(), + err.(*sobek.Object).ToString().String(), GoErrorPrefix+testData.err.Error()) }(t) diff --git a/topic.go b/topic.go index fe74060..e96aa74 100644 --- a/topic.go +++ b/topic.go @@ -5,7 +5,7 @@ import ( "net" "strconv" - "github.com/dop251/goja" + "github.com/grafana/sobek" kafkago "github.com/segmentio/kafka-go" "go.k6.io/k6/js/common" ) @@ -20,7 +20,7 @@ type ConnectionConfig struct { // that creates a new connection for creating, listing and deleting topics, // e.g. new Connection(...). // nolint: funlen -func (k *Kafka) connectionClass(call goja.ConstructorCall) *goja.Object { +func (k *Kafka) connectionClass(call sobek.ConstructorCall) *sobek.Object { runtime := k.vu.Runtime() var connectionConfig *ConnectionConfig if len(call.Arguments) == 0 { @@ -45,7 +45,7 @@ func (k *Kafka) connectionClass(call goja.ConstructorCall) *goja.Object { common.Throw(runtime, err) } - err := connectionObject.Set("createTopic", func(call goja.FunctionCall) goja.Value { + err := connectionObject.Set("createTopic", func(call sobek.FunctionCall) sobek.Value { var topicConfig *kafkago.TopicConfig if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) @@ -62,13 +62,13 @@ func (k *Kafka) connectionClass(call goja.ConstructorCall) *goja.Object { } k.createTopic(connection, topicConfig) - return goja.Undefined() + return sobek.Undefined() }) if err != nil { common.Throw(runtime, err) } - err = connectionObject.Set("deleteTopic", func(call goja.FunctionCall) goja.Value { + err = connectionObject.Set("deleteTopic", func(call sobek.FunctionCall) sobek.Value { if len(call.Arguments) > 0 { if topic, ok := call.Argument(0).Export().(string); !ok { common.Throw(runtime, ErrNotEnoughArguments) @@ -77,13 +77,13 @@ func (k *Kafka) connectionClass(call goja.ConstructorCall) *goja.Object { } } - return goja.Undefined() + return sobek.Undefined() }) if err != nil { common.Throw(runtime, err) } - err = connectionObject.Set("listTopics", func(call goja.FunctionCall) goja.Value { + err = connectionObject.Set("listTopics", func(call sobek.FunctionCall) sobek.Value { topics := k.listTopics(connection) return runtime.ToValue(topics) }) @@ -91,12 +91,12 @@ func (k *Kafka) connectionClass(call goja.ConstructorCall) *goja.Object { common.Throw(runtime, err) } - err = connectionObject.Set("close", func(call goja.FunctionCall) goja.Value { + err = connectionObject.Set("close", func(call sobek.FunctionCall) sobek.Value { if err := connection.Close(); err != nil { common.Throw(runtime, err) } - return goja.Undefined() + return sobek.Undefined() }) if err != nil { common.Throw(runtime, err) diff --git a/topic_test.go b/topic_test.go index a5511c0..fc19295 100644 --- a/topic_test.go +++ b/topic_test.go @@ -3,7 +3,7 @@ package kafka import ( "testing" - "github.com/dop251/goja" + "github.com/grafana/sobek" kafkago "github.com/segmentio/kafka-go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -68,8 +68,8 @@ func TestConnectionClass(t *testing.T) { require.NoError(t, test.moveToVUCode()) assert.NotPanics(t, func() { // Create a connection - connection := test.module.Kafka.connectionClass(goja.ConstructorCall{ - Arguments: []goja.Value{ + connection := test.module.Kafka.connectionClass(sobek.ConstructorCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "url": "localhost:9092", @@ -80,10 +80,10 @@ func TestConnectionClass(t *testing.T) { assert.NotNil(t, connection) // Create a topic - createTopic := connection.Get("createTopic").Export().(func(goja.FunctionCall) goja.Value) + createTopic := connection.Get("createTopic").Export().(func(sobek.FunctionCall) sobek.Value) assert.NotNil(t, createTopic) - result := createTopic(goja.FunctionCall{ - Arguments: []goja.Value{ + result := createTopic(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "topic": "test-connection-class", @@ -94,27 +94,27 @@ func TestConnectionClass(t *testing.T) { assert.Nil(t, result) // List all topics - listTopics := connection.Get("listTopics").Export().(func(goja.FunctionCall) goja.Value) + listTopics := connection.Get("listTopics").Export().(func(sobek.FunctionCall) sobek.Value) assert.NotNil(t, listTopics) - allTopics := listTopics(goja.FunctionCall{}).Export().([]string) + allTopics := listTopics(sobek.FunctionCall{}).Export().([]string) assert.Contains(t, allTopics, "test-connection-class") // Delete the topic - deleteTopic := connection.Get("deleteTopic").Export().(func(goja.FunctionCall) goja.Value) + deleteTopic := connection.Get("deleteTopic").Export().(func(sobek.FunctionCall) sobek.Value) assert.NotNil(t, deleteTopic) - result = deleteTopic(goja.FunctionCall{ - Arguments: []goja.Value{ + result = deleteTopic(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue("test-connection-class"), }, }).Export() assert.Nil(t, result) - allTopics = listTopics(goja.FunctionCall{}).Export().([]string) + allTopics = listTopics(sobek.FunctionCall{}).Export().([]string) assert.NotContains(t, allTopics, "test-connection-class") // Close the connection - close := connection.Get("close").Export().(func(goja.FunctionCall) goja.Value) + close := connection.Get("close").Export().(func(sobek.FunctionCall) sobek.Value) assert.NotNil(t, close) - result = close(goja.FunctionCall{}).Export() + result = close(sobek.FunctionCall{}).Export() assert.Nil(t, result) }) } diff --git a/utils.go b/utils.go index 1952a49..6fc0c66 100644 --- a/utils.go +++ b/utils.go @@ -4,14 +4,14 @@ import ( "encoding/base64" "encoding/json" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) // freeze disallows resetting or changing the properties of the object. -func freeze(o *goja.Object) { +func freeze(o *sobek.Object) { for _, key := range o.Keys() { if err := o.DefineDataProperty( - key, o.Get(key), goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_TRUE); err != nil { + key, o.Get(key), sobek.FLAG_FALSE, sobek.FLAG_FALSE, sobek.FLAG_TRUE); err != nil { panic(err) } } diff --git a/writer.go b/writer.go index b6cbb15..d54e2cf 100644 --- a/writer.go +++ b/writer.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/dop251/goja" + "github.com/grafana/sobek" kafkago "github.com/segmentio/kafka-go" "github.com/segmentio/kafka-go/compress" "go.k6.io/k6/js/common" @@ -75,7 +75,7 @@ type ProduceConfig struct { // writerClass is a wrapper around kafkago.writer and acts as a JS constructor // for this extension, thus it must be called with new operator, e.g. new Writer(...). // nolint: funlen -func (k *Kafka) writerClass(call goja.ConstructorCall) *goja.Object { +func (k *Kafka) writerClass(call sobek.ConstructorCall) *sobek.Object { runtime := k.vu.Runtime() var writerConfig *WriterConfig if len(call.Arguments) == 0 { @@ -100,7 +100,7 @@ func (k *Kafka) writerClass(call goja.ConstructorCall) *goja.Object { common.Throw(runtime, err) } - err := writerObject.Set("produce", func(call goja.FunctionCall) goja.Value { + err := writerObject.Set("produce", func(call sobek.FunctionCall) sobek.Value { var producerConfig *ProduceConfig if len(call.Arguments) == 0 { common.Throw(runtime, ErrNotEnoughArguments) @@ -118,19 +118,19 @@ func (k *Kafka) writerClass(call goja.ConstructorCall) *goja.Object { } k.produce(writer, producerConfig) - return goja.Undefined() + return sobek.Undefined() }) if err != nil { common.Throw(runtime, err) } // This is unnecessary, but it's here for reference purposes. - err = writerObject.Set("close", func(call goja.FunctionCall) goja.Value { + err = writerObject.Set("close", func(call sobek.FunctionCall) sobek.Value { if err := writer.Close(); err != nil { common.Throw(runtime, err) } - return goja.Undefined() + return sobek.Undefined() }) if err != nil { common.Throw(runtime, err) diff --git a/writer_test.go b/writer_test.go index f8d3cc8..84eb5b5 100644 --- a/writer_test.go +++ b/writer_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/riferrei/srclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -250,8 +250,8 @@ func TestWriterClass(t *testing.T) { test.createTopic("test-writer-class") assert.NotPanics(t, func() { - writer := test.module.writerClass(goja.ConstructorCall{ - Arguments: []goja.Value{ + writer := test.module.writerClass(sobek.ConstructorCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "brokers": []string{"localhost:9092"}, @@ -263,9 +263,9 @@ func TestWriterClass(t *testing.T) { assert.NotNil(t, writer) // Produce a message. - produce := writer.Get("produce").Export().(func(goja.FunctionCall) goja.Value) - result := produce(goja.FunctionCall{ - Arguments: []goja.Value{ + produce := writer.Get("produce").Export().(func(sobek.FunctionCall) sobek.Value) + result := produce(sobek.FunctionCall{ + Arguments: []sobek.Value{ test.module.vu.Runtime().ToValue( map[string]interface{}{ "messages": []map[string]interface{}{ @@ -287,9 +287,9 @@ func TestWriterClass(t *testing.T) { assert.Nil(t, result) // Close the writer. - close := writer.Get("close").Export().(func(goja.FunctionCall) goja.Value) + close := writer.Get("close").Export().(func(sobek.FunctionCall) sobek.Value) assert.NotNil(t, close) - result = close(goja.FunctionCall{}).Export() + result = close(sobek.FunctionCall{}).Export() assert.Nil(t, result) // Check if one message was produced.