How to use get_boot_time method in tempest

Best Python code snippet using tempest_python

hoststatsTests.py

Source:hoststatsTests.py Github

copy

Full Screen

...62 shutil.rmtree(self._tmpDir)63 def testBootTimeOk(self):64 with MonkeyPatchScope([(hoststats, '_PROC_STAT_PATH',65 self._good_path)]):66 self.assertEquals(hoststats.get_boot_time(),67 1395249141)68 def testBootTimeEmpty(self):69 with MonkeyPatchScope([(hoststats, '_PROC_STAT_PATH',70 '/dev/null')]):71 with self.assertRaises(ValueError):72 hoststats.get_boot_time()73 def testBootTimeMissing(self):74 with MonkeyPatchScope([(hoststats, '_PROC_STAT_PATH',75 self._missing_path)]):76 with self.assertRaises(ValueError):77 hoststats.get_boot_time()78 def testBootTimeMalformed(self):79 with MonkeyPatchScope([(hoststats, '_PROC_STAT_PATH',80 self._malformed_path)]):81 with self.assertRaises(ValueError):82 hoststats.get_boot_time()83 def testBootTimeNonExistantFile(self):84 with MonkeyPatchScope([(hoststats, '_PROC_STAT_PATH',85 '/i/do/not/exist/1234567890')]):86 with self.assertRaises(IOError):87 hoststats.get_boot_time()88 def testBootTimeExtra(self):89 with MonkeyPatchScope([(hoststats, '_PROC_STAT_PATH',90 self._extra_path)]):91 self.assertEquals(hoststats.get_boot_time(), 1395249141)92class HostStatsThreadTests(TestCaseBase):93 _core_zero_stats = {94 'cpuIdle': '100.00',95 'cpuSys': '0.00',96 'cpuUser': '0.00',97 'nodeIndex': 098 }99 _core_one_stats = {100 'cpuIdle': '100.00',101 'cpuSys': '0.00',102 'cpuUser': '0.00',103 'nodeIndex': 1104 }105 def _fakeNumaTopology(self):...

Full Screen

Full Screen

boot_monitor.py

Source:boot_monitor.py Github

copy

Full Screen

...15# along with this program; if not, write to the Free Software16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA17#18from time import sleep19def get_boot_time(con):20 timeepoch = None21 problem, out, _ = con.maybe_launch('net statistics server',timeout = 60)22 if problem: print 'BOOT_MONITOR:', 'problem',problem,'getting boot time' 23 else:24 try:25 print 'BOOT_MONITOR:', 'raw output',out 26 uout = out.replace('\r', '')27 lines = out.split('\n')28 timestring= ' '.join(lines[3].split()[2:])29 # 5/4/2010 5:37 PM30 colons = timestring.count(':')31 format = '%m/%d/%Y %I:%M %p' if colons == 1 else '%m/%d/%Y %I:%M:%S %p'32 timetuple = time.strptime(timestring, format)33 timeepoch = time.mktime(timetuple)34 print 'BOOT_MONITOR:', 'epoch',timeepoch 35 except IndexError: pass36 return (timeepoch)37class BootMonitor:38 def __init__(self, con):39 self.con = con40 self.boots = []41 42 def get_first_boot_time(self):43 while True:44 epoch = get_boot_time(self.con)45 if epoch is not None: break46 47 print 'BOOT_MONITOR:', 'boot time not available yet' 48 sleep(1)49 assert epoch > 050 self.boots.append(epoch)51 52 def get_boot_time(self):53 t = get_boot_time(self.con)54 if t is None: return55 if t not in self.boots: self.boots.append(t)56 return (t)57 def get_number_of_boots(self): return len(self.boots)58 def render_boot_times(self):59 return 'boot times %r' % ([time.asctime(time.localtime(t)) for ...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1from record_img import CapThread2from start_app import AppStartThread3import process_img4import get_boot_time5import device_info6import os7import shutil8import global_var9import airtest_app10times = 011while times < 11:12 target_dir = global_var.target_dir13 source_dir = global_var.source_dir14 # 每次删除文件夹再重新创建此文件夹15 shutil.rmtree(source_dir)16 os.mkdir(source_dir)17 # 创建新线程-启动App并且开启录屏18 thread1 = CapThread(1, "cap")19 thread2 = AppStartThread(2, "appstart")20 # 开启新线程21 thread1.start()22 thread2.start()23 thread1.join()24 thread2.join()25 print("退出主线程")26 process_img.processIMG()27 filelist = os.listdir(target_dir) # 获取该目录下的所有文件名28 filelist.sort()29 start_time = get_boot_time.get_start_time(filelist)30 end_time = get_boot_time.get_end_time(filelist, target_dir)31 boot_time = end_time - start_time32 print("启动时间(ms):" + str(boot_time))33 # 获取手机型号34 n = os.popen("adb shell getprop ro.product.model")35 devicename = n.readlines()36 # device_info.create_csv()37 device_info.write_csv("7.5.21", devicename[0], boot_time)38 global_var.exitFlag = 139 airtest_app.close()...

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 tempest 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