]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/rgw/notification: do not use netstat in the code
authorYuval Lifshitz <ylifshit@ibm.com>
Fri, 20 Feb 2026 15:41:14 +0000 (15:41 +0000)
committerYuval Lifshitz <ylifshit@ibm.com>
Mon, 23 Feb 2026 17:48:53 +0000 (17:48 +0000)
* 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 <ylifshit@ibm.com>
src/test/rgw/bucket_notification/test_bn.py

index 830b6e48ffec73950b7f185099dce5266ef795b7..3fd354e2898c33acf5f53f83f21bd8fddbd2a775 100644 (file)
@@ -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: