From b1a16ac35c0e83771e5d699f3e7c4eae6696dd62 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Sun, 27 Sep 2026 08:54:22 +0000
Subject: [PATCH] [#1085] Stop the server cleanly on SIGTERM in a container that bootstrapped its instance (#1098)

---
 .github/workflows/benchmark.yml |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index e1e1c1b..58efae2 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -177,8 +177,15 @@
 
       - name: Wait for OpenDJ + seed ou=People
         run: |
-          for i in $(seq 1 90); do
-            if ldapsearch -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
+          # An image with a HEALTHCHECK has to report healthy first: on a first start the
+          # server the bootstrap started answers, then is stopped and started again, and a
+          # request sent in between fails. An older image's health check may pass
+          # before the bootstrap is done, so the base entry is searched for in both cases.
+          # The wait lasts as long as the start period of the health check, 5 minutes.
+          for i in $(seq 1 150); do
+            health="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{end}}' opendj 2>/dev/null || true)"
+            if { [ -z "$health" ] || [ "$health" = healthy ]; } && \
+               ldapsearch -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
                  -b "$BASEDN" -s base dn >/dev/null 2>&1; then
               echo "OpenDJ is up"; break
             fi
@@ -186,6 +193,10 @@
           done
           ldapadd -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
             -f .github/benchmark/people.ldif || true
+          # without its users JMeter binds as users that do not exist, so a seed that missed fails the job
+          ldapsearch -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
+            -b "ou=People,$BASEDN" -s base dn >/dev/null \
+            || { echo "::error::ou=People was not seeded"; docker logs opendj; false; }
 
       - name: Configure OpenDJ password policy (SSHA hash-on-write)
         run: |

--
Gitblit v1.10.0