@@ -19,13 +19,21 @@ def reboot():
1919 if 'ATEX_TEST_CONTROL' in os .environ :
2020 fd = int (os .environ ['ATEX_TEST_CONTROL' ])
2121 with os .fdopen (fd , 'w' , closefd = False ) as control :
22- control .write ('reconnect\n ' )
23- # TODO: temporarily work around race which might cause the above
24- # to not be sent out before we reboot
25- time .sleep (1 )
26- # prevent the test runner from reconnecting before reboot
27- util .subprocess_run (['systemctl' , 'stop' , 'sshd' ], check = True , stderr = subprocess .PIPE )
28- util .subprocess_run (['reboot' ])
22+ util .log ("doing disconnect + reboot" )
23+ control .write ('disconnect\n ' )
24+ control .flush ()
25+ # wait for the test control to actually break
26+ while True :
27+ try :
28+ control .write ('noop\n ' )
29+ control .flush ()
30+ except BrokenPipeError :
31+ break
32+ time .sleep (0.1 )
33+ # do reboot without util.log() output as the ssh stdio might be broken
34+ # from the above - the DEVNULL also ensures 'reboot' can safely write
35+ # to its outputs without getting EPIPE
36+ subprocess .run (['reboot' ], stdout = subprocess .DEVNULL , stderr = subprocess .STDOUT )
2937 elif shutil .which ('tmt-reboot' ):
3038 util .subprocess_run (['tmt-reboot' ])
3139 elif shutil .which ('rstrnt-reboot' ):
0 commit comments