def execute(self,State): """ install linux build """ self.init(State) if self.logflag == True: self.logger.log(self.info) # 1.connect to Linux machine self = Command.getClient(self) if self.stat == self.FAILED: return self.FAILED #2. get official build path copyToPath = Command.checkPath(self.buildLocation)+self.buildNo+"/"+self.buildVersion+"/BIN/" print "version:"+self.buildVersion print "copyto path:" +copyToPath targetPath = Command.checkPath(self.buildInstallPath)+self.buildNo+"/"+self.buildVersion+"/" #3. check if copytopath and installpath exist if Command.checkPathExist(copyToPath,self.client) == False: self.stat = self.FAILED self.info = "can not open build folder, the test build may not be ready" if self.logflag == True: self.logger.log(self.info) return self.FAILED if Command.checkPathExist(self.buildInstallPath,self.client) == False: self.stat = self.FAILED self.info = "can not open build folder, please provide the right install path" if self.logflag == True: self.logger.log(self.info) return self.FAILED #4. Check if there are enough disk self = Command.getUnixOS(self) buildsize = Command.getFolderSize(self.client,copyToPath+self.OS); diskspace = Command.getDiskSpace(self.client,self.buildInstallPath) if int(diskspace) < int(buildsize): self.stat = self.FAILED self.info = "there is not enough disk space to install build, please clean the disk space" if self.logflag == True: self.logger.log(self.info) return self.FAILED #2. install build. cmd = "perl "+copyToPath+"copyto.pl "+targetPath result = Command.executeSsh(cmd, self.client) if result.lower().find("command not found") != -1: self.stat = self.FAILED self.info = "target build not found, please check if the build ready is ready" if self.logflag == True: self.logger.log(self.info) return self.FAILED else: self.stat = self.PASS self.info ="build install success: "+targetPath if self.logflag == True: self.logger.log(self.info) return self.PASS
def execute(self,State): """ download log file. """ self.init(State) if self.logflag == True: self.logger.log(self.info) self = Command.getClient(self) if self.stat == self.FAILED: return self.FAILED #get process id self = Command.getUnixOS(self) binpath = Command.checkPath(self.buildInstallPath)+self.buildNo+"/"+self.buildVersion+"/BIN/"+self.OS+"/bin/" getStatusCommnad = binpath+"mstrctl -s IntelligenceServer gs" statusInfo = Command.executeSsh(getStatusCommnad,self.client) xmlInfo = xml.dom.minidom.parseString(statusInfo) root=xmlInfo.documentElement process_id = "" node= root.getElementsByTagName('process_id')[0] for node in node.childNodes: process_id = node.data try: t=paramiko.Transport((self.server,22)) t.connect(username=self.serverLogin,password=self.serverPwd) sftp=paramiko.SFTPClient.from_transport(t) DSSErrorsFilesPath = Command.checkPath(self.buildInstallPath)+self.buildNo+"/"+self.buildVersion+"/BIN/"+self.OS+"/DSSErrors.log" DSSPerformanceFilesPath = Command.checkPath(self.buildInstallPath)+self.buildNo+"/"+self.buildVersion+"/BIN/"+self.OS+"/DSSPerformanceMonitor"+process_id+".csv" os.makedirs(self.localLogPath+self.buildNo+"/"+self.server) sftp.get(DSSErrorsFilesPath,self.localLogPath+self.buildNo+"/"+self.server+"/"+"DSSError.log") sftp.get(DSSPerformanceFilesPath,self.localLogPath+self.buildNo+"/"+self.server+"/"+"DSSPerformanceMonitor"+process_id+".csv") t.close() except Exception as e: self.stat = self.FAILED self.info ="log download failed"+str(e)+DSSErrorsFilesPath+DSSPerformanceFilesPath if self.logflag == True: self.logger.log(self.info) return self.FAILED self.stat=self.PASS self.info="download log file task has completed!" if self.logflag == True: self.logger.log(self.info) return self.PASS
def execute(self,State): """ Create DSN """ self.init(State) if self.logflag == True: self.logger.log(self.info) # 1.connect to Linux machine self = Command.getClient(self) if self.stat == self.FAILED: return self.FAILED #2.get odbc info self = Command.getOdbcInfo(self) if self.stat == self.FAILED: return self.FAILED #3.config dsn self = Command.getUnixOS(self) binpath = Command.checkPath(self.buildInstallPath)+self.buildNo+"/"+self.buildVersion+"/BIN/"+self.OS+"/bin/" for oif in self.odbcinfo["DSN"]: if oif["type"] == "SQLSERVER": self = Command.configSqlServerDSN(self,oif,binpath) if self.stat == self.FAILED: return self.FAILED elif oif["type"] == "ORCLW": self = Command.configOracleDSN(self,oif,binpath) if self.stat == self.FAILED: return self.FAILED self.stat = self.PASS self.info ="DSN created successfully" if self.logflag == True: self.logger.log(self.info) return self.PASS
def execute(self,State): """ monitor Linux server """ self.init(State) if self.logflag == True: self.logger.log(self.info) # 1.connect to Linux machine self = Command.getClient(self) if self.stat == self.FAILED: return self.FAILED # record time starttime = time.time() duration = 0 self = Command.getUnixOS(self) binpath = Command.checkPath(self.buildInstallPath)+self.buildNo+"/"+self.buildVersion+"/BIN/"+self.OS+"/bin/" getStatusCommnad = binpath+"mstrctl -s IntelligenceServer gs" # 2.monitor #check state :./mstrctl -s IntelligenceServer gs while duration < int(self.testTimeLimit)*60: #1. check if server crash #get server status statusInfo = Command.executeSsh(getStatusCommnad,self.client) xmlInfo = xml.dom.minidom.parseString(statusInfo) root=xmlInfo.documentElement process_id = "" node= root.getElementsByTagName('process_id')[0] for node in node.childNodes: process_id = node.data state = "" node= root.getElementsByTagName('state')[0] for node in node.childNodes: state = node.data if state.lower().find("stopped") != -1 : self.stat = self.FAILED self.info ="iserver is stopped, please check if server crashed" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+": "+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED elif state.lower().find("starting")!= -1: self.info ="iserver is starting" elif state.lower().find("running")!= -1: self.info ="iserver is running fine." elif state.lower().find("stopping")!= -1: self.stat = self.FAILED self.info ="iserver is stopping, please check if server crashed" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+": "+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED elif state.lower().find("terminated")!= -1: self.stat = self.FAILED self.info ="iserver is terminated, please check if server crashed" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+": "+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED elif state.lower().find("pausing")!= -1: self.stat = self.FAILED self.info ="iserver is pausing, please check if server crashed" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+": "+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED elif state.lower().find("paused")!= -1: self.stat = self.FAILED self.info ="iserver is paused, please check if server crashed" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+": "+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED elif state.lower().find("resuming")!= -1: self.info ="iserver is resuming, please check if server crashed" elif state.lower().find("hanging")!= -1: self.stat = self.FAILED self.info ="iserver is hanging, please check if server crashed" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+": "+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED #2. check if server hit assertion screeninfo = self.getScreenInfo() if screeninfo.lower().find("assertion") != -1: self.stat = self.FAILED self.info = "iserver hit assertion" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+"hit assertion:"+screeninfo, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.FAILED # print duration # print self.info # print state time.sleep(int(self.testCheckTime)*60) currenttime = time.time() duration = int(currenttime-starttime) self.stat=self.PASS self.info="monitor Linux iserver task has completed!" if self.logflag == True: self.logger.log(self.info) if self.emailflag == True: es = EmailSender(self.emailSender, self.server+self.info, self.server+": "+self.info,self.emailToList, "","", attachment=None) es.send() return self.PASS
def execute(self, State): """ configure the performance counter and log size """ self.init(State) if self.logflag == True: self.logger.log(self.info) # 1.connect to Linux machine self = Command.getClient(self) if self.stat == self.FAILED: return self.FAILED # regpath = "/build/MSITEST/Test_MSIReg.reg" self = Command.getUnixOS(self) regpath = ( Command.checkPath(self.buildInstallPath) + self.buildNo + "/" + self.buildVersion + "/BIN/" + self.OS + "/MSIReg.reg" ) # 2. backup the files self = Command.backupFiles(self, regpath) if self.stat == self.FAILED: return self.FAILED # 3. add missed counters self = Command.getMsiregInfo(self) for modi in self.msiModifyInfo["Reg"]: if modi["type"] == "append": self = Command.sedAppend(self, modi["oldstr"], modi["newstr"], regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED elif modi["type"] == "replace": self = Command.sedReplace(self, modi["oldstr"], modi["newstr"], regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED elif modi["type"] == "insert": self = Command.sedInsert(self, modi["oldstr"], modi["newstr"], regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED elif modi["type"] == "update": self = Command.sedDelete(self, modi["oldstr"], modi["endstr"], regpath) self = Command.sedInsert(self, modi["nextstr"], modi["newstr"], regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED # 4.set output log to null:sed 's/"DebugOutput"=""//g' MSIReg.reg > MSIReg.tmp self = Command.sedReplace(self, '"DebugOutput"=""', "", regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED # 5.change size of DSSError.log:sed 's/"MaxSize"=dword:00000800/"MaxSize"=dword:00032000/g' self = Command.sedReplace(self, '"MaxSize"=dword:00000800', '"MaxSize"=dword:00032000', regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED # 6.change size of DSSPerformance.log;sed 's/"MaxSize"=dword:000007d0/"MaxSize"=dword:00032000/g' self = Command.sedReplace(self, '"MaxSize"=dword:000007d0', '"MaxSize"=dword:00032000', regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED # 8.set DSSPerformance counters:sed 's/"Persist"=dword:00000000/"Persist"=dword:00000001/g' for modi in self.msiModifyInfo["Perf"]: if modi["AllPerfOn"] == "true": self = Command.sedReplace(self, '"Persist"=dword:00000000', '"Persist"=dword:00000001', regpath) if self.stat == self.FAILED: Command.restoreFiles(self, regpath) return self.FAILED self.stat = self.PASS self.info = "Linux diag configure successfully" if self.logflag == True: self.logger.log(self.info) return self.PASS