]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/rgw/pubsub: verify incremental sync is used in pubsub 33068/head
authorYuval Lifshitz <yuvalif@yahoo.com>
Tue, 4 Feb 2020 18:41:39 +0000 (20:41 +0200)
committerYuval Lifshitz <yuvalif@yahoo.com>
Tue, 4 Feb 2020 18:41:39 +0000 (20:41 +0200)
add test to verify that the pubsub zone is only synced incrementaly

Signed-off-by: Yuval Lifshitz <yuvalif@yahoo.com>
src/test/rgw/rgw_multi/tests_ps.py

index 40e18bd29bdd00a7ef59e439efcec4948c8e85b6..9dd037ba320c9fff96d22742877f8a53ff64ed0c 100644 (file)
@@ -2222,6 +2222,60 @@ def test_ps_subscription():
     topic_conf.del_config()
     master_zone.delete_bucket(bucket_name)
 
+def test_ps_incremental_sync():
+    """ test that events are only sent on incremental sync """
+    master_zone, ps_zone = init_env()
+    bucket_name = gen_bucket_name()
+    topic_name = bucket_name+TOPIC_SUFFIX
+
+    # create topic
+    topic_conf = PSTopic(ps_zone.conn, topic_name)
+    topic_conf.set_config()
+    # create bucket on the first of the rados zones
+    bucket = master_zone.create_bucket(bucket_name)
+    # create objects in the bucket
+    number_of_objects = 10
+    for i in range(0, number_of_objects):
+        key = bucket.new_key(str(i))
+        key.set_contents_from_string('foo')
+    # wait for sync
+    zone_bucket_checkpoint(ps_zone.zone, master_zone.zone, bucket_name)
+    # create notifications
+    notification_conf = PSNotification(ps_zone.conn, bucket_name,
+                                       topic_name)
+    _, status = notification_conf.set_config()
+    assert_equal(status/100, 2)
+    # create subscription
+    sub_conf = PSSubscription(ps_zone.conn, bucket_name+SUB_SUFFIX,
+                              topic_name)
+    _, status = sub_conf.set_config()
+    assert_equal(status/100, 2)
+    
+    # create more objects in the bucket
+    for i in range(number_of_objects, 2*number_of_objects):
+        key = bucket.new_key(str(i))
+        key.set_contents_from_string('bar')
+    # wait for sync
+    zone_bucket_checkpoint(ps_zone.zone, master_zone.zone, bucket_name)
+
+    # get the create events from the subscription
+    result, _ = sub_conf.get_events()
+    events = json.loads(result)
+    count = 0
+    for event in events['events']:
+        log.debug('Event: objname: "' + str(event['info']['key']['name']) + '" type: "' + str(event['event']) + '"')
+        count += 1
+   
+    # make sure we have 10 and not 20 events
+    assert_equal(count, number_of_objects)
+
+    # cleanup
+    for key in bucket.list():
+        key.delete()
+    sub_conf.del_config()
+    notification_conf.del_config()
+    topic_conf.del_config()
+    master_zone.delete_bucket(bucket_name)
 
 def test_ps_event_type_subscription():
     """ test subscriptions for different events """