summaryrefslogtreecommitdiffstats
path: root/src/test/rgw/test-rgw-multisite.sh
blob: d3a1b265ca61135163e0c89d935aafa3d0b1c173 (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
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
#!/usr/bin/env bash

[ $# -lt 1 ] && echo "usage: $0 <num-zones> <num-zonegroups>[rgw parameters...]" && exit 1

num_zones=$1
num_zonegroups=$2
shift

[ $num_zones -lt 1 ] && echo "clusters num must be at least 1" && exit 1

. "`dirname $0`/test-rgw-common.sh"
. "`dirname $0`/test-rgw-meta-sync.sh"

set -e

realm_name=earth
zg=zg1

system_access_key="1234567890"
system_secret="pencil"

# bring up first cluster
x $(start_ceph_cluster c1) -n $(get_mstart_parameters 1)

if [ -n "$RGW_PER_ZONE" ]; then
  rgws="$RGW_PER_ZONE"
else
  rgws=1
fi

url=http://localhost

i=1
while [ $i -le $rgws ]; do
  port=$((8100+i))
  endpoints="$endpoints""$url:$port,"
  i=$((i+1))
done

# create realm, zonegroup, zone, start rgws
init_first_zone c1 $realm_name $zg ${zg}-1 $endpoints $system_access_key $system_secret
i=1
while [ $i -le $rgws ]; do
  port=$((8100+i))
  x $(rgw c1 "$port" "$@")
  i="$((i+1))"
done

output=`$(rgw_admin c1) realm get`

echo realm_status=$output

# bring up next clusters

endpoints=""
i=2
while [ $i -le $num_zones ]; do
  x $(start_ceph_cluster c$i) -n $(get_mstart_parameters $i)
  j=1
  endpoints=""
  while [ $j -le $rgws ]; do
    port=$((8000+i*100+j))
    endpoints="$endpoints""$url:$port,"
    j=$((j+1))
  done

  # create new zone, start rgw
  init_zone_in_existing_zg c$i $realm_name $zg ${zg}-${i} 8101 $endpoints $zone_port $system_access_key $system_secret
  j=1
  while [ $j -le $rgws ]; do
    port=$((8000+i*100+j))
    x $(rgw c$i "$port" "$@")
    j="$((j+1))"
  done
  i=$((i+1))
done

endpoints=""
k=2
while [ $k -le $num_zonegroups ]; do
  x $(start_ceph_cluster c$i) -n $(get_mstart_parameters $i)
  j=1
  endpoints=""
  while [ $j -le $rgws ]; do
    port=$((8000+i*100+j))
    endpoints="$endpoints""$url:$port,"
    j=$((j+1))
  done

  # create new zone, start rgw
  init_first_zone_in_peer_zg c$i $realm_name zg${k} zg${k}-${i} 8101 $endpoints  $system_access_key $system_secret
  j=1
  while [ $j -le $rgws ]; do
    port=$((8000+i*100+j))
    x $(rgw c$i "$port" "$@")
    j="$((j+1))"
  done
# bring up next clusters in zonegroup k
  i=$((i+1))

  endpoints=""
  l=2
  while [ $l -le $num_zones ]; do
    x $(start_ceph_cluster c$i) -n $(get_mstart_parameters $i)
    j=1
    endpoints=""
    while [ $j -le $rgws ]; do
      port=$((8000+i*100+j))
      endpoints="$endpoints""$url:$port,"
      j=$((j+1))
    done

    # create new zone, start rgw
    init_zone_in_existing_zg c$i $realm_name zg${k} zg${k}-${i} 8101 $endpoints $zone_port $system_access_key $system_secret
    j=1
    while [ $j -le $rgws ]; do
      port=$((8000+i*100+j))
      x $(rgw c$i "$port" "$@")
      j="$((j+1))"
    done
    l=$((l+1))
    i=$((i+1))
  done

  k=$((k+1))
done