@@ -162,7 +162,7 @@ func TestProxyProtocol(t *testing.T) {
162162 sqlDB .Exec (t , `CREATE USER bob WITH PASSWORD 'builder'` )
163163
164164 var validateFn func (h * proxyproto.Header ) error
165- withProxyProtocol := func (p bool ) (server * Server , addrs * serverAddresses ) {
165+ withProxyProtocol := func (p bool , stopper * stop. Stopper ) (server * Server , addrs * serverAddresses ) {
166166 options := & ProxyOptions {
167167 RoutingRule : ts .AdvSQLAddr (),
168168 SkipVerify : true ,
@@ -171,7 +171,7 @@ func TestProxyProtocol(t *testing.T) {
171171 options .testingKnobs .validateProxyHeader = func (h * proxyproto.Header ) error {
172172 return validateFn (h )
173173 }
174- return newSecureProxyServer (ctx , t , sql . Stopper () , options )
174+ return newSecureProxyServer (ctx , t , stopper , options )
175175 }
176176
177177 timeout := 3 * time .Second
@@ -228,11 +228,10 @@ func TestProxyProtocol(t *testing.T) {
228228 })()
229229
230230 testSQLNoRequiredProxyProtocol := func (s * Server , addr string ) {
231- url := fmt .Sprintf ("postgres://bob:builder@%s/tenant-cluster-42.defaultdb?sslmode=require" , addr )
231+ url := fmt .Sprintf ("postgres://bob:builder@%s/tenant-cluster-42.defaultdb?sslmode=require&sslrootcert=%s " , addr , datapathutils . TestDataPath ( t , "testserver.crt" ) )
232232 // No proxy protocol.
233233 te .TestConnect (ctx , t , url ,
234234 func (conn * pgx.Conn ) {
235- t .Log ("B" )
236235 require .NotZero (t , s .metrics .CurConnCount .Value ())
237236 require .NoError (t , runTestQuery (ctx , conn ))
238237 },
@@ -247,7 +246,7 @@ func TestProxyProtocol(t *testing.T) {
247246 }
248247
249248 testSQLRequiredProxyProtocol := func (s * Server , addr string ) {
250- url := fmt .Sprintf ("postgres://bob:builder@%s/tenant-cluster-42.defaultdb?sslmode=require" , addr )
249+ url := fmt .Sprintf ("postgres://bob:builder@%s/tenant-cluster-42.defaultdb?sslmode=require&sslrootcert=%s " , addr , datapathutils . TestDataPath ( t , "testserver.crt" ) )
251250 // No proxy protocol.
252251 _ = te .TestConnectErr (ctx , t , url , codeClientReadFailed , "tls error" )
253252 // Proxy protocol.
@@ -264,7 +263,10 @@ func TestProxyProtocol(t *testing.T) {
264263 }
265264
266265 t .Run ("server doesn't require proxy protocol" , func (t * testing.T ) {
267- s , addrs := withProxyProtocol (false )
266+ ctx := context .Background ()
267+ stopper := stop .NewStopper ()
268+ defer stopper .Stop (ctx )
269+ s , addrs := withProxyProtocol (false , stopper )
268270 // Test SQL on the default listener. Both should go through.
269271 testSQLNoRequiredProxyProtocol (s , addrs .listenAddr )
270272 // Test SQL on the proxy protocol listener. Only request with PROXY should go
@@ -279,7 +281,10 @@ func TestProxyProtocol(t *testing.T) {
279281 })
280282
281283 t .Run ("server requires proxy protocol" , func (t * testing.T ) {
282- s , addrs := withProxyProtocol (true )
284+ ctx := context .Background ()
285+ stopper := stop .NewStopper ()
286+ defer stopper .Stop (ctx )
287+ s , addrs := withProxyProtocol (true , stopper )
283288 // Test SQL on the default listener. Both should go through.
284289 testSQLRequiredProxyProtocol (s , addrs .listenAddr )
285290 // Test SQL on the proxy protocol listener. Only request with PROXY should go
0 commit comments