@@ -87,6 +87,7 @@ use bytes::BytesMut;
87
87
use fallible_iterator:: FallibleIterator ;
88
88
use futures:: future;
89
89
use mz_adapter:: session:: DEFAULT_DATABASE_NAME ;
90
+ use mz_ore:: retry:: Retry ;
90
91
use postgres:: binary_copy:: BinaryCopyOutIter ;
91
92
use postgres:: error:: SqlState ;
92
93
use postgres:: types:: Type ;
@@ -365,15 +366,25 @@ fn test_conn_user() {
365
366
let server = util:: start_server ( util:: Config :: default ( ) ) . unwrap ( ) ;
366
367
let mut client = server. connect ( postgres:: NoTls ) . unwrap ( ) ;
367
368
368
- // Attempting to connect as a nonexistent user should fail. The initial
369
- // connection succeeds due to our delayed startup, but the first query will
370
- // fail.
371
- let mut conn = server
372
- . pg_config ( )
373
- . user ( "rj" )
374
- . connect ( postgres:: NoTls )
369
+ // This sometimes returns a network error, so retry until we get a db error.
370
+ let err = Retry :: default ( )
371
+ . retry ( |_| {
372
+ // Attempting to connect as a nonexistent user should fail. The initial
373
+ // connection succeeds due to our delayed startup, but the first query will
374
+ // fail.
375
+ let mut conn = server
376
+ . pg_config ( )
377
+ . user ( "rj" )
378
+ . connect ( postgres:: NoTls )
379
+ . unwrap ( ) ;
380
+ conn. batch_execute ( "SELECT 1" )
381
+ . unwrap_err ( )
382
+ . as_db_error ( )
383
+ . cloned ( )
384
+ . ok_or ( "unexpected error" )
385
+ } )
375
386
. unwrap ( ) ;
376
- let err = conn . batch_execute ( "SELECT 1" ) . unwrap_db_error ( ) ;
387
+
377
388
assert_eq ! ( err. severity( ) , "FATAL" ) ;
378
389
assert_eq ! ( * err. code( ) , SqlState :: INVALID_AUTHORIZATION_SPECIFICATION ) ;
379
390
assert_eq ! ( err. message( ) , "role \" rj\" does not exist" ) ;
0 commit comments