]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | #!/usr/bin/env bash |
7c673cae FG |
2 | |
3 | . "`dirname $0`/test-rgw-common.sh" | |
4 | ||
5 | set -e | |
6 | ||
7 | function get_metadata_sync_status { | |
8 | cid=$1 | |
9 | realm=$2 | |
10 | ||
11 | meta_sync_status_json=`$(rgw_admin $cid) --rgw-realm=$realm metadata sync status` | |
12 | ||
13 | global_sync_status=$(json_extract sync_status.info.status $meta_sync_status_json) | |
14 | num_shards=$(json_extract sync_status.info.num_shards $meta_sync_status_json) | |
15 | ||
16 | echo "sync_status: $global_sync_status" | |
17 | ||
18 | sync_markers=$(json_extract sync_status.markers $meta_sync_status_json) | |
19 | ||
20 | num_shards2=$(python_array_len $sync_markers) | |
21 | ||
22 | [ "$global_sync_status" == "sync" ] && $assert $num_shards2 -eq $num_shards | |
23 | ||
24 | sync_states=$(project_python_array_field val.state $sync_markers) | |
25 | eval secondary_status=$(project_python_array_field val.marker $sync_markers) | |
26 | } | |
27 | ||
28 | function get_metadata_log_status { | |
29 | cid=$1 | |
30 | realm=$2 | |
31 | ||
32 | master_mdlog_status_json=`$(rgw_admin $cid) --rgw-realm=$realm mdlog status` | |
33 | master_meta_status=$(json_extract "" $master_mdlog_status_json) | |
34 | ||
35 | eval master_status=$(project_python_array_field marker $master_meta_status) | |
36 | } | |
37 | ||
38 | function wait_for_meta_sync { | |
39 | master_id=$1 | |
40 | cid=$2 | |
41 | realm=$3 | |
42 | ||
43 | get_metadata_log_status $master_id $realm | |
44 | echo "master_status=${master_status[*]}" | |
45 | ||
46 | while true; do | |
47 | get_metadata_sync_status $cid $realm | |
48 | ||
49 | echo "secondary_status=${secondary_status[*]}" | |
50 | ||
51 | fail=0 | |
52 | for i in `seq 0 $((num_shards-1))`; do | |
53 | if [ "${master_status[$i]}" \> "${secondary_status[$i]}" ]; then | |
54 | echo "shard $i not done syncing (${master_status[$i]} > ${secondary_status[$i]})" | |
55 | fail=1 | |
56 | break | |
57 | fi | |
58 | done | |
59 | ||
60 | [ $fail -eq 0 ] && echo "Success" && return || echo "Sync not complete" | |
61 | ||
62 | sleep 5 | |
63 | done | |
64 | } | |
65 |