mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
2 days ago b1a16ac35c0e83771e5d699f3e7c4eae6696dd62
.github/benchmark/compare-opendj.sh
@@ -50,10 +50,19 @@
  tar -xzf /tmp/jmeter.tgz -C "$HOME/jmeter"
fi
wait_dj() {  # poll OpenDJ readiness on localhost:1389
  for _ in $(seq 1 90); do
    ldapsearch -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
      -b "$BASEDN" -s base dn >/dev/null 2>&1 && return 0
# Poll OpenDJ readiness on localhost:1389. 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.
wait_dj() {
  local health
  for _ in $(seq 1 150); do
    health="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{end}}' opendj-bench 2>/dev/null || true)"
    if [ -z "$health" ] || [ "$health" = healthy ]; then
      ldapsearch -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
        -b "$BASEDN" -s base dn >/dev/null 2>&1 && return 0
    fi
    sleep 2
  done
  return 1
@@ -72,6 +81,15 @@
    wait_dj || echo "WARN: $image not ready in time" >&2
    ldapadd -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
      -f "$HERE/people.ldif" >/dev/null 2>&1 || true
    # without its users JMeter binds as users that do not exist and the numbers mean nothing,
    # so a seed that missed stops the comparison (A_VER="$(bench_one ...)" under set -e)
    if ! ldapsearch -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
         -b "ou=People,$BASEDN" -s base dn >/dev/null 2>&1; then
      echo "ERROR: $image: ou=People was not seeded" >&2
      docker logs opendj-bench > "$out.docker.log" 2>&1 || true
      docker rm -f opendj-bench >/dev/null 2>&1 || true
      return 1
    fi
    ver="$( { ldapsearch -x -LLL -H ldap://localhost:1389 -D 'cn=Directory Manager' -w password \
              -b '' -s base fullVendorVersion 2>/dev/null || true; } | sed -n 's/^fullVendorVersion: //p')"
    rm -rf "$out" "$out.jtl"