blob: b30ca36192130c1389a4c4d83a1f7bd86323a58f (
plain)
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
|
TIMEOUT=60
N=4096
# test CONDSTORE/QRESYNC (behavior) in UID STORE commands, in particular
# the UNCHANGEDSINCE test: populate, keep assiging keywords at random,
# and make sure interimap is able to reconciliate the changes
# populate (with dummy messages to speed things up) only one server
# before initializing interimap, so UIDs concide with sequence numbers
# and are identical on both servers
for ((i = 0; i < N; i++)); do
deliver -u "local" <<< .
done
interimap_init
# assign a set of 16 tags; not more because in order to maximize the
# likelyhood of conflicts we want UID STORE commands to use large sets
declare -a FLAGS=(0 1 2 3 4 5 6 7 8 9 a b c d e f)
# start a long-lived interimap process
interimap --watch=1 & PID=$!
trap "ptree_abort $PID" EXIT INT TERM
timer=$(( $(date +%s) + TIMEOUT ))
while [ $(date +%s) -le $timer ]; do
a="$(shuf -n1 -e "add" "remove" "replace")"
u="$(shuf -n1 -e "local" "remote")"
f="$(shuf -n1 -e "${FLAGS[@]}")"
seqs="$(shuf -n$((N/8)) -i1-$N)" # trigger changes on 1/8 of all messages
doveadm -u "$u" flags "$a" "$f" mailbox "INBOX" "${seqs//$'\n'/,}"
sleep "0.0$(shuf -n1 -i10-99)" # 10 to 99ms
done
sleep 5
ptree_abort $PID
trap - EXIT INT TERM
# make sure the list of uids for a given tag match
flagged_uids() {
local u="$1" f="$2"
doveadm -u "$u" search mailbox "INBOX" keyword "$f" | cut -d" " -f2 | sort -n
}
for f in "${FLAGS[@]}"; do
diff --label="local/$f" --label="remote/$f" -u -- \
<(flagged_uids "local" "$f") <(flagged_uids "remote" "$f") ||
error "UID list differs for keyword '$f'"
done
# vim: set filetype=bash :
|