mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-10-29 18:12:34 +00:00
Wifi 13372 (#887)
* Added attach_name argumenet in run_generic_command method Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> * Added additional validation like ifconfig up0v0, ping before config push Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> * Added AP logread in teardown Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> * Modified Allure report failed Message Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> * Added TimeStamp in allure attach Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> * Added TimeStamp in setup for each AP command Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> * Added uci show in teardown Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com> --------- Signed-off-by: jitendracandela <jitendra.kushavah@candelatech.com>
This commit is contained in:
committed by
GitHub
parent
1410b040f1
commit
b5f45ab85d
@@ -4,7 +4,7 @@ import logging
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
|
||||
import datetime
|
||||
import allure
|
||||
import paramiko
|
||||
import pytest
|
||||
@@ -191,6 +191,8 @@ class APLIBS:
|
||||
logging.error("ubus call ucentral status has unexpected data")
|
||||
return False
|
||||
active_uuid = r_val["active"]
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("cat /etc/ucentral/ucentral.cfg Timestamp: " + str(timestamp))
|
||||
output = self.run_generic_command(cmd="cat /etc/ucentral/ucentral.cfg." + str(active_uuid), idx=idx,
|
||||
print_log=print_log,
|
||||
attach_allure=attach_allure,
|
||||
@@ -199,7 +201,7 @@ class APLIBS:
|
||||
data = dict(json.loads(output.replace("\n\t", "").replace("\n", "")))
|
||||
logging.info("Active config is : " + str(data))
|
||||
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(active_uuid),
|
||||
body=str(json.dumps(data, indent=2)),
|
||||
body="TimeStamp: " + str(timestamp) + "\n" + str(json.dumps(data, indent=2)),
|
||||
attachment_type=allure.attachment_type.JSON)
|
||||
except Exception as e:
|
||||
data = output
|
||||
@@ -265,7 +267,7 @@ class APLIBS:
|
||||
"Please add valid certificates on AP")
|
||||
|
||||
def run_generic_command(self, cmd="", idx=0, print_log=True, attach_allure=False,
|
||||
expected_attachment_type=allure.attachment_type.TEXT, restrictions=False):
|
||||
expected_attachment_type=allure.attachment_type.TEXT, restrictions=False, attach_name=None):
|
||||
input_command = cmd
|
||||
logging.info("Executing Command on AP: " + cmd)
|
||||
try:
|
||||
@@ -289,8 +291,11 @@ class APLIBS:
|
||||
f"cmd --value \'{cmd}\' "
|
||||
if print_log:
|
||||
logging.info(cmd)
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info(cmd + " Timestamp: " + str(timestamp))
|
||||
stdin, stdout, stderr = client.exec_command(cmd)
|
||||
output = stdout.read()
|
||||
# data = dict(json.loads(output.replace("\n\t", "").replace("\n", "")))
|
||||
final_output = str(output)
|
||||
if not output.__contains__(b"BOOTLOADER-CONSOLE-IPQ6018#"):
|
||||
status = output.decode('utf-8').splitlines()
|
||||
@@ -300,7 +305,13 @@ class APLIBS:
|
||||
logging.info(cmd)
|
||||
logging.info("Output for command: " + input_command + "\n" + final_output)
|
||||
if attach_allure:
|
||||
allure.attach(name=input_command, body=output, attachment_type=expected_attachment_type)
|
||||
if attach_name is None:
|
||||
allure.attach(name=input_command, body=str("TimeStamp: " + str(timestamp) + "\n").encode() +
|
||||
output, attachment_type=expected_attachment_type)
|
||||
else:
|
||||
allure.attach(name=attach_name,
|
||||
body=str("TimeStamp: " + str(timestamp) + "\n").encode() + output,
|
||||
attachment_type=expected_attachment_type)
|
||||
client.close()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
@@ -629,4 +640,4 @@ if __name__ == '__main__':
|
||||
# a = obj.get_active_config()
|
||||
# if a == l:
|
||||
# print("a = l")
|
||||
# print(obj.get_ap_version())
|
||||
# print(obj.get_ap_version())
|
||||
|
||||
@@ -8,7 +8,7 @@ import json
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
|
||||
import datetime
|
||||
import allure
|
||||
import pytest
|
||||
import requests
|
||||
@@ -300,6 +300,35 @@ class tip_2x:
|
||||
ret_val = dict()
|
||||
for i in range(0, len(self.device_under_tests_info)):
|
||||
self.pre_apply_check(idx=i) # Do check AP before pushing the configuration
|
||||
# Before config push ifconfig up0v0
|
||||
check_iface = self.get_dut_library_object().run_generic_command(cmd="ifconfig up0v0", idx=i,
|
||||
print_log=True,
|
||||
attach_allure=True,
|
||||
attach_name="Before config push ifconfig up0v0",
|
||||
expected_attachment_type=allure.attachment_type.TEXT)
|
||||
if check_iface.__contains__("error fetching interface information: Device not found"):
|
||||
logging.error(check_iface)
|
||||
pytest.exit("up0v0 interface is not available!!!")
|
||||
# Check internet connectivity in ap
|
||||
is_ping = False
|
||||
for i in range(3):
|
||||
check_ping = self.get_dut_library_object().run_generic_command(cmd="ping -c 3 mi.com", idx=i,
|
||||
print_log=True,
|
||||
attach_allure=True,
|
||||
attach_name="Before config push ping " + str(
|
||||
i),
|
||||
expected_attachment_type=allure.attachment_type.TEXT)
|
||||
if not check_ping.__contains__("100% packet loss"):
|
||||
is_ping = True
|
||||
break
|
||||
time.sleep(10)
|
||||
if not is_ping:
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("AP is unable to reach internet Timestamp: " + str(timestamp))
|
||||
ap_logs = self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs),
|
||||
name="AP is unable to reach internet: Logs")
|
||||
pytest.exit("AP is unreachable to internet")
|
||||
|
||||
S = 9
|
||||
instance_name = ''.join(random.choices(string.ascii_uppercase + string.digits, k=S))
|
||||
@@ -313,16 +342,20 @@ class tip_2x:
|
||||
# uuid_before_apply = r_data["latest"]
|
||||
|
||||
# attaching ap logs before config push
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("AP Log Before config push Timestamp: " + str(timestamp))
|
||||
ap_logs = self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body=ap_logs, name="AP Log Before config push: ")
|
||||
allure.attach(body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs), name="AP Log Before config push: ")
|
||||
resp = object()
|
||||
# Apply the Config
|
||||
try:
|
||||
resp = profile_object.push_config(serial_number=self.device_under_tests_info[i]["identifier"])
|
||||
logging.info("Response" + str(resp))
|
||||
except Exception as e:
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("Failure while pushing Timestamp: " + str(timestamp))
|
||||
ap_logs = self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body=ap_logs, name="Failure while pushing- AP Logs: ")
|
||||
allure.attach(body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs), name="Failure while pushing- AP Logs: ")
|
||||
allure.attach(body=str(e), name="Exception data after config push: ")
|
||||
logging.info("Error in apply config" + str(e))
|
||||
logging.info("Response for Config apply: " + str(resp.status_code))
|
||||
@@ -330,20 +363,29 @@ class tip_2x:
|
||||
logging.info("Failed to apply Configuration to AP. Response Code" +
|
||||
str(resp.status_code) +
|
||||
"Retrying in 5 Seconds... ")
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("AP logs during config fails Timestamp: " + str(timestamp))
|
||||
ap_logs = self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body=ap_logs, name="AP logs during config fails: ")
|
||||
allure.attach(body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs),
|
||||
name="AP logs during config fails: ")
|
||||
time.sleep(5)
|
||||
try:
|
||||
resp = profile_object.push_config(serial_number=self.device_under_tests_info[i]["identifier"])
|
||||
logging.info("Response" + str(resp))
|
||||
except Exception as e:
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("Failure while pushing Timestamp: " + str(timestamp))
|
||||
ap_logs = self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body=ap_logs, name="Failure while pushing- AP Logs: ")
|
||||
allure.attach(body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs),
|
||||
name="Failure while pushing- AP Logs: ")
|
||||
allure.attach(body=str(e), name="Exception data after config push: ")
|
||||
logging.info("Error in apply config" + str(e))
|
||||
if resp.status_code != 200:
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("AP logs during config fails Timestamp: " + str(timestamp))
|
||||
ap_logs = self.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body=ap_logs, name="AP logs during config fails: ")
|
||||
allure.attach(body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs),
|
||||
name="AP logs during config fails: ")
|
||||
logging.error("Failed to apply Config, Response code:" + str(resp.status_code))
|
||||
pytest.fail("Failed to apply Config, Response code :" + str(resp.status_code))
|
||||
# Find uuid from response
|
||||
@@ -478,6 +520,7 @@ class tip_2x:
|
||||
a["frequency"] = temp[j][2]
|
||||
ret_val[dut]["radio_data"][j] = a
|
||||
return ret_val
|
||||
|
||||
"""
|
||||
setup_special_configuration - Method to configure APs in mesh operating modes with multiple SSID's and multiple AP's
|
||||
This covers, mesh and other roaming scenarios which includes any special type of modes
|
||||
@@ -666,8 +709,11 @@ class tip_2x:
|
||||
self.dut_library_object.setup_serial_environment(idx=idx)
|
||||
self.dut_library_object.verify_certificates(idx=idx)
|
||||
ret_val = self.dut_library_object.ubus_call_ucentral_status(idx=idx, attach_allure=False, retry=10)
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("wifi status before apply Timestamp: " + str(timestamp))
|
||||
wifi_status = self.dut_library_object.get_wifi_status(idx=idx, attach_allure=False)
|
||||
allure.attach(name="wifi_status_before_apply: ", body=str(json.dumps(wifi_status, indent=2)))
|
||||
allure.attach(name="wifi_status_before_apply: ", body="TimeStamp: " + str(timestamp) + "\n" +
|
||||
str(json.dumps(wifi_status, indent=2)))
|
||||
if not ret_val["connected"] or ret_val["connected"] is None:
|
||||
self.dut_library_object.check_connectivity(idx=idx)
|
||||
self.dut_library_object.restart_ucentral_service(idx=idx, attach_allure=False)
|
||||
@@ -705,8 +751,11 @@ class tip_2x:
|
||||
logging.error("Failed the post apply check on: " + self.device_under_tests_info[idx]["identifier"])
|
||||
self.dut_library_object.check_connectivity(idx=idx, attach_allure=False)
|
||||
self.dut_library_object.check_connectivity(idx=idx)
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("wifi status after apply Timestamp: " + str(timestamp))
|
||||
r_data = self.dut_library_object.get_wifi_status(idx=idx, attach_allure=False)
|
||||
allure.attach(name="wifi_status_after_apply: ", body=str(json.dumps(r_data, indent=2)))
|
||||
allure.attach(name="wifi_status_after_apply: ", body="TimeStamp: " + str(timestamp) + "\n" +
|
||||
str(json.dumps(r_data, indent=2)))
|
||||
logging.info("Checking Wifi Status after Config Apply...")
|
||||
for radio in r_data:
|
||||
if not r_data[radio]["up"]:
|
||||
@@ -1088,8 +1137,9 @@ class tip_2x:
|
||||
# request.addfinalizer(teardown_session)
|
||||
# yield status
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
basic_shivam= {
|
||||
basic_shivam = {
|
||||
"target": "tip_2x",
|
||||
"controller": {
|
||||
"url": "https://sec-qa01.cicd.lab.wlan.tip.build:16001",
|
||||
@@ -1206,4 +1256,4 @@ if __name__ == '__main__':
|
||||
d = var.setup_basic_configuration(configuration=setup_params_enterprise, requested_combination=target)
|
||||
print(d)
|
||||
# var.setup_firmware()
|
||||
# var.teardown_objects()
|
||||
# var.teardown_objects()
|
||||
|
||||
@@ -5,7 +5,7 @@ import re
|
||||
import string
|
||||
import sys
|
||||
import random
|
||||
|
||||
import datetime
|
||||
import allure
|
||||
import pytest
|
||||
import json
|
||||
@@ -481,8 +481,13 @@ def get_dut_logs_per_test_case(request, run_lf, get_testbed_details, get_target_
|
||||
ap_logs = get_target_object.get_dut_library_object().get_logread(
|
||||
start_ref="start testcase: " + instance_name,
|
||||
stop_ref="stop testcase: " + instance_name)
|
||||
allure.attach(name='Logs - ' + get_testbed_details["device_under_tests"][i]["identifier"],
|
||||
allure.attach(name='dut_logs_per_test_case - ' + get_testbed_details["device_under_tests"][i]["identifier"],
|
||||
body=str(ap_logs))
|
||||
ap_logs = get_target_object.dut_library_object.get_dut_logs(idx=i, print_log=False, attach_allure=False)
|
||||
allure.attach(body=ap_logs, name="AP logread")
|
||||
uci_show = get_target_object.get_dut_library_object().run_generic_command(idx=i, attach_allure=False,
|
||||
cmd="uci show", print_log=False)
|
||||
allure.attach(body=uci_show, name="uci show")
|
||||
|
||||
request.addfinalizer(collect_logs)
|
||||
|
||||
@@ -526,9 +531,11 @@ def check_connectivity(request, get_testbed_details, get_target_object, run_lf):
|
||||
ret_val = get_target_object.get_dut_library_object().ubus_call_ucentral_status(idx=i, attach_allure=True,
|
||||
retry=10)
|
||||
if not ret_val["connected"] or ret_val["connected"] is None:
|
||||
timestamp = datetime.datetime.utcnow()
|
||||
logging.info("check_connectivity ap logs Timestamp: " + str(timestamp))
|
||||
ap_logs = get_target_object.get_dut_library_object().get_dut_logs()
|
||||
allure.attach(name='Logs - ' + get_testbed_details["device_under_tests"][i]["identifier"],
|
||||
body=str(ap_logs))
|
||||
body="TimeStamp: " + str(timestamp) + "\n" + str(ap_logs))
|
||||
|
||||
allure.attach(name='Device : ' + get_testbed_details["device_under_tests"][i]["identifier"] +
|
||||
" is connected after Test", body="")
|
||||
|
||||
Reference in New Issue
Block a user