-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdump-test-data-03.sh
executable file
·57 lines (47 loc) · 1.56 KB
/
dump-test-data-03.sh
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
#!/usr/bin/env bash
set -eE
if [ -z "${TYCHO_BUILD_PROFILE}" ]; then
profile="debug"
else
profile="${TYCHO_BUILD_PROFILE}"
fi
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
root_dir=$(cd "${script_dir}/../" && pwd -P)
tycho_bin="${root_dir}/target/${profile}/tycho"
echo "script_dir: $script_dir"
echo "root_dir: $root_dir"
echo "tycho_bin: $tycho_bin"
source "${script_dir}/common.sh"
# dump first 3 archives
CHECK_INTERVAL=10
TARGET_COUNT=3
while true; do
output=$($tycho_bin node list-archives --sock .temp/control-1.sock)
echo "$output"
if [ $? -ne 0 ]; then
echo "Command 'node list-archives' returned error. Repeat attempt in $CHECK_INTERVAL seconds..."
else
count=$(echo "$output" | jq 'length')
if ! is_number "$count"; then
echo "Unable to detect archives count. Repeat attempt in $CHECK_INTERVAL seconds..."
elif [ "$count" -ge "$TARGET_COUNT" ]; then
echo "Found $count/$TARGET_COUNT archives. Will dump them."
break
else
echo "Found $count/$TARGET_COUNT archives. Repeat attempt in $CHECK_INTERVAL seconds..."
fi
fi
sleep "$CHECK_INTERVAL"
done
output_dir="${root_dir}/core/tests/data"
ids=$(echo "$output" | jq -r '.[].id')
counter=1
for id in $ids; do
output="$output_dir/archive_${counter}.bin"
$tycho_bin node dump-archive --sock .temp/control-1.sock --seqno $id $output
echo "Archive '$id' dumped into '$output'."
counter=$((counter + 1))
if [ "$counter" -gt "$TARGET_COUNT" ]; then
break
fi
done