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

Valery Kharseko
20 hours ago 400fb2694641b05e53217d3c742a6e49e3a254c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
#
#
# The contents of this file are subject to the terms of the Common Development and
# Distribution License (the License). You may not use this file except in compliance with the
# License.
#
# You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
# specific language governing permission and limitations under the License.
#
# When distributing Covered Software, include this CDDL Header Notice in each file and include
# the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
# Header, with the fields enclosed by brackets [] replaced by your own identifying
# information: "Portions copyright [year] [name of copyright owner]".
#
# Copyright 2026 3A Systems, LLC.
 
# Writes to every directory server of a replication topology at once, then checks that the
# replicas hold the same data (#1090). The Docker image jobs of build.yml hand their image to
# the job that runs it; it runs as well on a laptop with Docker alone.
#
# Usage: run.sh <image>; the settings and their defaults are in lib.sh
 
set -eE -o pipefail
 
IMAGE=${1:?usage: $0 <image>}
HERE=$(cd "$(dirname "$0")" && pwd)
# changelog-gaps.py reads the changelogs of the replication servers
command -v python3 >/dev/null || { echo "run.sh needs python3" >&2; exit 2; }
. "$HERE/lib.sh"
. "$HERE/topology-up.sh"
. "$HERE/monitor.sh"
. "$HERE/load.sh"
. "$HERE/assert-converged.sh"
. "$HERE/collect.sh"
after_convergence() { :; }
if [ "$DISTURBANCE" != none ]; then
  [ "$DISTURB_AT" -gt 0 ] && [ "$DISTURB_AT" -lt "$DURATION" ] \
    || { echo "DISTURB_AT=$DISTURB_AT is not within the load of $DURATION s" >&2; exit 2; }
  case $DISTURBANCE in
    scale-kept|scale-empty|scale-rs-kept|scale-rs-empty)
      SCALE_VOLUME=${DISTURBANCE##*-}
      . "$HERE/scale-membership.sh"
      . "$HERE/rolling-load.sh"
      . "$HERE/disturb-scale.sh"
      ;;
    *)
      [ -f "$HERE/disturb-$DISTURBANCE.sh" ] \
        || { echo "unknown DISTURBANCE $DISTURBANCE: none, or the <name> of a disturb-<name>.sh in $HERE" >&2; exit 2; }
      . "$HERE/disturb-$DISTURBANCE.sh"
      ;;
  esac
fi
 
# the files of an earlier run would mix into this one's: the samples are appended to, and the
# summary of a run that failed early would show what a run that got further left
if [ -n "$(ls -A "$OUT" 2>/dev/null)" ]; then
  echo "$OUT holds the files of an earlier run: remove it, or set OUT to another directory" >&2
  exit 2
fi
mkdir -p "$OUT"
# set -E hands the trap to every $(...) as well: there a failure only ends the subshell, and
# the main shell decides. A run that fails before the online checks - a load check, a wait
# that timed out, which a reconnection under load would explain - counts the reconnections
# while the servers are still up
trap 'code=$?; [ "$BASH_SUBSHELL" -eq 0 ] || exit $code; sampler_stop; [ -f "$OUT/reconnections.txt" ] || [ ! -f "$OUT/logs/${DS_NODES%% *}.mark" ] || record_reconnections || true; timings; case $DISTURBANCE in scale-*) collect_scale_bootstrap ;; esac; collect; finalize_failure_csn_traces; summarize failed; [ "$KEEP" = 1 ] || cleanup; exit $code' ERR
cleanup
 
phase "topology up ($TOPOLOGY)"
topology_up
for n in $RS_NODES; do
  runs_replication_server "$n" || fail "$n runs no replication server"
done
for n in $DS_NODES; do
  case " $RS_NODES " in
    *" $n "*) ;;
    *) ! runs_replication_server "$n" || fail "$n runs a replication server although its role is directory" ;;
  esac
done
for n in $DS_NODES; do
  users=$(ldaps_search "$n" "ou=People,$BASE_DN" one "(objectClass=inetOrgPerson)" 1.1 | grep -c '^dn:' || true)
  [ "$users" -eq "$SAMPLE_DATA" ] || fail "$n holds $users of the $SAMPLE_DATA seeded users"
done
 
mark_logs
record_server_ids
 
case $DISTURBANCE in scale-*) load_limit='up to ' ;; *) load_limit= ;; esac
phase "load (${load_limit}$DURATION s${DISTURBED:+, $DISTURBANCE of $DISTURBED at $DISTURB_AT s})"
# the changes of the load: assert_changelogs looks for gaps among the changes made in between
LOAD_START_MS=$(($(date +%s) * 1000))
case $DISTURBANCE in
  scale-kept|scale-empty|scale-rs-kept|scale-rs-empty) prepare_rolling_deadline ;;
esac
sampler_start
case $DISTURBANCE in
  scale-kept|scale-empty|scale-rs-kept|scale-rs-empty) rolling_run_load ;;
  *) run_load ;;
esac
sampler_stop
 
phase "converge"
load_end=$SECONDS
# a disturbed server is left as topology_up leaves every server, and the wait for convergence
# still counts from the end of the load
[ "$DISTURBANCE" = none ] || settle
wait_converged $load_end
echo "converged in $CONVERGED_IN s"
after_convergence
LOAD_END_MS=$(($(date +%s) * 1000))
 
if [ "$INJECT_DIVERGENCE" = 1 ]; then
  phase "inject a divergence"
  inject_divergence
fi
 
# the offline checks run after online checks that failed as well: they tell which changes are
# missing where
phase "online checks"
checks=
assert_online || checks="the online checks"
 
phase "offline checks"
stop_all
check_csn_traces || checks="${checks:+$checks and }the CSN traces"
assert_offline || checks="${checks:+$checks and }the offline checks"
diagnose_csn_gaps || checks="${checks:+$checks and }the CSN trace diagnostics"
[ -z "$checks" ] || fail "$checks failed"
 
timings
case $DISTURBANCE in scale-*) collect_scale_bootstrap ;; esac
summarize passed
cleanup