Added fix for Vlan creation in wifi capacity test logic

Signed-off-by: shivam <shivam.thakur@candelatech.com>
This commit is contained in:
shivam
2022-10-18 14:44:46 +05:30
parent 59f8d1a3ab
commit f28329facd
2 changed files with 58 additions and 46 deletions

View File

@@ -1100,12 +1100,13 @@ class lf_libs:
data = self.json_get("/radiostatus/all") data = self.json_get("/radiostatus/all")
return data[radio]["max_vifs"] return data[radio]["max_vifs"]
def add_vlan(self, vlan_ids=[]): def add_vlan(self, vlan_ids=[], build=True):
self.temp_raw_lines = self.default_scenario_raw_lines.copy() self.temp_raw_lines = self.default_scenario_raw_lines.copy()
data = self.json_get("/port/all") data = self.json_get("/port/all")
flag = 0 flag = 0
profile_name = "" profile_name = ""
port_list = [] port_list = []
vlan_raws = []
# temp_raw_lines = self.default_scenario_raw_lines.copy() # temp_raw_lines = self.default_scenario_raw_lines.copy()
for port in self.wan_ports: for port in self.wan_ports:
for vlans in vlan_ids: for vlans in vlan_ids:
@@ -1119,53 +1120,60 @@ class lf_libs:
elif self.scenario == "dhcp-external": elif self.scenario == "dhcp-external":
profile_name = "vlan_profile" profile_name = "vlan_profile"
port_list.append(str(port) + "." + str(vlans)) port_list.append(str(port) + "." + str(vlans))
vlan_raws.append(["profile_link " + port + " " + profile_name + " 1 " + port
+ " NA " + port.split(".")[2] + ",AUTO -1 " + str(vlans)])
self.temp_raw_lines.append(["profile_link " + port + " " + profile_name + " 1 " + port self.temp_raw_lines.append(["profile_link " + port + " " + profile_name + " 1 " + port
+ " NA " + port.split(".")[2] + ",AUTO -1 " + str(vlans)]) + " NA " + port.split(".")[2] + ",AUTO -1 " + str(vlans)])
self.chamber_view(raw_lines="custom") if build:
if self.scenario == "dhcp-external": self.chamber_view(raw_lines="custom")
for port in port_list: if self.scenario == "dhcp-external":
data = { for port in port_list:
"shelf": port.split(".")[0], data = {
"resource": port.split(".")[1], "shelf": port.split(".")[0],
"port": port.split(".")[2] + "." + port.split(".")[3], "resource": port.split(".")[1],
"current_flags": 2147483648, "port": port.split(".")[2] + "." + port.split(".")[3],
"interest": 16384 "current_flags": 2147483648,
} "interest": 16384
self.json_post("/cli-json/set_port", data) }
time.sleep(2) self.json_post("/cli-json/set_port", data)
time.sleep(5) time.sleep(2)
# query and fetch vlan Ip Address time.sleep(5)
port_data = self.json_get(_req_url="/port?fields=alias,parent+dev,port+type,ip,mac")['interfaces'] # query and fetch vlan Ip Address
logging.info("Port data: " + str(port_data)) port_data = self.json_get(_req_url="/port?fields=alias,parent+dev,port+type,ip,mac")['interfaces']
vlan_table_data = {} logging.info("Port data: " + str(port_data))
port = [] vlan_table_data = {}
ip = [] port = []
parent_dev = [] ip = []
not_ip_vlans = [] parent_dev = []
vlan_ip_fail = False not_ip_vlans = []
for i in port_data: vlan_ip_fail = False
for item in i: for i in port_data:
if i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] == '0.0.0.0': for item in i:
vlan_ip_fail = True if i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] == '0.0.0.0':
logging.error(f"VLAN Interface - {i[item]['alias']} do not have IP") vlan_ip_fail = True
port.append(item) logging.error(f"VLAN Interface - {i[item]['alias']} do not have IP")
ip.append(i[item]['ip']) port.append(item)
not_ip_vlans.append(item) ip.append(i[item]['ip'])
parent_dev.append(i[item]['parent dev']) not_ip_vlans.append(item)
elif i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] != '0.0.0.0': parent_dev.append(i[item]['parent dev'])
port.append(item) elif i[item]['port type'] == '802.1Q VLAN' and i[item]['ip'] != '0.0.0.0':
ip.append(i[item]['ip']) port.append(item)
parent_dev.append(i[item]['parent dev']) ip.append(i[item]['ip'])
# creating dict for vlan table parent_dev.append(i[item]['parent dev'])
vlan_table_data["Port"] = port # creating dict for vlan table
vlan_table_data["Parent Dev"] = parent_dev vlan_table_data["Port"] = port
vlan_table_data["ip"] = ip vlan_table_data["Parent Dev"] = parent_dev
# Attaching vlan table to allure vlan_table_data["ip"] = ip
self.attach_table_allure(data=vlan_table_data, allure_name="VLAN Table") # Attaching vlan table to allure
if vlan_ip_fail: self.attach_table_allure(data=vlan_table_data, allure_name="VLAN Table")
# Fail if Vlan don't have IP if vlan_ip_fail:
pytest.fail("VLAN do not have IP:-" + str(not_ip_vlans)) # Fail if Vlan don't have IP
pytest.fail("VLAN do not have IP:-" + str(not_ip_vlans))
return vlan_raws
else:
return vlan_raws
def chamber_view(self, delete_old_scenario=True, raw_lines="default"): def chamber_view(self, delete_old_scenario=True, raw_lines="default"):
"""create chamber view. raw_lines values are default | custom""" """create chamber view. raw_lines values are default | custom"""

