]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw: initial work on multi site test framework
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 9 Dec 2015 21:55:21 +0000 (13:55 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:43 +0000 (16:13 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/test/rgw/test-rgw-common.sh [new file with mode: 0644]
src/test/rgw/test-rgw-multisite.sh [new file with mode: 0755]

diff --git a/src/test/rgw/test-rgw-common.sh b/src/test/rgw/test-rgw-common.sh
new file mode 100644 (file)
index 0000000..838169a
--- /dev/null
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+function var_to_python_json_index {
+  echo "['$1']" | sed "s/\./'\]\['/g"
+}
+
+function json_extract {
+var=$(var_to_python_json_index $1)
+shift
+python - <<END
+import json
+s='$@'
+data = json.loads(s) 
+print data$var
+END
+}
+
+x() {
+  echo "x " "$@"
+  eval "$@"
+}
+
+
+script_dir=`dirname $0`
+root_path=`(cd $script_dir/../..; pwd)`
+
+mstart=$root_path/mstart.sh
+mstop=$root_path/mstop.sh
+mrun=$root_path/mrun
+
+function start_ceph_cluster {
+  [ $# -ne 1 ] && echo "start_ceph_cluster() needs 1 param" && exit 1
+
+  echo "$mstart c$1"
+}
+
+function rgw_admin {
+  [ $# -ne 1 ] && echo "rgw_admin() needs 1 param" && exit 1
+
+  echo "$mrun c$1 radosgw-admin"
+}
+
+function rgw {
+  [ $# -ne 2 ] && echo "rgw() needs 2 params" && exit 1
+
+  echo "$root_path/mrgw.sh c$1 $2"
+}
+
+function init_first_zone {
+  [ $# -ne 7 ] && echo "init_first_zone() needs 7 params" && exit 1
+
+  id=$1
+  realm=$2
+  zg=$3
+  zone=$4
+  port=$5
+
+  access_key=$6
+  secret=$7
+
+# initialize realm
+  x $(rgw_admin $id) realm create --rgw-realm=$realm
+
+# create zonegroup, zone
+  x $(rgw_admin $id) zonegroup create --rgw-zonegroup=$zg --endpoints=http://localhost:$port --master --default
+  x $(rgw_admin $id) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=http://localhost:$port --default
+  x $(rgw_admin $id) user create --uid=zone.user --display-name="Zone User" --access-key=${access_key} --secret=${secret} --system
+
+  x $(rgw_admin $id) period update --commit
+
+  x $(rgw $id $port) --rgw-zone=$zone
+}
+
+function init_zone_in_existing_zg {
+  [ $# -ne 7 ] && echo "init_zone_in_existing_zg() needs 7 params" && exit 1
+
+  id=$1
+  realm=$2
+  zg=$3
+  zone=$4
+  port=$5
+
+  access_key=$6
+  secret=$7
+
+  x $(rgw_admin $id) realm pull --url=http://localhost:$zone1_port --access-key=${system_access_key} --secret=${system_secret} --default
+  x $(rgw_admin $id) zonegroup default --rgw-zonegroup=$zg
+  x $(rgw_admin $id) zone create --rgw-zonegroup=$zg --rgw-zone=$zone2 --access-key=${system_access_key} --secret=${system_secret} --endpoints=http://localhost:$zone2_port
+  x $(rgw_admin $id) period update --commit
+
+  x $(rgw $id $zone2_port) --rgw-zone=$zone2
+}
diff --git a/src/test/rgw/test-rgw-multisite.sh b/src/test/rgw/test-rgw-multisite.sh
new file mode 100755 (executable)
index 0000000..921d433
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+. "`dirname $0`/test-rgw-common.sh"
+
+set -e
+
+
+realm_name=earth
+zg=us
+zone1=${zg}-1
+zone2=${zg}-2
+
+zone1_port=8000
+zone2_port=8001
+
+system_access_key="1234567890"
+system_secret="pencil"
+
+# bring up first cluster
+x $(start_ceph_cluster 1) -n
+
+# create realm, zonegroup, zone, start rgw
+init_first_zone 1 $realm_name $zg $zone1 $zone1_port $system_access_key $system_secret
+
+output=`$(rgw_admin 1) realm get`
+
+echo realm_status=$output
+
+# bring up second cluster
+x $(start_ceph_cluster 2) -n
+
+
+# create new zone, start rgw
+init_zone_in_existing_zg 2 $realm_name $zg $zone1 $zone1_port $system_access_key $system_secret
+