From 5e204e17684ec6d2ab5b44e114be6cc4dfcf10b9 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Fri, 20 Feb 2026 15:41:14 +0000 Subject: [PATCH] test/rgw/notification: do not use netstat in the code * net-tools are deprecated in fedora and ubuntu * using netstat -p (used to verify that the http server is listening on a port) requires root privilages, which may fail in some tests environments Signed-off-by: Yuval Lifshitz --- src/test/rgw/bucket_notification/test_bn.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/test/rgw/bucket_notification/test_bn.py b/src/test/rgw/bucket_notification/test_bn.py index 830b6e48ffe..3fd354e2898 100644 --- a/src/test/rgw/bucket_notification/test_bn.py +++ b/src/test/rgw/bucket_notification/test_bn.py @@ -1550,7 +1550,7 @@ def test_notification_amqp_idleness_check(): print('waiting for 40sec for checking idleness') time.sleep(40) - os.system("netstat -nnp | grep 5672"); + os.system("ss -tnp | grep 5672") # do the process of uploading an object and checking for notification again number_of_objects = 10 @@ -1593,7 +1593,7 @@ def test_notification_amqp_idleness_check(): # check amqp receiver 1 for deletions receiver1.verify_s3_events(keys, exact_match=True, deletions=True) - os.system("netstat -nnp | grep 5672"); + os.system("ss -tnp | grep 5672") # cleanup stop_amqp_receiver(receiver1, task1) @@ -3095,12 +3095,15 @@ def test_persistent_cleanup(): def check_http_server(http_port): str_port = str(http_port) - cmd = 'netstat -tlnnp | grep python | grep '+str_port - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) - out = proc.communicate()[0] - assert len(out) > 0, 'http python server NOT listening on port '+str_port - log.info("http python server listening on port "+str_port) - log.info(out.decode('utf-8')) + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + s.settimeout(1) + s.connect((get_ip(), http_port)) + log.info("http server listening on port "+str_port) + except (socket.error, socket.timeout): + assert False, 'http server NOT listening on port '+str_port + finally: + s.close() def wait_for_queue_to_drain(topic_name, tenant=None, account=None, http_port=None): @@ -3631,7 +3634,7 @@ def test_notification_kafka_idle_behaviour(): while not is_idle: print('waiting for 10sec for checking idleness') time.sleep(10) - cmd = "netstat -nnp | grep 9092 | grep radosgw" + cmd = "ss -tnp | grep 9092 | grep radosgw" proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) out = proc.communicate()[0] if len(out) == 0: -- 2.47.3