From b653c759cd9f0629ea19ef7c8a11400c065c7efd Mon Sep 17 00:00:00 2001
From: Diego Lopez Recas <diego.lopez.recas@gmail.com>
Date: Tue, 1 Aug 2023 17:03:33 +0200
Subject: [PATCH] Fix race condition in tests/unit/auth.tcl (#12444)

Changing the masterauth while turning into a replica is racy.

Turn into replica after changing the masterauth instead.
---
 tests/unit/auth.tcl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/unit/auth.tcl b/tests/unit/auth.tcl
index 26d125579..9532e0bd2 100644
--- a/tests/unit/auth.tcl
+++ b/tests/unit/auth.tcl
@@ -70,8 +70,8 @@ start_server {tags {"auth_binary_password external:skip"}} {
 
             # Configure the replica with masterauth
             set loglines [count_log_lines 0]
-            $slave slaveof $master_host $master_port
             $slave config set masterauth "abc"
+            $slave slaveof $master_host $master_port
 
             # Verify replica is not able to sync with master
             wait_for_log_messages 0 {"*Unable to AUTH to MASTER*"} $loglines 1000 10