How to use wait_for_machine_to_recover method in autotest

Best Python code snippet using autotest_python

crashcollect.py

Source:crashcollect.py Github

copy

Full Screen

...12def get_crashinfo(host, test_start_time):13 logging.info("Collecting crash information...")14 # include crashdumps as part of the general crashinfo15 get_crashdumps(host, test_start_time)16 if wait_for_machine_to_recover(host):17 # run any site-specific collection18 get_site_crashinfo(host, test_start_time)19 crashinfo_dir = get_crashinfo_dir(host)20 collect_messages(host)21 collect_log_file(host, "/var/log/monitor-ssh-reboots", crashinfo_dir)22 collect_command(host, "dmesg", os.path.join(crashinfo_dir, "dmesg"))23 collect_uncollected_logs(host)24def wait_for_machine_to_recover(host, hours_to_wait=4.0):25 """Wait for a machine (possibly down) to become accessible again.26 @param host: A RemoteHost instance to wait on27 @param hours_to_wait: Number of hours to wait before giving up28 @returns: True if the machine comes back up, False otherwise29 """30 current_time = time.strftime("%b %d %H:%M:%S", time.localtime())31 if host.is_up():32 logging.info("%s already up, collecting crash info", host.hostname)33 return True34 logging.info("Waiting four hours for %s to come up (%s)",35 host.hostname, current_time)36 if not host.wait_up(timeout=hours_to_wait * 3600):37 logging.warning("%s down, unable to collect crash info",38 host.hostname)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful