def firstRun(): print("Before install") launchinstall.installBluestacks() print("Installed") time.sleep(5) print("\n\nChecking First Boot\n\n") bt = bootCheck.startBootTest(0) if bt: #print("here") print("Time taken to boot = " + str(bt) + " s") else: print("Failed to boot, exiting..") sys.exit(0) time.sleep(10) print("\n\nStarting OTS\n\n") sikuliController.runSikuli(0) time.sleep(10) print("\n\nQuitting Bluestacks\n\n") sikuliController.runSikuli(1) time.sleep(15) print("\n\nChecking Subsequent Boot\n\n") bt2 = bootCheck.startBootTest(1) if bt2: #print("here") print("Time taken to boot = " + str(bt2) + " s") else: print("Failed to boot, exiting..") sys.exit(0) time.sleep(10) print("\n\nQuitting Bluestacks\n\n") sikuliController.runSikuli(1) time.sleep(15) BluestacksUninstall.uninstall()
def BenchMarkPerf(): with open(r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json') as f1: data = json.load(f1) if data["bmark_p"]["IterationFlag"] <= data["bmark_p"]["TotalIterations"]: if data["bmark_p"]["isCompleted"] == 0: boot = bootCheck.startBootTest(1) if boot: if data["bmark_p"]["IterationFlag"] == 1 and data["bmark_p"]["isAppInstalled"] == 0: bmark.adb_connect() bmark.install_app() bmark.benchmark_app_setup() print("Waiting for icestorm installation") time.sleep(120) sikuliController.runSikuli(1) data["bmark_p"]["isAppInstalled"] == 1 with open(r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) return(0) bmark.launch_test(data["bmark_p"]["IterationFlag"]) sikuliController.runSikuli(1) data["bmark_p"]["IterationFlag"] += 1 with open(r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) return(1)
def FirstBoot(): with open(r'flags.json') as f1: data = json.load(f1) resultFilePath = r'results.json' if not os.path.isfile(resultFilePath): dataDump = {} with open(resultFilePath, 'w') as json_file: json.dump(dataDump, json_file) logging.info( str(datetime.datetime.now()) + " Created new results.json file") with open(resultFilePath) as f2: result = json.load(f2) logging.info( str(datetime.datetime.now()) + " Loaded previous boot results in dict") iterFlag = data["fboot"]["IterationFlag"] Iterations = data["fboot"]["TotalIterations"] isCompleted = data["fboot"]["CompletionFlag"] if iterFlag <= Iterations: try: #print("here1") #if isCompleted == 1: # return if isCompleted == 0: #print("here2") #print("Before install") launchinstall.installBluestacks() print("Installed") time.sleep(5) if stable_cpu.main(0, 60) == True: logging.info( str(datetime.datetime.now()) + " Checking for fboot bootup...") bootTime = bootCheck.startBootTest(0) #sikuliController.runSikuli(1) if iterFlag != Iterations: BluestacksUninstall.uninstall() print("Sleeping for Uninstall") time.sleep(20) if data["fboot"]["IterationFlag"] < data["fboot"][ "TotalIterations"]: print("Changing Flag") data["fboot"]["IterationFlag"] += 1 logging.info( str(datetime.datetime.now()) + " Incrementing fboot flag") with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) elif data["fboot"]["IterationFlag"] == data["fboot"][ "TotalIterations"]: print( "Resetting iterFlag and switching CompletionFlag to 1") data["fboot"]["IterationFlag"] = 1 data["fboot"]["CompletionFlag"] = 1 with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) logging.info( str(datetime.datetime.now()) + " Changing Completion and resetting iteration flag for fboot" ) if iterFlag == 1: result.update({"fboot": {}}) result["fboot"].update({iterFlag: bootTime}) logging.info( str(datetime.datetime.now()) + " Updating fboot result of iteration - " + str(iterFlag)) with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\results.json', 'w') as json_file: json.dump(result, json_file) else: print("All iterations completed") return (0) return (result) except Exception as e: print("CompletionFlag value corrupted; Error - " + str(e)) logging.info( str(datetime.datetime.now()) + " Error getting fboot result - " + str(e))
def ReleaseCriteria(): print(os.getcwd()) with open(r'flags.json') as f: data = json.load(f) if data["builds"]["1"]["isFinished"] == 1 and data["builds"]["2"][ "isFinished"] == 1: print("Finished readings for all builds") sys.exit(0) curBuild = data["builds"]["current"] logging.info( str(datetime.datetime.now()) + " Starting test on Build number - " + str(curBuild)) testCases = ["cpuram", "fboot", "sboot", "sboot_p"] for test in testCases: if data["builds"][str(curBuild)]["toTest"][str(test)] == 0: data[str(test)]["CompletionFlag"] = 1 logging.info( str(datetime.datetime.now()) + " Not testing for current build - " + str(test)) with open(r'flags.json', 'w') as json_file: json.dump(data, json_file) if data["builds"][str(curBuild)]["toTest"]["fboot"] == 0: print("Necessary first boot started") logging.info( str(datetime.datetime.now()) + " Starting necessary First Boot") print("Before install") launchinstall.installBluestacks() print("Installed") time.sleep(5) bootTime = bootCheck.startBootTest(0) logging.info(str(datetime.datetime.now()) + " Starting OTS") sikuliController.runSikuli(0) logging.info(str(datetime.datetime.now()) + " Completed OTS") sikuliController.runSikuli(1) logging.info(str(datetime.datetime.now()) + " Quit Emulator") data["fboot"]["CompletionFlag"] = 1 if data["fboot"]["CompletionFlag"] == 0: print("\nStarting First Boot Test\nWaiting for 30 seconds\n") logging.info( str(datetime.datetime.now()) + " Starting First Boot Test (RC)") time.sleep(30) if stable_cpu.main(0, 60) == True: logging.info( str(datetime.datetime.now()) + " Machine stable, continuing with test") boot_result = PRC_Boot.rcBoot(0) if data["fboot"]["IterationFlag"] != data["fboot"]["TotalIterations"]: print("restarting Machine") logging.info( str(datetime.datetime.now()) + " Restarting Machine for First Boot") restart_machine.restart() else: logging.info( str(datetime.datetime.now()) + " Last First boot, starting OTS") sikuliController.runSikuli(0) logging.info(str(datetime.datetime.now()) + " Quitting Emulator") sikuliController.runSikuli(1) print(boot_result) else: print("First Boot Data recorded") logging.info( str(datetime.datetime.now()) + " First Boot data Recorded") if data["sboot"]["CompletionFlag"] == 0: print("\nStarting Subsequent Boot Test\nWaiting for 15 seconds\n") logging.info( str(datetime.datetime.now()) + " Starting Subsequent Boot Test (RC)") time.sleep(15) boot_result = PRC_Boot.rcBoot(1) print(boot_result) else: print("Subsequent Boot Data recorded") logging.info( str(datetime.datetime.now()) + " Subsequent Boot Data Recorded") if data["sboot_p"]["CompletionFlag"] == 0: print( "\nStarting Subsequent Boot with PerfView Test\nWaiting for 15 seconds\n" ) logging.info( str(datetime.datetime.now()) + " Starting Subsequent Boot with PerfView Test (RC)") time.sleep(15) boot_result = PRC_Boot.rcBoot(2) print(boot_result) else: print("Subsequent Boot with PerfView Data recorded") logging.info( str(datetime.datetime.now()) + " Subsequent Boot with PerfView data recorded") if data["cpuram"]["CompletionFlag"] == 0: if data["cpuram"]["IterationFlag"] == 1: if data["cpuram"]["firstRestart"] == 0: print("Updating flag for restart") with open(r'flags.json') as f: data = json.load(f) data["cpuram"]["firstRestart"] = 1 with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) print("restarting Machine") logging.info( str(datetime.datetime.now()) + " Restarting Machine for first CPU RAM recording") restart_machine.restart() print("\nStarting CPU/RAM Test\nWaiting for 30 seconds\n") logging.info( str(datetime.datetime.now()) + " Starting CPU RAM Test (RC)") time.sleep(30) PRC_CPU_RAM.RecordcpuramData() print("Cpu ram completed") if data["cpuram"]["IterationFlag"] != data["cpuram"]["TotalIterations"]: print("restarting Machine") sikuliController.runSikuli(1) time.sleep(15) logging.info( str(datetime.datetime.now()) + " Restarting Machine for next CPU RAM test") restart_machine.restart() else: #print("Exiting BS from cpu ram") sikuliController.runSikuli(1) time.sleep(15) else: print("CPU and RAM Data recorded") #print("reading flag") with open(r'flags.json') as f: data = json.load(f) if data["fboot"]["CompletionFlag"] == 1 and data["sboot"][ "CompletionFlag"] == 1 and data["sboot_p"][ "CompletionFlag"] == 1 and data["cpuram"][ "CompletionFlag"] == 1: logging.info( str(datetime.datetime.now()) + " All test cases completed") emuDir = os.path.join(os.getcwd(), "Emulator") list = os.listdir(emuDir) with open(r'flags.json') as f: data = json.load(f) for i in range(1, len(list) + 1): #print("checking isFinished") flag = data["builds"][str(i)]["isFinished"] if flag == 0: #print("changing and resetting flags") data["builds"][str(i)]["isFinished"] = 1 data["fboot"]["CompletionFlag"] = 0 data["sboot"]["CompletionFlag"] = 0 data["sboot_p"]["CompletionFlag"] = 0 data["cpuram"]["CompletionFlag"] = 0 data["cpuram"]["firstRestart"] = 0 if i == len(list): data["builds"]["current"] = 1 elif i < len(list): data["builds"]["current"] += 1 break logging.info( str(datetime.datetime.now()) + " Resetting all flags after Build data recorded") #elif data["builds"]["2"]["isFinished"] == 0: # data["builds"]["2"]["isFinished"] = 1 # data["fboot"]["CompletionFlag"] = 0 # data["sboot"]["CompletionFlag"] = 0 # data["sboot_p"]["CompletionFlag"] = 0 # data["cpuram"]["CompletionFlag"] = 0 saveData() BluestacksUninstall.uninstall() print("Sleeping for Uninstall") time.sleep(20) with open(r'flags.json', 'w') as json_file: json.dump(data, json_file) if data["builds"]["1"]["isFinished"] == 1 and data["builds"]["2"][ "isFinished"] == 1: print("Finished readings for all builds") sys.exit(0) elif data["builds"]["1"]["isFinished"] == 1 and data["builds"]["2"][ "isFinished"] == 0: print("restarting") logging.info( str(datetime.datetime.now()) + " Restarting Machine to start testing next build") restart_machine.restart()
def SubBoot(perfCheck): with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json') as f1: data = json.load(f1) resultFilePath = r'results.json' if not os.path.isfile(resultFilePath): dataDump = {} with open(resultFilePath, 'w') as json_file: json.dump(dataDump, json_file) logging.info( str(datetime.datetime.now()) + " Created new results.json file") with open(r'C:\Users\Administrator\Desktop\perf_rc_suite\results.json' ) as f2: result = json.load(f2) logging.info( str(datetime.datetime.now()) + " Loaded previous results.json file") if not perfCheck: dictKey = "sboot" else: dictKey = "sboot_p" iterFlag = data[dictKey]["IterationFlag"] Iterations = data[dictKey]["TotalIterations"] isCompleted = data[dictKey]["CompletionFlag"] if iterFlag <= Iterations: try: #print("here1") #if isCompleted == 1: # return if isCompleted == 0: #print("here2") if stable_cpu.main(1, 30) == True: logging.info( str(datetime.datetime.now()) + " Checking for boot...") if not perfCheck: bootTime = bootCheck.startBootTest(1) #print("test false") else: bootTime = bootCheck.startBootTest(2) #print("test true") sikuliController.runSikuli(1) #bootTime = 42 if data[dictKey]["IterationFlag"] < data[dictKey][ "TotalIterations"]: data[dictKey]["IterationFlag"] += 1 logging.info( str(datetime.datetime.now()) + " Incrementing " + str(dictKey) + " iteration flag") with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) elif data[dictKey]["IterationFlag"] == data[dictKey][ "TotalIterations"]: data[dictKey]["IterationFlag"] = 1 data[dictKey]["CompletionFlag"] = 1 with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\flags.json', 'w') as json_file: json.dump(data, json_file) logging.info( str(datetime.datetime.now()) + " Changing Completion and resetting iteration flag for " + str(dictKey)) if iterFlag == 1: result.update({dictKey: {}}) result[dictKey].update({iterFlag: bootTime}) with open( r'C:\Users\Administrator\Desktop\perf_rc_suite\results.json', 'w') as json_file: json.dump(result, json_file) logging.info( str(datetime.datetime.now()) + " Updating " + str(dictKey) + " result of iteration " + str(iterFlag)) print("Sleeping for 15 seconds") time.sleep(15) else: print("All iterations completed") return (0) return (result) except Exception as e: print("CompletionFlag value corrupted; Error - " + str(e)) logging.info( str(datetime.datetime.now()) + " Error getting " + str(dictKey) + " result - " + str(e))