Added fileio and generic endpoint tests

This commit is contained in:
Logan Lipke
2020-04-10 11:02:59 -07:00
parent 867bb762fe
commit e6a4f800b8

View File

@@ -7,6 +7,7 @@ import json
import pprint
from LANforge import LFRequest
from LANforge import LFUtils
import create_genlink as genl
if sys.version_info[0] != 3:
print("This script requires Python 3")
@@ -20,6 +21,17 @@ def execWrap(cmd):
print("\nError with " + cmd + ",bye\n")
exit(1)
def jsonReq(mgrURL, reqURL, data, debug=False):
lf_r = LFRequest.LFRequest(mgrURL + reqURL)
lf_r.addPostData(data)
if debug:
json_response = lf_r.jsonPost(True)
LFUtils.debug_printer.pprint(json_response)
sys.exit(1)
else:
lf_r.jsonPost()
#create cx for tcp and udp
cmd = ("perl lf_firemod.pl --action create_cx --cx_name test1 --use_ports sta00000,eth1 --use_speeds 360000,150000 --endp_type tcp")
execWrap(cmd)
@@ -27,9 +39,8 @@ cmd = ("perl lf_firemod.pl --action create_cx --cx_name test2 --use_ports sta000
execWrap(cmd)
#create l4 endpoint
lf_r = LFRequest.LFRequest(mgrURL + "cli-json/add_l4_endp")
lf_r.addPostData(
{
url = "cli-json/add_l4_endp"
data = {
"alias":"l4Test",
"shelf":1,
"resource":1,
@@ -38,37 +49,71 @@ lf_r.addPostData(
"timeout":1000,
"url_rate":600,
"url":"dl http://10.40.0.1/ /dev/null"
})
lf_r.jsonPost()
#json_response = lf_r.jsonPost(True)
#LFUtils.debug_printer.pprint(json_response)
#sys.exit(1)
}
jsonReq(mgrURL, url, data)
#create cx for l4_endp
lf_r = LFRequest.LFRequest(mgrURL + "cli-json/add_cx")
lf_r.addPostData(
{
url = "cli-json/add_cx"
data = {
"alias":"CX_l4Test",
"test_mgr":"default_tm",
"tx_endp":"l4Test",
"rx_endp":"NA"
})
}
lf_r.jsonPost()
json_response = lf_r.jsonPost(True)
LFUtils.debug_printer.pprint(json_response)
#sys.exit(1)
jsonReq(mgrURL, 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"
}
jsonReq(mgrURL,url,data)
#create fileio cx
url = "cli-json/add_cx"
data = {
"alias":"CX_fioTest",
"test_mgr":"default_tm",
"tx_endp":"fioTest",
"rx_endp":"NA"
}
jsonReq(mgrURL,url,data)
#create generic endpoint
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")
#create generic cx
url = "cli-json/add_cx"
data = {
"alias":"CX_genTest1",
"test_mgr":"default_tm",
"tx_endp":"genTest1",
"rx_endp":"genTest2"
}
jsonReq(mgrURL,url,data)
#start cx traffic
cmd = ("perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm test1 RUNNING\"")
execWrap(cmd)
cmd = ("perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm test2 RUNNING\"")
execWrap(cmd)
cmd = ("perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm CX_l4Test RUNNING\"")
execWrap(cmd)
cxNames = ["test1","test2", "CX_l4Test", "CX_fioTest", "CX_genTest1"]
for name in range(len(cxNames)):
cmd = (f"perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} RUNNING\"")
execWrap(cmd)
time.sleep(5)
@@ -100,15 +145,16 @@ execWrap(cmd)
print("l4Test")
cmd = ("./lf_firemod.pl --action show_endp --endp_name l4Test")
execWrap(cmd)
cmd = ("./lf_firemod.pl --action show_endp --endp_name fioTest")
execWrap(cmd)
cmd = ("./lf_firemod.pl --action show_endp --endp_name genTest1")
execWrap(cmd)
#stop cx traffic
cmd = ("perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm test1 STOPPED\"")
execWrap(cmd)
cmd = ("perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm test2 STOPPED\"")
execWrap(cmd)
cmd = ("perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm CX_l4 STOPPED\"")
execWrap(cmd)
for name in range(len(cxNames)):
cmd = (f"perl lf_firemod.pl --mgr localhost --quiet 0 --action do_cmd --cmd \"set_cx_state default_tm {cxNames[name]} STOPPED\"")
execWrap(cmd)
#get JSON info from webpage for ports and endps
url = ["port/","endp/"]
@@ -117,7 +163,7 @@ timeout = 5 # seconds
for i in range(len(url)):
lf_r = LFRequest.LFRequest(mgrURL + url[i])
json_response = lf_r.getAsJson()
#print(json_response)
print(json_response)
j_printer = pprint.PrettyPrinter(indent=2)
if not i:
print("Ports: \n")