Best Python code snippet using lisa_python
timesync.py
Source:timesync.py
...301 ntp.set_server_setting()302 # 5. Restart Ntp service to reload with new config.303 ntp.restart()304 # 6. Check leap code using `ntpq -c rv`.305 ntp.check_leap_code()306 ntpstat = node.tools[Ntpstat]307 # 7. Check local time is synchronised with time server using `ntpstat`.308 ntpstat.check_time_sync()309 @TestCaseMetadata(310 description="""311 This test is to check chrony works properly.312 1. Restart chrony service.313 2. Check and set server setting in config file.314 3. Restart chrony service to reload with new config.315 4. Check chrony sources and sourcestats.316 5. Check chrony tracking.317 """,318 priority=2,319 )...
ntp.py
Source:ntp.py
...22 posix_os: Posix = cast(Posix, self.node.os)23 posix_os.install_packages("ntp")24 return self._check_exists()25 @retry(tries=300, delay=1)26 def check_leap_code(self) -> None:27 cmd_result = self.run("-c rv", shell=True, sudo=True, force_run=True)28 if not self.__leap_pattern.match(cmd_result.stdout):29 # leap_none - normal synchronized state30 # leap_alarm - NTP was never synchronized31 raise LisaException(32 "The leap code is not lean_none."33 " Please check ntp server setting and service status."34 )35 def set_server_setting(self) -> None:36 cmd_result = self.run("-np", shell=True, sudo=True, force_run=True)37 if self.__no_server_set in cmd_result.stdout:38 echo = self.node.tools[Echo]39 echo.run("server 0.pool.ntp.org >> /etc/ntp.conf", shell=True, sudo=True)40 echo.run("server 1.pool.ntp.org >> /etc/ntp.conf", shell=True, sudo=True)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!