From cb284b0c29369e167ffe900e4a5a442ebc1c89c9 Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 8 May 2020 12:24:38 -0700 Subject: [PATCH] Added color coding and statistics to html logging --- stationStressTest.py | 63 ++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/stationStressTest.py b/stationStressTest.py index a6d6c327..e2030ee9 100755 --- a/stationStressTest.py +++ b/stationStressTest.py @@ -5,7 +5,7 @@ import time sys.path.append('py-json') import json import pprint -from datetime import date +import datetime from LANforge import LFRequest from LANforge import LFUtils @@ -160,8 +160,18 @@ for name in stations: #create weblog for monitoring stations -webLog = "stationStressTestLog.html" -f = open(webLog,"w") +curTime = datetime.datetime.now().strftime("%Y-%m-%d_%H%M") +webLog = "/home/lanforge/Documents/load-test/loadTest{}.html".format(curTime) + +try: + f = open(webLog,"w") + +except IOError as err: + print(err) + print("Please ensure correct permissions have been assigned in target directory") + sys.exit() + + top = """ Test report @@ -171,29 +181,31 @@ h1, h2, h3 { text-align: center; font-family: "Century Gothic",Arial,Helvetica,s -

Long test on {}

+

Long test on %s

-""".format(date.today()) +""" % datetime.date.today() f.write(top) f.close() +f = open(webLog, "a") +f.write("\n") +for name in radios: + f.write("\n".format(name)) -for min5 in range(1): +f.write("\n") + +print("Logging Info to {}".format(webLog)) +for min5 in range(3): + f.write("") for radio, numStations in radios.items(): - - f = open(webLog, "a") - f.write("\n") - f.write("\n".format(radio)) - f.write("\n") - - + #print(radio) withoutIP = 0 dissociated = 0 + good = 0 - f.write("") for i in range(0,numStations): staName = "sta" + radio[-1:] + str(paddingNum + i)[1:] staStatus = getJsonInfo(mgrURL, "port/1/1/" + staName) @@ -201,19 +213,23 @@ for min5 in range(1): withoutIP += 1 if staStatus['interface']['ap'] == None: dissociated += 1 + else: + good += 1 - f.write("".format(staName)) - f.write("\n") - f.write("") + if withoutIP and not dissociated: + f.write("".format(good,numStations)) #without IP assigned + elif dissociated: + f.write("".format(good,numStations)) #dissociated from AP + else: + f.write("".format(good,numStations)) #with IP and associated - f.write("
{}
{}
\n") - f.write("{}
{}/{}{}/{}{}/{}
\n") - f.close() + f.write("") + time.sleep((min5 + 1) * 30) #Sleeps for five minutes at a time per loop - #print("Without IP: {}".format(withoutIP)) - #print("Dissociated: {}".format(dissociated)) - time.sleep((min5 + 1) * 300) #Sleeps for five minutes at a time per loop +f.write("\n") +f.close() + print("Stopping CX Traffic") for name in stations: @@ -223,6 +239,7 @@ for name in stations: time.sleep(10) #remove all created stations and cross connects + print("Cleaning Up...") for staName in stations: reqURL = "cli-json/rm_vlan"