@@ -604,3 +604,34 @@ def test_check_nodestatus(tmp_path):
604
604
else :
605
605
_ , status = os .waitpid (pid , 0 )
606
606
assert status != 0
607
+
608
+
609
+ def test_ensure_ctdb_port_in_services (tmp_path ):
610
+ fname = tmp_path / "fake.services"
611
+ with open (fname , "w" ) as fh :
612
+ # random snippets from a real /etc/services
613
+ print ("# this is a comment" , file = fh )
614
+ print ("ftp 21/tcp" , file = fh )
615
+ print ("ftp 21/udp fsp fspd" , file = fh )
616
+ print ("ssh 22/tcp" , file = fh )
617
+ print ("ssh 22/udp" , file = fh )
618
+ print ("telnet 23/tcp" , file = fh )
619
+ print ("telnet 23/udp" , file = fh )
620
+ print ("ctdb 4379/tcp # CTDB" , file = fh )
621
+ print ("ctdb 4379/udp # CTDB" , file = fh )
622
+ print ("roce 4791/udp" , file = fh )
623
+ print ("# a random comment..." , file = fh )
624
+ print ("snss 11171/udp" , file = fh )
625
+ print ("oemcacao-jmxmp 11172/tcp" , file = fh )
626
+
627
+ ctdb .ensure_ctdb_port_in_services (9099 , fname )
628
+
629
+ with open (fname ) as fh :
630
+ content = fh .read ()
631
+ assert "ctdb 9099/tcp" in content
632
+ assert "ctdb 9099/udp" in content
633
+ assert "ctdb 4379/tcp" not in content
634
+ assert "ctdb 4379/udp" not in content
635
+ # others
636
+ assert "ssh 22/tcp" in content
637
+ assert "snss 11171/udp" in content
0 commit comments