diff --git a/config/getters_test.go b/config/getters_test.go index 2d485c39..4c3d6b71 100644 --- a/config/getters_test.go +++ b/config/getters_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/panjf2000/gnet/v2" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" ) @@ -75,18 +74,6 @@ func TestGetTickInterval(t *testing.T) { assert.Equal(t, DefaultTickInterval, server.GetTickInterval()) } -// TestGetLoadBalancer tests the GetLoadBalancer function. -func TestGetLoadBalancer(t *testing.T) { - server := Server{} - assert.Equal(t, gnet.RoundRobin, server.GetLoadBalancer()) -} - -// TestGetTCPNoDelay tests the GetTCPNoDelay function. -func TestGetTCPNoDelay(t *testing.T) { - server := Server{} - assert.Equal(t, gnet.TCPDelay, server.GetTCPNoDelay()) -} - // TestGetSize tests the GetSize function. func TestGetSize(t *testing.T) { pool := Pool{} diff --git a/network/proxy_test.go b/network/proxy_test.go index 6b680193..14f7a0ec 100644 --- a/network/proxy_test.go +++ b/network/proxy_test.go @@ -252,12 +252,12 @@ func BenchmarkProxyConnectDisconnect(b *testing.B) { config.DefaultPluginTimeout) defer proxy.Shutdown() - gconn := testGNetConnection{} + conn := testConnection{} // Connect to the proxy for i := 0; i < b.N; i++ { - proxy.Connect(gconn.Conn) //nolint:errcheck - proxy.Disconnect(&gconn) //nolint:errcheck + proxy.Connect(conn.Conn) //nolint:errcheck + proxy.Disconnect(&conn) //nolint:errcheck } } @@ -306,13 +306,14 @@ func BenchmarkProxyPassThrough(b *testing.B) { config.DefaultPluginTimeout) defer proxy.Shutdown() - gconn := testGNetConnection{} - proxy.Connect(gconn.Conn) //nolint:errcheck - defer proxy.Disconnect(&gconn) //nolint:errcheck + conn := testConnection{} + proxy.Connect(conn.Conn) //nolint:errcheck + defer proxy.Disconnect(&conn) //nolint:errcheck // Connect to the proxy for i := 0; i < b.N; i++ { - proxy.PassThrough(&gconn) //nolint:errcheck + proxy.PassThroughToClient(&conn) //nolint:errcheck + proxy.PassThroughToServer(&conn) //nolint:errcheck } } @@ -362,9 +363,9 @@ func BenchmarkProxyIsHealthyAndIsExhausted(b *testing.B) { config.DefaultPluginTimeout) defer proxy.Shutdown() - gconn := testGNetConnection{} - proxy.Connect(gconn.Conn) //nolint:errcheck - defer proxy.Disconnect(&gconn) //nolint:errcheck + conn := testConnection{} + proxy.Connect(conn.Conn) //nolint:errcheck + defer proxy.Disconnect(&conn) //nolint:errcheck // Connect to the proxy for i := 0; i < b.N; i++ { @@ -419,9 +420,9 @@ func BenchmarkProxyAvailableAndBusyConnections(b *testing.B) { config.DefaultPluginTimeout) defer proxy.Shutdown() - gconn := testGNetConnection{} - proxy.Connect(gconn.Conn) //nolint:errcheck - defer proxy.Disconnect(&gconn) //nolint:errcheck + conn := testConnection{} + proxy.Connect(conn.Conn) //nolint:errcheck + defer proxy.Disconnect(&conn) //nolint:errcheck // Connect to the proxy for i := 0; i < b.N; i++ { diff --git a/network/server_test.go b/network/server_test.go index 2a3028c6..0a2ee253 100644 --- a/network/server_test.go +++ b/network/server_test.go @@ -14,7 +14,6 @@ import ( "github.com/gatewayd-io/gatewayd/logging" "github.com/gatewayd-io/gatewayd/plugin" "github.com/gatewayd-io/gatewayd/pool" - "github.com/panjf2000/gnet/v2" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "google.golang.org/grpc" @@ -173,11 +172,8 @@ func TestRunServer(t *testing.T) { "tcp", "127.0.0.1:15432", config.DefaultTickInterval, - []gnet.Option{ - gnet.WithMulticore(false), - gnet.WithReuseAddr(true), - gnet.WithReusePort(true), - gnet.WithTicker(true), // Enable ticker. + Option{ + EnableTicker: false, }, proxy, logger, diff --git a/network/utils_test.go b/network/utils_test.go index 2ab4f0d4..8d6e1d77 100644 --- a/network/utils_test.go +++ b/network/utils_test.go @@ -10,7 +10,6 @@ import ( "github.com/gatewayd-io/gatewayd/config" "github.com/gatewayd-io/gatewayd/logging" - "github.com/panjf2000/gnet/v2" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" ) @@ -112,18 +111,18 @@ func BenchmarkResolveUnix(b *testing.B) { } } -type testGNetConnection struct { - gnet.Conn +type testConnection struct { + net.Conn } -func (c *testGNetConnection) LocalAddr() net.Addr { +func (c *testConnection) LocalAddr() net.Addr { return &net.TCPAddr{ IP: net.ParseIP("127.0.0.1"), Port: 0, } } -func (c *testGNetConnection) RemoteAddr() net.Addr { +func (c *testConnection) RemoteAddr() net.Addr { return &net.TCPAddr{ IP: net.ParseIP("127.0.0.1"), Port: 0, @@ -139,7 +138,7 @@ func BenchmarkTrafficData(b *testing.B) { NoColor: true, }) - gconn := &testGNetConnection{} + conn := &testConnection{} client := NewClient(context.Background(), &config.Client{ Network: "tcp", Address: "localhost:5432", @@ -159,7 +158,7 @@ func BenchmarkTrafficData(b *testing.B) { } err := "test error" for i := 0; i < b.N; i++ { - trafficData(gconn, client, fields, err) + trafficData(conn, client, fields, err) } }