mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
connectTest.py: refactors test into a class; fixes how port is brought up, now reliably creates port and it get IP address; NOT DONE
This commit is contained in:
728
connectTest.py
728
connectTest.py
@@ -1,17 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append('py-json')
|
||||
|
||||
import subprocess
|
||||
import json
|
||||
import pprint
|
||||
from LANforge import LFRequest
|
||||
from LANforge import LFUtils
|
||||
from LANforge.LFUtils import *
|
||||
from LANforge.lfcli_base import LFCliBase
|
||||
|
||||
import create_genlink as genl
|
||||
|
||||
@@ -21,494 +16,459 @@ if sys.version_info[0] != 3:
|
||||
exit(1)
|
||||
|
||||
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)
|
||||
|
||||
if exitWhenCalled:
|
||||
json_response = lf_r.jsonPost(True)
|
||||
print("jsonReq: debugdie Response: ")
|
||||
LFUtils.debug_printer.pprint(vars(json_response))
|
||||
print("jsonReq: bye")
|
||||
sys.exit(1)
|
||||
class ConnectTest(LFCliBase):
|
||||
def __init__(self, lfhost, lfport):
|
||||
super().__init__(lfhost, lfport, True)
|
||||
super().checkConnect()
|
||||
|
||||
# compare pre-test values to post-test values
|
||||
@staticmethod
|
||||
def CompareVals(_name, preVal, postVal):
|
||||
print(f"Comparing {_name}")
|
||||
if postVal > preVal:
|
||||
print(" Test Passed")
|
||||
else:
|
||||
lf_r.jsonPost(exitWhenCalled)
|
||||
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)
|
||||
def run(self):
|
||||
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)
|
||||
|
||||
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')
|
||||
# Create stations and turn dhcp on
|
||||
print("Creating station and turning on dhcp")
|
||||
|
||||
if duration >= 300:
|
||||
print("Could not connect to LANforge Client")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
print("See home/lanforge/Documents/connectTestLogs/connectTestLatest for specific values on latest test")
|
||||
#Create stations and turn dhcp on
|
||||
print("Creating station and turning on dhcp")
|
||||
|
||||
url = "port/1/1/sta00000"
|
||||
debugOn = True
|
||||
response = getJsonInfo(mgrURL, url)
|
||||
if (response is not None):
|
||||
if (response["interface"] is not None):
|
||||
response = super().jsonGet(staNameUri)
|
||||
if response is not None:
|
||||
if response["interface"] is not None:
|
||||
print("removing old station")
|
||||
LFUtils.removePortByName("1.1.sta00000", mgrURL)
|
||||
removePort(1, staName, mgrURL)
|
||||
waitUntilPortsDisappear(1, mgrURL, [staName])
|
||||
time.sleep(1)
|
||||
|
||||
url = "cli-json/add_sta"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"radio":"wiphy0",
|
||||
"sta_name":"sta00000",
|
||||
"ssid":"jedway-wpa2-x2048-5-1",
|
||||
"key":"jedway-wpa2-x2048-5-1",
|
||||
"mode":1,
|
||||
"mac":"xx:xx:xx:xx:*:xx",
|
||||
"flags":1024 #0x400 | 1024
|
||||
}
|
||||
print("adding new station")
|
||||
jsonReq(mgrURL, url, data)
|
||||
url = "cli-json/add_sta"
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"radio": "wiphy0",
|
||||
"sta_name": staName,
|
||||
"ssid": "jedway-wpa2-x2048-5-1",
|
||||
"key": "jedway-wpa2-x2048-5-1",
|
||||
"mode": 0,
|
||||
"mac": "xx:xx:xx:xx:*:xx",
|
||||
"flags": (0x400 + 0x20000 + 0x1000000000) # create admin down
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(0.05)
|
||||
reqURL = "cli-json/set_port"
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": staName,
|
||||
"current_flags": (0x1 + 0x80000000),
|
||||
"interest": (0x2 + 0x4000 + 0x800000) # current, dhcp, down,
|
||||
}
|
||||
super().jsonPost(reqURL, data)
|
||||
time.sleep(0.5)
|
||||
super().jsonPost("cli-json/set_port", portUpRequest(1, staName))
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
reqURL = "cli-json/set_port"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"sta00000",
|
||||
"current_flags": 2147483648, #0x80000000 | 2147483648
|
||||
"interest":16386 # 0x4002 | 16386
|
||||
}
|
||||
print("configuring port")
|
||||
jsonReq(mgrURL, reqURL, data)
|
||||
|
||||
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"
|
||||
data = { "shelf":1,
|
||||
"resource":1,
|
||||
"port":"sta0000",
|
||||
"probe_flags":1 }
|
||||
jsonReq(mgrURL, reqURL, data)
|
||||
|
||||
station_info = getJsonInfo(mgrURL, "port/1/1/sta00000?fields=port,ip")
|
||||
duration = 0
|
||||
maxTime = 300
|
||||
ip = "0.0.0.0"
|
||||
while ((ip == "0.0.0.0") and (duration < maxTime)):
|
||||
station_info = getJsonInfo(mgrURL, "port/1/1/sta00000?fields=port,ip")
|
||||
reqURL = "cli-json/nc_show_ports"
|
||||
data = {"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": staName,
|
||||
"probe_flags": 1}
|
||||
super().jsonPost(reqURL, data)
|
||||
time.sleep(0.5)
|
||||
waitUntilPortsAdminUp(1, mgrURL, [staName])
|
||||
|
||||
duration = 0
|
||||
maxTime = 300
|
||||
ip = "0.0.0.0"
|
||||
while (ip == "0.0.0.0") and (duration < maxTime):
|
||||
station_info = super().jsonGet(staNameUri + "?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"])):
|
||||
if (station_info is not None) and ("interface" in station_info) and ("ip" in station_info["interface"]):
|
||||
ip = station_info["interface"]["ip"]
|
||||
if ip == "0.0.0.0":
|
||||
duration += 4
|
||||
time.sleep(4)
|
||||
else:
|
||||
break
|
||||
|
||||
if duration >= maxTime:
|
||||
print("sta00000 failed to get an ip. Ending test")
|
||||
if duration >= maxTime:
|
||||
print(staName+" failed to get an ip. Ending test")
|
||||
print("Cleaning up...")
|
||||
removePort(1,"sta00000", mgrURL)
|
||||
removePort(1, staName, mgrURL)
|
||||
sys.exit(1)
|
||||
|
||||
print("Creating endpoints and cross connects")
|
||||
# create cx for tcp and udp
|
||||
cmd = (
|
||||
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)
|
||||
cmd = (
|
||||
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)
|
||||
time.sleep(.05)
|
||||
|
||||
#create endpoints and cxs
|
||||
# create l4 endpoint
|
||||
url = "cli-json/add_l4_endp"
|
||||
data = {
|
||||
"alias": "l4Test",
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "sta00000",
|
||||
"type": "l4_generic",
|
||||
"timeout": 1000,
|
||||
"url_rate": 600,
|
||||
"url": "dl http://10.40.0.1/ /dev/null"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
# create cx for l4_endp
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias": "CX_l4Test",
|
||||
"test_mgr": "default_tm",
|
||||
"tx_endp": "l4Test",
|
||||
"rx_endp": "NA"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
print("Creating endpoints and cross connects")
|
||||
#create cx for tcp and udp
|
||||
cmd = ("./lf_firemod.pl --action create_cx --cx_name testTCP --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type tcp > /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
cmd = ("./lf_firemod.pl --action create_cx --cx_name testUDP --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type udp >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
time.sleep(.5)
|
||||
# create fileio endpoint
|
||||
url = "cli-json/add_file_endp"
|
||||
data = {
|
||||
"alias": "fioTest",
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "sta00000",
|
||||
"type": "fe_nfs",
|
||||
"directory": "/mnt/fe-test"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
#create l4 endpoint
|
||||
url = "cli-json/add_l4_endp"
|
||||
data = {
|
||||
"alias":"l4Test",
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"sta00000",
|
||||
"type":"l4_generic",
|
||||
"timeout":1000,
|
||||
"url_rate":600,
|
||||
"url":"dl http://10.40.0.1/ /dev/null"
|
||||
}
|
||||
# create fileio cx
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias": "CX_fioTest",
|
||||
"test_mgr": "default_tm",
|
||||
"tx_endp": "fioTest",
|
||||
"rx_endp": "NA"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
jsonReq(mgrURL, url, data)
|
||||
time.sleep(.5)
|
||||
# create generic endpoints
|
||||
genl.createGenEndp("genTest1", 1, 1, "sta00000", "gen_generic")
|
||||
genl.createGenEndp("genTest2", 1, 1, "sta00000", "gen_generic")
|
||||
genl.setFlags("genTest1", "ClearPortOnStart", 1)
|
||||
genl.setFlags("genTest2", "ClearPortOnStart", 1)
|
||||
genl.setFlags("genTest2", "Unmanaged", 1)
|
||||
genl.setCmd("genTest1", "lfping -i 0.1 -I sta00000 10.40.0.1")
|
||||
time.sleep(.05)
|
||||
|
||||
#create cx for l4_endp
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias":"CX_l4Test",
|
||||
"test_mgr":"default_tm",
|
||||
"tx_endp":"l4Test",
|
||||
"rx_endp":"NA"
|
||||
}
|
||||
# create generic cx
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias": "CX_genTest1",
|
||||
"test_mgr": "default_tm",
|
||||
"tx_endp": "genTest1",
|
||||
"rx_endp": "genTest2"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
jsonReq(mgrURL, url, data)
|
||||
time.sleep(.5)
|
||||
# create redirects for wanlink
|
||||
url = "cli-json/add_rdd"
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "rdd0",
|
||||
"peer_ifname": "rdd1"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
|
||||
#create fileio endpoint
|
||||
url = "cli-json/add_file_endp"
|
||||
data = {
|
||||
"alias":"fioTest",
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"sta00000",
|
||||
"type":"fe_nfs",
|
||||
"directory":"/mnt/fe-test"
|
||||
}
|
||||
url = "cli-json/add_rdd"
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "rdd1",
|
||||
"peer_ifname": "rdd0"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
# reset redirect ports
|
||||
url = "cli-json/reset_port"
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "rdd0"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
|
||||
#create fileio cx
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias":"CX_fioTest",
|
||||
"test_mgr":"default_tm",
|
||||
"tx_endp":"fioTest",
|
||||
"rx_endp":"NA"
|
||||
}
|
||||
url = "cli-json/reset_port"
|
||||
data = {
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "rdd1"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
# create wanlink endpoints
|
||||
url = "cli-json/add_wl_endp"
|
||||
data = {
|
||||
"alias": "wlTest1",
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "rdd0",
|
||||
"latency": 20,
|
||||
"max_rate": 1544000
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
|
||||
#create generic endpoints
|
||||
genl.createGenEndp("genTest1",1,1,"sta00000","gen_generic")
|
||||
genl.createGenEndp("genTest2",1,1,"sta00000","gen_generic")
|
||||
genl.setFlags("genTest1","ClearPortOnStart",1)
|
||||
genl.setFlags("genTest2","ClearPortOnStart",1)
|
||||
genl.setFlags("genTest2","Unmanaged",1)
|
||||
genl.setCmd("genTest1","lfping -i 0.1 -I sta00000 10.40.0.1")
|
||||
time.sleep(.5)
|
||||
url = "cli-json/add_wl_endp"
|
||||
data = {
|
||||
"alias": "wlTest2",
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": "rdd1",
|
||||
"latency": 30,
|
||||
"max_rate": 1544000
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.05)
|
||||
|
||||
#create generic cx
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias":"CX_genTest1",
|
||||
"test_mgr":"default_tm",
|
||||
"tx_endp":"genTest1",
|
||||
"rx_endp":"genTest2"
|
||||
}
|
||||
# create wanlink cx
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias": "CX_wlTest1",
|
||||
"test_mgr": "default_tm",
|
||||
"tx_endp": "wlTest1",
|
||||
"rx_endp": "wlTest2"
|
||||
}
|
||||
super().jsonPost(url, data)
|
||||
time.sleep(.5)
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
cxNames = ["testTCP", "testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlTest1"]
|
||||
|
||||
#create redirects for wanlink
|
||||
url = "cli-json/add_rdd"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"rdd0",
|
||||
"peer_ifname":"rdd1"
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
|
||||
url = "cli-json/add_rdd"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"rdd1",
|
||||
"peer_ifname":"rdd0"
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
|
||||
#reset redirect ports
|
||||
url = "cli-json/reset_port"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"rdd0"
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
|
||||
url = "cli-json/reset_port"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"rdd1"
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
|
||||
|
||||
#create wanlink endpoints
|
||||
url = "cli-json/add_wl_endp"
|
||||
data = {
|
||||
"alias":"wlTest1",
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"rdd0",
|
||||
"latency":20,
|
||||
"max_rate":1544000
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
|
||||
url = "cli-json/add_wl_endp"
|
||||
data = {
|
||||
"alias":"wlTest2",
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"rdd1",
|
||||
"latency":30,
|
||||
"max_rate":1544000
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
|
||||
#create wanlink cx
|
||||
url = "cli-json/add_cx"
|
||||
data = {
|
||||
"alias":"CX_wlTest1",
|
||||
"test_mgr":"default_tm",
|
||||
"tx_endp":"wlTest1",
|
||||
"rx_endp":"wlTest2"
|
||||
}
|
||||
|
||||
jsonReq(mgrURL,url,data)
|
||||
time.sleep(.5)
|
||||
|
||||
cxNames = ["testTCP","testUDP", "CX_l4Test", "CX_fioTest", "CX_genTest1", "CX_wlTest1"]
|
||||
|
||||
#get data before running traffic
|
||||
try:
|
||||
testTCPA = getJsonInfo(mgrURL, "endp/testTCP-A?fields=tx+bytes,rx+bytes")
|
||||
# get data before running traffic
|
||||
try:
|
||||
testTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes")
|
||||
testTCPATX = testTCPA['endpoint']['tx 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']
|
||||
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']
|
||||
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']
|
||||
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']
|
||||
|
||||
genTest1 = getJsonInfo(mgrURL, "generic/genTest1?fields=last+results")
|
||||
genTest1 = super().jsonGet("generic/genTest1?fields=last+results")
|
||||
genTest1LR = genTest1['endpoint']['last results']
|
||||
|
||||
wlTest1 = getJsonInfo(mgrURL,"wl_ep/wlTest1")
|
||||
wlTest1 = super().jsonGet("wl_ep/wlTest1")
|
||||
wlTest1TXB = wlTest1['endpoint']['tx bytes']
|
||||
wlTest1RXP = wlTest1['endpoint']['rx pkts']
|
||||
wlTest2 = getJsonInfo(mgrURL,"wl_ep/wlTest2")
|
||||
wlTest2 = super().jsonGet("wl_ep/wlTest2")
|
||||
wlTest2TXB = wlTest2['endpoint']['tx bytes']
|
||||
wlTest2RXP = wlTest2['endpoint']['rx pkts']
|
||||
except Exception as e:
|
||||
|
||||
except Exception as e:
|
||||
print("Something went wrong")
|
||||
print(e)
|
||||
print("Cleaning up...")
|
||||
LFUtils.removePort(1,"sta00000", mgrURL)
|
||||
|
||||
LFUtils.removePort(1, staName, mgrURL)
|
||||
endpNames = ["testTCP-A", "testTCP-B",
|
||||
"testUDP-A", "testUDP-B",
|
||||
"l4Test", "fioTest",
|
||||
"genTest1", "genTest2",
|
||||
"wlTest1","wlTest2"]
|
||||
"wlTest1", "wlTest2"]
|
||||
removeCX(mgrURL, cxNames)
|
||||
removeEndps(mgrURL, endpNames)
|
||||
sys.exit(1)
|
||||
|
||||
#start cx traffic
|
||||
print("\nStarting CX Traffic")
|
||||
for name in range(len(cxNames)):
|
||||
cmd = (f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} RUNNING\" >> /tmp/connectTest.log")
|
||||
# start cx traffic
|
||||
print("\nStarting CX Traffic")
|
||||
for name in range(len(cxNames)):
|
||||
cmd = (
|
||||
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)
|
||||
|
||||
#print("Sleeping for 5 seconds")
|
||||
time.sleep(5)
|
||||
# print("Sleeping for 5 seconds")
|
||||
time.sleep(5)
|
||||
|
||||
#show tx and rx bytes for ports
|
||||
# show tx and rx bytes for ports
|
||||
|
||||
os.system("echo eth1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_portmod.pl --quiet 1 --manager localhost --port_name eth1 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo sta00000 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_portmod.pl --quiet 1 --manager localhost --port_name sta00000 --show_port \"Txb,Rxb\" >> /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")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name testTCP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo TestTCP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name testTCP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo TestUDP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name testUDP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo TestUDP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name testUDP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo l4Test >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name l4Test --endp_vals Bytes-Read-Total >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo fioTest >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name fioTest --endp_vals \"Bytes Written,Bytes Read\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = ("./lf_firemod.pl --action show_endp --endp_name genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo wlTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
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")
|
||||
execWrap(cmd)
|
||||
os.system("echo wlTest2 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
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)
|
||||
|
||||
|
||||
|
||||
#stop cx traffic
|
||||
print("Stopping CX Traffic")
|
||||
for name in range(len(cxNames)):
|
||||
cmd = (f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} STOPPED\" >> /tmp/connectTest.log")
|
||||
os.system("echo eth1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_portmod.pl --quiet 1 --manager localhost --port_name eth1 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo sta00000 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_portmod.pl --quiet 1 --manager localhost --port_name sta00000 --show_port \"Txb,Rxb\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
#print("Sleeping for 15 seconds")
|
||||
time.sleep(15)
|
||||
|
||||
#get data for endpoints JSON
|
||||
print("Collecting Data")
|
||||
try:
|
||||
ptestTCPA = getJsonInfo(mgrURL, "endp/testTCP-A?fields=tx+bytes,rx+bytes")
|
||||
# show tx and rx for endpoints PERL
|
||||
os.system("echo TestTCP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name testTCP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo TestTCP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name testTCP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo TestUDP-A >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name testUDP-A --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo TestUDP-B >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name testUDP-B --endp_vals \"Tx Bytes,Rx Bytes\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo l4Test >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name l4Test --endp_vals Bytes-Read-Total >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo fioTest >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name fioTest --endp_vals \"Bytes Written,Bytes Read\" >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
cmd = (
|
||||
"./lf_firemod.pl --action show_endp --endp_name genTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
execWrap(cmd)
|
||||
os.system("echo wlTest1 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
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")
|
||||
execWrap(cmd)
|
||||
os.system("echo wlTest2 >> /home/lanforge/Documents/connectTestLogs/connectTestLatest.log")
|
||||
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)
|
||||
|
||||
# stop cx traffic
|
||||
print("Stopping CX Traffic")
|
||||
for name in range(len(cxNames)):
|
||||
cmd = (
|
||||
f"./lf_firemod.pl --mgr localhost --quiet yes --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} STOPPED\" >> /tmp/connectTest.log")
|
||||
execWrap(cmd)
|
||||
# print("Sleeping for 15 seconds")
|
||||
time.sleep(15)
|
||||
|
||||
# get data for endpoints JSON
|
||||
print("Collecting Data")
|
||||
try:
|
||||
ptestTCPA = super().jsonGet("endp/testTCP-A?fields=tx+bytes,rx+bytes")
|
||||
ptestTCPATX = ptestTCPA['endpoint']['tx 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']
|
||||
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']
|
||||
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']
|
||||
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']
|
||||
|
||||
pgenTest1 = getJsonInfo(mgrURL, "generic/genTest1?fields=last+results")
|
||||
pgenTest1 = super().jsonGet("generic/genTest1?fields=last+results")
|
||||
pgenTest1LR = pgenTest1['endpoint']['last results']
|
||||
|
||||
pwlTest1 = getJsonInfo(mgrURL,"wl_ep/wlTest1")
|
||||
pwlTest1 = super().jsonGet("wl_ep/wlTest1")
|
||||
pwlTest1TXB = pwlTest1['endpoint']['tx bytes']
|
||||
pwlTest1RXP = pwlTest1['endpoint']['rx pkts']
|
||||
pwlTest2 = getJsonInfo(mgrURL,"wl_ep/wlTest2")
|
||||
pwlTest2 = super().jsonGet("wl_ep/wlTest2")
|
||||
pwlTest2TXB = pwlTest2['endpoint']['tx bytes']
|
||||
pwlTest2RXP = pwlTest2['endpoint']['rx pkts']
|
||||
except Exception as e:
|
||||
except Exception as e:
|
||||
print("Something went wrong")
|
||||
print(e)
|
||||
print("Cleaning up...")
|
||||
reqURL = "cli-json/rm_vlan"
|
||||
data = {
|
||||
"shelf":1,
|
||||
"resource":1,
|
||||
"port":"sta00000"
|
||||
"shelf": 1,
|
||||
"resource": 1,
|
||||
"port": staName
|
||||
}
|
||||
|
||||
jsonReq(mgrURL, reqURL, data)
|
||||
super().jsonPost(reqURL, data)
|
||||
|
||||
endpNames = ["testTCP-A", "testTCP-B",
|
||||
"testUDP-A", "testUDP-B",
|
||||
"l4Test", "fioTest",
|
||||
"genTest1", "genTest2",
|
||||
"wlTest1","wlTest2"]
|
||||
"wlTest1", "wlTest2"]
|
||||
removeCX(mgrURL, cxNames)
|
||||
removeEndps(mgrURL, endpNames)
|
||||
sys.exit(1)
|
||||
|
||||
#print("Sleeping for 5 seconds")
|
||||
time.sleep(5)
|
||||
# print("Sleeping for 5 seconds")
|
||||
time.sleep(5)
|
||||
|
||||
print("\n")
|
||||
self.CompareVals("testTCP-A TX", testTCPATX, ptestTCPATX)
|
||||
self.CompareVals("testTCP-A RX", testTCPARX, ptestTCPARX)
|
||||
self.CompareVals("testTCP-B TX", testTCPBTX, ptestTCPBTX)
|
||||
self.CompareVals("testTCP-B RX", testTCPBRX, ptestTCPBRX)
|
||||
self.CompareVals("testUDP-A TX", testUDPATX, ptestUDPATX)
|
||||
self.CompareVals("testUDP-A RX", testUDPARX, ptestUDPARX)
|
||||
self.CompareVals("testUDP-B TX", testUDPBTX, ptestUDPBTX)
|
||||
self.CompareVals("testUDP-B RX", testUDPBRX, ptestUDPBRX)
|
||||
self.CompareVals("l4Test Bytes Read", l4TestBR, pl4TestBR)
|
||||
self.CompareVals("genTest1 Last Results", genTest1LR, pgenTest1LR)
|
||||
self.CompareVals("wlTest1 TX Bytes", wlTest1TXB, pwlTest1TXB)
|
||||
self.CompareVals("wlTest1 RX Pkts", wlTest1RXP, pwlTest1RXP)
|
||||
self.CompareVals("wlTest2 TX Bytes", wlTest2TXB, pwlTest2TXB)
|
||||
self.CompareVals("wlTest2 RX Pkts", wlTest2RXP, pwlTest2RXP)
|
||||
print("\n")
|
||||
|
||||
# remove all endpoints and cxs
|
||||
print("Cleaning up...")
|
||||
LFUtils.removePort(1, "sta00000", mgrURL)
|
||||
|
||||
#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")
|
||||
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("wlTest1 TX Bytes", wlTest1TXB, pwlTest1TXB)
|
||||
compareVals("wlTest1 RX Pkts", wlTest1RXP, pwlTest1RXP)
|
||||
|
||||
compareVals("wlTest2 TX Bytes", wlTest2TXB, pwlTest2TXB)
|
||||
compareVals("wlTest2 RX Pkts", wlTest2RXP, pwlTest2RXP)
|
||||
|
||||
print("\n")
|
||||
|
||||
|
||||
|
||||
#remove all endpoints and cxs
|
||||
print("Cleaning up...")
|
||||
|
||||
LFUtils.removePort(1,"sta00000", mgrURL)
|
||||
|
||||
endpNames = ["testTCP-A", "testTCP-B",
|
||||
endpNames = ["testTCP-A", "testTCP-B",
|
||||
"testUDP-A", "testUDP-B",
|
||||
"l4Test", "fioTest",
|
||||
"genTest1", "genTest2",
|
||||
"wlTest1","wlTest2"]
|
||||
removeCX(mgrURL, cxNames)
|
||||
removeEndps(mgrURL, endpNames)
|
||||
"wlTest1", "wlTest2"]
|
||||
removeCX(mgrURL, cxNames)
|
||||
removeEndps(mgrURL, endpNames)
|
||||
|
||||
|
||||
# ~class
|
||||
|
||||
def main():
|
||||
lfjson_host = "localhost"
|
||||
lfjson_port = 8080
|
||||
test = ConnectTest(lfjson_host, lfjson_port)
|
||||
test.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user