Skip to content

Commit

Permalink
add some retry logic with a delay to check the VM's state
Browse files Browse the repository at this point in the history
  • Loading branch information
libhe committed Sep 14, 2024
1 parent aa00e17 commit 7f2f72c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions os_tests/tests/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,19 +1003,11 @@ def test_reboot_simultaneous(self):
def _start_vm_and_check(self):
self.vm.start(wait=True)
time.sleep(60)
for _ in range(10):
try:
utils_lib.init_connection(self, timeout=self.ssh_timeout)
output = utils_lib.run_cmd(self, 'whoami').strip()
self.assertEqual(self.vm.vm_username,
output,
"Start VM error: output of cmd `who` unexpected -> %s" % output)
break
except Exception as e:
self.log.error("SSH connection failed, retrying... Error: {}".format(e))
time.sleep(60)
else:
self.fail("Failed to establish SSH connection after VM restart.")
utils_lib.init_connection(self, timeout=self.ssh_timeout*10)
output = utils_lib.run_cmd(self, 'whoami').strip()
self.assertEqual(self.vm.vm_username,
output,
"Start VM error: output of cmd `who` unexpected -> %s" % output)

def test_stop_start_vm(self):
"""
Expand Down

0 comments on commit 7f2f72c

Please sign in to comment.