How to use run_conmux method in autotest

Best Python code snippet using autotest_python

serial.py

Source:serial.py Github

copy

Full Screen

...69 self.__logger = None70 if self.job:71 self.job.warning_loggers.discard(self.__warning_stream)72 self.__warning_stream.close()73 def run_conmux(self, cmd):74 """75 Send a command to the conmux session76 """77 if not self.conmux_attach or not os.path.exists(self.conmux_attach):78 return False79 cmd = '%s %s echo %s 2> /dev/null' % (self.conmux_attach,80 self.get_conmux_hostname(),81 cmd)82 result = utils.system(cmd, ignore_status=True)83 return result == 084 def hardreset(self, timeout=DEFAULT_REBOOT_TIMEOUT, wait=True,85 conmux_command='hardreset', num_attempts=1, halt=False,86 **wait_for_restart_kwargs):87 """88 Reach out and slap the box in the power switch.89 @params conmux_command: The command to run via the conmux interface90 @params timeout: timelimit in seconds before the machine is91 considered unreachable92 @params wait: Whether or not to wait for the machine to reboot93 @params num_attempts: Number of times to attempt hard reset erroring94 on the last attempt.95 @params halt: Halts the machine before hardresetting.96 @params **wait_for_restart_kwargs: keyword arguments passed to97 wait_for_restart()98 """99 conmux_command = "'~$%s'" % conmux_command100 # if the machine is up, grab the old boot id, otherwise use a dummy101 # string and NOT None to ensure that wait_down always returns True,102 # even if the machine comes back up before it's called103 try:104 old_boot_id = self.get_boot_id()105 except error.AutoservSSHTimeout:106 old_boot_id = 'unknown boot_id prior to SerialHost.hardreset'107 def reboot():108 if halt:109 self.halt()110 if not self.run_conmux(conmux_command):111 self.record("ABORT", None, "reboot.start",112 "hard reset unavailable")113 raise error.AutoservUnsupportedError(114 'Hard reset unavailable')115 self.record("GOOD", None, "reboot.start", "hard reset")116 if wait:117 warning_msg = ('Serial console failed to respond to hard reset '118 'attempt (%s/%s)')119 for attempt in xrange(num_attempts-1):120 try:121 self.wait_for_restart(timeout, log_failure=False,122 old_boot_id=old_boot_id,123 **wait_for_restart_kwargs)124 except error.AutoservShutdownError:125 logging.warning(warning_msg, attempt+1, num_attempts)126 # re-send the hard reset command127 self.run_conmux(conmux_command)128 else:129 break130 else:131 # Run on num_attempts=1 or last retry132 try:133 self.wait_for_restart(timeout,134 old_boot_id=old_boot_id,135 **wait_for_restart_kwargs)136 except error.AutoservShutdownError:137 logging.warning(warning_msg, num_attempts, num_attempts)138 msg = "Host did not shutdown"139 raise error.AutoservShutdownError(msg)140 if self.job:141 self.job.disable_warnings("POWER_FAILURE")...

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