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,504 +16,459 @@ 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):
lf_r = LFRequest.LFRequest(mgrURL + reqURL)
lf_r.addPostData(data) class ConnectTest(LFCliBase):
def __init__(self, lfhost, lfport):
if exitWhenCalled: super().__init__(lfhost, lfport, True)
json_response = lf_r.jsonPost(True) super().checkConnect()
print("jsonReq: debugdie Response: ")
LFUtils.debug_printer.pprint(vars(json_response)) # compare pre-test values to post-test values
print("jsonReq: bye") @staticmethod
sys.exit(1) def CompareVals(_name, preVal, postVal):
else: print(f"Comparing {_name}")
lf_r.jsonPost(False) # False means don't print info on errors if postVal > preVal:
print(" Test Passed")
else:
def getJsonInfo(mgrURL, reqURL, debug=False): print(f" Test Failed: {_name} did not increase after 5 seconds")
lf_r = LFRequest.LFRequest(mgrURL + reqURL)
json_response = lf_r.getAsJson(debug) def run(self):
return json_response print("See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test")
# print(name)
# j_printer = pprint.PrettyPrinter(indent=2) eth1IP = super().jsonGet("port/1/1/eth1")
# j_printer.pprint(json_response) if eth1IP['interface']['ip'] == "0.0.0.0":
# for record in json_response[key]: print("Warning: Eth1 lacks ip address")
# j_printer.pprint(record) exit(1)
# Create stations and turn dhcp on
print("Checking for LANforge Client") print("Creating station and turning on dhcp")
response = getJsonInfo(mgrURL, 'port/1/1/wiphy0')
duration = 0 response = super().jsonGet(staNameUri)
while ((response == None) and (duration < 300)): if response is not None:
print("LANforge Client not found sleeping 5 seconds") if response["interface"] is not None:
duration += 2 print("removing old station")
time.sleep(2) removePort(1, staName, mgrURL)
response = getJsonInfo(mgrURL, 'port/1/1/wiphy0') waitUntilPortsDisappear(1, mgrURL, [staName])
time.sleep(1)
if duration >= 300:
print("Could not connect to LANforge Client") url = "cli-json/add_sta"
sys.exit(1) data = {
"shelf": 1,
print("See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test") "resource": 1,
# Create stations and turn dhcp on "radio": "wiphy0",
print("Creating station and turning on dhcp") "sta_name": staName,
"ssid": "jedway-wpa2-x2048-5-1",
url = "port/1/1/sta00000" "key": "jedway-wpa2-x2048-5-1",
debugOn = True "mode": 0,
response = getJsonInfo(mgrURL, url) "mac": "xx:xx:xx:xx:*:xx",
if (response is not None): "flags": (0x400 + 0x20000 + 0x1000000000) # create admin down
if (response["interface"] is not None): }
print("removing old station") super().jsonPost(url, data)
LFUtils.removePort("1", "sta00000", mgrURL) time.sleep(0.05)
time.sleep(1) reqURL = "cli-json/set_port"
data = {
url = "cli-json/add_sta" "shelf": 1,
data = { "resource": 1,
"shelf": 1, "port": staName,
"resource": 1, "current_flags": (0x1 + 0x80000000),
"radio": "wiphy0", "interest": (0x2 + 0x4000 + 0x800000) # current, dhcp, down,
"sta_name": "sta00000", }
"ssid": "jedway-wpa2-x2048-5-1", super().jsonPost(reqURL, data)
"key": "jedway-wpa2-x2048-5-1", time.sleep(0.5)
"mode": 1, super().jsonPost("cli-json/set_port", portUpRequest(1, staName))
"mac": "xx:xx:xx:xx:*:xx",
"flags": 1024 # 0x400 | 1024 reqURL = "cli-json/nc_show_ports"
} data = {"shelf": 1,
print("adding new station") "resource": 1,
jsonReq(mgrURL, url, data) "port": staName,
"probe_flags": 1}
time.sleep(1) super().jsonPost(reqURL, data)
time.sleep(0.5)
reqURL = "cli-json/set_port" waitUntilPortsAdminUp(1, mgrURL, [staName])
data = {
"shelf": 1, duration = 0
"resource": 1, maxTime = 300
"port": "sta00000", ip = "0.0.0.0"
"current_flags": 2147483648, # 0x80000000 | 2147483648 while (ip == "0.0.0.0") and (duration < maxTime):
"interest": 16386 # 0x4002 | 16386 station_info = super().jsonGet(staNameUri + "?fields=port,ip")
} LFUtils.debug_printer.pprint(station_info)
print("configuring port") if (station_info is not None) and ("interface" in station_info) and ("ip" in station_info["interface"]):
jsonReq(mgrURL, reqURL, data) ip = station_info["interface"]["ip"]
if ip == "0.0.0.0":
time.sleep(5) duration += 4
time.sleep(4)
eth1IP = getJsonInfo(mgrURL, "port/1/1/eth1") else:
if eth1IP['interface']['ip'] == "0.0.0.0": break
print("Warning: Eth1 lacks ip address")
if duration >= maxTime:
reqURL = "cli-json/nc_show_ports" print(staName+" failed to get an ip. Ending test")
data = {"shelf": 1, print("Cleaning up...")
"resource": 1, removePort(1, staName, mgrURL)
"port": "sta0000", sys.exit(1)
"probe_flags": 1}
jsonReq(mgrURL, reqURL, data) print("Creating endpoints and cross connects")
# create cx for tcp and udp
station_info = getJsonInfo(mgrURL, "port/1/1/sta00000?fields=port,ip") cmd = (
duration = 0 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")
maxTime = 300 execWrap(cmd)
ip = "0.0.0.0" cmd = (
while ((ip == "0.0.0.0") and (duration < maxTime)): 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")
print("Station failed to get IP. Waiting 10 seconds...") execWrap(cmd)
station_info = getJsonInfo(mgrURL, "port/1/1/sta00000?fields=port,ip") time.sleep(.05)
# LFUtils.debug_printer.pprint(station_info) # create l4 endpoint
if ((station_info is not None) and ("interface" in station_info) and ("ip" in station_info["interface"])): url = "cli-json/add_l4_endp"
ip = station_info["interface"]["ip"] data = {
duration += 2 "alias": "l4Test",
time.sleep(2) "shelf": 1,
"resource": 1,
if duration >= maxTime: "port": "sta00000",
print("sta00000 failed to get an ip. Ending test") "type": "l4_generic",
print("Cleaning up...") "timeout": 1000,
removePort("1", "sta00000", mgrURL) "url_rate": 600,
sys.exit(1) "url": "dl http://10.40.0.1/ /dev/null"
}
# create endpoints and cxs super().jsonPost(url, data)
time.sleep(.05)
print("Creating endpoints and cross connects") # create cx for l4_endp
# create cx for tcp and udp url = "cli-json/add_cx"
cmd = ( data = {
"./lf_firemod.pl --action create_cx --cx_name testTCP --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type tcp > ~/Documents/connectTestLogs/connectTestLatest.log") "alias": "CX_l4Test",
execWrap(cmd) "test_mgr": "default_tm",
cmd = ( "tx_endp": "l4Test",
"./lf_firemod.pl --action create_cx --cx_name testUDP --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type udp >> ~/Documents/connectTestLogs/connectTestLatest.log") "rx_endp": "NA"
execWrap(cmd) }
time.sleep(.5) super().jsonPost(url, data)
time.sleep(.05)
# create l4 endpoint
url = "cli-json/add_l4_endp" # create fileio endpoint
data = { url = "cli-json/add_file_endp"
"alias": "l4Test", data = {
"shelf": 1, "alias": "fioTest",
"resource": 1, "shelf": 1,
"port": "sta00000", "resource": 1,
"type": "l4_generic", "port": "sta00000",
"timeout": 1000, "type": "fe_nfs",
"url_rate": 600, "directory": "/mnt/fe-test"
"url": "dl http://10.40.0.1/ /dev/null" }
} super().jsonPost(url, data)
time.sleep(.05)
jsonReq(mgrURL, url, data)
time.sleep(.5) # create fileio cx
url = "cli-json/add_cx"
# create cx for l4_endp data = {
url = "cli-json/add_cx" "alias": "CX_fioTest",
data = { "test_mgr": "default_tm",
"alias": "CX_l4Test", "tx_endp": "fioTest",
"test_mgr": "default_tm", "rx_endp": "NA"
"tx_endp": "l4Test", }
"rx_endp": "NA" super().jsonPost(url, data)
} time.sleep(.05)
jsonReq(mgrURL, url, data) # create generic endpoints
time.sleep(.5) genl.createGenEndp("genTest1", 1, 1, "sta00000", "gen_generic")
genl.createGenEndp("genTest2", 1, 1, "sta00000", "gen_generic")
# create fileio endpoint genl.setFlags("genTest1", "ClearPortOnStart", 1)
url = "cli-json/add_file_endp" genl.setFlags("genTest2", "ClearPortOnStart", 1)
data = { genl.setFlags("genTest2", "Unmanaged", 1)
"alias": "fioTest", genl.setCmd("genTest1", "lfping -i 0.1 -I sta00000 10.40.0.1")
"shelf": 1, time.sleep(.05)
"resource": 1,
"port": "sta00000", # create generic cx
"type": "fe_nfs", url = "cli-json/add_cx"
"directory": "/mnt/fe-test" data = {
} "alias": "CX_genTest1",
"test_mgr": "default_tm",
jsonReq(mgrURL, url, data) "tx_endp": "genTest1",
time.sleep(.5) "rx_endp": "genTest2"
}
# create fileio cx super().jsonPost(url, data)
url = "cli-json/add_cx" time.sleep(.05)
data = {
"alias": "CX_fioTest", # create redirects for wanlink
"test_mgr": "default_tm", url = "cli-json/add_rdd"
"tx_endp": "fioTest", data = {
"rx_endp": "NA" "shelf": 1,
} "resource": 1,
"port": "rdd0",
jsonReq(mgrURL, url, data) "peer_ifname": "rdd1"
time.sleep(.5) }
super().jsonPost(url, data)
# create generic endpoints
genl.createGenEndp("genTest1", 1, 1, "sta00000", "gen_generic") url = "cli-json/add_rdd"
genl.createGenEndp("genTest2", 1, 1, "sta00000", "gen_generic") data = {
genl.setFlags("genTest1", "ClearPortOnStart", 1) "shelf": 1,
genl.setFlags("genTest2", "ClearPortOnStart", 1) "resource": 1,
genl.setFlags("genTest2", "Unmanaged", 1) "port": "rdd1",
genl.setCmd("genTest1", "lfping -i 0.1 -I sta00000 10.40.0.1") "peer_ifname": "rdd0"
time.sleep(.5) }
super().jsonPost(url, data)
# create generic cx time.sleep(.05)
url = "cli-json/add_cx"
data = { # reset redirect ports
"alias": "CX_genTest1", url = "cli-json/reset_port"
"test_mgr": "default_tm", data = {
"tx_endp": "genTest1", "shelf": 1,
"rx_endp": "genTest2" "resource": 1,
} "port": "rdd0"
}
jsonReq(mgrURL, url, data) super().jsonPost(url, data)
time.sleep(.5)
url = "cli-json/reset_port"
# create redirects for wanlink data = {
url = "cli-json/add_rdd" "shelf": 1,
data = { "resource": 1,
"shelf": 1, "port": "rdd1"
"resource": 1, }
"port": "rdd0", super().jsonPost(url, data)
"peer_ifname": "rdd1" time.sleep(.05)
}
# create wanlink endpoints
jsonReq(mgrURL, url, data) url = "cli-json/add_wl_endp"
data = {
url = "cli-json/add_rdd" "alias": "wlTest1",
data = { "shelf": 1,
"shelf": 1, "resource": 1,
"resource": 1, "port": "rdd0",
"port": "rdd1", "latency": 20,
"peer_ifname": "rdd0" "max_rate": 1544000
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data)
time.sleep(.5) url = "cli-json/add_wl_endp"
data = {
# reset redirect ports "alias": "wlTest2",
url = "cli-json/reset_port" "shelf": 1,
data = { "resource": 1,
"shelf": 1, "port": "rdd1",
"resource": 1, "latency": 30,
"port": "rdd0" "max_rate": 1544000
} }
super().jsonPost(url, data)
jsonReq(mgrURL, url, data) time.sleep(.05)
url = "cli-json/reset_port" # create wanlink cx
data = { url = "cli-json/add_cx"
"shelf": 1, data = {
"resource": 1, "alias": "CX_wlTest1",
"port": "rdd1" "test_mgr": "default_tm",
} "tx_endp": "wlTest1",
"rx_endp": "wlTest2"
jsonReq(mgrURL, url, data) }
time.sleep(.5) super().jsonPost(url, data)
time.sleep(.5)
# create wanlink endpoints
url = "cli-json/add_wl_endp" cxNames = ["testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlTest1"]
data = {
"alias": "wlan0", # get data before running traffic
"shelf": 1, try:
"resource": 1, testTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes")
"port": "rdd0", testTCPATX = testTCPA['endpoint']['tx bytes']
"latency": 20, testTCPARX = testTCPA['endpoint']['rx bytes']
"max_rate": 1544000
} testTCPB = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes")
testTCPBTX = testTCPB['endpoint']['tx bytes']
jsonReq(mgrURL, url, data) testTCPBRX = testTCPB['endpoint']['rx bytes']
url = "cli-json/add_wl_endp" testUDPA = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes")
data = { testUDPATX = testUDPA['endpoint']['tx bytes']
"alias": "wlan1", testUDPARX = testUDPA['endpoint']['rx bytes']
"shelf": 1,
"resource": 1, testUDPB = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes")
"port": "rdd1", testUDPBTX = testUDPB['endpoint']['tx bytes']
"latency": 30, testUDPBRX = testUDPB['endpoint']['rx bytes']
"max_rate": 1544000
} l4Test = super().jsonGet("layer4/l4Test?fields=bytes-rd")
l4TestBR = l4Test['endpoint']['bytes-rd']
jsonReq(mgrURL, url, data)
time.sleep(.5) genTest1 = super().jsonGet("generic/genTest1?fields=last+results")
genTest1LR = genTest1['endpoint']['last results']
# create wanlink cx
url = "cli-json/add_cx" wlTest1 = super().jsonGet("wl_ep/wlTest1")
data = { wlTest1TXB = wlTest1['endpoint']['tx bytes']
"alias": "CX_wlan0", wlTest1RXP = wlTest1['endpoint']['rx pkts']
"test_mgr": "default_tm", wlTest2 = super().jsonGet("wl_ep/wlTest2")
"tx_endp": "wlan0", wlTest2TXB = wlTest2['endpoint']['tx bytes']
"rx_endp": "wlan1" wlTest2RXP = wlTest2['endpoint']['rx pkts']
}
except Exception as e:
jsonReq(mgrURL, url, data) print("Something went wrong")
time.sleep(.5) print(e)
print("Cleaning up...")
cxNames = ["testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlan0"] LFUtils.removePort(1, staName, mgrURL)
endpNames = ["testTCP-A", "testTCP-B",
# get data before running traffic "testUDP-A", "testUDP-B",
try: "l4Test", "fioTest",
testTCPA = getJsonInfo(mgrURL, "endp/testTCP-A?fields=tx+bytes,rx+bytes") "genTest1", "genTest2",
testTCPATX = testTCPA['endpoint']['tx bytes'] "wlTest1", "wlTest2"]
testTCPARX = testTCPA['endpoint']['rx bytes'] removeCX(mgrURL, cxNames)
removeEndps(mgrURL, endpNames)
testTCPB = getJsonInfo(mgrURL, "endp/testTCP-B?fields=tx+bytes,rx+bytes") sys.exit(1)
testTCPBTX = testTCPB['endpoint']['tx bytes']
testTCPBRX = testTCPB['endpoint']['rx bytes'] # start cx traffic
print("\nStarting CX Traffic")
testUDPA = getJsonInfo(mgrURL, "endp/testUDP-A?fields=tx+bytes,rx+bytes") for name in range(len(cxNames)):
testUDPATX = testUDPA['endpoint']['tx bytes'] cmd = (
testUDPARX = testUDPA['endpoint']['rx bytes'] f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} RUNNING\" >> /tmp/connectTest.log")
execWrap(cmd)
testUDPB = getJsonInfo(mgrURL, "endp/testUDP-B?fields=tx+bytes,rx+bytes")
testUDPBTX = testUDPB['endpoint']['tx bytes'] # print("Sleeping for 5 seconds")
testUDPBRX = testUDPB['endpoint']['rx bytes'] time.sleep(5)
l4Test = getJsonInfo(mgrURL, "layer4/l4Test?fields=bytes-rd") # show tx and rx bytes for ports
l4TestBR = l4Test['endpoint']['bytes-rd']
os.system("echo eth1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
genTest1 = getJsonInfo(mgrURL, "generic/genTest1?fields=last+results") cmd = (
genTest1LR = genTest1['endpoint']['last results'] "./lf_portmod.pl --quiet 1 --manager localhost --port_name eth1 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
execWrap(cmd)
wlan0 = getJsonInfo(mgrURL, "wl_ep/wlan0") os.system("echo sta00000 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
wlan0TXB = wlan0['endpoint']['tx bytes'] cmd = (
wlan0RXP = wlan0['endpoint']['rx pkts'] "./lf_portmod.pl --quiet 1 --manager localhost --port_name sta00000 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
wlan1 = getJsonInfo(mgrURL, "wl_ep/wlan1") execWrap(cmd)
wlan1TXB = wlan1['endpoint']['tx bytes']
wlan1RXP = wlan1['endpoint']['rx pkts'] # show tx and rx for endpoints PERL
except Exception as e: os.system("echo TestTCP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
print("Something went wrong") cmd = (
print(e) "./lf_firemod.pl --action show_endp --endp_name testTCP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
print("Cleaning up...") execWrap(cmd)
LFUtils.removePort("1", "sta00000", mgrURL) os.system("echo TestTCP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
cmd = (
endpNames = ["testTCP-A", "testTCP-B", "./lf_firemod.pl --action show_endp --endp_name testTCP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
"testUDP-A", "testUDP-B", execWrap(cmd)
"l4Test", "fioTest", os.system("echo TestUDP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
"genTest1", "genTest2", cmd = (
"wlan0", "wlan1"] "./lf_firemod.pl --action show_endp --endp_name testUDP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
removeCX(mgrURL, cxNames) execWrap(cmd)
removeEndps(mgrURL, endpNames) os.system("echo TestUDP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
sys.exit(1) cmd = (
"./lf_firemod.pl --action show_endp --endp_name testUDP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
# start cx traffic execWrap(cmd)
print("\nStarting CX Traffic") os.system("echo l4Test >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
for name in range(len(cxNames)): cmd = (
cmd = ( "./lf_firemod.pl --action show_endp --endp_name l4Test --endp_vals Bytes-Read-Total >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} RUNNING\" >> /tmp/connectTest.log") execWrap(cmd)
execWrap(cmd) os.system("echo fioTest >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
cmd = (
# print("Sleeping for 5 seconds") "./lf_firemod.pl --action show_endp --endp_name fioTest --endp_vals \"Bytes Written,Bytes Read\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
time.sleep(5) execWrap(cmd)
os.system("echo genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
# show tx and rx bytes for ports cmd = (
"./lf_firemod.pl --action show_endp --endp_name genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
os.system("echo eth1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") execWrap(cmd)
cmd = ( os.system("echo wlTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
"./lf_portmod.pl --quiet 1 --manager localhost --port_name eth1 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") cmd = (
execWrap(cmd) "./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")
os.system("echo sta00000 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") execWrap(cmd)
cmd = ( os.system("echo wlTest2 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
"./lf_portmod.pl --quiet 1 --manager localhost --port_name sta00000 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") cmd = (
execWrap(cmd) "./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)
# show tx and rx for endpoints PERL
os.system("echo TestTCP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") # stop cx traffic
cmd = ( print("Stopping CX Traffic")
"./lf_firemod.pl --action show_endp --endp_name testTCP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") for name in range(len(cxNames)):
execWrap(cmd) cmd = (
os.system("echo TestTCP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} STOPPED\" >> /tmp/connectTest.log")
cmd = ( execWrap(cmd)
"./lf_firemod.pl --action show_endp --endp_name testTCP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") # print("Sleeping for 15 seconds")
execWrap(cmd) time.sleep(15)
os.system("echo TestUDP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
cmd = ( # get data for endpoints JSON
"./lf_firemod.pl --action show_endp --endp_name testUDP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") print("Collecting Data")
execWrap(cmd) try:
os.system("echo TestUDP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes")
cmd = ( ptestTCPATX = ptestTCPA['endpoint']['tx bytes']
"./lf_firemod.pl --action show_endp --endp_name testUDP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestTCPARX = ptestTCPA['endpoint']['rx bytes']
execWrap(cmd)
os.system("echo l4Test >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestTCPB = super().jsonGet("endp/testTCP-B?fields=tx+bytes,rx+bytes")
cmd = ( ptestTCPBTX = ptestTCPB['endpoint']['tx bytes']
"./lf_firemod.pl --action show_endp --endp_name l4Test --endp_vals Bytes-Read-Total >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestTCPBRX = ptestTCPB['endpoint']['rx bytes']
execWrap(cmd)
os.system("echo fioTest >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestUDPA = super().jsonGet("endp/testUDP-A?fields=tx+bytes,rx+bytes")
cmd = ( ptestUDPATX = ptestUDPA['endpoint']['tx bytes']
"./lf_firemod.pl --action show_endp --endp_name fioTest --endp_vals \"Bytes Written,Bytes Read\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestUDPARX = ptestUDPA['endpoint']['rx bytes']
execWrap(cmd)
os.system("echo genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestUDPB = super().jsonGet("endp/testUDP-B?fields=tx+bytes,rx+bytes")
cmd = ( ptestUDPBTX = ptestUDPB['endpoint']['tx bytes']
"./lf_firemod.pl --action show_endp --endp_name genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") ptestUDPBRX = ptestUDPB['endpoint']['rx bytes']
execWrap(cmd)
os.system("echo wlan0 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") pl4Test = super().jsonGet("layer4/l4Test?fields=bytes-rd")
cmd = ( pl4TestBR = pl4Test['endpoint']['bytes-rd']
"./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")
execWrap(cmd) pgenTest1 = super().jsonGet("generic/genTest1?fields=last+results")
os.system("echo wlan1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log") pgenTest1LR = pgenTest1['endpoint']['last results']
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") pwlTest1 = super().jsonGet("wl_ep/wlTest1")
execWrap(cmd) pwlTest1TXB = pwlTest1['endpoint']['tx bytes']
pwlTest1RXP = pwlTest1['endpoint']['rx pkts']
# stop cx traffic pwlTest2 = super().jsonGet("wl_ep/wlTest2")
print("Stopping CX Traffic") pwlTest2TXB = pwlTest2['endpoint']['tx bytes']
for name in range(len(cxNames)): pwlTest2RXP = pwlTest2['endpoint']['rx pkts']
cmd = ( except Exception as e:
f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} STOPPED\" >> /tmp/connectTest.log") print("Something went wrong")
execWrap(cmd) print(e)
# print("Sleeping for 15 seconds") print("Cleaning up...")
time.sleep(15) reqURL = "cli-json/rm_vlan"
data = {
# get data for endpoints JSON "shelf": 1,
print("Collecting Data") "resource": 1,
try: "port": staName
ptestTCPA = getJsonInfo(mgrURL, "endp/testTCP-A?fields=tx+bytes,rx+bytes") }
ptestTCPATX = ptestTCPA['endpoint']['tx bytes'] super().jsonPost(reqURL, data)
ptestTCPARX = ptestTCPA['endpoint']['rx bytes']
endpNames = ["testTCP-A", "testTCP-B",
ptestTCPB = getJsonInfo(mgrURL, "endp/testTCP-B?fields=tx+bytes,rx+bytes") "testUDP-A", "testUDP-B",
ptestTCPBTX = ptestTCPB['endpoint']['tx bytes'] "l4Test", "fioTest",
ptestTCPBRX = ptestTCPB['endpoint']['rx bytes'] "genTest1", "genTest2",
"wlTest1", "wlTest2"]
ptestUDPA = getJsonInfo(mgrURL, "endp/testUDP-A?fields=tx+bytes,rx+bytes") removeCX(mgrURL, cxNames)
ptestUDPATX = ptestUDPA['endpoint']['tx bytes'] removeEndps(mgrURL, endpNames)
ptestUDPARX = ptestUDPA['endpoint']['rx bytes'] sys.exit(1)
ptestUDPB = getJsonInfo(mgrURL, "endp/testUDP-B?fields=tx+bytes,rx+bytes") # print("Sleeping for 5 seconds")
ptestUDPBTX = ptestUDPB['endpoint']['tx bytes'] time.sleep(5)
ptestUDPBRX = ptestUDPB['endpoint']['rx bytes']
print("\n")
pl4Test = getJsonInfo(mgrURL, "layer4/l4Test?fields=bytes-rd") self.CompareVals("testTCP-A TX", testTCPATX, ptestTCPATX)
pl4TestBR = pl4Test['endpoint']['bytes-rd'] self.CompareVals("testTCP-A RX", testTCPARX, ptestTCPARX)
self.CompareVals("testTCP-B TX", testTCPBTX, ptestTCPBTX)
pgenTest1 = getJsonInfo(mgrURL, "generic/genTest1?fields=last+results") self.CompareVals("testTCP-B RX", testTCPBRX, ptestTCPBRX)
pgenTest1LR = pgenTest1['endpoint']['last results'] self.CompareVals("testUDP-A TX", testUDPATX, ptestUDPATX)
self.CompareVals("testUDP-A RX", testUDPARX, ptestUDPARX)
pwlan0 = getJsonInfo(mgrURL, "wl_ep/wlan0") self.CompareVals("testUDP-B TX", testUDPBTX, ptestUDPBTX)
pwlan0TXB = pwlan0['endpoint']['tx bytes'] self.CompareVals("testUDP-B RX", testUDPBRX, ptestUDPBRX)
pwlan0RXP = pwlan0['endpoint']['rx pkts'] self.CompareVals("l4Test Bytes Read", l4TestBR, pl4TestBR)
pwlan1 = getJsonInfo(mgrURL, "wl_ep/wlan1") self.CompareVals("genTest1 Last Results", genTest1LR, pgenTest1LR)
pwlan1TXB = pwlan1['endpoint']['tx bytes'] self.CompareVals("wlTest1 TX Bytes", wlTest1TXB, pwlTest1TXB)
pwlan1RXP = pwlan1['endpoint']['rx pkts'] self.CompareVals("wlTest1 RX Pkts", wlTest1RXP, pwlTest1RXP)
except Exception as e: self.CompareVals("wlTest2 TX Bytes", wlTest2TXB, pwlTest2TXB)
print("Something went wrong") self.CompareVals("wlTest2 RX Pkts", wlTest2RXP, pwlTest2RXP)
print(e) print("\n")
print("Cleaning up...")
reqURL = "cli-json/rm_vlan" # remove all endpoints and cxs
data = { print("Cleaning up...")
"shelf": 1, LFUtils.removePort(1, "sta00000", mgrURL)
"resource": 1,
"port": "sta00000" endpNames = ["testTCP-A", "testTCP-B",
} "testUDP-A", "testUDP-B",
"l4Test", "fioTest",
jsonReq(mgrURL, reqURL, data) "genTest1", "genTest2",
"wlTest1", "wlTest2"]
endpNames = ["testTCP-A", "testTCP-B", removeCX(mgrURL, cxNames)
"testUDP-A", "testUDP-B", removeEndps(mgrURL, endpNames)
"l4Test", "fioTest",
"genTest1", "genTest2",
"wlan0", "wlan1"] # ~class
removeCX(mgrURL, cxNames)
removeEndps(mgrURL, endpNames) def main():
sys.exit(1) lfjson_host = "localhost"
lfjson_port = 8080
# print("Sleeping for 5 seconds") test = ConnectTest(lfjson_host, lfjson_port)
time.sleep(5) test.run()
# compare pre-test values to post-test values if __name__ == "__main__":
main()
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")
compareVals("testTCP-A TX", testTCPATX, ptestTCPATX)
compareVals("testTCP-A RX", testTCPARX, ptestTCPARX)
compareVals("testTCP-B TX", testTCPBTX, ptestTCPBTX)
compareVals("testTCP-B RX", testTCPBRX, ptestTCPBRX)
compareVals("testUDP-A TX", testUDPATX, ptestUDPATX)
compareVals("testUDP-A RX", testUDPARX, ptestUDPARX)
compareVals("testUDP-B TX", testUDPBTX, ptestUDPBTX)
compareVals("testUDP-B RX", testUDPBRX, ptestUDPBRX)
compareVals("l4Test Bytes Read", l4TestBR, pl4TestBR)
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")
# remove all endpoints and cxs
print("Cleaning up...")
LFUtils.removePort("1", "sta00000", mgrURL)
endpNames = ["testTCP-A", "testTCP-B",
"testUDP-A", "testUDP-B",
"l4Test", "fioTest",
"genTest1", "genTest2",
"wlan0", "wlan1"]
removeCX(mgrURL, cxNames)
removeEndps(mgrURL, endpNames)

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"