From 20140a4860771e4f4eb161df4add0e2f2c5f9e20 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 20 Jan 2025 17:53:13 +0200 Subject: [PATCH] stop using httpmultibin - it was barely used at all either way --- go.mod | 4 ---- go.sum | 4 ---- redis/client_test.go | 24 ++++++++++++------------ redis/stub_test.go | 2 ++ 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index be4d883..cb07ec3 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -27,14 +26,11 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 // indirect - github.com/gorilla/websocket v1.5.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.17.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa // 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 diff --git a/go.sum b/go.sum index 0c7b133..45fea06 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/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= @@ -44,7 +43,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6 h1:ZgoomqkdjGbQ3+qQXCkvYMCDvGDNg2k5JJDjjdTB6jY= github.com/google/pprof v0.0.0-20230728192033-2ba5b33183c6/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= 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-20240606091932-2da0e9e5f3e7 h1:Ed0df3dkkPsjL0RKagJAv/821vrTBiB6GBk+198pxi4= github.com/grafana/sobek v0.0.0-20240606091932-2da0e9e5f3e7/go.mod h1:6ZH0b0iOxyigeTh+/IlGoL0Hd3lVXA94xoXf0ldNgCM= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= @@ -53,7 +51,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= 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.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -64,7 +61,6 @@ 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.5.0 h1:E2FgWf73BQt0ddgn7aoITkQHmgwAcHup1s//MsS5/f8= diff --git a/redis/client_test.go b/redis/client_test.go index a66d02c..880396d 100644 --- a/redis/client_test.go +++ b/redis/client_test.go @@ -1,8 +1,10 @@ package redis import ( + "crypto/tls" "errors" "fmt" + "net" "strconv" "testing" @@ -11,7 +13,8 @@ import ( "github.com/stretchr/testify/require" "go.k6.io/k6/js/modulestest" "go.k6.io/k6/lib" - "go.k6.io/k6/lib/testutils/httpmultibin" + "go.k6.io/k6/lib/netext" + "go.k6.io/k6/lib/types" "go.k6.io/k6/metrics" "gopkg.in/guregu/null.v3" ) @@ -2557,7 +2560,6 @@ type testSetup struct { rt *sobek.Runtime state *lib.State samples chan metrics.SampleContainer - tb *httpmultibin.HTTPMultiBin } // newTestSetup initializes a new test setup. @@ -2566,15 +2568,12 @@ type testSetup struct { // main context of k6. func newTestSetup(t testing.TB) testSetup { ts := newInitContextTestSetup(t) - tb := httpmultibin.NewHTTPMultiBin(t) - // We use self-signed TLS certificates for some tests, and need to disable - // strict verification. Since we don't use the k6 js.Runner, we can't set - // the k6 option InsecureSkipTLSVerify for this, and must override it in the - // TLS config we use from HTTPMultiBin. - tb.TLSClientConfig.InsecureSkipVerify = true state := &lib.State{ - Dialer: tb.Dialer, + Dialer: netext.NewDialer( + net.Dialer{}, + netext.NewResolver(net.LookupIP, 0, types.DNSfirst, types.DNSpreferIPv4), + ), Options: lib.Options{ SystemTags: metrics.NewSystemTagSet( metrics.TagURL, @@ -2585,14 +2584,13 @@ func newTestSetup(t testing.TB) testSetup { UserAgent: null.StringFrom("TestUserAgent"), }, Samples: ts.samples, - TLSConfig: tb.TLSClientConfig, + TLSConfig: &tls.Config{}, //nolint:gosec BuiltinMetrics: metrics.RegisterBuiltinMetrics(metrics.NewRegistry()), Tags: lib.NewVUStateTags(metrics.NewRegistry().RootTagSet()), } ts.runtime.MoveToVUContext(state) ts.state = state - ts.tb = tb return ts } @@ -2619,6 +2617,7 @@ func TestClientTLS(t *testing.T) { t.Parallel() ts := newTestSetup(t) + ts.state.TLSConfig.InsecureSkipVerify = true rs := RunTSecure(t, nil) err := ts.rt.Set("caCert", string(rs.TLSCertificate())) @@ -2657,6 +2656,7 @@ func TestClientTLSAuth(t *testing.T) { require.NoError(t, err) ts := newTestSetup(t) + ts.state.TLSConfig.InsecureSkipVerify = true rs := RunTSecure(t, clientCert) err = ts.rt.Set("caCert", string(rs.TLSCertificate())) @@ -2713,7 +2713,7 @@ func TestClientTLSRespectsNetworkOPtions(t *testing.T) { // Set the redis server's IP to be blacklisted. net, err := lib.ParseCIDR(rs.Addr().IP.String() + "/32") require.NoError(t, err) - ts.tb.Dialer.Blacklist = []*lib.IPNet{net} + ts.state.Dialer.(*netext.Dialer).Blacklist = []*lib.IPNet{net} gotScriptErr := ts.runtime.EventLoop.Start(func() error { _, err := ts.rt.RunString(fmt.Sprintf(` diff --git a/redis/stub_test.go b/redis/stub_test.go index 958c21c..6cb9b3e 100644 --- a/redis/stub_test.go +++ b/redis/stub_test.go @@ -69,6 +69,7 @@ type StubServer struct { commandsHistory [][]string tlsCert []byte + cert *tls.Certificate } // NewStubServer instantiates a new RedisStub server. @@ -103,6 +104,7 @@ func (rs *StubServer) Start(secure bool, clientCert []byte) error { if err != nil { return err } + rs.cert = &certPair config := &tls.Config{ MinVersion: tls.VersionTLS13, PreferServerCipherSuites: true,