]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/rgw/notification: fix threading issue in test
authorYuval Lifshitz <ylifshit@ibm.com>
Tue, 9 Apr 2024 10:00:08 +0000 (10:00 +0000)
committerYuval Lifshitz <ylifshit@ibm.com>
Tue, 9 Apr 2024 17:05:45 +0000 (17:05 +0000)
test_ps_s3_persistent_topic_stats may delete boto client threads
before they are done.
also, no need to run the http server twice

Fixes: https://tracker.ceph.com/issues/63909
Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
src/test/rgw/bucket_notification/test_bn.py

index 5345143b8b7f2b988eda6949c57da4785273fdcd..25770487ccaca3d845b1ae9dd53d9ef58a39536c 100644 (file)
@@ -3094,9 +3094,6 @@ def test_ps_s3_persistent_topic_stats():
     host = get_ip()
     port = random.randint(10000, 20000)
 
-    # start an http server in a separate thread
-    http_server = HTTPServerWithEvents((host, port))
-
     # create bucket
     bucket_name = gen_bucket_name()
     bucket = conn.create_bucket(bucket_name)
@@ -3117,10 +3114,6 @@ def test_ps_s3_persistent_topic_stats():
     response, status = s3_notification_conf.set_config()
     assert_equal(status/100, 2)
 
-    delay = 30
-    time.sleep(delay)
-    http_server.close()
-
     # topic stats
     result = admin(['topic', 'stats', '--topic', topic_name], get_config_cluster())
     parsed_result = json.loads(result[0])
@@ -3150,18 +3143,13 @@ def test_ps_s3_persistent_topic_stats():
     # delete objects from the bucket
     client_threads = []
     start_time = time.time()
-    count = 0
     for key in bucket.list():
-        count += 1
         thr = threading.Thread(target = key.delete, args=())
         thr.start()
         client_threads.append(thr)
-        if count%100 == 0:
-            [thr.join() for thr in client_threads]
-            time_diff = time.time() - start_time
-            print('average time for deletion + async http notification is: ' + str(time_diff*1000/number_of_objects) + ' milliseconds')
-            client_threads = []
-            start_time = time.time()
+    [thr.join() for thr in client_threads]
+    time_diff = time.time() - start_time
+    print('average time for deletion + async http notification is: ' + str(time_diff*1000/number_of_objects) + ' milliseconds')
 
     # topic stats
     result = admin(['topic', 'stats', '--topic', topic_name], get_config_cluster())
@@ -3179,7 +3167,6 @@ def test_ps_s3_persistent_topic_stats():
     topic_conf.del_config()
     # delete the bucket
     conn.delete_bucket(bucket_name)
-    time.sleep(delay)
     http_server.close()
 
 def ps_s3_persistent_topic_configs(persistency_time, config_dict):