def insertXlImage(xlFile=None, xlImage=None, row=1, col=1): if xlFile == None: testLogs.ERROR("Please provide XL file to parse") exit(1) if xlImage == None: testLogs.ERROR("Please provide Image file to insert") exit(1) testLogs.INFO("FUNCTION : Inser a Image {} file into XL file : {}".format( xlImage, xlFile)) fileExist = os.path.exists(xlFile) if fileExist != True: try: wb = openpyxl.Workbook() wb.create_sheet("sheet1", 0) wb.active = 0 except Exception as E: testLogs.ERROR("Could not create XL file : {}".format(xlFile)) testLogs.ERROR(E) else: testLogs.INFO(xlFile) testLogs.INFO(xlFile.strip()) wb = openpyxl.load_workbook(xlFile, data_only=True) ws = wb.active img = openpyxl.drawing.image.Image(xlImage) ws.add_image(img, '{}{}'.format(chr(col + 64), row)) wb.save(xlFile)
def getTpInLogFiles(filesDict=None, logFolder=None): testLogs.INFO("FUNCTION : Reading Throughput from many files") if filesDict == None: testLogs.ERROR("Kindly provide data to parse...") exit(1) if logFolder != None: logDirectory = logFolder testLogs.INFO("----LOG FOLDER : {}".format(logDirectory)) testLogs.INFO("----FILES : {}".format(filesDict)) tpts = [] # testLogs.INFO("File : {}".format(filesDict)) for ang in range(10, 361, 10): file = logDirectory + filesDict[ang] fd = open(file, 'r') lines = fd.readlines() # prints.INFO("LINES : {}".format(lines)) tp = int(float(lines[-1].split(' ')[-2])) fd.close() tpts.append(tp) return tpts
def readXlFileRows(xlFile=None, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart, numberOfCols=wifiConfig.xlTotalCols): if xlFile == None: testLogs.ERROR("Please provide XL file to parse") exit(1) testLogs.INFO("FUNCTION : Reading row data in XL file : {}".format(xlFile)) try: wb = openpyxl.load_workbook(xlFile.strip(), data_only=True) wb.active = 0 except Exception as E: testLogs.ERROR("Could not open XL file : {}".format(xlFile)) testLogs.ERROR(E) currentSheet = wb.active colEnd = colStart + numberOfCols # Read row values from XL file values = [] for col in range(colStart, colEnd): testLogs.INFO("Row Col : {} {}".format(rowStart, col)) cellToRead = currentSheet.cell(row=rowStart, column=col) testLogs.INFO(cellToRead.value) values.append(cellToRead.value) testLogs.INFO("Values of Row No {} is : {}".format(rowStart, values)) return values
def createDirectories(): testLogs.INFO("FUNCTION : Genetaing Iperf directories") if wifiConfig.test == 0: wifiConfig.iperfDirectory = wifiConfig.outputDirectory + wifiConfig.builds[ wifiConfig.build] + wifiConfig.pathDivider testLogs.INFO("Creating Iperf Directory : {}".format( wifiConfig.iperfDirectory)) createDirectory(wifiConfig.iperfDirectory) elif wifiConfig.test == 1: wifiConfig.iperfDirectory = wifiConfig.outputDirectory + wifiConfig.aps[ wifiConfig.ap] + wifiConfig.pathDivider testLogs.INFO("Creating Iperf Directory : {}".format( wifiConfig.iperfDirectory)) createDirectory(wifiConfig.iperfDirectory) elif wifiConfig.test == 2 or wifiConfig.test == 3: wifiConfig.iperfDirectory = wifiConfig.outputDirectory + wifiConfig.bands[ wifiConfig.band] + wifiConfig.pathDivider testLogs.INFO("Creating Iperf Directory : {}".format( wifiConfig.iperfDirectory)) createDirectory(wifiConfig.iperfDirectory) if wifiConfig.test == 0 or wifiConfig.test == 1: log = "{}_{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.bands[wifiConfig.band], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) elif wifiConfig.test == 2 or wifiConfig.test == 3: log = "{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) wifiConfig.iperfLogDirectory = wifiConfig.iperfDirectory + log + wifiConfig.pathDivider testLogs.INFO("Creating Iperf Log Directory : {}".format( wifiConfig.iperfLogDirectory)) createDirectory(wifiConfig.iperfLogDirectory)
def runRemoteIperfClient(host=wifiConfig.remoteIP, user=wifiConfig.remoteUsername, password=wifiConfig.remotePassword): """ Running iperf client in Station which is connected with AP Arguments : host, IP address of Station user, User name of station password, Password of station Returns : True, On successful start of iperf client False, On failure in starting iperf client """ testLogs.INFO("FUNCTION : Running Remote Iperf Client") station = remoteAccess.remoteAccess(host=host, user=user, password=password) command = "{} -c {} -i 1 -f m -w {} -p {} -t {} ".format( wifiConfig.iperf, wifiConfig.localIP, wifiConfig.windowSize, wifiConfig.listeningPort, wifiConfig.executionTime) if wifiConfig.stream == 1: command += "-P {}".format(wifiConfig.numberOfStream) testLogs.INFO(command) status = station.executeCommand(command) if status != False: return str(status) return status
def createSingleRadarGraph(listValue=[5, 6, 7, 6, 5, 10, 2], fileName="radarChart"): testLogs.INFO("FUNCTION : Creating Single Radar Graph") fig = plt.figure() po = fig.add_subplot(111, polar=True) po.grid(True) anglePerValue = int(360 / len(listValue)) namesOfEachValue = [ anglePerValue * ele for ele in range(1, len(listValue) + 1) ] N = len(listValue) # Number of values testLogs.INFO("length of the list is : {}".format(N)) listValue += listValue[:1] # Repeat first value to close the circle testLogs.INFO("listValuse after alter : {}".format(listValue)) angles = [n / float(N) * 2 * np.pi for n in range(N)] # Calculate angle for each value angles += angles[:1] testLogs.INFO("Angles calculated : {}".format(angles)) listValue = [int(float(i)) for i in listValue] po.plot(angles, listValue) po.set_theta_direction(-1) po.set_theta_offset(np.pi / 2.0) plt.xticks(angles[:-1], namesOfEachValue) if wifiConfig.test == 0: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.build] if wifiConfig.test == 1: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.ap] if wifiConfig.test == 2 or wifiConfig.test == 3: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.band] plt.legend(labels=[ label, ], loc='upper right', bbox_to_anchor=(wifiConfig.legendXpos, wifiConfig.legendYpos), ncol=2, fancybox=True, shadow=True) plt.xlabel(wifiConfig.labelXname) plt.ylabel(wifiConfig.labelYname) plt.title(wifiConfig.graphTitle) #graphDirectory = "{}\\output\\{}_{}_{}\\graphs\\".format(wifiConfig.baseDirectory, wifiConfig.tests[wifiConfig.test], wifiConfig.aps[wifiConfig.ap], wifiConfig.builds[wifiConfig.build]) #plt.savefig(graphDirectory + fileName + '_RADAR.png') plt.savefig(fileName + '_RADAR.png')
def main(): fileName = "test_Position_{}.csv" global directory directory += wifiConfig.pathDivider xlFileName = directory + "averageValues.xlsx" xlParser.writeXlFileRows(xlFileName, ["Position"] + wifiConfig.cbClients + ["Aggregate"], 2, 1) for i in range(1, 37): row = i + 2 xlParser.writeXlFileRows(xlFileName, [ i, ], row, 1) fileToOpen = directory + fileName.format(i) testLogs.INFO("File Name is : {}".format(fileToOpen)) readDataFromFile(fileToOpen) avgValue = '' for index, client in enumerate(clientPosition.keys()): clientValues = getValueFromClient(client) testLogs.INFO("client {} values are : {}".format( client, clientValues)) if clientValues != []: avgValue = sum(clientValues) / len(clientValues) else: avgValue = 0 testLogs.INFO("Average value is : {}".format(avgValue)) xlParser.writeXlFileRows(xlFileName, [ avgValue, ], row, index + 2) aggregateValue = getAggregateValue() if aggregateValue != '': aggregateValue = float(aggregateValue) else: aggregateValue = 0 testLogs.INFO("Aggregate value is : {}".format(aggregateValue)) xlParser.writeXlFileRows(xlFileName, [ aggregateValue, ], row, 6) # Write average values for col in range(2, 7): values = xlParser.readXlFileColums(xlFileName, 3, col, 36) print(values) average = round(sum(values) / len(values), 3) xlParser.writeXlFileRows(xlFileName, [ average, ], 39, col) xlParser.writeXlFileRows(xlFileName, [ "AVERAGE", ], 39, 1)
def writeXlFileColums(xlFile=None, data=[1, 2, 3, 4, 5], rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart): if xlFile == None: testLogs.ERROR("Please provide XL file to parse") exit(1) testLogs.INFO( "FUNCTION : Writing colum data in XL file : {}".format(xlFile)) fileExist = os.path.exists(xlFile) if fileExist != True: try: wb = openpyxl.Workbook() wb.create_sheet("sheet1", 0) wb.active = 0 except Exception as E: testLogs.ERROR("Could not create XL file : {}".format(xlFile)) testLogs.ERROR(E) else: wb = openpyxl.load_workbook(xlFile.strip(), data_only=True) currentSheet = wb.active rowEnd = rowStart + len(data) for index, row in enumerate(range(rowStart, rowEnd)): cellToModify = currentSheet.cell(row=row, column=colStart) cellToModify.value = data[index] wb.save(xlFile)
def killLocalIperf(): """ To terminate all the iperf tasks running in backbone PC Arguments : None Returns : True, On successful termination of iperf tasks False, On failure of terminating iperf tasks """ testLogs.INFO("FUNCTION : Terminating Local Iperf tasks") # Windows command to get all the running task ps = os.popen('wmic process get description').read() if wifiConfig.iperf in ps: # Windows command to kill all the running iperf task s = os.system("taskkill /f /im {}".format(wifiConfig.iperf)) if s != 0: testLogs.ERROR("Could Not kill {}".format(wifiConfig.iperf)) return False testLogs.SUCCESS("Terminated the process : {}".format( wifiConfig.iperf)) else: testLogs.STATUS("Process {} Not found".format(wifiConfig.iperf)) return True
def getLogFilesInDirectory(directory=None): testLogs.INFO( "FUNCTION : Getting Log files in directory : {}".format(directory)) if directory == None: testLogs.ERROR("Kindly provide the directory to get log files") exit(1) try: files = os.listdir(directory) except Exception as E: testLogs.ERROR( "Could not get files from the directory : {}".format(directory)) testLogs.ERROR(E) exit(1) filesDict = {} for file in files: if '_' not in file: continue angle = file.split('.')[0].split("_")[-1] try: angle = int(angle) filesDict[angle] = file except Exception as E: testLogs.ERROR( "This file is not is expected format : {}".format(file)) #for ele in filesDict: # print ("{} : {}".format(ele, filesDict[ele])) return filesDict
def parseCommandLineArgs(): testLogs.INFO("FUNCTION : Parsing Command line arguments") myParser = argparse.ArgumentParser( description= 'Getting Command line arguments from tester for WiFi Testing...') myParser.add_argument( 'directory', type=str, help="Provide the dirctory which contains the ixChariot report files") args = myParser.parse_args() global directory directory = args.directory testLogs.INFO("Directory is : {}".format(directory))
def rotateTurnTable(angle=wifiConfig.anglePerMove): #if direction == 0: # rotateTtClockWise(angle) #elif direction == 1: # rotateTtAntiClockWise(angle) rotateTtClockWise(angle) waitTime = angle * wifiConfig.ttStepsPerAngle * wifiConfig.ttTimePerStep time.sleep(waitTime + 1) testLogs.INFO("Rotation completed")
def runIperfClient(): """ Running iperf client in Backbone PC or Station based on parameters given by the user Arguments: None Returns: True, On Success Failuer, On Failure """ testLogs.INFO("FUNCTION : Running iperf client") testLogs.INFO(wifiConfig.link) if wifiConfig.link == 0: return runLocalIperfClient() elif wifiConfig.link == 1: return runRemoteIperfClient(wifiConfig.remoteIP, wifiConfig.remoteUsername, wifiConfig.remotePassword)
def createMultipleBarGraph(listValue=[[5, 6, 7, 6, 5, 10], [2, 7, 5, 10, 6, 5]], fileName="avmGraph"): testLogs.INFO("FUNCTION : Creating Multiple Bar Graph") fig, ax = plt.subplots() for index, lst in enumerate(listValue): if wifiConfig.test in [0, 1, 2, 3]: data = [min(lst), int(sum(lst) / len(lst)), max(lst)] else: data = lst testLogs.INFO("data is : {}".format(data)) N = len(data) indentation = np.arange(N) ax.bar(indentation + (index * wifiConfig.barWidth), data, width=wifiConfig.barWidth) for ind, dat in enumerate(data): testLogs.INFO("dat is : {}".format(dat)) plt.text(x=ind + (index * wifiConfig.barWidth), y=dat + 1, s=f"{dat}", fontdict=dict(fontsize=12)) # plt.tight_layout() plt.xticks(indentation + wifiConfig.barWidth / 2, wifiConfig.barXticks[0]) ax.legend(labels=wifiConfig.graphLegend[wifiConfig.test], loc='upper right', bbox_to_anchor=(wifiConfig.legendXpos, wifiConfig.legendYpos), ncol=2, fancybox=True, shadow=True, prop={'size': 8}) plt.xlabel(wifiConfig.labelXname) plt.ylabel(wifiConfig.labelYname) plt.title(wifiConfig.graphTitle) #graphDirectory = "{}\\output\\{}_{}_{}\\graphs\\".format(wifiConfig.baseDirectory, wifiConfig.tests[wifiConfig.test], wifiConfig.aps[wifiConfig.ap], wifiConfig.builds[wifiConfig.build]) #plt.savefig(graphDirectory + fileName + '_BAR.png') plt.savefig(fileName + '_BAR.png')
def generateIndividualTestReport(): testLogs.INFO("FUNCTION : Generating individual test reports") if wifiConfig.test == 0 or wifiConfig.test == 1: log = "{}_{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.bands[wifiConfig.band], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) elif wifiConfig.test == 2 or wifiConfig.test == 3: log = "{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) #### Generating report files from throughput files files = logParser.getLogFilesInDirectory(wifiConfig.iperfLogDirectory) throughputs = logParser.getTpInLogFiles(files, wifiConfig.iperfLogDirectory) logFile = wifiConfig.iperfLogDirectory + "throughputs.txt" testLogs.INFO("Log file is : {}".format(logFile)) try: fd = open(logFile, 'w+') fd.write(' '.join([str(tp) for tp in throughputs])) fd.close() except Exception as E: testLogs.ERROR("Could not write throughputs in throughputs.txt file") testLogs.ERROR(E) exit(1) testLogs.INFO("Throughputs : {}".format(throughputs)) graphName = wifiConfig.iperfLogDirectory + log graphs.createSingleRadarGraph(throughputs, graphName) throughputs = throughputs[:-1] graphs.createSingleBarGraph(throughputs, graphName) xlFileName = graphName + '.xlsx' createXlFile(xlFileName, throughputs) xlParser.insertXlImage(xlFileName, graphName + '_RADAR.png', 3, 5) xlParser.insertXlImage(xlFileName, graphName + '_BAR.png', 3, 15) return 0
def killRemoteIperf(host=wifiConfig.remoteIP, user=wifiConfig.remoteUsername, password=wifiConfig.remotePassword): """ To terminate all the iperf tasks running in remote station Arguments : None Returns : True, On successful termination of iperf tasks False, On failure of terminating iperf tasks """ testLogs.INFO("FUNCTION : Terminating Remote Iperf tasks") station = remoteAccess.remoteAccess(host=host, user=user, password=password) command = "taskkill /f /im {}".format(wifiConfig.iperf) testLogs.INFO(command) status = station.executeCommand(command) if status != False: return str(status) return status
def createDirectory(directory=None): if directory == None: testLogs.ERROR("Please provide a directory name to create") exit(1) testLogs.INFO("Directory is about to create in : {}".format(directory)) try: if os.path.exists(directory) == False: os.mkdir(directory) testLogs.SUCCESS("Directory created") except Exception as E: testLogs.ERROR(E) exit(1)
def runLocalIperfClient(): """ Running iperf client in backbone PC which is connected with AP Arguments : None Returns : True, On successful start of iperf client False, On failure in starting iperf client """ testLogs.INFO("FUNCTION : Running Local Iperf Client") command = "{} -c {} -i 1 -f m -w {} -p {} -t {} ".format( wifiConfig.iperf, wifiConfig.remoteIP, wifiConfig.windowSize, wifiConfig.listeningPort, wifiConfig.executionTime) if wifiConfig.stream == 1: command += "-P {}".format(wifiConfig.numberOfStream) testLogs.INFO(command) try: p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() out = str(out) err = str(err) if err == "b''": return out testLogs.ERROR(err) return False except Exception as E: testLogs.ERROR("Could not start the {} client...".format( wifiConfig.iperf)) testLogs.ERROR(E) return False
def runLocalIperfServer(): """ Running iperf server in backbone PC which is connected with AP Arguments : None Returns : True, On successful start of iperf server False, On failure in starting iperf server """ testLogs.INFO("FUNCTION : Running Local Iperf Server") command = wifiConfig.iperfServer testLogs.INFO(command) try: p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) return True except Exception as E: testLogs.ERROR("Could not start the {} server...".format( wifiConfig.iperf)) testLogs.ERROR(E) return False
def runRemoteIperfServer(host=wifiConfig.remoteIP, user=wifiConfig.remoteUsername, password=wifiConfig.remotePassword): """ Running iperf server in Station which is connected with AP Arguments : host, IP address of Station user, User name of station password, Password of station Returns : True, On successful start of iperf server False, On failure in starting iperf server """ testLogs.INFO("FUNCTION : Running Remote Iperf Server") station = remoteAccess.remoteAccess(host=host, user=user, password=password) command = wifiConfig.iperfServer testLogs.INFO(command) status = station.executeCommandInBackground(command) if status != False: return True return status
def createXlFile(xlFile=None, data=[1, 2, 3, 4, 5]): testLogs.INFO("FUNCTION : Creating XL file : {}".format(xlFile)) if wifiConfig.test == 0: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.build] if wifiConfig.test == 1: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.ap] if wifiConfig.test == 2 or wifiConfig.test == 3: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.band] data1 = ['ANGLE'] + list(range(10, (len(data) * 10 + 1), 10)) + ['MIN', 'AVG', 'MAX'] data2 = [label] + data + [min(data), int(sum(data) / len(data)), max(data)] xlParser.writeXlFileColums(xlFile, data1, 3, 1) xlParser.writeXlFileColums(xlFile, data2, 3, 2)
def createMultipleRadarGraph(listValue=[[5, 6, 7, 6, 5, 10, 2], [2, 7, 5, 10, 6, 5, 5]], fileName="testGraph"): testLogs.INFO("FUNCTION : Creating Multiple Radar Graph") fig = plt.figure() po = fig.add_subplot(111, polar=True) po.grid(True) if 360 % len(listValue[0]) == 0: anglePerValue = int(360 / len(listValue[0])) else: anglePerValue = 360 / len(listValue[0]) namesOfEachValue = [ int(float(anglePerValue * ele)) for ele in range(1, len(listValue[0]) + 1) ] N = len(listValue[0]) # Number of values angles = [n / float(N) * 2 * np.pi for n in range(N)] angles += angles[:1] colors = ['g', 'y', 'b', 'r', 'm', 'c', 'k', 'w'] for index, l in enumerate(listValue): l += l[:1] # Repeat first value to close the circle l = [int(float(i)) for i in l] po.plot(angles, l) po.set_theta_direction(-1) po.set_theta_offset(np.pi / 2.0) plt.xticks(angles[:-1], namesOfEachValue) plt.legend(labels=wifiConfig.graphLegend[wifiConfig.test], loc='upper right', bbox_to_anchor=(wifiConfig.legendXpos, wifiConfig.legendYpos), ncol=2, fancybox=True, shadow=True, prop={'size': 8}) plt.xlabel(wifiConfig.labelXname) plt.ylabel(wifiConfig.labelYname) plt.title(wifiConfig.graphTitle) #graphDirectory = "{}\\output\\{}_{}_{}\\graphs\\".format(wifiConfig.baseDirectory, wifiConfig.tests[wifiConfig.test], wifiConfig.aps[wifiConfig.ap], wifiConfig.builds[wifiConfig.build]) #plt.savefig(graphDirectory + fileName + '_RADAR.png') plt.savefig(fileName + '_RADAR.png')
def createSingleBarGraph(listValue=[5, 6, 7, 6, 5, 10, 2], fileName="avmGraph"): testLogs.INFO("FUNCTION : Creating Single Bar Graph") # Bar chart list1 = [int(float(i)) for i in listValue] minValue1 = min(list1) avgValuse1 = int(sum(list1) / len(list1)) maxValue1 = max(list1) values1 = [minValue1, avgValuse1, maxValue1] N = len(values1) indentation = np.arange(N) fig, ax = plt.subplots() ax.bar(indentation, values1, width=wifiConfig.barWidth) for index, data in enumerate(values1): plt.text(x=index, y=data + 1, s=f"{data}", fontdict=dict(fontsize=12)) # plt.tight_layout() plt.xticks(indentation + wifiConfig.barWidth / 2, wifiConfig.barXticks[0]) if wifiConfig.test == 0: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.build] if wifiConfig.test == 1: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.ap] if wifiConfig.test == 2 or wifiConfig.test == 3: label = wifiConfig.graphLegend[wifiConfig.test][wifiConfig.band] ax.legend(labels=[ label, ], loc='upper right', bbox_to_anchor=(wifiConfig.legendXpos, wifiConfig.legendYpos), ncol=2, fancybox=True, shadow=True, prop={'size': 8}) plt.xlabel(wifiConfig.labelXname) plt.ylabel(wifiConfig.labelYname) plt.title(wifiConfig.graphTitle) #graphDirectory = "{}\\output\\{}_{}_{}\\graphs\\".format(wifiConfig.baseDirectory, wifiConfig.tests[wifiConfig.test], wifiConfig.aps[wifiConfig.ap], wifiConfig.builds[wifiConfig.build]) #plt.savefig(graphDirectory + fileName + '_BAR.png') plt.savefig(fileName + '_BAR.png')
def getTpInLogFile(file=None): testLogs.INFO( "FUNCTION : Reading Throughput in from single file : {}".format(file)) if file == None: testLogs.ERROR("Kindly provide file to parse...") exit(1) tpts = [] try: fd = open(file, 'r') lines = fd.readlines() for line in lines: if "Mbits/sec" in line: # print (line) tp = int(float(line.split(' ')[-2])) fd.close() tpts.append(tp) except Exception as E: testLogs.ERROR("Could not open given log file to parse") exit(1) return tpts
def parseWifiCommandLineArgs(): testLogs.INFO ("FUNCTION : Parsing Command line arguments") myParser = argparse.ArgumentParser(description='Getting Command line arguments from tester for WiFi Testing...') myParser.add_argument('--test', type=int, choices=list(tests.keys()), help="Select the type of TEST\nAvailable TEST types are : {}".format(tests)) myParser.add_argument('--ap', type=int, choices=list(aps.keys()), help="Select the AP in which the testing is about to Run\n Available AP types are : {}".format(aps)) myParser.add_argument('--build', type=int, choices=list(builds.keys()), help="Select the BUILD in which the testing is about to Run\n Available BUILDS types are : {}".format(builds)) myParser.add_argument('--band', type=int, choices=list(bands.keys()), help="Select the BAND in which the testing is about to Run\n Available BANDS types are : {}".format(bands)) myParser.add_argument('--link', type=int, choices=list(links.keys()), help="Select the LINK in which the testing is about to Run\n Available LINKS types are : {}".format(links)) myParser.add_argument('--stream', type=int, choices=list(streams.keys()), help="Select the STREAM in which the testing is about to Run\n Available STREAMS types are : {}".format(streams)) myParser.add_argument('--protocol', type=int, choices=list(protocols.keys()), help="Select the PROTOCOL in which the testing is about to Run\n Available PROTOCOLS types are : {}".format(protocols)) myParser.add_argument('--graph', type=int, choices=list(graphs.keys()), help="Select the type of GRAPH\nAvailable GRAPHS types are : {}".format(graphs)) myParser.add_argument('--barwidth', type=int, help="Select the Bar width of the BAR chart") myParser.add_argument('--legendx', type=float, help="Place the legends of a graph in X position") myParser.add_argument('--legendy', type=float, help="Place the legends of a graph in Y position") myParser.add_argument('--labelx', type=str, help="To give a name to X label") myParser.add_argument('--labely', type=str, help="To give a name to Y label") myParser.add_argument('--gtitle', type=str, help="To give a Title to a Graph") myParser.add_argument('--xlin', type=str, help="To give XL file name from which the datas retrived to generate graphs") myParser.add_argument('--xlout', type=str, help="To give XL file name in which the datas are about to saved") myParser.add_argument('--xlrows', type=int, help="To give total numbers of ROWS to get data from") myParser.add_argument('--xlcols', type=int, help="To give total numbers of COLUMS to get data from") myParser.add_argument('--xlrowstart', type=int, help="To identify where the ROWS starts to get data") myParser.add_argument('--xlcolstart', type=int, help="To identify where the COLUMS starts to get data") myParser.add_argument('--xlreportfromxl', type=int, choices = [0, 1], help="To select whether the final report generated from a XL file or individual test file") myParser.add_argument('--ttport', type=str, help="To identify serial port in which the Turn Table connected. Values given must be 'COMx' -> x is number of the COM port") myParser.add_argument('--angle', type=int, help="To Rotate the Turn Table into given angle") myParser.add_argument('--generatereport', type=int, choices = [0, 1], help="To decide whether Reports are needs to be generated or not") myParser.add_argument('--modifyreport', type=int, choices = [0, 1], help="To decide whether modified reports are needs to be generated or not") myParser.add_argument('--lip', type=str, help="To provide Local IP address") myParser.add_argument('--rip', type=str, help="To provide Remote IP address") myParser.add_argument('--rusername', type=str, help="To provide Remote User name") myParser.add_argument('--rpassword', type=str, help="To provide Remote Password") myParser.add_argument('--cbqacdirectory', type=str, help="To provide report directory of Carrier backoff test for Qualcom AP") myParser.add_argument('--cbcompdirectory', type=str, help="To provide report directory of Carrier backoff test for Competitor AP") args = myParser.parse_args() global ap global build global band global link global stream global protocol global graph global test global generateReport global modifyReport global localIP global remoteIP global remoteUsername global remotePassword global ttPort global anglePerMove global barWidth global legendXpos global legendYpos global labelXname global labelYname global graphTitle global xlToParse global xlToCreate global xlTotalRows global xlTotalCols global xlRowStart global xlColStart global xlReportFromXl global cbQacDirectory global cbCompDirectory if args.ap != None: ap = args.ap if args.build != None: build = args.build if args.band != None: band = args.band if args.link != None: link = args.link if args.stream != None: stream = args.stream if args.protocol != None: protocol = args.protocol if args.graph != None: graph = args.graph if args.test != None: test = args.test if args.barwidth != None: barWidth = args.barwidth if args.legendx != None: legendXpos = args.legendx if args.legendy != None: legendYpos = args.legendy if args.labelx != None: labelXname = args.labelx if args.labely != None: labelYname = args.labely if args.gtitle != None: graphTitle = args.gtitle if args.xlin != None: xlToParse = args.xlin if args.xlout != None: xlToCreate = args.xlout if args.xlrows != None: xlTotalRows = args.xlrows if args.xlcols != None: xlTotalCols = args.xlcols if args.xlrowstart != None: xlRowStart = args.xlrowstart if args.xlcolstart != None: xlColStart = args.xlcolstart if args.ttport != None: ttPort = args.ttport if args.generatereport != None: generateReport = args.generatereport if args.modifyreport != None: modifyReport = args.modifyreport if args.lip != None: localIP = args.lip if args.rip != None: remoteIP = args.rip if args.rusername != None: remoteUsername = args.rusername if args.rpassword != None: remotePassword = args.rpassword if args.angle != None: anglePerMove = args.angle if args.cbqacdirectory != None: cbQacDirectory = args.cbqacdirectory if args.cbcompdirectory != None: cbCompDirectory = args.cbcompdirectory if args.xlreportfromxl != None: xlReportFromXl = args.xlreportfromxl
def generateReport(): testLogs.INFO("QAC Report Directory is : {}".format( wifiConfig.cbQacDirectory)) testLogs.INFO("Competitor Report Directory is : {}".format( wifiConfig.cbCompDirectory)) log = "{}_{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.bands[wifiConfig.band], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) outputXlFile = wifiConfig.baseXlDirectory + log + '.xlsx' qacXlFile = wifiConfig.cbQacDirectory + wifiConfig.pathDivider + "averageValues.xlsx" compXlFile = wifiConfig.cbCompDirectory + wifiConfig.pathDivider + "averageValues.xlsx" testLogs.INFO("QAC XL file is : {}".format(qacXlFile)) testLogs.INFO("Competitor XL file is : {}".format(compXlFile)) testLogs.INFO("Output XL file is : {}".format(outputXlFile)) # Get QAC's Values qacClientsValues = xlParser.readXlFileRows(qacXlFile, 39, 2, 4) qacAggValues = xlParser.readXlFileColums(qacXlFile, 3, 6, 36) qacAggAverage = xlParser.readXlFileColums(qacXlFile, 39, 6, 1) # Get Competitor's values compClientsValues = xlParser.readXlFileRows(compXlFile, 39, 2, 4) compAggValues = xlParser.readXlFileColums(compXlFile, 3, 6, 36) compAggAverage = xlParser.readXlFileColums(compXlFile, 39, 6, 1) testLogs.INFO("QAC's Client Values are : {}".format(qacClientsValues)) testLogs.INFO("QAC's Aggregate Values are : {}".format(qacAggValues)) testLogs.INFO( "QAC's Average of Aggregate Values are : {}".format(qacAggAverage)) testLogs.INFO( "Competitors's Client Values are : {}".format(compClientsValues)) testLogs.INFO( "Competitors's Aggregate Values are : {}".format(compAggValues)) testLogs.INFO("Competitors's Average of Aggregate Values are : {}".format( compAggAverage)) #Writing Clients Values xlParser.writeXlFileRows(outputXlFile, ["AP"] + wifiConfig.cbClients, 2, 1) xlParser.writeXlFileRows(outputXlFile, [wifiConfig.aps[0]] + qacClientsValues, 3, 1) xlParser.writeXlFileRows(outputXlFile, [wifiConfig.aps[1]] + compClientsValues, 4, 1) #Writing Average Aggregate values xlParser.writeXlFileColums(outputXlFile, ["AP", "AGGREGATE"], 7, 1) xlParser.writeXlFileColums(outputXlFile, [wifiConfig.aps[0]] + qacAggAverage, 7, 2) xlParser.writeXlFileColums(outputXlFile, [wifiConfig.aps[1]] + compAggAverage, 7, 3) #Writing Aggregate values xlParser.writeXlFileColums(outputXlFile, ["POSITION"] + list(range(1, 37)), 11, 1) xlParser.writeXlFileColums(outputXlFile, [wifiConfig.aps[0]] + qacAggValues, 11, 2) xlParser.writeXlFileColums(outputXlFile, [wifiConfig.aps[1]] + compAggValues, 11, 3)
wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) wifiConfig.iperfLogDirectory = wifiConfig.iperfDirectory + log + wifiConfig.pathDivider testLogs.INFO("Creating Iperf Log Directory : {}".format( wifiConfig.iperfLogDirectory)) createDirectory(wifiConfig.iperfLogDirectory) if __name__ == "__main__": wifiConfig.parseWifiCommandLineArgs() createDirectories() if wifiConfig.modifyReport == 1: generateIndividualTestReport() exit(0) if wifiConfig.generateReport == 1 and wifiConfig.xlReportFromXl == 0: testLogs.INFO("Generating reports from Text Files....") createFinalReport() exit(0) elif wifiConfig.generateReport == 1 and wifiConfig.xlReportFromXl == 1: testLogs.INFO("Generating reports from XL File : {}".format( wifiConfig.xlToParse)) createFinalReportFromXlFile(wifiConfig.xlToParse) exit(0) else: runTest() generateIndividualTestReport()
def createFinalReportFromXlFile(xlFile=None): testLogs.INFO( "FUNCTION : Generating Final test report from XL file : {}".format( xlFile)) if wifiConfig.test == 0 or wifiConfig.test == 1: log = "{}_{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.bands[wifiConfig.band], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) elif wifiConfig.test == 2 or wifiConfig.test == 3: log = "{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) print("Link 0 Stream 0") print(log) if wifiConfig.test == 0 or wifiConfig.test == 1: if wifiConfig.band == 5: if wifiConfig.link == 0 and wifiConfig.stream == 0: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 1, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 0 and wifiConfig.stream == 1: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 2, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 3, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 1 and wifiConfig.stream == 0: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 8, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 9, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 1 and wifiConfig.stream == 1: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 10, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 11, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.band == 2: if wifiConfig.link == 0 and wifiConfig.stream == 0: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 4, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 5, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 0 and wifiConfig.stream == 1: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 6, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 7, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 1 and wifiConfig.stream == 0: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 12, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 13, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 1 and wifiConfig.stream == 1: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 14, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 15, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.test == 2 or wifiConfig.test == 3: if wifiConfig.link == 0 and wifiConfig.stream == 0: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 1, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 0 and wifiConfig.stream == 1: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 2, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 3, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 1 and wifiConfig.stream == 0: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 4, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 5, numberOfRows=wifiConfig.xlTotalRows) if wifiConfig.link == 1 and wifiConfig.stream == 1: throughputs1 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 6, numberOfRows=wifiConfig.xlTotalRows) throughputs2 = xlParser.readXlFileColums( xlFile, rowStart=wifiConfig.xlRowStart, colStart=wifiConfig.xlColStart + 7, numberOfRows=wifiConfig.xlTotalRows) #### Graph Generation graphName = wifiConfig.baseGraphDirectory + log graphs.createMultipleBarGraph([throughputs1, throughputs2], graphName) graphs.createMultipleRadarGraph([throughputs1, throughputs2], graphName) throughputs1 = throughputs1[:-1] throughputs2 = throughputs2[:-1] #### XL File Generation data1 = ['ANGLE'] + list(range(10, (len(throughputs1) * 10 + 1), 10)) + ['MIN', 'AVG', 'MAX'] if wifiConfig.test == 0: heading = [wifiConfig.builds[0], wifiConfig.builds[1]] elif wifiConfig.test == 1: heading = [wifiConfig.aps[0], wifiConfig.aps[1]] elif wifiConfig.test == 2: heading = [wifiConfig.bands[6], wifiConfig.bands[5]] elif wifiConfig.test == 3: heading = [wifiConfig.bands[5], wifiConfig.bands[2]] data2 = [heading[0]] + throughputs1 + [ min(throughputs1), int(sum(throughputs1) / len(throughputs1)), max(throughputs1) ] data3 = [heading[1]] + throughputs2 + [ min(throughputs2), int(sum(throughputs2) / len(throughputs2)), max(throughputs2) ] xlFileName = wifiConfig.baseXlDirectory + log + '.xlsx' xlParser.writeXlFileColums(xlFileName, data1, 3, 1) xlParser.writeXlFileColums(xlFileName, data2, 3, 2) xlParser.writeXlFileColums(xlFileName, data3, 3, 3) xlParser.insertXlImage(xlFileName, graphName + '_RADAR.png', 3, 5) xlParser.insertXlImage(xlFileName, graphName + '_BAR.png', 3, 18)
def runTest(): testLogs.INFO("FUNCTION : Run the AVM test") if wifiConfig.test == 0 or wifiConfig.test == 1: log = "{}_{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.bands[wifiConfig.band], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) elif wifiConfig.test == 2 or wifiConfig.test == 3: log = "{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) if True: #### Terminate the iperf process which is running already in local PC status = iperf.killLocalIperf() testLogs.STATUS("Kill iperf in local PC status is : {}".format(status)) #### Terminate the iperf process which is running already in remote Station status = iperf.killRemoteIperf(wifiConfig.remoteIP, wifiConfig.remoteUsername, wifiConfig.remotePassword) testLogs.STATUS( "Kill iperf in remote Station status is : {}".format(status)) #### Start the iperf server if iperf.runIperfServer() == False: testLogs.ERROR("Could not start iperf server") exit(1) #### Calculating number of times to rotate the Turn table based on the degree per rotation steps = int(360 / wifiConfig.ttRotateAngle) #### Executing a loop for the given number of steps for step in range(1, steps + 1): testLogs.INFO("=============== RUNNING TEST IS : {}".format(log)) #### Deriving log file name from the parameters testLogs.INFO("Rotate to angle : {}".format( step * wifiConfig.ttRotateAngle)) iperfLogFile = wifiConfig.iperfLogDirectory + log + '_' + str( step * wifiConfig.ttRotateAngle) + ".txt" testLogs.INFO("Iperf Log File : {}".format(iperfLogFile)) #### Rotate turn table to decided angle and wait for turn table to setteld in the position if turnTable.rotateTurnTable(wifiConfig.ttRotateAngle) == False: exit(1) time.sleep((wifiConfig.ttTimePerStep * wifiConfig.ttStepsPerAngle * wifiConfig.ttRotateAngle) + .1) #### Run iperf client in local or remote station based on the command line argument status = iperf.runIperfClient() testLogs.STATUS(status) #### Write iperf client output into log file if status != False: try: fd = open(iperfLogFile, 'w+') fd.close() fd = open(iperfLogFile, 'a') fd.write(status) fd.close() except Exception as E: testLogs.ERROR(E) exit(1) else: testLogs.ERROR("Could Not get output from iperf client") exit(1)
def createFinalReport(): testLogs.INFO("FUNCTION : Generating Final test reports") if wifiConfig.test == 0 or wifiConfig.test == 1: log = "{}_{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.bands[wifiConfig.band], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) elif wifiConfig.test == 2 or wifiConfig.test == 3: log = "{}_{}_{}".format(wifiConfig.streams[wifiConfig.stream], wifiConfig.protocols[wifiConfig.protocol], wifiConfig.links[wifiConfig.link]) if wifiConfig.test == 0: iperfDirectory1 = wifiConfig.outputDirectory + wifiConfig.builds[ 0] + wifiConfig.pathDivider + log + wifiConfig.pathDivider iperfDirectory2 = wifiConfig.outputDirectory + wifiConfig.builds[ 1] + wifiConfig.pathDivider + log + wifiConfig.pathDivider elif wifiConfig.test == 1: iperfDirectory1 = wifiConfig.outputDirectory + wifiConfig.aps[ 0] + wifiConfig.pathDivider + log + wifiConfig.pathDivider iperfDirectory2 = wifiConfig.outputDirectory + wifiConfig.aps[ 1] + wifiConfig.pathDivider + log + wifiConfig.pathDivider elif wifiConfig.test == 2: iperfDirectory1 = wifiConfig.outputDirectory + wifiConfig.bands[ 5] + wifiConfig.pathDivider + log + wifiConfig.pathDivider iperfDirectory2 = wifiConfig.outputDirectory + wifiConfig.bands[ 6] + wifiConfig.pathDivider + log + wifiConfig.pathDivider elif wifiConfig.test == 3: iperfDirectory1 = wifiConfig.outputDirectory + wifiConfig.bands[ 2] + wifiConfig.pathDivider + log + wifiConfig.pathDivider iperfDirectory2 = wifiConfig.outputDirectory + wifiConfig.bands[ 5] + wifiConfig.pathDivider + log + wifiConfig.pathDivider testLogs.INFO("iperfDirectory1 is : {}".format(iperfDirectory1)) files = logParser.getLogFilesInDirectory(iperfDirectory1) throughputs1 = logParser.getTpInLogFiles(files, iperfDirectory1) testLogs.INFO("Throuputs1 is : {}".format(throughputs1)) testLogs.INFO("iperfDirectory2 is : {}".format(iperfDirectory2)) files = logParser.getLogFilesInDirectory(iperfDirectory2) throughputs2 = logParser.getTpInLogFiles(files, iperfDirectory2) testLogs.INFO("Throuputs2 is : {}".format(throughputs2)) #### Graph Generation graphName = wifiConfig.baseGraphDirectory + log graphs.createMultipleBarGraph([throughputs1, throughputs2], graphName) graphs.createMultipleRadarGraph([throughputs1, throughputs2], graphName) throughputs1 = throughputs1[:-1] throughputs2 = throughputs2[:-1] #### XL File Generation data1 = ['ANGLE'] + list(range(10, (len(throughputs1) * 10 + 1), 10)) + ['MIN', 'AVG', 'MAX'] if wifiConfig.test == 0: heading = [wifiConfig.builds[0], wifiConfig.builds[1]] elif wifiConfig.test == 1: heading = [wifiConfig.aps[0], wifiConfig.aps[1]] elif wifiConfig.test == 2: heading = [wifiConfig.bands[5], wifiConfig.bands[6]] elif wifiConfig.test == 3: heading = [wifiConfig.bands[2], wifiConfig.bands[5]] data2 = [heading[0]] + throughputs1 + [ min(throughputs1), int(sum(throughputs1) / len(throughputs1)), max(throughputs1) ] data3 = [heading[1]] + throughputs2 + [ min(throughputs2), int(sum(throughputs2) / len(throughputs2)), max(throughputs2) ] xlFileName = wifiConfig.baseXlDirectory + log + '.xlsx' xlParser.writeXlFileColums(xlFileName, data1, 3, 1) xlParser.writeXlFileColums(xlFileName, data2, 3, 2) xlParser.writeXlFileColums(xlFileName, data3, 3, 3) xlParser.insertXlImage(xlFileName, graphName + '_RADAR.png', 3, 5) xlParser.insertXlImage(xlFileName, graphName + '_BAR.png', 3, 18)