From b76fa3619b91c597b2206552c34df618ca2a5c2d Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 29 Oct 2026 10:24:08 +0000
Subject: [PATCH] [#1247] Wait for the join of the restarted replication server before the joins on empty volumes of the Docker replication test (#1249)

---
 .github/scripts/docker-test-replication.sh |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/.github/scripts/docker-test-replication.sh b/.github/scripts/docker-test-replication.sh
index 9070639..7035f68 100755
--- a/.github/scripts/docker-test-replication.sh
+++ b/.github/scripts/docker-test-replication.sh
@@ -95,7 +95,10 @@
 }
 
 # the container logged the text after the last line that holds <since> - after a restart,
-# say, which the join of the start before may still have logged into until it was stopped
+# say, which the join of the start before may still have logged into until it was stopped.
+# Not right after the start: until this start logs <since> itself, the last such line and the
+# text after it are those of the start before - run.sh prints "Starting OpenDJ" only after
+# the upgrade
 logs_have_since() { # <container> <since> <text>
   docker logs "$1" 2>&1 | awk -v s="$2" 'index($0, s) { buf = ""; next } { buf = buf $0 "\n" } END { printf "%s", buf }' \
     | grep -F -- "$3" >/dev/null
@@ -1045,7 +1048,17 @@
 done
 add_ou dj-d0 roles-other-rs
 wait_has dj-d1 "ou=roles-other-rs,dc=example,dc=com"
+# dj-r1 joins through dj-r0 below, and a joiner skips a peer that publishes itself rejoining:
+# a replication server does so on every start until its join finds it a member again, and
+# it reports itself healthy as soon as it serves, before that. What it published on its
+# start before still reads ready until this join replaces it, so the join is waited for -
+# by a count taken while dj-r0 is down: its log still holds the line the join of the start
+# before logged, and the new start prints "Starting OpenDJ" only after its upgrade
+members=$(logs_count dj-r0 "the health check may probe it")
 docker start dj-r0 >/dev/null
+rejoined() { [ "$(logs_count dj-r0 "the health check may probe it")" -gt "$members" ]; }
+wait_until 300 "the restarted dj-r0 is a member again" rejoined
+published_ready dj-r0 || fail "dj-r0 does not publish itself ready after it rejoined"
 wait_healthy dj-r0
 
 phase "roles: joins on empty volumes"

--
Gitblit v1.10.0