Wifi 7226 query max clients from ap and run wifi capacity in that (#419)

* Added improvement around lf_tools add stations

Signed-off-by: shivam <shivam.thakur@candelatech.com>

* removed ax stations in wifi capacity for a while

Signed-off-by: shivam <shivam.thakur@candelatech.com>

* Added wifi_capacity in regular sanity tests and added nat mode wifi capacity in performance

Signed-off-by: shivam <shivam.thakur@candelatech.com>

* removed get_vif_state from test cases

Signed-off-by: shivam <shivam.thakur@candelatech.com>
This commit is contained in:
Shivam Thakur
2022-03-05 14:16:52 +05:30
committed by GitHub
parent 8d891a93bd
commit a0b4a32a9e
18 changed files with 605 additions and 341 deletions

305
libs/lanforge/lf_tools.py Normal file → Executable file
View File

@@ -1,7 +1,7 @@
import re
import sys
import os
import importlib
import importlib
import pytest
@@ -30,8 +30,15 @@ from LANforge.lfcli_base import LFCliBase
import json
import os
import pandas as pd
realm = importlib.import_module("py-json.realm")
Realm = realm.Realm
import logging
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
stdout_handler = logging.StreamHandler(sys.stdout)
LOGGER.addHandler(stdout_handler)
class ChamberView:
@@ -116,15 +123,15 @@ class ChamberView:
if "6g-ssid" in self.ssid_data.keys():
print("yes")
self.sixg_ssid = ["ssid_idx=2 ssid=" +
self.ssid_data["6g-ssid"] +
" security=" +
self.ssid_data["6g-encryption"].upper() +
" password=" +
self.ssid_data["6g-password"] +
" bssid=" +
self.ssid_data["6g-bssid"].lower().replace(" ", "")]
self.ssid_data["6g-ssid"] +
" security=" +
self.ssid_data["6g-encryption"].upper() +
" password=" +
self.ssid_data["6g-password"] +
" bssid=" +
self.ssid_data["6g-bssid"].lower().replace(" ", "")]
ssid_var = [self.twog_ssid, self.fiveg_ssid, self.sixg_ssid]
else :
else:
ssid_var = [self.twog_ssid, self.fiveg_ssid]
self.CreateDut.ssid = ssid_var
# print(self.CreateDut.ssid)
@@ -242,7 +249,6 @@ class ChamberView:
# print(self.CreateDut.ssid)
self.Create_Dut()
def reset_scenario(self):
# self.layer3_cleanup()
# self.Create_Dut()
@@ -265,7 +271,7 @@ class ChamberView:
self.CreateDut.add_ssids()
def get_station_list(self):
#realm_obj = self.staConnect.localrealm
# realm_obj = self.staConnect.localrealm
sta = self.staConnect.station_list()
sta_list = []
for i in sta:
@@ -273,9 +279,8 @@ class ChamberView:
sta_list.append(j)
return sta_list
def admin_up_down(self, sta_list=[], option="up"):
#realm_obj = self.staConnect.localrealm
# realm_obj = self.staConnect.localrealm
if option == "up":
for i in sta_list:
self.staConnect.admin_up(i)
@@ -313,99 +318,176 @@ class ChamberView:
self.Chamber_View()
def add_stations(self, band="2G", num_stations="max", dut="NA", ssid_name=[], idx=0):
LOGGER.info("Adding Stations:" + band + " band, Number of Stations: " + str(num_stations) +
" DUT: " + str(dut) + " SSID: " + str(ssid_name) + " idx: " + str(idx))
if num_stations == 0:
LOGGER.warning("0 Stations")
return
idx = idx
if self.run_lf:
if band == "2G":
idx = 0
if band == "5G":
idx = 1
print(self.dut_idx_mapping)
for i in self.dut_idx_mapping:
if self.dut_idx_mapping[i][0] == ssid_name and self.dut_idx_mapping[i][3] == band:
idx = i
max_stations = 0
print(idx)
if band == "2G":
if num_stations != "max":
if num_stations > 64:
num_stations = int(num_stations / len(self.twog_radios))
for radio in self.twog_radios:
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
else:
num_stations = num_stations
station_data = ["profile_link " + self.fiveg_radios[0].split(".")[0] + "." +
self.fiveg_radios[0].split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + self.twog_radios[0].split(".")[2]]
self.raw_line.append(station_data)
if num_stations == "max":
LOGGER.info("Total 2G Radios Available in Testbed: " + str(len(self.twog_radios)))
total_sta = num_stations
max_possible = 0
for radio in self.twog_radios:
num_stations = 64
max_possible = max_possible + int(self.get_max_sta(radio))
if total_sta <= max_possible:
per_radio_sta = int(total_sta / len(self.twog_radios))
rem = total_sta % len(self.twog_radios)
else:
total_sta = max_possible
per_radio_sta = int(total_sta / len(self.twog_radios))
rem = total_sta % len(self.twog_radios)
if rem != 0 and per_radio_sta == 0:
per_radio_sta = rem / len(self.twog_radios)
LOGGER.info("Total stations per radio: " + str(per_radio_sta))
for radio in self.twog_radios:
max_possible = int(self.get_max_sta(radio))
if total_sta == 0:
return
num_stations = per_radio_sta
if rem == 0 and num_stations == 0:
return
if max_possible - num_stations >= rem:
num_stations = num_stations + rem
rem = 0
elif max_possible - rem >= num_stations:
num_stations = num_stations + rem
rem = 0
elif total_sta <= max_possible:
num_stations = total_sta
if per_radio_sta < 1:
num_stations = 1
total_sta = total_sta - num_stations
LOGGER.info("Adding " + str(num_stations) + " Stations on " + str(radio))
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
LOGGER.debug("Raw Line : " + str(station_data))
if num_stations == "max":
LOGGER.info("Total 2G Radios Available in Testbed: " + str(len(self.twog_radios)))
for radio in self.twog_radios:
num_stations = self.get_max_sta(radio)
LOGGER.info("Total stations: " + str(num_stations) + " On Radio: " + str(radio))
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
LOGGER.debug("Raw Line : " + str(station_data))
if band == "5G":
if num_stations != "max":
if num_stations > 64:
num_stations = int(num_stations / len(self.fiveg_radios))
for radio in self.fiveg_radios:
station_dataupstream_port_1 = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
print(station_data)
self.raw_line.append(station_data)
else:
num_stations = num_stations
station_data = ["profile_link " + self.fiveg_radios[0].split(".")[0] + "." +
self.fiveg_radios[0].split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + self.fiveg_radios[0].split(".")[2]]
print(station_data)
self.raw_line.append(station_data)
if num_stations == "max":
LOGGER.info("Total 2G Radios Available in Testbed: " + str(len(self.fiveg_radios)))
total_sta = num_stations
max_possible = 0
for radio in self.fiveg_radios:
num_stations = 64
max_possible = max_possible + int(self.get_max_sta(radio))
if total_sta <= max_possible:
per_radio_sta = int(total_sta / len(self.fiveg_radios))
rem = total_sta % len(self.fiveg_radios)
else:
total_sta = max_possible
per_radio_sta = int(total_sta / len(self.fiveg_radios))
rem = total_sta % len(self.fiveg_radios)
if rem != 0 and per_radio_sta == 0:
per_radio_sta = rem / len(self.fiveg_radios)
LOGGER.info("Total stations per radio: " + str(per_radio_sta))
for radio in self.fiveg_radios:
max_possible = int(self.get_max_sta(radio))
if total_sta == 0:
return
num_stations = per_radio_sta
if rem == 0 and num_stations == 0:
return
if max_possible - num_stations >= rem:
num_stations = num_stations + rem
rem = 0
elif max_possible - rem >= num_stations:
num_stations = num_stations + rem
rem = 0
elif total_sta <= max_possible:
num_stations = total_sta
if per_radio_sta < 1:
num_stations = 1
total_sta = total_sta - num_stations
LOGGER.info("Adding " + str(num_stations) + " Stations on " + str(radio))
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
print(station_data)
self.raw_line.append(station_data)
LOGGER.debug("Raw Line : " + str(station_data))
if num_stations == "max":
LOGGER.info("Total 5G Radios Available in Testbed: " + str(len(self.fiveg_radios)))
for radio in self.fiveg_radios:
num_stations = self.get_max_sta(radio)
LOGGER.info("Total stations: " + str(num_stations) + " On Radio: " + str(radio))
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
LOGGER.debug("Raw Line : " + str(station_data))
if band == "ax":
if num_stations != "max":
LOGGER.info("Total 2G Radios Available in Testbed: " + str(len(self.ax_radios)))
total_sta = num_stations
max_possible = 0
for radio in self.ax_radios:
max_possible = max_possible + self.get_max_sta(radio)
if num_stations > 1:
if num_stations > max_possible:
pytest.exit("Error: Can't Create " + num_stations + ", only " + max_possible + " Stations can be created")
num_stations = int(num_stations / len(self.ax_radios))
for radio in self.ax_radios:
max = self.get_max_sta(radio)
num_stations = num_stations - max
station_data = ["profile_link 1.1 STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
max_possible = max_possible + int(self.get_max_sta(radio))
if total_sta <= max_possible:
per_radio_sta = int(total_sta / len(self.ax_radios))
rem = total_sta % len(self.ax_radios)
else:
num_stations = num_stations
station_data = ["profile_link 1.1 STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
if num_stations == "max":
total_sta = max_possible
per_radio_sta = int(total_sta / len(self.ax_radios))
rem = total_sta % len(self.ax_radios)
if rem != 0 and per_radio_sta == 0:
per_radio_sta = rem / len(self.ax_radios)
LOGGER.info("Total stations per radio: " + str(per_radio_sta))
for radio in self.ax_radios:
print("radio", radio)
num_stations = self.get_max_sta(radio)
print("num_stations", num_stations)
station_data = ["profile_link 1.1 STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
max_possible = int(self.get_max_sta(radio))
if total_sta == 0:
return
num_stations = per_radio_sta
if rem == 0 and num_stations == 0:
return
if max_possible - num_stations >= rem:
num_stations = num_stations + rem
rem = 0
elif max_possible - rem >= num_stations:
num_stations = num_stations + rem
rem = 0
elif total_sta <= max_possible:
num_stations = total_sta
if per_radio_sta < 1:
num_stations = 1
total_sta = total_sta - num_stations
LOGGER.info("Adding " + str(num_stations) + " Stations on " + str(radio))
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
LOGGER.debug("Raw Line : " + str(station_data))
if num_stations == "max":
LOGGER.info("Total AX Radios Available in Testbed: " + str(len(self.ax_radios)))
for radio in self.ax_radios:
num_stations = self.get_max_sta(radio)
LOGGER.info("Total stations: " + str(num_stations) + " On Radio: " + str(radio))
station_data = ["profile_link " + radio.split(".")[0] + "." + radio.split(".")[1] +
" STA-AUTO " + str(num_stations) + " 'DUT: " + dut + " Radio-" +
str(int(idx) + 1) + "'" + " NA " + radio.split(".")[2]]
self.raw_line.append(station_data)
LOGGER.debug("Raw Line : " + str(station_data))
def Create_Dut(self):
self.CreateDut.setup()
@@ -446,12 +528,11 @@ class ChamberView:
def station_data_query(self, station_name="wlan0", query="channel"):
x = self.upstream_port.split(".")
url = f"/port/{x[0]}/{x[1]}/{station_name}?fields={query}"
# print("url//////", url)
response = self.json_get(_req_url=url)
print("response: ", response)
if (response is None) or ("interface" not in response):
print("station_list: incomplete response:")
#pprint(response)
# pprint(response)
exit(1)
y = response["interface"][query]
return y
@@ -526,13 +607,12 @@ class ChamberView:
name=i,
attachment_type="image/png", extension=None)
def create_mesh_scenario(self):
# upstream_list = []
# for data in range(0,len(self.access_point_data)):
self.CreateDut = DUT(lfmgr=self.lanforge_ip,
port=self.lanforge_port,
dut_name="upstream" ) # + str(data))
dut_name="upstream") # + str(data))
self.CreateDut.lan_port = "10.28.2.1/24"
# name = "upstream" + str(data)
# upstream_list.append(name)
@@ -540,12 +620,21 @@ class ChamberView:
self.CreateDut.setup()
# data = data + 1
self.raw_line = [
["profile_link " + self.upstream_resource_2 + " upstream-dhcp 1 NA NA " + self.upstream_port_2.split(".")[2] + ",AUTO -1 NA"],
["profile_link " + self.uplink_resource_2 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " + self.uplink_port_2.split(".")[2] + "," + self.upstream_port_2.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_3 + " upstream-dhcp 1 NA NA " + self.upstream_port_3.split(".")[2] + ",AUTO -1 NA"],
["profile_link " + self.uplink_resource_3 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " + self.uplink_port_3.split(".")[2] + "," + self.upstream_port_3.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_4 + " upstream-dhcp 1 NA NA " + self.upstream_port_4.split(".")[2] + ",AUTO -1 NA"],
["profile_link " + self.uplink_resource_4 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " + self.uplink_port_4.split(".")[2] + "," + self.upstream_port_4.split(".")[2] + " -1 NA"]
["profile_link " + self.upstream_resource_2 + " upstream-dhcp 1 NA NA " + self.upstream_port_2.split(".")[
2] + ",AUTO -1 NA"],
[
"profile_link " + self.uplink_resource_2 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " +
self.uplink_port_2.split(".")[2] + "," + self.upstream_port_2.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_3 + " upstream-dhcp 1 NA NA " + self.upstream_port_3.split(".")[
2] + ",AUTO -1 NA"],
[
"profile_link " + self.uplink_resource_3 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " +
self.uplink_port_3.split(".")[2] + "," + self.upstream_port_3.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_4 + " upstream-dhcp 1 NA NA " + self.upstream_port_4.split(".")[
2] + ",AUTO -1 NA"],
[
"profile_link " + self.uplink_resource_4 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " +
self.uplink_port_4.split(".")[2] + "," + self.upstream_port_4.split(".")[2] + " -1 NA"]
]
print(self.raw_line)
mesh = self.Chamber_View()
@@ -557,7 +646,7 @@ class ChamberView:
# for data in range(0,len(self.access_point_data)):
self.CreateDut = DUT(lfmgr=self.lanforge_ip,
port=self.lanforge_port,
dut_name="upstream" )
dut_name="upstream")
self.CreateDut.lan_port = "10.28.2.1/24"
# name = "upstream" + str(data)
# upstream_list.append(name)
@@ -565,12 +654,21 @@ class ChamberView:
self.CreateDut.setup()
# data = data + 1
self.raw_line = [
["profile_link " + self.upstream_resource_2 + " upstream-dhcp 1 NA NA " + self.upstream_port_2.split(".")[2] + ",AUTO -1 NA"],
["profile_link " + self.uplink_resource_2 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " + self.uplink_port_2.split(".")[2] + "," + self.upstream_port_2.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_3 + " upstream 1 NA NA " + self.upstream_port_3.split(".")[2] + ",AUTO -1 NA"],
["profile_link " + self.uplink_resource_3 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " + self.uplink_port_3.split(".")[2] + "," + self.upstream_port_3.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_4 + " upstream 1 NA NA " + self.upstream_port_4.split(".")[2] + ",AUTO -1 NA"],
["profile_link " + self.uplink_resource_4 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " + self.uplink_port_4.split(".")[2] + "," + self.upstream_port_4.split(".")[2] + " -1 NA"]
["profile_link " + self.upstream_resource_2 + " upstream-dhcp 1 NA NA " + self.upstream_port_2.split(".")[
2] + ",AUTO -1 NA"],
[
"profile_link " + self.uplink_resource_2 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " +
self.uplink_port_2.split(".")[2] + "," + self.upstream_port_2.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_3 + " upstream 1 NA NA " + self.upstream_port_3.split(".")[
2] + ",AUTO -1 NA"],
[
"profile_link " + self.uplink_resource_3 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " +
self.uplink_port_3.split(".")[2] + "," + self.upstream_port_3.split(".")[2] + " -1 NA"],
["profile_link " + self.upstream_resource_4 + " upstream 1 NA NA " + self.upstream_port_4.split(".")[
2] + ",AUTO -1 NA"],
[
"profile_link " + self.uplink_resource_4 + " uplink-nat 1 'DUT: upstream LAN " + self.upstream_subnet + "' NA " +
self.uplink_port_4.split(".")[2] + "," + self.upstream_port_4.split(".")[2] + " -1 NA"]
]
print(self.raw_line)
mesh = self.Chamber_View()
@@ -598,7 +696,6 @@ class ChamberView:
# [['ssid_idx=0 ssid=Default-SSID-2g security=WPA|WEP| password=12345678 bssid=90:3c:b3:94:48:58']]
self.update_ssid(ssid_data=ssid_data[ssid])
def set_radio_antenna(self, req_url, shelf, resources, radio, antenna):
data = {
"shelf": shelf,
@@ -693,34 +790,34 @@ def main():
# ]
# testbed = "mesh"
lanforge_data = {
"ip": "10.28.3.6",
"ip": "10.28.3.32",
"port": 8080,
"ssh_port": 22,
"2.4G-Radio": ["1.1.wiphy4"],
"5G-Radio": ["1.1.wiphy5"],
"AX-Radio": ["1.1.wiphy0", "1.1.wiphy1", "1.1.wiphy2", "1.1.wiphy3"],
"2.4G-Radio": ["1.1.wiphy0", "1.1.wiphy2", "1.1.wiphy1"],
"5G-Radio": ["1.1.wiphy1", "1.1.wiphy3"],
"AX-Radio": ["1.1.wiphy4", "1.1.wiphy5", "1.1.wiphy6", "1.1.wiphy7"],
"upstream": "1.1.eth2",
"upstream_subnet": "10.28.2.1/24",
"uplink": "1.1.eth3",
"2.4G-Station-Name": "wlan0",
"5G-Station-Name": "wlan1",
"2.4G-Station-Name": "sta10",
"5G-Station-Name": "sta00",
"AX-Station-Name": "ax"
}
ap_data = [{
"model": "edgecore_ecw5410",
"mode": "wifi5",
"serial": "3c2c99f44e77",
"model": "edgecore_eap101",
"mode": "wifi6",
"serial": "903cb36ae223",
"jumphost": True,
"ip": "10.28.3.100",
"ip": "10.28.3.103",
"username": "lanforge",
"password": "pumpkin77",
"port": 22,
"jumphost_tty": "/dev/ttyAP1",
"jumphost_tty": "/dev/ttyAP3",
"version": "release-latest"
}]
obj = ChamberView(lanforge_data=lanforge_data, access_point_data=ap_data, testbed="basic")
a = obj.get_max_sta("1.1.wiphy0")
print(a)
obj.add_stations("2G", "max", obj.dut_name, "abc")
# lf_tools.add_stations(band="2G", num_stations="max", dut=lf_tools.dut_name, ssid_name=ssid_name)
# obj.create_mesh_dut()