summaryrefslogtreecommitdiffstats
path: root/src/test/rgw
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@redhat.com>2017-05-02 21:45:40 +0200
committerYehuda Sadeh <yehuda@redhat.com>2017-05-30 22:26:57 +0200
commitcd3fb7936e3d7efc92c1f39550381af8368f5397 (patch)
tree175605d9c27ec4eeca6beab037fc89062a39fa2b /src/test/rgw
parentrgw/test-multi: test more complicated queries (diff)
downloadceph-cd3fb7936e3d7efc92c1f39550381af8368f5397.tar.xz
ceph-cd3fb7936e3d7efc92c1f39550381af8368f5397.zip
rgw/test_multi: add test_es_bucket_conf test
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src/test/rgw')
-rw-r--r--src/test/rgw/rgw_multi/tests_es.py43
-rw-r--r--src/test/rgw/rgw_multi/zone_es.py16
2 files changed, 53 insertions, 6 deletions
diff --git a/src/test/rgw/rgw_multi/tests_es.py b/src/test/rgw/rgw_multi/tests_es.py
index b96bd591ac5..e313018b6f8 100644
--- a/src/test/rgw/rgw_multi/tests_es.py
+++ b/src/test/rgw/rgw_multi/tests_es.py
@@ -82,6 +82,9 @@ def init_env(create_obj, num_keys = 5, buckets_per_zone = 1, bucket_init_cb = No
objname = obj_prefix + str(count)
k = new_key(zone, bucket.name, objname)
# k.set_contents_from_string(content + 'x' * count)
+ if not create_obj:
+ continue
+
create_obj(k, count)
if not owner:
@@ -96,9 +99,11 @@ def init_env(create_obj, num_keys = 5, buckets_per_zone = 1, bucket_init_cb = No
zonegroup_meta_checkpoint(zonegroup)
+ sources = []
targets = []
for target_conn in zonegroup_conns.zones:
if not is_es_zone(target_conn):
+ sources.append(target_conn)
continue
targets.append(target_conn)
@@ -110,7 +115,7 @@ def init_env(create_obj, num_keys = 5, buckets_per_zone = 1, bucket_init_cb = No
for target_conn in targets:
zone_bucket_checkpoint(target_conn.zone, source_conn.zone, bucket.name)
- return targets, buckets, src_keys
+ return targets, sources, buckets, src_keys
def test_es_object_search():
min_size = 10
@@ -119,7 +124,7 @@ def test_es_object_search():
def create_obj(k, i):
k.set_contents_from_string(content + 'x' * i)
- targets, buckets, src_keys = init_es_test(create_obj, num_keys = 5, buckets_per_zone = 2)
+ targets, _, buckets, src_keys = init_env(create_obj, num_keys = 5, buckets_per_zone = 2)
for target_conn in targets:
@@ -185,7 +190,7 @@ def test_es_object_search_custom():
'X-Amz-Meta-Foo-Int': str(i * 5),
'X-Amz-Meta-Foo-Date': date_str})
- targets, buckets, src_keys = init_es_test(create_obj, num_keys = 5, buckets_per_zone = 1, bucket_init_cb = bucket_init)
+ targets, _, buckets, src_keys = init_env(create_obj, num_keys = 5, buckets_per_zone = 1, bucket_init_cb = bucket_init)
for target_conn in targets:
@@ -236,3 +241,35 @@ def test_es_object_search_custom():
' and (x-amz-meta-foo-str <= ' + str_vals[i + 1] + ')',
lambda k: k.bucket.name == bucket.name and (k.get_metadata('foo-str') >= str_vals[i] and
k.get_metadata('foo-str') <= str_vals[i + 1]) )
+
+def test_es_bucket_conf():
+ min_size = 0
+
+ def bucket_init(zone_conn, bucket):
+ req = MDSearchConfig(zone_conn.conn, bucket.name)
+ req.set_config('x-amz-meta-foo-str; string, x-amz-meta-foo-int; int, x-amz-meta-foo-date; date')
+
+ targets, sources, buckets, _ = init_env(None, num_keys = 5, buckets_per_zone = 1, bucket_init_cb = bucket_init)
+
+ for source_conn in sources:
+ for bucket in buckets:
+ req = MDSearchConfig(source_conn.conn, bucket.name)
+ conf = req.get_config()
+
+ d = {}
+
+ for entry in conf:
+ d[entry['Key']] = entry['Type']
+
+ eq(len(d), 3)
+ eq(d['x-amz-meta-foo-str'], 'str')
+ eq(d['x-amz-meta-foo-int'], 'int')
+ eq(d['x-amz-meta-foo-date'], 'date')
+
+ req.del_config()
+
+ conf = req.get_config()
+
+ eq(len(conf), 0)
+
+ break # no need to iterate over all zones
diff --git a/src/test/rgw/rgw_multi/zone_es.py b/src/test/rgw/rgw_multi/zone_es.py
index d89d5edfea2..6397de4e172 100644
--- a/src/test/rgw/rgw_multi/zone_es.py
+++ b/src/test/rgw/rgw_multi/zone_es.py
@@ -143,17 +143,27 @@ class MDSearchConfig:
def send_request(self, conf, method):
query_args = 'mdsearch'
- headers = { 'X-Amz-Meta-Search': conf }
+ headers = None
+ if conf:
+ headers = { 'X-Amz-Meta-Search': conf }
+
+ query_args = append_query_arg(query_args, 'format', 'json')
result = make_request(self.conn, method, bucket=self.bucket_name, key='', query_args=query_args, headers=headers)
if result.status / 100 != 2:
raise boto.exception.S3ResponseError(result.status, result.reason, result.read())
+ return result
+
+ def get_config(self):
+ result = self.send_request(None, 'GET')
+ return json.loads(result.read())
+
def set_config(self, conf):
self.send_request(conf, 'POST')
- def del_config(self, conf):
- self.send_request(conf, 'DELETE')
+ def del_config(self):
+ self.send_request(None, 'DELETE')
class ESZoneBucket: