Merge remote-tracking branch 'origin/master'

# Conflicts:
#	connectTest.py
This commit is contained in:
Logan Lipke
2020-06-03 09:18:50 -07:00
3 changed files with 501 additions and 526 deletions

View File

@@ -40,7 +40,7 @@ for file in searchResults:
if ver == file[1]: if ver == file[1]:
webFiles.append({'filename':file[0], 'timestamp': datetime.datetime.strptime(file[2], "%Y-%m-%d %H:%M")}) webFiles.append({'filename':file[0], 'timestamp': datetime.datetime.strptime(file[2], "%Y-%m-%d %H:%M")})
if len(webFiles) == 0: if len(webFiles) == 0:
print(f"Unable to find webfile with version number {ver}") print(f"Failed to find webfile with version number {ver}")
sys.exit(1) sys.exit(1)
@@ -95,7 +95,7 @@ if newestWebFile['timestamp'] > newestDirFile['timestamp']:
print("Attempting to extract files") print("Attempting to extract files")
subprocess.call(["tar", "-xf", f"{filePath}{newestWebFile['filename']}", "-C", "/home/lanforge/"]) subprocess.call(["tar", "-xf", f"{filePath}{newestWebFile['filename']}", "-C", "/home/lanforge/"])
except Exception as e: except Exception as e:
print(f"{e}\nExtraction Failed. Please try again") print(f"{e}\nExtraction failed. Please try again")
sys.exit(1) sys.exit(1)
#time.sleep(90) #time.sleep(90)
@@ -104,8 +104,8 @@ if newestWebFile['timestamp'] > newestDirFile['timestamp']:
print("Copying LANforge-auto.desktop to /home/lanforge/.config/autostart/") print("Copying LANforge-auto.desktop to /home/lanforge/.config/autostart/")
subprocess.call(["cp", f"/home/lanforge/{newestWebFile['filename'][:len(newestWebFile)-18]}/LANforge-auto.desktop", "/home/lanforge/.config/autostart/"]) subprocess.call(["cp", f"/home/lanforge/{newestWebFile['filename'][:len(newestWebFile)-18]}/LANforge-auto.desktop", "/home/lanforge/.config/autostart/"])
except Exception as e: except Exception as e:
print(e) print(f"{e}\nCopy failed. Please try again")
sys.exit(1)
try: try:
print(f"Attempting to install {newestWebFile['filename']} at /home/lanforge") print(f"Attempting to install {newestWebFile['filename']} at /home/lanforge")
@@ -114,12 +114,12 @@ if newestWebFile['timestamp'] > newestDirFile['timestamp']:
print(f"{e}\nInstallation failed. Please Try again.") print(f"{e}\nInstallation failed. Please Try again.")
sys.exit(1) sys.exit(1)
#=========ATTEMPT TO RESTART GUI========== #=========ATTEMPT TO RESTART GUI==========
try: # try:
print("Killing current GUI process") # print("Killing current GUI process")
os.system("pgrep java | xargs kill") # os.system("if pgrep java; then pgrep java | xargs kill -9 ;fi")
except Exception as e: # except Exception as e:
print(e) # print(f"{e}\nProcess kill failed. Please try again")
# sys.exit(1)
else: else:
print("Current GUI version up to date") print("Current GUI version up to date")

View File

@@ -1,17 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os
import time
import sys import sys
if 'py-json' not in sys.path: if 'py-json' not in sys.path:
sys.path.append('py-json') sys.path.append('py-json')
import subprocess
import json
import pprint
from LANforge import LFRequest
from LANforge import LFUtils from LANforge import LFUtils
from LANforge.LFUtils import * from LANforge.LFUtils import *
from LANforge.lfcli_base import LFCliBase
import create_genlink as genl import create_genlink as genl
@@ -21,57 +16,41 @@ if sys.version_info[0] != 3:
exit(1) exit(1)
mgrURL = "http://localhost:8080/" mgrURL = "http://localhost:8080/"
staName = "sta0"
staNameUri = "port/1/1/" + staName
def jsonReq(mgrURL, reqURL, data, exitWhenCalled=False): class ConnectTest(LFCliBase):
lf_r = LFRequest.LFRequest(mgrURL + reqURL) def __init__(self, lfhost, lfport):
lf_r.addPostData(data) super().__init__(lfhost, lfport, True)
super().checkConnect()
if exitWhenCalled: # compare pre-test values to post-test values
json_response = lf_r.jsonPost(True) @staticmethod
print("jsonReq: debugdie Response: ") def CompareVals(_name, preVal, postVal):
LFUtils.debug_printer.pprint(vars(json_response)) print(f"Comparing {_name}")
print("jsonReq: bye") if postVal > preVal:
sys.exit(1) print(" Test Passed")
else: else:
lf_r.jsonPost(False) # False means don't print info on errors print(f" Test Failed: {_name} did not increase after 5 seconds")
def getJsonInfo(mgrURL, reqURL, debug=False):
lf_r = LFRequest.LFRequest(mgrURL + reqURL)
json_response = lf_r.getAsJson(debug)
return json_response
# print(name)
# j_printer = pprint.PrettyPrinter(indent=2)
# j_printer.pprint(json_response)
# for record in json_response[key]:
# j_printer.pprint(record)
print("Checking for LANforge Client")
response = getJsonInfo(mgrURL, 'port/1/1/wiphy0')
duration = 0
while ((response == None) and (duration < 300)):
print("LANforge Client not found sleeping 5 seconds")
duration += 2
time.sleep(2)
response = getJsonInfo(mgrURL, 'port/1/1/wiphy0')
if duration >= 300:
print("Could not connect to LANforge Client")
sys.exit(1)
def run(self):
print("See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test") print("See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test")
eth1IP = super().jsonGet("port/1/1/eth1")
if eth1IP['interface']['ip'] == "0.0.0.0":
print("Warning: Eth1 lacks ip address")
exit(1)
# Create stations and turn dhcp on # Create stations and turn dhcp on
print("Creating station and turning on dhcp") print("Creating station and turning on dhcp")
url = "port/1/1/sta00000" response = super().jsonGet(staNameUri)
debugOn = True if response is not None:
response = getJsonInfo(mgrURL, url) if response["interface"] is not None:
if (response is not None):
if (response["interface"] is not None):
print("removing old station") print("removing old station")
LFUtils.removePort("1", "sta00000", mgrURL) removePort(1, staName, mgrURL)
waitUntilPortsDisappear(1, mgrURL, [staName])
time.sleep(1) time.sleep(1)
url = "cli-json/add_sta" url = "cli-json/add_sta"
@@ -79,74 +58,65 @@ data = {
"shelf": 1, "shelf": 1,
"resource": 1, "resource": 1,
"radio": "wiphy0", "radio": "wiphy0",
"sta_name": "sta00000", "sta_name": staName,
"ssid": "jedway-wpa2-x2048-5-1", "ssid": "jedway-wpa2-x2048-5-1",
"key": "jedway-wpa2-x2048-5-1", "key": "jedway-wpa2-x2048-5-1",
"mode": 1, "mode": 0,
"mac": "xx:xx:xx:xx:*:xx", "mac": "xx:xx:xx:xx:*:xx",
"flags": 1024 # 0x400 | 1024 "flags": (0x400 + 0x20000 + 0x1000000000) # create admin down
} }
print("adding new station") super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(0.05)
time.sleep(1)
reqURL = "cli-json/set_port" reqURL = "cli-json/set_port"
data = { data = {
"shelf": 1, "shelf": 1,
"resource": 1, "resource": 1,
"port": "sta00000", "port": staName,
"current_flags": 2147483648, # 0x80000000 | 2147483648 "current_flags": (0x1 + 0x80000000),
"interest": 16386 # 0x4002 | 16386 "interest": (0x2 + 0x4000 + 0x800000) # current, dhcp, down,
} }
print("configuring port") super().jsonPost(reqURL, data)
jsonReq(mgrURL, reqURL, data) time.sleep(0.5)
super().jsonPost("cli-json/set_port", portUpRequest(1, staName))
time.sleep(5)
eth1IP = getJsonInfo(mgrURL, "port/1/1/eth1")
if eth1IP['interface']['ip'] == "0.0.0.0":
print("Warning: Eth1 lacks ip address")
reqURL = "cli-json/nc_show_ports" reqURL = "cli-json/nc_show_ports"
data = {"shelf": 1, data = {"shelf": 1,
"resource": 1, "resource": 1,
"port": "sta0000", "port": staName,
"probe_flags": 1} "probe_flags": 1}
jsonReq(mgrURL, reqURL, data) super().jsonPost(reqURL, data)
time.sleep(0.5)
waitUntilPortsAdminUp(1, mgrURL, [staName])
station_info = getJsonInfo(mgrURL, "port/1/1/sta00000?fields=port,ip")
duration = 0 duration = 0
maxTime = 300 maxTime = 300
ip = "0.0.0.0" ip = "0.0.0.0"
while ((ip == "0.0.0.0") and (duration < maxTime)): while (ip == "0.0.0.0") and (duration < maxTime):
print("Station failed to get IP. Waiting 10 seconds...") station_info = super().jsonGet(staNameUri + "?fields=port,ip")
station_info = getJsonInfo(mgrURL, "port/1/1/sta00000?fields=port,ip") LFUtils.debug_printer.pprint(station_info)
if (station_info is not None) and ("interface" in station_info) and ("ip" in station_info["interface"]):
# LFUtils.debug_printer.pprint(station_info)
if ((station_info is not None) and ("interface" in station_info) and ("ip" in station_info["interface"])):
ip = station_info["interface"]["ip"] ip = station_info["interface"]["ip"]
duration += 2 if ip == "0.0.0.0":
time.sleep(2) duration += 4
time.sleep(4)
else:
break
if duration >= maxTime: if duration >= maxTime:
print("sta00000 failed to get an ip. Ending test") print(staName+" failed to get an ip. Ending test")
print("Cleaning up...") print("Cleaning up...")
removePort("1", "sta00000", mgrURL) removePort(1, staName, mgrURL)
sys.exit(1) sys.exit(1)
# create endpoints and cxs
print("Creating endpoints and cross connects") print("Creating endpoints and cross connects")
# create cx for tcp and udp # create cx for tcp and udp
cmd = ( cmd = (
"./lf_firemod.pl --action create_cx --cx_name testTCP --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type tcp > ~/Documents/connectTestLogs/connectTestLatest.log") f"./lf_firemod.pl --action create_cx --cx_name testTCP --use_ports {staName},eth1 --use_speeds 360000,150000 --endp_type tcp > /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
execWrap(cmd) execWrap(cmd)
cmd = ( cmd = (
"./lf_firemod.pl --action create_cx --cx_name testUDP --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type udp >> ~/Documents/connectTestLogs/connectTestLatest.log") f"./lf_firemod.pl --action create_cx --cx_name testUDP --use_ports {staName},eth1 --use_speeds 360000,150000 --endp_type udp >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
execWrap(cmd) execWrap(cmd)
time.sleep(.5) time.sleep(.05)
# create l4 endpoint # create l4 endpoint
url = "cli-json/add_l4_endp" url = "cli-json/add_l4_endp"
@@ -160,9 +130,8 @@ data = {
"url_rate": 600, "url_rate": 600,
"url": "dl http://10.40.0.1/ /dev/null" "url": "dl http://10.40.0.1/ /dev/null"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create cx for l4_endp # create cx for l4_endp
url = "cli-json/add_cx" url = "cli-json/add_cx"
@@ -172,9 +141,8 @@ data = {
"tx_endp": "l4Test", "tx_endp": "l4Test",
"rx_endp": "NA" "rx_endp": "NA"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create fileio endpoint # create fileio endpoint
url = "cli-json/add_file_endp" url = "cli-json/add_file_endp"
@@ -186,9 +154,8 @@ data = {
"type": "fe_nfs", "type": "fe_nfs",
"directory": "/mnt/fe-test" "directory": "/mnt/fe-test"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create fileio cx # create fileio cx
url = "cli-json/add_cx" url = "cli-json/add_cx"
@@ -198,9 +165,8 @@ data = {
"tx_endp": "fioTest", "tx_endp": "fioTest",
"rx_endp": "NA" "rx_endp": "NA"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create generic endpoints # create generic endpoints
genl.createGenEndp("genTest1", 1, 1, "sta00000", "gen_generic") genl.createGenEndp("genTest1", 1, 1, "sta00000", "gen_generic")
@@ -209,7 +175,7 @@ genl.setFlags("genTest1", "ClearPortOnStart", 1)
genl.setFlags("genTest2", "ClearPortOnStart", 1) genl.setFlags("genTest2", "ClearPortOnStart", 1)
genl.setFlags("genTest2", "Unmanaged", 1) genl.setFlags("genTest2", "Unmanaged", 1)
genl.setCmd("genTest1", "lfping -i 0.1 -I sta00000 10.40.0.1") genl.setCmd("genTest1", "lfping -i 0.1 -I sta00000 10.40.0.1")
time.sleep(.5) time.sleep(.05)
# create generic cx # create generic cx
url = "cli-json/add_cx" url = "cli-json/add_cx"
@@ -219,9 +185,8 @@ data = {
"tx_endp": "genTest1", "tx_endp": "genTest1",
"rx_endp": "genTest2" "rx_endp": "genTest2"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create redirects for wanlink # create redirects for wanlink
url = "cli-json/add_rdd" url = "cli-json/add_rdd"
@@ -231,8 +196,7 @@ data = {
"port": "rdd0", "port": "rdd0",
"peer_ifname": "rdd1" "peer_ifname": "rdd1"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data)
url = "cli-json/add_rdd" url = "cli-json/add_rdd"
data = { data = {
@@ -241,9 +205,8 @@ data = {
"port": "rdd1", "port": "rdd1",
"peer_ifname": "rdd0" "peer_ifname": "rdd0"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# reset redirect ports # reset redirect ports
url = "cli-json/reset_port" url = "cli-json/reset_port"
@@ -252,8 +215,7 @@ data = {
"resource": 1, "resource": 1,
"port": "rdd0" "port": "rdd0"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data)
url = "cli-json/reset_port" url = "cli-json/reset_port"
data = { data = {
@@ -261,91 +223,87 @@ data = {
"resource": 1, "resource": 1,
"port": "rdd1" "port": "rdd1"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create wanlink endpoints # create wanlink endpoints
url = "cli-json/add_wl_endp" url = "cli-json/add_wl_endp"
data = { data = {
"alias": "wlan0", "alias": "wlTest1",
"shelf": 1, "shelf": 1,
"resource": 1, "resource": 1,
"port": "rdd0", "port": "rdd0",
"latency": 20, "latency": 20,
"max_rate": 1544000 "max_rate": 1544000
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data)
url = "cli-json/add_wl_endp" url = "cli-json/add_wl_endp"
data = { data = {
"alias": "wlan1", "alias": "wlTest2",
"shelf": 1, "shelf": 1,
"resource": 1, "resource": 1,
"port": "rdd1", "port": "rdd1",
"latency": 30, "latency": 30,
"max_rate": 1544000 "max_rate": 1544000
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
time.sleep(.5)
# create wanlink cx # create wanlink cx
url = "cli-json/add_cx" url = "cli-json/add_cx"
data = { data = {
"alias": "CX_wlan0", "alias": "CX_wlTest1",
"test_mgr": "default_tm", "test_mgr": "default_tm",
"tx_endp": "wlan0", "tx_endp": "wlTest1",
"rx_endp": "wlan1" "rx_endp": "wlTest2"
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data)
time.sleep(.5) time.sleep(.5)
cxNames = ["testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlan0"] cxNames = ["testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlTest1"]
# get data before running traffic # get data before running traffic
try: try:
testTCPA = getJsonInfo(mgrURL, "endp/testTCP-A?fields=tx+bytes,rx+bytes") testTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes")
testTCPATX = testTCPA['endpoint']['tx bytes'] testTCPATX = testTCPA['endpoint']['tx bytes']
testTCPARX = testTCPA['endpoint']['rx bytes'] testTCPARX = testTCPA['endpoint']['rx bytes']
testTCPB = getJsonInfo(mgrURL, "endp/testTCP-B?fields=tx+bytes,rx+bytes") testTCPB = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes")
testTCPBTX = testTCPB['endpoint']['tx bytes'] testTCPBTX = testTCPB['endpoint']['tx bytes']
testTCPBRX = testTCPB['endpoint']['rx bytes'] testTCPBRX = testTCPB['endpoint']['rx bytes']
testUDPA = getJsonInfo(mgrURL, "endp/testUDP-A?fields=tx+bytes,rx+bytes") testUDPA = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes")
testUDPATX = testUDPA['endpoint']['tx bytes'] testUDPATX = testUDPA['endpoint']['tx bytes']
testUDPARX = testUDPA['endpoint']['rx bytes'] testUDPARX = testUDPA['endpoint']['rx bytes']
testUDPB = getJsonInfo(mgrURL, "endp/testUDP-B?fields=tx+bytes,rx+bytes") testUDPB = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes")
testUDPBTX = testUDPB['endpoint']['tx bytes'] testUDPBTX = testUDPB['endpoint']['tx bytes']
testUDPBRX = testUDPB['endpoint']['rx bytes'] testUDPBRX = testUDPB['endpoint']['rx bytes']
l4Test = getJsonInfo(mgrURL, "layer4/l4Test?fields=bytes-rd") l4Test = super().jsonGet("layer4/l4Test?fields=bytes-rd")
l4TestBR = l4Test['endpoint']['bytes-rd'] l4TestBR = l4Test['endpoint']['bytes-rd']
genTest1 = getJsonInfo(mgrURL, "generic/genTest1?fields=last+results") genTest1 = super().jsonGet("generic/genTest1?fields=last+results")
genTest1LR = genTest1['endpoint']['last results'] genTest1LR = genTest1['endpoint']['last results']
wlan0 = getJsonInfo(mgrURL, "wl_ep/wlan0") wlTest1 = super().jsonGet("wl_ep/wlTest1")
wlan0TXB = wlan0['endpoint']['tx bytes'] wlTest1TXB = wlTest1['endpoint']['tx bytes']
wlan0RXP = wlan0['endpoint']['rx pkts'] wlTest1RXP = wlTest1['endpoint']['rx pkts']
wlan1 = getJsonInfo(mgrURL, "wl_ep/wlan1") wlTest2 = super().jsonGet("wl_ep/wlTest2")
wlan1TXB = wlan1['endpoint']['tx bytes'] wlTest2TXB = wlTest2['endpoint']['tx bytes']
wlan1RXP = wlan1['endpoint']['rx pkts'] wlTest2RXP = wlTest2['endpoint']['rx pkts']
except Exception as e: except Exception as e:
print("Something went wrong") print("Something went wrong")
print(e) print(e)
print("Cleaning up...") print("Cleaning up...")
LFUtils.removePort("1", "sta00000", mgrURL) LFUtils.removePort(1, staName, mgrURL)
endpNames = ["testTCP-A", "testTCP-B", endpNames = ["testTCP-A", "testTCP-B",
"testUDP-A", "testUDP-B", "testUDP-A", "testUDP-B",
"l4Test", "fioTest", "l4Test", "fioTest",
"genTest1", "genTest2", "genTest1", "genTest2",
"wlan0", "wlan1"] "wlTest1", "wlTest2"]
removeCX(mgrURL, cxNames) removeCX(mgrURL, cxNames)
removeEndps(mgrURL, endpNames) removeEndps(mgrURL, endpNames)
sys.exit(1) sys.exit(1)
@@ -400,13 +358,13 @@ os.system("echo genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTes
cmd = ( cmd = (
"./lf_firemod.pl --action show_endp --endp_name genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") "./lf_firemod.pl --action show_endp --endp_name genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
execWrap(cmd) execWrap(cmd)
os.system("echo wlan0 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") os.system("echo wlTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
cmd = ( cmd = (
"./lf_firemod.pl --action show_endp --endp_name wlan0 --endp_vals \"Rx Pkts,Tx Bytes,Cur-Backlog,Dump File,Tx3s\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") "./lf_firemod.pl --action show_endp --endp_name wlTest1 --endp_vals \"Rx Pkts,Tx Bytes,Cur-Backlog,Dump File,Tx3s\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
execWrap(cmd) execWrap(cmd)
os.system("echo wlan1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") os.system("echo wlTest2 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
cmd = ( cmd = (
"./lf_firemod.pl --action show_endp --endp_name wlan1 --endp_vals \"Rx Pkts,Tx Bytes,Cur-Backlog,Dump File,Tx3s\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") "./lf_firemod.pl --action show_endp --endp_name wlTest2 --endp_vals \"Rx Pkts,Tx Bytes,Cur-Backlog,Dump File,Tx3s\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
execWrap(cmd) execWrap(cmd)
# stop cx traffic # stop cx traffic
@@ -421,34 +379,34 @@ time.sleep(15)
# get data for endpoints JSON # get data for endpoints JSON
print("Collecting Data") print("Collecting Data")
try: try:
ptestTCPA = getJsonInfo(mgrURL, "endp/testTCP-A?fields=tx+bytes,rx+bytes") ptestTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes")
ptestTCPATX = ptestTCPA['endpoint']['tx bytes'] ptestTCPATX = ptestTCPA['endpoint']['tx bytes']
ptestTCPARX = ptestTCPA['endpoint']['rx bytes'] ptestTCPARX = ptestTCPA['endpoint']['rx bytes']
ptestTCPB = getJsonInfo(mgrURL, "endp/testTCP-B?fields=tx+bytes,rx+bytes") ptestTCPB = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes")
ptestTCPBTX = ptestTCPB['endpoint']['tx bytes'] ptestTCPBTX = ptestTCPB['endpoint']['tx bytes']
ptestTCPBRX = ptestTCPB['endpoint']['rx bytes'] ptestTCPBRX = ptestTCPB['endpoint']['rx bytes']
ptestUDPA = getJsonInfo(mgrURL, "endp/testUDP-A?fields=tx+bytes,rx+bytes") ptestUDPA = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes")
ptestUDPATX = ptestUDPA['endpoint']['tx bytes'] ptestUDPATX = ptestUDPA['endpoint']['tx bytes']
ptestUDPARX = ptestUDPA['endpoint']['rx bytes'] ptestUDPARX = ptestUDPA['endpoint']['rx bytes']
ptestUDPB = getJsonInfo(mgrURL, "endp/testUDP-B?fields=tx+bytes,rx+bytes") ptestUDPB = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes")
ptestUDPBTX = ptestUDPB['endpoint']['tx bytes'] ptestUDPBTX = ptestUDPB['endpoint']['tx bytes']
ptestUDPBRX = ptestUDPB['endpoint']['rx bytes'] ptestUDPBRX = ptestUDPB['endpoint']['rx bytes']
pl4Test = getJsonInfo(mgrURL, "layer4/l4Test?fields=bytes-rd") pl4Test = super().jsonGet("layer4/l4Test?fields=bytes-rd")
pl4TestBR = pl4Test['endpoint']['bytes-rd'] pl4TestBR = pl4Test['endpoint']['bytes-rd']
pgenTest1 = getJsonInfo(mgrURL, "generic/genTest1?fields=last+results") pgenTest1 = super().jsonGet("generic/genTest1?fields=last+results")
pgenTest1LR = pgenTest1['endpoint']['last results'] pgenTest1LR = pgenTest1['endpoint']['last results']
pwlan0 = getJsonInfo(mgrURL, "wl_ep/wlan0") pwlTest1 = super().jsonGet("wl_ep/wlTest1")
pwlan0TXB = pwlan0['endpoint']['tx bytes'] pwlTest1TXB = pwlTest1['endpoint']['tx bytes']
pwlan0RXP = pwlan0['endpoint']['rx pkts'] pwlTest1RXP = pwlTest1['endpoint']['rx pkts']
pwlan1 = getJsonInfo(mgrURL, "wl_ep/wlan1") pwlTest2 = super().jsonGet("wl_ep/wlTest2")
pwlan1TXB = pwlan1['endpoint']['tx bytes'] pwlTest2TXB = pwlTest2['endpoint']['tx bytes']
pwlan1RXP = pwlan1['endpoint']['rx pkts'] pwlTest2RXP = pwlTest2['endpoint']['rx pkts']
except Exception as e: except Exception as e:
print("Something went wrong") print("Something went wrong")
print(e) print(e)
@@ -457,16 +415,15 @@ except Exception as e:
data = { data = {
"shelf": 1, "shelf": 1,
"resource": 1, "resource": 1,
"port": "sta00000" "port": staName
} }
super().jsonPost(reqURL, data)
jsonReq(mgrURL, reqURL, data)
endpNames = ["testTCP-A", "testTCP-B", endpNames = ["testTCP-A", "testTCP-B",
"testUDP-A", "testUDP-B", "testUDP-A", "testUDP-B",
"l4Test", "fioTest", "l4Test", "fioTest",
"genTest1", "genTest2", "genTest1", "genTest2",
"wlan0", "wlan1"] "wlTest1", "wlTest2"]
removeCX(mgrURL, cxNames) removeCX(mgrURL, cxNames)
removeEndps(mgrURL, endpNames) removeEndps(mgrURL, endpNames)
sys.exit(1) sys.exit(1)
@@ -474,51 +431,44 @@ except Exception as e:
# print("Sleeping for 5 seconds") # print("Sleeping for 5 seconds")
time.sleep(5) time.sleep(5)
# compare pre-test values to post-test values
def compareVals(name, preVal, postVal):
print(f"Comparing {name}")
if postVal > preVal:
print(" Test Passed")
else:
print(f" Test Failed: {name} did not increase after 5 seconds")
print("\n") print("\n")
compareVals("testTCP-A TX", testTCPATX, ptestTCPATX) self.CompareVals("testTCP-A TX", testTCPATX, ptestTCPATX)
compareVals("testTCP-A RX", testTCPARX, ptestTCPARX) self.CompareVals("testTCP-A RX", testTCPARX, ptestTCPARX)
self.CompareVals("testTCP-B TX", testTCPBTX, ptestTCPBTX)
compareVals("testTCP-B TX", testTCPBTX, ptestTCPBTX) self.CompareVals("testTCP-B RX", testTCPBRX, ptestTCPBRX)
compareVals("testTCP-B RX", testTCPBRX, ptestTCPBRX) self.CompareVals("testUDP-A TX", testUDPATX, ptestUDPATX)
self.CompareVals("testUDP-A RX", testUDPARX, ptestUDPARX)
compareVals("testUDP-A TX", testUDPATX, ptestUDPATX) self.CompareVals("testUDP-B TX", testUDPBTX, ptestUDPBTX)
compareVals("testUDP-A RX", testUDPARX, ptestUDPARX) self.CompareVals("testUDP-B RX", testUDPBRX, ptestUDPBRX)
self.CompareVals("l4Test Bytes Read", l4TestBR, pl4TestBR)
compareVals("testUDP-B TX", testUDPBTX, ptestUDPBTX) self.CompareVals("genTest1 Last Results", genTest1LR, pgenTest1LR)
compareVals("testUDP-B RX", testUDPBRX, ptestUDPBRX) self.CompareVals("wlTest1 TX Bytes", wlTest1TXB, pwlTest1TXB)
self.CompareVals("wlTest1 RX Pkts", wlTest1RXP, pwlTest1RXP)
compareVals("l4Test Bytes Read", l4TestBR, pl4TestBR) self.CompareVals("wlTest2 TX Bytes", wlTest2TXB, pwlTest2TXB)
self.CompareVals("wlTest2 RX Pkts", wlTest2RXP, pwlTest2RXP)
compareVals("genTest1 Last Results", genTest1LR, pgenTest1LR)
compareVals("wlan0 TX Bytes", wlan0TXB, pwlan0TXB)
compareVals("wlan0 RX Pkts", wlan0RXP, pwlan0RXP)
compareVals("wlan1 TX Bytes", wlan1TXB, pwlan1TXB)
compareVals("wlan1 RX Pkts", wlan1RXP, pwlan1RXP)
print("\n") print("\n")
# remove all endpoints and cxs # remove all endpoints and cxs
print("Cleaning up...") print("Cleaning up...")
LFUtils.removePort(1, "sta00000", mgrURL)
LFUtils.removePort("1", "sta00000", mgrURL)
endpNames = ["testTCP-A", "testTCP-B", endpNames = ["testTCP-A", "testTCP-B",
"testUDP-A", "testUDP-B", "testUDP-A", "testUDP-B",
"l4Test", "fioTest", "l4Test", "fioTest",
"genTest1", "genTest2", "genTest1", "genTest2",
"wlan0", "wlan1"] "wlTest1", "wlTest2"]
removeCX(mgrURL, cxNames) removeCX(mgrURL, cxNames)
removeEndps(mgrURL, endpNames) removeEndps(mgrURL, endpNames)
# ~class
def main():
lfjson_host = "localhost"
lfjson_port = 8080
test = ConnectTest(lfjson_host, lfjson_port)
test.run()
if __name__ == "__main__":
main()

View File

@@ -9,21 +9,46 @@ GUIUpdate="/home/lanforge/Documents/GUIUpdateLog.txt"
CTLGUI="/home/lanforge/Documents/connectTestGUILog.txt" CTLGUI="/home/lanforge/Documents/connectTestGUILog.txt"
CTLH="/home/lanforge/Documents/connectTestHLog.txt" CTLH="/home/lanforge/Documents/connectTestHLog.txt"
verNum="5.4.2" verNum="5.4.2"
GUIDIR="${HL}/LANforgeGUI_${verNum}"
ST="/tmp/summary.txt"
for f in $GUILog $GUIUpdate $CTLGUI $CTLH; do rm -f $f; done rm -f $GUILog $GUIUpdate $CTLGUI $CTLH $ST
touch "${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART"
pgrep java &>/dev/null && killall -9 java
python3 ${scripts}/auto-install-gui.py --versionNumber $verNum &> $GUIUpdate python3 ${scripts}/auto-install-gui.py --versionNumber $verNum &> $GUIUpdate
sleep 5 sleep 1
rm -f "${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART"
( cd $GUIDIR; nohup env RESTARTS=999999 ./lfclient.bash -s localhost &> $GUILog & )
sleep 10
grep -q "Current GUI version up to date" $GUIUpdate && exit grep -q "Current GUI version up to date" $GUIUpdate && exit
echo "===============================================" > $ST
head $GUILog >> $ST
echo "===============================================" >> $ST
head $GUIUpdate >> $ST
if grep -q -i "fail" $GUIUpdate; then
cat $ST | mail -s 'GUI Update Test Failure' -a $GUILog -a $GUIUpdate "test.notice@candelatech.com"
fi
#pgrep java &>/dev/null && killall -9 java
#( cd $GUIDIR; nohup env RESTARTS=999999 ./lfclient.bash -s localhost &> $GUILog & )
python3 ${scripts}/connectTest.py &> $CTLGUI python3 ${scripts}/connectTest.py &> $CTLGUI
sleep 1
killall -9 java
sleep 1
${HL}/LANforgeGUI_5.4.2/lfclient.bash -daemon -s localhost &> $GUILog & touch "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE"
sleep 5
pgrep java &>/dev/null && killall -9 java
sleep 10
python3 ${scripts}/connectTest.py &> $CTLH python3 ${scripts}/connectTest.py &> $CTLH
sleep 1
echo "Logs Attached" | mail -s 'GUI Update Logs' -a $GUILog -a $GUIUpdate -a $CTLGUI -a $CTLH "test.notice@candelatech.com" rm "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE"
pgrep java &>/dev/null && killall -9 java
echo "===============================================" >> $ST
head $CTLGUI >> $ST
echo "===============================================" >> $ST
head $CTLH >> $ST
echo "===============================================" >> $ST
cat $ST | mail -s 'GUI Update Test' -a $GUILog -a $GUIUpdate -a $CTLGUI -a $CTLH "test.notice@candelatech.com"