2828
2929base_path = ['container' ]
3030PROCESS_NAME = 'conmon'
31- PROCESS_PIDFILE = '/run/vyos-container-{0}.service.pid'
3231
3332busybox_image = 'busybox:stable'
3433busybox_image_path = '/usr/share/vyos/busybox-stable.tar'
@@ -68,9 +67,13 @@ def tearDown(self):
6867 self .assertIsNone (process_named_running (PROCESS_NAME ))
6968
7069 # Ensure systemd units are removed
71- units = glob .glob ('/run/systemd/system/ vyos-container- *' )
70+ units = glob .glob ('/run/containers/ systemd/vyos*' )
7271 self .assertEqual (units , [])
7372
73+ def is_running (self , name ):
74+ command = f'systemctl show vyos-{ name } --property=ActiveState --value'
75+ return cmd (command ).strip () == 'active'
76+
7477 def test_basic (self ):
7578 cont_name = 'c1'
7679
@@ -99,12 +102,7 @@ def test_basic(self):
99102 # commit changes
100103 self .cli_commit ()
101104
102- pid = 0
103- with open (PROCESS_PIDFILE .format (cont_name ), 'r' ) as f :
104- pid = int (f .read ())
105-
106- # Check for running process
107- self .assertEqual (process_named_running (PROCESS_NAME ), pid )
105+ self .assertTrue (self .is_running (cont_name ))
108106
109107 # verify
110108 tmp = cmd (f'sudo podman exec -it { cont_name } sysctl kernel.msgmax' )
@@ -143,6 +141,8 @@ def test_name_server(self):
143141 self .cli_set (base_path + ['network' , net_name , 'no-name-server' ])
144142 self .cli_commit ()
145143
144+ self .assertTrue (self .is_running (cont_name ))
145+
146146 n = cmd_to_json (f'sudo podman inspect { cont_name } ' )
147147 self .assertEqual (n ['HostConfig' ]['Dns' ][0 ], name_server )
148148
@@ -158,12 +158,7 @@ def test_cpu_limit(self):
158158
159159 self .cli_commit ()
160160
161- pid = 0
162- with open (PROCESS_PIDFILE .format (cont_name ), 'r' ) as f :
163- pid = int (f .read ())
164-
165- # Check for running process
166- self .assertEqual (process_named_running (PROCESS_NAME ), pid )
161+ self .assertTrue (self .is_running (cont_name ))
167162
168163 def test_ipv4_network (self ):
169164 prefix = '192.0.2.0/24'
0 commit comments