mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 11:18:03 +00:00
lf_dataplane_test.py : added support for json
lf_dataplane_config.json : sample json file for configuration of lf_dataplane_test.py Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
@@ -231,11 +231,53 @@ def main():
|
||||
--influx_token=-u_Wd-L8o992701QF0c5UmqEp7w7Z7YOMaWLxOMgmHfATJGnQbbmYyNxHBR9PgD6taM_tcxqJl6U8DjU1xINFQ== \
|
||||
--influx_bucket ben \
|
||||
--influx_tag testbed Ferndale-01
|
||||
|
||||
|
||||
Example 2:
|
||||
./lf_dataplane_test.py --json <name>.json
|
||||
|
||||
see sample json file: lf_dataplane_config.json
|
||||
|
||||
Sample <name>.json between using eth1 and eth2
|
||||
{
|
||||
"mgr":"192.168.0.101",
|
||||
"port":"8080",
|
||||
"lf_user":"lanforge",
|
||||
"lf_password":"lanforge",
|
||||
"instance_name":"dataplane-instance",
|
||||
"config_name":"test_con",
|
||||
"upstream":"1.1.eth1",
|
||||
"dut":"asus_5g",
|
||||
"duration":"15s",
|
||||
"station":"1.1.eth2",
|
||||
"download_speed":"85%",
|
||||
"upload_speed":"0",
|
||||
"raw_line": ["pkts: Custom;60;MTU", "cust_pkt_sz: 88 1200", "directions: DUT Transmit", "traffic_types: UDP", "bandw_options: 20", "spatial_streams: 1"]
|
||||
}
|
||||
|
||||
Sample <name>.json between using eth1 and station 1.1.sta0002
|
||||
{
|
||||
"mgr":"192.168.0.101",
|
||||
"port":"8080",
|
||||
"lf_user":"lanforge",
|
||||
"lf_password":"lanforge",
|
||||
"instance_name":"dataplane-instance",
|
||||
"config_name":"test_con",
|
||||
"upstream":"1.1.eth1",
|
||||
"dut":"asus_5g",
|
||||
"duration":"15s",
|
||||
"station":"1.1.sta0002",
|
||||
"download_speed":"85%",
|
||||
"upload_speed":"0",
|
||||
"raw_line": ["pkts: Custom;60;MTU", "cust_pkt_sz: 88 1200", "directions: DUT Transmit", "traffic_types: UDP", "bandw_options: 20", "spatial_streams: 1"]
|
||||
}
|
||||
|
||||
"""
|
||||
)
|
||||
|
||||
cv_add_base_parser(parser) # see cv_test_manager.py
|
||||
|
||||
parser.add_argument('--json', help="--json <config.json> json input file", default="")
|
||||
parser.add_argument("-u", "--upstream", type=str, default="",
|
||||
help="Upstream port for wifi capacity test ex. 1.1.eth2")
|
||||
parser.add_argument("--station", type=str, default="",
|
||||
@@ -254,6 +296,45 @@ def main():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# use json config file
|
||||
if args.json != "":
|
||||
try:
|
||||
with open(args.json, 'r') as json_config:
|
||||
json_data = json.load(json_config)
|
||||
except:
|
||||
print("Error reading {}".format(args.json))
|
||||
# json configuation takes presidence to command line
|
||||
# TODO see if there is easier way to search presence, look at parser args
|
||||
if "mgr" in json_data:
|
||||
args.mgr = json_data["mgr"]
|
||||
if "port" in json_data:
|
||||
args.port = json_data["port"]
|
||||
if "lf_user" in json_data:
|
||||
args.lf_user = json_data["lf_user"]
|
||||
if "lf_password" in json_data:
|
||||
args.lf_password = json_data["lf_password"]
|
||||
if "instance_name" in json_data:
|
||||
args.instance_name = json_data["instance_name"]
|
||||
if "config_name" in json_data:
|
||||
args.config_name = json_data["config_name"]
|
||||
if "upstream" in json_data:
|
||||
args.upstream = json_data["upstream"]
|
||||
if "dut" in json_data:
|
||||
args.dut = json_data["dut"]
|
||||
if "duration" in json_data:
|
||||
args.duration = json_data["duration"]
|
||||
if "station" in json_data:
|
||||
args.station = json_data["station"]
|
||||
if "download_speed" in json_data:
|
||||
args.download_speed = json_data["download_speed"]
|
||||
if "upload_speed" in json_data:
|
||||
args.upload_speed = json_data["upload_speed"]
|
||||
if "raw_line" in json_data:
|
||||
# the json_data is a list , need to make into a list of lists, to match command line raw_line paramaters
|
||||
# https://www.tutorialspoint.com/convert-list-into-list-of-lists-in-python
|
||||
json_data_tmp = [[x] for x in json_data["raw_line"]]
|
||||
args.raw_line = json_data_tmp
|
||||
|
||||
cv_base_adjust_parser(args)
|
||||
|
||||
CV_Test = DataplaneTest(lf_host = args.mgr,
|
||||
|
||||
Reference in New Issue
Block a user