diff --git a/t/010_check_stack.pl b/t/010_check_stack.pl
index 5563671..4ea1761 100644
--- a/t/010_check_stack.pl
+++ b/t/010_check_stack.pl
@@ -136,7 +136,7 @@ sub read_until_ready
 # Open a raw socket to the node and complete startup (trust auth, no password).
 sub pg_connect
 {
-    my ($node) = @_;
+    my ($node, $user) = @_;
     my $host = $node->host;
     my $sock;
 
@@ -154,7 +154,7 @@ sub pg_connect
     $sock->autoflush(1);
     binmode($sock);
 
-    print $sock startup_msg(user => 'postgres', database => 'postgres');
+    print $sock startup_msg(user => $user, database => 'postgres');
     read_until_ready($sock);
 
     return $sock;
@@ -171,6 +171,10 @@ sub pg_connect
 $node->append_conf('postgresql.conf', "logging_collector = off");
 $node->start;
 
+# initdb created the cluster with the current operating system user as its
+# bootstrap superuser, which is not necessarily postgres
+my $superuser = $node->safe_psql('postgres', 'SELECT current_user');
+
 # One scenario per command tag that pgaudit_ProcessUtility_hook() allows to
 # remain on the stack.  Each statement returns more than one row, so the
 # row-limited Execute below suspends its portal and leaves the tag behind.
@@ -216,7 +220,7 @@ sub pg_connect
 {
     # Connect and begin transaction
     my $name = $test->{name};
-    my $sock = pg_connect($node);
+    my $sock = pg_connect($node, $superuser);
     my $offset = -s $node->logfile;
 
     print $sock query_msg('BEGIN');
