def checkReady(cid): hostname = config.client port = config.port username = config.username password = config.password cmd = "nohup kubectl --context " + config.context + " -n " + config.namespace + " port-forward `kubectl --context " + config.context + " -n " + config.namespace + " get pods |grep proxy|head -1|cut -d ' ' -f 1` 5555 > nohup.out 2> nohup.err < /dev/null &" ssh.ssh2(hostname, port, username, password, cmd) cmd = "curl --basic -u dataplaneapi:changeit http://127.0.0.1:5555/v2/services/haproxy/configuration/raw | jq -r .data" stdout = ssh.ssh2(hostname, port, username, password, cmd, ignore_error=True) str_out = stdout.decode("utf-8") #print(str_out) reg = r'[A-Fa-f0-9]{80,}' list_hex = re.findall(reg, str_out) print(list_hex) for hex_str in list_hex: cid1 = bytes.fromhex(hex_str).decode("ASCII") print("CID:" + cid1) if (cid == cid1): print("ready") return True return False
def read_pickle(self, filename): if not (os.path.exists('./result/{}'.format(filename))): # Ssh.getall('./result','./result') Ssh.get(local='./result/{}'.format(filename), server='./result/{}'.format(filename)) with open('./result/' + filename, 'rb') as file: P = pickle.load(file) return P
def runSftpTest(duration): # Declare Module-Scope variables global threadLock global testPassOrFail # Initialize variables threadPassOrFail = True # run Sftp test startTime = time.time() totalTestTime = startTime + duration while time.time() < totalTestTime: # Put file in target (host) file path sftpPassOrFail = Ssh.sftpPutFile(Config.mixedTrafficStressLocalFilePath, \ Config.mixedTrafficStressHostFilePath) if sftpPassOrFail: UtilLogger.verboseLogger.info("MixedTrafficStressTest.runSftpTest: " + \ "successfully put file via Sftp.") else: UtilLogger.verboseLogger.error("MixedTrafficStressTest.runSftpTest: " + \ "failed to put file via Sftp. Local path: " + \ Config.mixedTrafficStressLocalFilePath + " Host path: " + \ Config.mixedTrafficStressHostFilePath) threadPassOrFail &= sftpPassOrFail # Remove file from target (host) file path sftpPassOrFail = Ssh.sftpRemoveFile( Config.mixedTrafficStressHostFilePath) if sftpPassOrFail: UtilLogger.verboseLogger.info("MixedTrafficStressTest.runSftpTest: " + \ "successfully removed file via Sftp.") else: UtilLogger.verboseLogger.error("MixedTrafficStressTest.runSftpTest: " + \ "failed to remove file via Sftp. Host path: " + \ Config.mixedTrafficStressHostFilePath) threadPassOrFail &= sftpPassOrFail # Sleep for 100 milliseconds time.sleep(0.1) if threadPassOrFail: UtilLogger.verboseLogger.info("MixedTrafficStressTest.runSftpTest: " + \ "runSftpTest passed.") else: UtilLogger.verboseLogger.info("MixedTrafficStressTest.runSftpTest: " + \ "runSftpTest failed.") # Update testPassOrFail threadLock.acquire() testPassOrFail &= threadPassOrFail threadLock.release() return
def test_co(access_token: str, protocole: str, users: list, passwords: list): """Test the server provided in access_token with every user""" global LOGGER if protocole == 'ftp': Ftp.ftp_test(LOGGER, access_token, users, passwords) if protocole == 'http': Http.http_test(LOGGER, access_token, users, passwords) if protocole == 'ssh': Ssh.ssh_test(LOGGER, access_token, users, passwords) if protocole == 'sftp': Ssh.ssh_test(LOGGER, access_token, users, passwords, True)
def undeployment(cid): #cmd = "export PATH=$PATH:/home/jmeter/go/bin/; cd /var/www/html/tony/analysis/asr-config-server-tester; " #cmd+="./undeploy-request.sh " + cid cmd = 'echo "/var/www/html/tony/analysis/asr-config-server-tester/undeploy-request.sh ' + cid + '"|at -m now + 1 minute' hostname = config.client port = config.port username = config.username password = config.password print("undeploy:" + cid) ssh.ssh2(hostname, port, username, password, cmd) print("undeploy issued")
def _GetAndUnZip(): Logs = None FuncPassOrFail = True try: if _CheckSnapshotFile(): # Try get log-snapshot.zip on BMC getPassOrFail = Ssh.sftpGetFile(hostFilePath='/var/wcs/home/log-snapshot.zip', \ localFilePath='./log-snapshot.zip') if not getPassOrFail: UtilLogger.verboseLogger.info( "%s: Get log-snapshot.zip via sftp failed!" % (fileName)) return False, Logs # Try delete log-snapshot.zip on BMC DeletePassOrFail = Ssh.sftpRemoveFile( hostFilePath='/var/wcs/home/log-snapshot.zip') if not DeletePassOrFail: UtilLogger.verboseLogger.info("%s: Delete log-snapshot.zip on BMC via sftp failed!" \ %(fileName)) return False, Logs else: UtilLogger.verboseLogger.info\ ("%s: log-snapshot.zip doesn't create on BMC. Failed with timeout" %(fileName)) return False, Logs # Unzip log file LogZipFile = zipfile.ZipFile('./log-snapshot.zip', 'r') LogZipFile.extractall('./') FilePath = LogZipFile.namelist() LogZipFile.close() with open('./' + FilePath[0]) as LogFile: Logs = LogFile.readlines() if not Logs: FuncPassOrFail = False # Delete temparary files os.remove('./log-snapshot.zip') shutil.rmtree('./var') except Exception as e: UtilLogger.verboseLogger.error("%s: _GetAndUnZip() failed with %s" % (fileName, str(e))) FuncPassOrFail = False return FuncPassOrFail, Logs
def _PowerOnOffByRackManager(PowerSwitch, RMSlotNumber=Config.BMCSlotIDOnRM, RackManagerIP=Config.RackManagerIPAddress,\ RMUsername=Config.RackManagerUsername, RMPasswaord=Config.RackManagerPassword): if (not RMSlotNumber) or (not RackManagerIP) or (not RMUsername) or ( not RMPasswaord): UtilLogger.verboseLogger.info(\ "%s: Some of rack manager arguments in Config.py are empty. Failed to execute rack manager command!" %(fileName)) return False, None # Initial command execCmds = ['\n'] execCmds.append('wcscli setpower' + PowerSwitch + ' -i ' + str(RMSlotNumber) + '\n') try: execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand(execCmds,\ username=RMUsername, password=RMPasswaord, connectAddress=RackManagerIP) # Parcing log number if execPassOrFail: tokens = sshOutputs[1].split() for word in tokens: if word == 'Success:': return True, sshOutputs[1] else: UtilLogger.verboseLogger.info( "%s: Execute PowerOnOff commmand failed" % (fileName)) except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e)))
def _CheckExpanderRollOver(ExpanderID): global ExpanderSshResponseLimit # Initial command execCmds = ['test oem2'] execCmds.append('\r') try: execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand(execCmds,\ username=Config.bmcUser, password=Config.bmcPassword, port=Config.J2010sshPorts[ExpanderID-1], sshResponseLimit=ExpanderSshResponseLimit) # Find "log is full:1" message if execPassOrFail: tokens = sshOutputs[1].split() for line in tokens: Keyword = line.split(':') if Keyword[0] == "full": if Keyword[1] == '1': return True else: return False else: UtilLogger.verboseLogger.info( "%s: Failed to get Expander %s rollover status" % (fileName, ExpanderID)) except Exception as e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) return False
def Execute(interfaceParams): global cmdPassOrFail, fileName username = Config.bmcUser password = Config.bmcPassword # Define Test variables response = None execCmds = ['\n'] # execCmds.append('\nhelp\n') # Help command execCmdsResponse = "GNU bash" UtilLogger.verboseLogger.info("%s: running Execute" % (fileName)) UtilLogger.verboseLogger.info( "SSH executing commands %s with username %s and password %s" % (execCmds, username, password)) (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand(execCmds, username, password) cmdPassOrFail &= execPassOrFail if (execPassOrFail): for sshOutput in sshOutputs: if execCmdsResponse in sshOutput: UtilLogger.verboseLogger.info( "%s: successfully found '%s' in response" % (fileName, execCmdsResponse)) cmdPassOrFail = True if (not execPassOrFail): UtilLogger.verboseLogger.error("%s: failed to find '%s' in response" % (fileName, execCmdsResponse)) return cmdPassOrFail
def _CheckSnapshotFile(): # Initial command execCmds = ['\n'] execCmds.append('cd /var/wcs/home\n') execCmds.append('ls | grep log-snapshot.zip\n') getFilePassOrFail = False StartTime = time.time() MaxTimeout = 30 while not getFilePassOrFail and (time.time() - StartTime) < MaxTimeout: try: execPassOrFail, sshOutputs, parsedCmdOutputs = \ Ssh.sshExecuteCommand(execCmds) # Check Ssh command respose if execPassOrFail: if sshOutputs[-1].split()[0] == 'log-snapshot.zip': getFilePassOrFail = True else: UtilLogger.verboseLogger.info( "%s: Check Snapshot File failed" % (fileName)) except Exception as e: UtilLogger.verboseLogger.error\ ("%s: CheckSnapshotFile failed. Exception: %s" %(fileName, str(e))) return getFilePassOrFail
def Execute(interfaceParams): ExpanderBinFile = Config.expanderBinFilePath connection = Connection() testPassOrFail = True try: expandFilePath = _GetFirmwareImageName(ExpanderBinFile) if not expandFilePath: return False for seId in Config.J2010allSeIDs: UtilLogger.verboseLogger.info( "================Expander %s================" % (seId)) # Update the Firmware execPassOrFail = UpdateFWwithMonitorCPU(expandFilePath, connection.auth, connection.port, connection.auth[0], connection.auth[1], seId) if execPassOrFail: UtilLogger.verboseLogger.info( "%s: Expander %s update success!" % (fileName, seId)) execCmds = ['\n'] execCmds.append("cat /var/wcs/home/CPU.txt\n") execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand( execCmds, username=connection.auth[0], password=connection.auth[1]) # Check CPU utilization if execPassOrFail: # CPU utilization matches 70%-199% regexPattern = r"([7-9]\d|1\d{2})%" regex = re.compile(regexPattern) matches = regex.findall(sshOutputs[-1]) if not matches: UtilLogger.verboseLogger.info( "%s: CPU utilization passed!" % (fileName)) else: maxCPU = max(matches) UtilLogger.verboseLogger.error( "%s: failed: CPU utilization goes pass 70 percent. CPU utilization up to %s percent." % (fileName, maxCPU)) testPassOrFail = False else: UtilLogger.verboseLogger.error( "%s: failed to monitor CPU utilization during update." % (fileName)) testPassOrFail = False else: UtilLogger.verboseLogger.info( "%s: Expander #%s update failed!" % (fileName, seId)) testPassOrFail = False continue except Exception, e: UtilLogger.verboseLogger.error(fileName + ": Test failed with exception - " + str(e)) testPassOrFail = False
def _CheckExpanderDiskNumber(ExpanderID): global ExpanderSshResponseLimit # Initial command execCmds = ['status'] execCmds.append('\r') RegexPattern = "^Disk\[[0-9]{2}\] status : \[Present\]" regexCompile = re.compile(RegexPattern, re.L) DiskCounter = 0 ExpanderStatusResponseSize = 4096 try: execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand(execCmds,\ username=Config.bmcUser, password=Config.bmcPassword, port=Config.J2010sshPorts[ExpanderID-1], \ sshResponseLimit=ExpanderSshResponseLimit, sshResponseSize=ExpanderStatusResponseSize) # Find Present Disk if execPassOrFail: tokens = sshOutputs[1].split('\n') for line in tokens: m = regexCompile.match(line) if m: DiskCounter += 1 return DiskCounter else: UtilLogger.verboseLogger.info( "%s: Failed to get Expander %s status" % (fileName, ExpanderID)) except Exception as e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) return 0
def _CheckExpanderLogNumber(ExpanderID): global ExpanderSshResponseLimit # Initial command execCmds = ['test oem2'] execCmds.append('\r') try: (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand(execCmds, username=Config.bmcUser,\ password=Config.bmcPassword, port=Config.J2010sshPorts[ExpanderID-1], sshResponseLimit=ExpanderSshResponseLimit) # Parsing log number if execPassOrFail: tokens = sshOutputs[1].split() for line in tokens: Keyword = line.split(':') if Keyword[0] == "offset": LogNumber = int(Keyword[1]) / 8 return True, LogNumber break else: UtilLogger.verboseLogger.info( "%s: Excute get expander log number command failed" % (fileName)) except Exception as e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) return False, 0
def runTestTokenize(namespace, listCid, url): allGood = True results = [] for cidItem in listCid: cid = list(cidItem)[0] language = cidItem.get(cid) cwd = "/var/www/html/MonitorAsr" #os.getcwd() command = "date +%s.%N;" command += "cd " + cwd + "/cars-server-grpc-testers;" command += "sed 's/{{CID}}/" + cid + "/' Tokenize.sentence01.json >Tokenize.sentence01ConfigReplaced.json;" command += 'sh grpcurl-tokenize.sh ' + url + ' 443 ' command += ";date +%s.%N;" hostname = config.client port = config.port username = config.username password = config.password start = time.time() stdout = ssh.ssh2(hostname, port, username, password, command) logging.info(stdout) end = time.time() str_out = stdout.decode("utf-8") elapse = getElapse(str_out) result = [] result.append(namespace) result.append("Tokenize") result.append(url) result.append(cid) result.append(language) sessionId = helper.getString(str_out, 'cerence-session-id:', ' ') elaspeDiff = checkElapse(elapse, elapseThreshold_tokenize, language) if (elaspeDiff < 0 or elapse == 999999): resultPassFail = checkTps(language, str_out, 'tokens') if (elapse == 999999 or resultPassFail == 'FAIL'): allGood = False result.append(resultPassFail) results.append(result) result.append(elapse) result.append(sessionId) else: resultPassFail = checkTps(language, str_out, 'tokens') if (resultPassFail == 'FAIL'): result.append("FAIL") results.append(result) result.append(elapse) result.append("HIGH CPL AND FAILED:" + sessionId) allGood = False else: if 'dev' in namespace: result.append("PASS") else: result.append("FAIL") allGood = False results.append(result) result.append(elapse) result.append("HIGH CPL:" + sessionId) return results, allGood
def ValidateGPIOslotID(expectedData): global gpioTestPassOrFail, fileName global GPIOLen try: # remove two bits (bits [5:0] in the response) IPMISlotIDdataFilter = expectedData & 0x3f # incode to GPIO slot ID (PMDU_NODE_INCODE dictionary) SlotIdIncode = PMDU_NODE_INCODE.get(IPMISlotIDdataFilter) # GPIO slot ID binary bits GPIOSlotIDBin = "{0:06b}".format(SlotIdIncode) GPIOSlotID = list(GPIOSlotIDBin) # read slot id gpio definition from getgpioslotid.xml xmlParserObj = XmlParser.XmlParser(Config.J2010getGpioSlotIDFilePath) if not xmlParserObj.root: UtilLogger.verboseLogger.error(("[GPIOgetTest error]%s: failed to parse Xml file. Will not execute test." %(fileName))) return False gpioTestPassOrFail = True GPIOLen = len(GPIOSlotID) # Verify Get GPIO for each GPIO number listed in XML for gpioInfo in xmlParserObj.root: signal = gpioInfo.attrib['signal'] gpio_pin = gpioInfo.attrib['gpio_pin'] UtilLogger.verboseLogger.info("[GPIOgetTest info]%s: running Execute for Signal %s and gpio_pin %s" %(fileName, signal, gpio_pin)) execCmds = ['\n'] execCmds.append("gpioutil -p %s\n" %(gpio_pin)) expectedSlotId = GPIOSlotID[GPIOLen-1] regexPattern = r'(\d)\s+j2010' (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand( execCmds, username=Config.bmcUser, password=Config.bmcPassword, expectedOutput = expectedSlotId, regExpPattern = regexPattern ) gpioTestPassOrFail &= execPassOrFail if (execPassOrFail): #timeout or channel not ready, it don't judge the result correct or not actualSlotId = parsedCmdOutputs if not actualSlotId: UtilLogger.verboseLogger.error("%s: Signal Slot ID failed: Actual Slot Id was returned an empty string" %(fileName)) gpioTestPassOrFail = False if (actualSlotId == expectedSlotId): UtilLogger.verboseLogger.info("%s: Signal Slot ID successful: '%s'; Slot ID value: %s" %(fileName, signal, parsedCmdOutputs)) else: UtilLogger.verboseLogger.error("%s: failed: %s slot ID is not correct " %(fileName, signal)) gpioTestPassOrFail = False else: UtilLogger.verboseLogger.error("%s: failed to find '%s' in response" %(fileName, signal)) gpioTestPassOrFail = False GPIOLen = GPIOLen-1 except Exception, e: UtilLogger.verboseLogger.error( fileName + ": Test failed with exception - " + str(e)) gpioTestPassOrFail = False
def deployment(cid): cmd = "export PATH=$PATH:/home/jmeter/go/bin/; cd /var/www/html/tony/analysis/asr-config-server-tester; " cmd += "./deploy-request.sh " + cid hostname = config.client port = config.port username = config.username password = config.password stdout = ssh.ssh2(hostname, port, username, password, cmd) print(stdout) return stdout
def Execute(interfaceParams): global testPassOrFail, fileName # Parse Get Gpio List xml file try: xmlParserObj = XmlParser.XmlParser(Config.G50getGpioListFilePath) if not xmlParserObj.root: UtilLogger.verboseLogger.error(("%s: failed to parse Xml file. Will not execute test." %(fileName))) return False testPassOrFail = True # Verify Get GPIO for each GPIO number listed in XML for gpioInfo in xmlParserObj.root: testPassOrFail &= True signal = gpioInfo.attrib['signal'] theDirection = [] theDirection = gpioInfo.attrib['direction'].split(',') expectedDirection = theDirection[0] UtilLogger.verboseLogger.info("%s: running Execute for Signal %s" %(fileName, signal)) execCmds = ['\n'] execCmds.append("gpioutil -n %s\n" %(signal)) # Get GPIO Pin Direction regexPattern = r"DIRECTION: (\w+)" (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand( execCmds, username=Config.bmcUser, password=Config.bmcPassword, expectedOutput = expectedDirection, regExpPattern = regexPattern ) testPassOrFail &= execPassOrFail if (execPassOrFail): actualDirection = parsedCmdOutputs if not actualDirection: UtilLogger.verboseLogger.error("%s: Signal Direction failed: Actual Direction was returned an empty string" %(fileName)) testPassOrFail = False continue # Note: pinDirection may contain several directions, seperated by # a comma (i.e. "in,falling") pinDirections = expectedDirection.split(',') for pinDirection in pinDirections: # Validate GPIO pin direction if pinDirection.strip() == actualDirection: UtilLogger.verboseLogger.info("%s: Signal Direction successful: '%s'; Direction: %s" %(fileName, signal, actualDirection)) break if pinDirection == pinDirections[-1]: UtilLogger.verboseLogger.error("%s: Signal Direction failed : '%s'; Actual Direction: %s; Expected Direction(s): %s" %(fileName, signal, actualDirection, ','.join(pinDirections))) testPassOrFail = False else: UtilLogger.verboseLogger.error("%s: failed to find '%s' in response" %(fileName, signal)) testPassOrFail = False except Exception, e: UtilLogger.verboseLogger.error( fileName + ": Test failed with exception - " + str(e)) testPassOrFail = False
def test_demo(testCase, nodeIp): urls = [(GET, '/url1'), (POST, '/url2'), (GET, '/url3')] #SSH handles for SUT resobj1 = Ssh(nodeIp['IP1'], 'admin', 'admin') resobj2 = Ssh(nodeIp['IP2'], 'admin', 'admin') #start monitoring parallely cpuResObj1 = cpuMonitoring(resobj1)) cpuResObj2 = cpuMonitoring(resobj2)) memoryResObj1 = memoryMonitoring(resobj1)) memoryResObj2 = memoryMonitoring(resobj2)) #getting authentication done and storing token authObj = RestAuthentication('1.1.1.1', 'rajesh', 'kumar') #sending query for url in urls: func = authObj.call_http response = authObj.call_http(url[0], url[1]) if response.ok: LOGGER.info('query is successfull. Output is {output}. Time taken to run query is {time} '.format(output=response, time=timeit.timeit(func,1) )) else : LOGGER.error('Query Failed') #stopping monitoring cpuOutput1 = cpuResObj1.stop_monitoring() cpuOutput2 = cpuResObj2.stop_monitoring() memoryOutput1 = memoryResObj1.stop_monitoring() memoryOutput2 = memoryResObj2.stop_monitoring() #printing Memory and CPU Data LOGGER.info('Memory Data for Node 1: {memoryData}'.format(memoryData=memoryOutput1)) LOGGER.info('CPU DATA for Node 1: {cpudata}'.format(cpudata=cpuOutput1)) #Same for Node 2 LOGGER.info('Memory Data for Node 2: {memoryData}'.format(memoryData=memoryOutput1)) LOGGER.info('CPU DATA for Node 2: {cpudata}'.format(cpudata=cpuOutput2))
def authorized_keys_generate(port, remotepath, localpath, target_path): f = open("conf/hostname.txt") if os.path.exists(target_path): shutil.rmtree(target_path) os.mkdir(target_path) else: os.mkdir(target_path) while True: line = f.readline() if line: ini_line = line.split(':', 3) c = map(string.strip, ini_line) hostname = c[0] username = c[1] password = c[2] # sftp file to remote s = Sftp.Sftp(hostname=hostname, username=username, password=password, port=port, localpath=localpath, remotepath=remotepath) s.sftpput() #remote gernerakey path = remotepath + "/" + localpath cmd1 = "/usr/bin/python /tmp/gernerRSAkey/gernerakey.py" ssh_file_path = os.path.expanduser('~') + "/" + ".ssh" #ssh=Ssh.Ssh(hostname,username,password,cmd1,cmd2) ssh = Ssh.Ssh(hostname, username, password, cmd1) ssh.sshconnect() #copy remote authorized_keys user = '******' + username s = Sftp.Sftp(hostname=hostname, username=username, password=password, port=port, localpath=localpath, remotepath=remotepath) src = os.path.expanduser(user) + "/.ssh/authorized_keys" target = target_path + '/%s' % (hostname) s.sftpget(src, target) else: break f.close()
def Execute(interfaceParams): global cmdPassOrFail, fileName # Define Test variables cmdPassOrFail = True response = None # Specify Expander Board to Power On data = {"ResetType":"ForceOn"} # Update the specified Storage Enclosure field # Define Test variables try: for seId in Config.J2010allSeIDs: postResource = 'redfish/v1/Chassis/System/StorageEnclosure/%s/Actions/Chassis.Reset' %(seId) # Send REST Post request (execPassOrFail, response) = RedFish.PostResourceValues( postResource, data ) cmdPassOrFail &= execPassOrFail if(cmdPassOrFail == False ): UtilLogger.verboseLogger.error("%s: Powering ON the board on seId %d failed with response %s" %(fileName, seId, response)) return False execCmds = ['\r'] # execCmds.append('\rhelp\r') # Help command execCmdsResponse = "CLI Help" for sshPort in Config.J2010sshPorts: UtilLogger.verboseLogger.info("%s: running Execute for Port %s" %(fileName, sshPort)) (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand( execCmds, Config.bmcUser, Config.bmcPassword, sshPort ) if (execPassOrFail): for sshOutput in sshOutputs: if execCmdsResponse in sshOutput: UtilLogger.verboseLogger.info("%s: successfully found '%s' in response" %(fileName, execCmdsResponse)) cmdPassOrFail = True if (not execPassOrFail): UtilLogger.verboseLogger.error("%s: failed to find '%s' in response" %(fileName, execCmdsResponse)) cmdPassOrFail = False except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" %(fileName, str(e))) return False
def Execute(interfaceParams): global cmdPassOrFail # Define Test variables cmdPassOrFail = False HWaddr = None interface = "eth0" regexPattern = "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" execCmds = ['\n'] execCmds.append("ifconfig %s\n" %(interface)) try: # Get MAC Address (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand(execCmds, username=Config.bmcUser, password=Config.bmcPassword) # Search ALL lines in response from the HWaddr if (execPassOrFail): for sshOutput in sshOutputs: if "HWaddr" in sshOutput: tokens = sshOutput.split("HWaddr") HWaddr = tokens[1].split()[0] # Validate the address regexCompile = re.compile(regexPattern) m = regexCompile.match(HWaddr) if (m): UtilLogger.verboseLogger.info("%s: MAC Address: %s" %(fileName, HWaddr)) cmdPassOrFail = True else: UtilLogger.verboseLogger.error("%s: invalid MACAddr format - %s" %(fileName, HWaddr)) # FIXME - Compare value to EEPROM if (not HWaddr): UtilLogger.verboseLogger.error("%s: failed to find MACAddr in response" %(fileName)) except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" %(fileName, str(e)))
def runSftpTest(duration): # Declare Module-Scope variables global threadLock global testPassOrFail # Initialize variables threadPassOrFail = True # run Sftp test startTime = time.time() totalTestTime = startTime + duration try: while time.time() < totalTestTime: # Put file in target (host) file path sftpPassOrFail = Ssh.sftpPutFile(localFilePath, theHostPath, Config.bmcUser, Config.bmcPassword) if sftpPassOrFail: UtilLogger.verboseLogger.info( "MixedTrafficStressTest.runSftpTest: successfully put file via Sftp." ) else: UtilLogger.verboseLogger.error( "MixedTrafficStressTest.runSftpTest: failed to put file via Sftp. Local path: " + localFilePath + ": Host path: " + theHostPath) threadPassOrFail &= sftpPassOrFail # Remove file from target (host) file path sftpPassOrFail = Ssh.sftpRemoveFile(theHostPath, Config.bmcUser, Config.bmcPassword) if sftpPassOrFail: UtilLogger.verboseLogger.info( "MixedTrafficStressTest.runSftpTest: successfully removed file via Sftp." ) else: UtilLogger.verboseLogger.error( "MixedTrafficStressTest.runSftpTest: failed to remove file via Sftp. Host path: " + Config.G50MixedTrafficStressHostFilePath) threadPassOrFail &= sftpPassOrFail # Sleep for 100 milliseconds time.sleep(0.1) if threadPassOrFail: UtilLogger.verboseLogger.info( "MixedTrafficStressTest.runSftpTest: runSftpTest passed.") else: UtilLogger.verboseLogger.info( "MixedTrafficStressTest.runSftpTest: runSftpTest failed.") # Update testPassOrFail threadLock.acquire() testPassOrFail &= threadPassOrFail threadLock.release() except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) threadLock.acquire() testPassOrFail = False threadLock.release()
def SshBootToBMCStartScreenTest(startTime = None, username = None, password = None, ptrn = None ): # Initialize variables bootToBMCStartTime = None bootToBMCEndTime = -1 testPassOrFail = True # Define start time if startTime is None: bootToBMCStartTime = time.time() else: bootToBMCStartTime = startTime try: # Import Ssh Module import Ssh # Initialize SSH Client sshPassOrFail, ssh = Ssh.sshInit( username, password ) if sshPassOrFail: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "successfully created SSH Client.") else: UtilLogger.verboseLogger.error("SshBootToBMCStartScreenTest: " + \ "failed to create SSH Client.") return False # SSH Client Init successful # Check for any character via SSH until max limit # bootToBMCStartScreenLimitInSeconds # Invoke Shell (default terminal: vt100) channel = ssh.invoke_shell() # Verify successful SSH connection with BMC sentBytes = channel.send('\n') time.sleep(Config.sshResponseLimit) # wait <sshResponseLimit> seconds sshOut = channel.recv(2024)[sentBytes:] if Config.debugEn: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "ssh output: " + str(sshOut)) # Check for BMC start screen via SSH bootToBMCPassOrFail = False UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "checking for BMC start screen.") while (time.time() - bootToBMCStartTime) <= int(Config.bootToBMCStartScreenLimitInSeconds): outputStr = None # Verify successful SSH connection with BMC sentBytes = channel.send('\n') time.sleep(5) # wait 5 seconds sshOut = channel.recv(2024)[sentBytes:] if Config.debugEn: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: channel out: " + str(sshOut)) if( ptrn != None ): outputStr = regExpParser( sshOut, ptrn, ptrn ) if( outputStr == ptrn ): UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "BMC booted to login on console, with the following output: " + \ str(sshOut) + " and after " + str(bootToBMCEndTime) + \ " seconds.") bootToBMCPassOrFail = True break testPassOrFail &= bootToBMCPassOrFail # Verify bootToBiosPassOrFail is false if not bootToBMCPassOrFail: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "unable to detect boot to BMC start screen after " + \ str(Config.bootToBMCStartScreenLimitInSeconds) + \ " seconds.") # Close SSH Session closePassOrFail = Ssh.sshClose(ssh) if closePassOrFail: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "successfully closed SSH session.") else: UtilLogger.verboseLogger.error("SshBootToBMCStartScreenTest: " + \ "failed to close SSH session.") if testPassOrFail: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "test to detect BMC Start Screen via SSH passed.") else: UtilLogger.verboseLogger.info("SshBootToBMCStartScreenTest: " + \ "test to detect BMC Start Screen via SSH failed.") except Exception, e: UtilLogger.verboseLogger.error("SshBootToBMCStartScreenTest: " + \ "exception occurred: " + str(e)) testPassOrFail = False
def GetFileSystemUsage(dir): global testPassOrFail # Define Test variables fs = None totalBlocks = None blocksUsed = None blocksAvailable = None percentInUse = None mountedOn = None dfOutput = [] sshOutput = [] threshold = Config.folderThresholdPercent # In percent username = Config.bmcUser password = Config.bmcPassword execCmds = ['\n'] execCmds.append("df -k %s\n" % (dir)) try: # Get Filesystem usage expected = str(dir.split('/')[1]) regexPattern = r"([\w+]+)" (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand(execCmds, username, password, expectedOutput=expected, regExpPattern=regexPattern) if (not execPassOrFail): UtilLogger.verboseLogger.error( "%s: command = \"df -k %s\" failed to get file system usage on '%s'" % (fileName, dir, dir)) execPassOrFail &= False return (execPassOrFail) """ Sample df response Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 94822236 87277364 2705156 97% / """ # Parse dk response sshOutput = sshOutputs[-1] header = sshOutput.split('\r')[0].split() dfOutput = sshOutput.split('\r')[1].split() # Parse df response if (len(sshOutputs) >= 2): sshOutput = sshOutputs[1] header = sshOutput.split('\r')[0].split() dfOutput = sshOutput.split('\r')[1].split() if (len(dfOutput) >= 6): fs = dfOutput[0] totalBlocks = dfOutput[1] blocksUsed = dfOutput[2] blocksAvailable = dfOutput[3] percentInUse = dfOutput[4].replace('%', '') mountedOn = dfOutput[5] else: UtilLogger.verboseLogger.error( "%s: failed to parse file system usage on '%s, len(sshOutputs) = %d'\n sshOutputs = %s" % (fileName, dir, len(sshOutputs), str(sshOutputs))) execPassOrFail &= False return (execPassOrFail) execCmds = ['\n'] execCmds.append("du -s %s\n" % (dir)) # Get Filesystem usage (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand(execCmds, username, password, expectedOutput=expected, regExpPattern=regexPattern) if (not execPassOrFail): UtilLogger.verboseLogger.error( "%s: command = \"du -s %s\" failed to get disk usage on '%s'" % (fileName, dir, dir)) execPassOrFail &= False return (execPassOrFail) """ Sample du response 999999 . """ # Parse du response directory = None blocks = None sshOutput = sshOutputs[-1] duOutput = sshOutput.split('\r')[0].split() if len(duOutput): blocks = duOutput[0] directory = duOutput[1] else: UtilLogger.verboseLogger.error( "%s: failed to parse disk usage on '%s'. len(duOutput) = %d\n sshOutputs = %s" % (fileName, dir, len(duOutput), str(sshOutputs))) execPassOrFail &= False return (execPassOrFail) UtilLogger.verboseLogger.info( "%s: FileSystem: %-20s Mount: %-20s InUse: %2d%% Blocks: %s" % (fileName, fs, mountedOn, int(percentInUse), blocks)) # Verify if the threshold has been exceeded if (int(percentInUse) >= threshold): UtilLogger.verboseLogger.error( "%s: Directory '%s' disk usage of %s%% exceeds threshold of %s%%" % (fileName, directory, percentInUse, threshold)) execPassOrFail &= False except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) testPassOrFail = False
def _CreateFakeLog(): global ExpanderSshResponseLimit cmdPassOrFail = True # Fake Expander Log command execCmds = ['test 100'] execCmds.append('\r') # Clear Expander Log command ClearLogCmds = ['syslog clr'] ClearLogCmds.append('\r') MaxExpanderLogNumber = 8000 LogGenBuffer = 100 try: # Create logs for ExpanderID in Config.J2010allSeIDs: # Clear expander logs execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand(ClearLogCmds, username=Config.bmcUser,\ password=Config.bmcPassword, port=Config.J2010sshPorts[ExpanderID-1], sshResponseLimit=ExpanderSshResponseLimit) if execPassOrFail: UtilLogger.verboseLogger.info( "%s: Expander %s log is cleared" % (fileName, ExpanderID)) CreateLogsComplete = False while not CreateLogsComplete: # Get expander log number to excuted how many fake log we should genarate execPassOrFail, ExpanderLogNumbers = _CheckExpanderLogNumber( ExpanderID) if not execPassOrFail: UtilLogger.verboseLogger.info( "%s: Failed to get expander %s log number" % (fileName, ExpanderID)) cmdPassOrFail = False break else: if ((MaxExpanderLogNumber - 1) - ExpanderLogNumbers) <= LogGenBuffer: UtilLogger.verboseLogger.info("%s: Expander %s is almost rollover with %s logs, ready to fill with real logs" \ %(fileName, ExpanderID, ExpanderLogNumbers)) TimesNeeded = 0 CreateLogsComplete = True break # Logs not enough else: UtilLogger.verboseLogger.info("%s: We need more fake logs on Expander %s, current logs: %s" \ %(fileName, ExpanderID, ExpanderLogNumbers)) TimesNeeded = ((MaxExpanderLogNumber - 1) - ExpanderLogNumbers) / LogGenBuffer CreateLogsComplete = False # Generate logs for runTimes in range(TimesNeeded): execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand(execCmds, username=Config.bmcUser,\ password=Config.bmcPassword, port=Config.J2010sshPorts[ExpanderID-1], sshResponseLimit=ExpanderSshResponseLimit) # Sleep 110 seconds for each 'test100' command cost 100 seconds to execute. time.sleep(110) if execPassOrFail: UtilLogger.verboseLogger.info( "%s: Log created %s" % (fileName, ExpanderLogNumbers + (runTimes + 1) * LogGenBuffer)) else: UtilLogger.verboseLogger.info( "%s: Log create failed" % (fileName)) else: UtilLogger.verboseLogger.info( "%s: Clear expander log on expander %s failed" % (fileName, ExpanderID)) cmdPassOrFail = False except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) cmdPassOrFail = False
def UpdateFWwithMonitorCPU(expBinFile, auth, port, username, password, expId, times=350, interval=2): global filename cmdPassOrFail = True execPassOrFail = True funcName = inspect.stack()[0][3] UtilLogger.verboseLogger.info("%s: running %s fxn. Fw: %s" % (fileName, funcName, expBinFile)) execPassOrFail = CheckExpanderFirmware(auth, port, expId) if not execPassOrFail: return False # Push expander's image to BMC execPassOrFail = RedFish.PushImage(expBinFile, Config.expanderFlashFilePath, username, password) if execPassOrFail: UtilLogger.verboseLogger.info("%s: \t2: PushImage passed" % (fileName)) else: UtilLogger.verboseLogger.info("%s: \t2: PushImage failed" % (fileName)) return False sshCmd = "rm -f /var/wcs/home/CPU.txt;" sshCmd += "$(top -b -n %d -d %d| grep CPU | awk '/CPU:\s/{print $2}' > /var/wcs/home/CPU.txt &)\n " % ( times, interval) execCmds = ['\n'] execCmds.append(sshCmd) resource = "redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate" postResource = 'file://image-expander.fw?component=expander%s' % (expId) payload = {'ImageURI': postResource, 'TransferProtocol': 'OEM'} execPassOrFail, response = RedFish.SendRestRequest( resource, auth, port, payload, restRequestMethod="POST", timeout=5) cmdPassOrFail &= execPassOrFail UtilLogger.verboseLogger.info("RestApiCall call: " + resource + \ "Response Status Code: " + str(response.status_code) + " " + \ "Response Content: " + str(response.text)) if execPassOrFail: UtilLogger.verboseLogger.info( "%s: \t3: SimpleUpdate POST call passed" % (fileName)) else: UtilLogger.verboseLogger.info( "%s: \t3: SimpleUpdate POST call failed" % (fileName)) return False # Check CPU utilization and wait for the FirmwareUpdate command to complete execPassOrFail, sshOutputs, parsedCmdOutputs = Ssh.sshExecuteCommand( execCmds, username=username, password=password, timeSleep=700) if execPassOrFail: UtilLogger.verboseLogger.info( "%s: \t2: Ssh commands execution passed" % (fileName)) else: UtilLogger.verboseLogger.info( "%s: \t2: Ssh commands execution failed" % (fileName)) return False execPassOrFail = CheckExpanderFirmware(auth, port, expId) if not execPassOrFail: cmdPassOrFail = False return cmdPassOrFail
def runTest_dev(namespace, jsonCids, url): allGood = True results = [] readyStatus = False for key in jsonCids: cid = jsonCids[key] language = key deployment(cid) time.sleep(30) for unused in range(50): if checkReady(cid): readyStatus = True time.sleep(60) break else: print('Not Ready') #deployment(cid) time.sleep(10) cwd = "/var/www/html/MonitorAsr" #os.getcwd() command = "date +%s.%N;" command += "cd " + cwd + "/cars-server-grpc-testers;" command += "sed 's/{{CID}}/" + cid + "/' pcmStreamingConfig.json >pcmStreamingConfigReplaced.json;" if (language in knownLanguages_asr): command += 'sh grpcurl-stream.sh ' + url + ' 443 ' + language + '.opus' else: command += 'sh grpcurl-stream.sh ' + url + ' 443 eng-USA.opus' #command +='sh grpcurl-stream.sh '+url+' 443 '+language+'.opus' command += ";date +%s.%N" hostname = config.client port = config.port username = config.username password = config.password stdout = ssh.ssh2(hostname, port, username, password, command) time.sleep(10) print("again") stdout = ssh.ssh2(hostname, port, username, password, command) print("again") start = time.time() stdout = ssh.ssh2(hostname, port, username, password, command) end = time.time() str_out = stdout.decode("utf-8") elapse = getElapse(str_out) #logging.info(stdout) result = [] result.append(namespace) result.append("ASR") result.append(url) if (readyStatus): result.append(cid) else: result.append("NOT READY:" + cid) result.append(language) sessionId = helper.getString(str_out, 'cerence-session-id:', ' ') elaspeDiff = checkElapse(elapse, elapseThreshold_asr, language) if (elaspeDiff < 0 or elapse == 999999): if ('finalAlternatives' in str_out): resultPassFail = checkAsrResult(language, str_out) if (elapse == 999999 or resultPassFail == 'FAIL'): allGood = False result.append(resultPassFail) results.append(result) result.append(elapse) result.append(sessionId) else: result.append("FAIL") allGood = False results.append(result) result.append(elapse) result.append(sessionId + ":" + str_out) else: resultPassFail = checkAsrResult(language, str_out) if (resultPassFail == 'FAIL'): result.append("FAIL") results.append(result) result.append(elapse) result.append("HIGH CPL AND FAILED:" + sessionId + ":" + str_out) allGood = False else: result.append("PASS") results.append(result) result.append(elapse) result.append("HIGH CPL:" + sessionId) undeployment(cid) #for unused in range(100): # if not checkReady(cid): # break # else: # time.sleep(5) return results, allGood
def runTest(namespace, listCid, url): allGood = True results = [] for cidItem in listCid: cid = list(cidItem)[0] language = cidItem.get(cid) cwd = "/var/www/html/MonitorAsr" #os.getcwd() command = "date +%s.%N;" command += "cd " + cwd + "/cars-server-grpc-testers;" command += "sed 's/{{CID}}/" + cid + "/' pcmStreamingConfig.json >pcmStreamingConfigReplaced.json;" if (language in knownLanguages_asr): command += 'sh grpcurl-stream.sh ' + url + ' 443 ' + language + '.opus' else: command += 'sh grpcurl-stream.sh ' + url + ' 443 eng-USA.opus' command += ";date +%s.%N" hostname = config.client port = config.port username = config.username password = config.password start = time.time() stdout = ssh.ssh2(hostname, port, username, password, command) end = time.time() str_out = stdout.decode("utf-8") elapse = getElapse(str_out) #logging.info(stdout) result = [] result.append(namespace) result.append("ASR") result.append(url) result.append(cid) result.append(language) sessionId = helper.getString(str_out, 'cerence-session-id:', ' ') elaspeDiff = checkElapse(elapse, elapseThreshold_asr, language) if (elaspeDiff < 0 or elapse == 999999): if ('finalAlternatives' in str_out): resultPassFail = checkAsrResult(language, str_out) if (elapse == 999999 or resultPassFail == 'FAIL'): allGood = False result.append(resultPassFail) else: result.append("FAIL") allGood = False results.append(result) result.append(elapse) result.append(sessionId) else: resultPassFail = checkAsrResult(language, str_out) if (resultPassFail == 'FAIL'): result.append("FAIL") results.append(result) result.append(elapse) result.append("HIGH CPL AND FAILED:" + sessionId) else: result.append("FAIL") results.append(result) result.append(elapse) result.append("HIGH CPL:" + sessionId) allGood = False return results, allGood
def Execute(interfaceParams): global fileName, session, headers, auth, testPassOrFail username = Config.bmcUser password = Config.bmcPassword testPassOrFail = True execCmds = ['\r'] # execCmds.append('\rhelp\r') # Help command execCmdsResponse = "CLI Help" sshPort = None try: FRU_Fields = [ "Id", "Name", "ChassisType", "Manufacturer", "Model", "SKU", "IndicatorLED", "PowerState" ] # Read the current FRU values (fruPassOrFail, response) = _GetStorageEnclosureValues() testPassOrFail &= fruPassOrFail responseJson = response.json() # Print the current FRU values if (fruPassOrFail): for FRU_field in FRU_Fields: if FRU_field in responseJson: FRU_value = responseJson[FRU_field] UtilLogger.verboseLogger.info( "%s: FRU Field: %s; Current Value: %s" % (fileName, FRU_field, FRU_value)) else: UtilLogger.verboseLogger.info( "%s: test failed with error code %d" % (fileName, response.status_code)) # Specify Expander Board to Power Off payload = {} payload["ResetType"] = "ForceOff" # Update the specified Storage Enclosure fields (fruPassOrFail, response) = _PatchStorageEnclosureValues(payload) testPassOrFail &= fruPassOrFail # Get ALL messages for the FRU fields that were updated if (fruPassOrFail): RedFish.DisplayFRUValues(response, payload) # Verify the FRU fields testPassOrFail &= RedFish.VerifyFRUValues(response, payload) # Specify Expander Board to Power On payload = {} payload["ResetType"] = "ForceOn" # Update the specified Storage Enclosure field (fruPassOrFail, response) = _PatchStorageEnclosureValues(payload) testPassOrFail &= fruPassOrFail # Get ALL messages for the FRU fields that were updated if (fruPassOrFail): RedFish.DisplayFRUValues(response, payload) # Verify the FRU fields testPassOrFail &= RedFish.VerifyFRUValues(response, payload) # Sleep for 5 seconds UtilLogger.verboseLogger.info("%s: sleeping for 5 seconds.." % (fileName)) sshPort = Config.J2010sshPorts[Config.J2010seId] UtilLogger.verboseLogger.info( "SSH executing commands %s with username %s and password %s" % (execCmds, username, password)) (execPassOrFail, sshOutputs, parsedCmdOutputs) = Ssh.sshExecuteCommand(execCmds, username, password, sshPort) # Verify Expander is powered ON by checking console redirection UtilLogger.verboseLogger.info( "%s: running Expander Console Redirection validation for Port %s" % (fileName, Config.sshPort)) if (execPassOrFail): for sshOutput in sshOutputs: if execCmdsResponse in sshOutput: UtilLogger.verboseLogger.info( "%s: successfully found '%s' in response" % (fileName, execCmdsResponse)) testPassOrFail = True else: UtilLogger.verboseLogger.info( "%s: test failed with error code %d" % (fileName, response.status_code)) if (not execPassOrFail): UtilLogger.verboseLogger.error( "%s: failed to find '%s' in response" % (fileName, execCmdsResponse)) except Exception, e: UtilLogger.verboseLogger.error("%s: test failed. Exception: %s" % (fileName, str(e))) testPassOrFail = False
def runTestFormat(namespace, listCid, url): allGood = True results = [] for cidItem in listCid: cid = list(cidItem)[0] language = cidItem.get(cid) cwd = "/var/www/html/MonitorAsr" #os.getcwd() command = "date +%s.%N;" command += "cd " + cwd + "/cars-server-grpc-testers;" command += "sed 's/{{CID}}/" + cid + "/' Format.sentence01.json >Format.sentence01ConfigReplacedMid.json;" if (language == 'eng-USA'): command += "sed 's/{{CONTENT}}/One/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" elif (language == 'deu-DEU'): command += "sed 's/{{CONTENT}}/Einer/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" elif (language == 'cmn-CHN'): command += "sed 's/{{CONTENT}}/一/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" elif (language == 'eng-GBR'): command += "sed 's/{{CONTENT}}/One/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" elif (language == 'fra-FRA'): command += "sed 's/{{CONTENT}}/Un/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" elif (language == 'ita-ITA'): command += "sed 's/{{CONTENT}}/Una/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" elif (language == 'spa-ESP'): command += "sed 's/{{CONTENT}}/Una/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" else: command += "sed 's/{{CONTENT}}/1/' Format.sentence01ConfigReplacedMid.json >Format.sentence01ConfigReplaced.json;" command += 'sh grpcurl-format.sh ' + url + ' 443 ' command += ";date +%s.%N;" hostname = config.client port = config.port username = config.username password = config.password start = time.time() stdout = ssh.ssh2(hostname, port, username, password, command) logging.info(stdout) end = time.time() str_out = stdout.decode("utf-8") elapse = getElapse(str_out) result = [] result.append(namespace) result.append("Format") result.append(url) result.append(cid) result.append(language) sessionId = helper.getString(str_out, 'cerence-session-id:', ' ') elaspeDiff = checkElapse(elapse, elapseThreshold_format, language) if (elaspeDiff < 0 or elapse == 999999): resultPassFail = checkTps(language, str_out, 'formatWords') if (elapse == 999999 or resultPassFail == 'FAIL'): allGood = False result.append(resultPassFail) results.append(result) result.append(elapse) result.append(sessionId) else: resultPassFail = checkTps(language, str_out, 'formatWords') if (resultPassFail == 'FAIL'): result.append('FAIL') results.append(result) result.append(elapse) result.append("HIGH CPL AND FAILED:" + sessionId) allGood = False else: if 'dev' in namespace: result.append("PASS") else: result.append("FAIL") allGood = False results.append(result) result.append(elapse) result.append("HIGH CPL:" + sessionId) return results, allGood