View File

@@ -969,6 +969,7 @@ class lf_tests(lf_libs):
sort="interleave", raw_lines=[], move_to_influx=False, dut_data={}, ssid_name=None, sort="interleave", raw_lines=[], move_to_influx=False, dut_data={}, ssid_name=None,
num_stations={}, add_stations=True): num_stations={}, add_stations=True):
wificapacity_obj_list = [] wificapacity_obj_list = []
vlan_raw_lines = None
for dut in self.dut_data: for dut in self.dut_data:
sets = [["DUT_NAME", dut["model"]]] sets = [["DUT_NAME", dut["model"]]]
identifier = dut["identifier"] identifier = dut["identifier"]
@@ -989,7 +990,7 @@ class lf_tests(lf_libs):
logging.error("VLAN ID is Unspecified in the VLAN Case") logging.error("VLAN ID is Unspecified in the VLAN Case")
pytest.skip("VLAN ID is Unspecified in the VLAN Case") pytest.skip("VLAN ID is Unspecified in the VLAN Case")
else: else:
self.add_vlan(vlan_ids=[vlan_id]) vlan_raw_lines = self.add_vlan(vlan_ids=[vlan_id], build=True)
ret = self.get_wan_upstream_ports() ret = self.get_wan_upstream_ports()
upstream_port = ret[identifier] + "." + str(vlan_id) upstream_port = ret[identifier] + "." + str(vlan_id)
logging.info("Upstream data: " + str(upstream_port)) logging.info("Upstream data: " + str(upstream_port))
@@ -1028,6 +1029,9 @@ class lf_tests(lf_libs):
self.add_stations(band=band_, num_stations=num_stations[band_], ssid_name=ssid_name, self.add_stations(band=band_, num_stations=num_stations[band_], ssid_name=ssid_name,
dut_data=dut_data, dut_data=dut_data,
identifier=identifier) identifier=identifier)
if vlan_raw_lines is not None:
for i in vlan_raw_lines:
self.temp_raw_lines.append(i)
self.chamber_view(raw_lines="custom") self.chamber_view(raw_lines="custom")
wificapacity_obj = WiFiCapacityTest(lfclient_host=self.manager_ip, wificapacity_obj = WiFiCapacityTest(lfclient_host=self.manager_ip,
lf_port=self.manager_http_port, lf_port=self.manager_http_port,