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:
Jitendrakumar Kushavah
2024-02-12 10:13:23 +05:30
committed by GitHub
parent 1410b040f1
commit b5f45ab85d
3 changed files with 86 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ import logging
import random import random
import string import string
import time import time
import datetime
import allure import allure
import paramiko import paramiko
import pytest import pytest
@@ -191,6 +191,8 @@ class APLIBS:
logging.error("ubus call ucentral status has unexpected data") logging.error("ubus call ucentral status has unexpected data")
return False return False
active_uuid = r_val["active"] 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, output = self.run_generic_command(cmd="cat /etc/ucentral/ucentral.cfg." + str(active_uuid), idx=idx,
print_log=print_log, print_log=print_log,
attach_allure=attach_allure, attach_allure=attach_allure,
@@ -199,7 +201,7 @@ class APLIBS:
data = dict(json.loads(output.replace("\n\t", "").replace("\n", ""))) data = dict(json.loads(output.replace("\n\t", "").replace("\n", "")))
logging.info("Active config is : " + str(data)) logging.info("Active config is : " + str(data))
allure.attach(name="cat /etc/ucentral/ucentral.cfg." + str(active_uuid), 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) attachment_type=allure.attachment_type.JSON)
except Exception as e: except Exception as e:
data = output data = output
@@ -265,7 +267,7 @@ class APLIBS:
"Please add valid certificates on AP") "Please add valid certificates on AP")
def run_generic_command(self, cmd="", idx=0, print_log=True, attach_allure=False, 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 input_command = cmd
logging.info("Executing Command on AP: " + cmd) logging.info("Executing Command on AP: " + cmd)
try: try:
@@ -289,8 +291,11 @@ class APLIBS:
f"cmd --value \'{cmd}\' " f"cmd --value \'{cmd}\' "
if print_log: if print_log:
logging.info(cmd) logging.info(cmd)
timestamp = datetime.datetime.utcnow()
logging.info(cmd + " Timestamp: " + str(timestamp))
stdin, stdout, stderr = client.exec_command(cmd) stdin, stdout, stderr = client.exec_command(cmd)
output = stdout.read() output = stdout.read()
# data = dict(json.loads(output.replace("\n\t", "").replace("\n", "")))
final_output = str(output) final_output = str(output)
if not output.__contains__(b"BOOTLOADER-CONSOLE-IPQ6018#"): if not output.__contains__(b"BOOTLOADER-CONSOLE-IPQ6018#"):
status = output.decode('utf-8').splitlines() status = output.decode('utf-8').splitlines()
@@ -300,7 +305,13 @@ class APLIBS:
logging.info(cmd) logging.info(cmd)
logging.info("Output for command: " + input_command + "\n" + final_output) logging.info("Output for command: " + input_command + "\n" + final_output)
if attach_allure: 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() client.close()
except Exception as e: except Exception as e:
logging.error(e) logging.error(e)

View File

@@ -8,7 +8,7 @@ import json
import random import random
import string import string
import time import time
import datetime
import allure import allure
import pytest import pytest
import requests import requests
@@ -300,6 +300,35 @@ class tip_2x:
ret_val = dict() ret_val = dict()
for i in range(0, len(self.device_under_tests_info)): for i in range(0, len(self.device_under_tests_info)):
self.pre_apply_check(idx=i) # Do check AP before pushing the configuration 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 S = 9
instance_name = ''.join(random.choices(string.ascii_uppercase + string.digits, k=S)) 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"] # uuid_before_apply = r_data["latest"]
# attaching ap logs before config push # 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) 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() resp = object()
# Apply the Config # Apply the Config
try: try:
resp = profile_object.push_config(serial_number=self.device_under_tests_info[i]["identifier"]) resp = profile_object.push_config(serial_number=self.device_under_tests_info[i]["identifier"])
logging.info("Response" + str(resp)) logging.info("Response" + str(resp))
except Exception as e: 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) 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: ") allure.attach(body=str(e), name="Exception data after config push: ")
logging.info("Error in apply config" + str(e)) logging.info("Error in apply config" + str(e))
logging.info("Response for Config apply: " + str(resp.status_code)) 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" + logging.info("Failed to apply Configuration to AP. Response Code" +
str(resp.status_code) + str(resp.status_code) +
"Retrying in 5 Seconds... ") "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) 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) time.sleep(5)
try: try:
resp = profile_object.push_config(serial_number=self.device_under_tests_info[i]["identifier"]) resp = profile_object.push_config(serial_number=self.device_under_tests_info[i]["identifier"])
logging.info("Response" + str(resp)) logging.info("Response" + str(resp))
except Exception as e: 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) 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: ") allure.attach(body=str(e), name="Exception data after config push: ")
logging.info("Error in apply config" + str(e)) logging.info("Error in apply config" + str(e))
if resp.status_code != 200: 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) 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)) logging.error("Failed to apply Config, Response code:" + str(resp.status_code))
pytest.fail("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 # Find uuid from response
@@ -478,6 +520,7 @@ class tip_2x:
a["frequency"] = temp[j][2] a["frequency"] = temp[j][2]
ret_val[dut]["radio_data"][j] = a ret_val[dut]["radio_data"][j] = a
return ret_val return ret_val
""" """
setup_special_configuration - Method to configure APs in mesh operating modes with multiple SSID's and multiple AP's 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 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.setup_serial_environment(idx=idx)
self.dut_library_object.verify_certificates(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) 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) 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: if not ret_val["connected"] or ret_val["connected"] is None:
self.dut_library_object.check_connectivity(idx=idx) self.dut_library_object.check_connectivity(idx=idx)
self.dut_library_object.restart_ucentral_service(idx=idx, attach_allure=False) 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"]) 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, attach_allure=False)
self.dut_library_object.check_connectivity(idx=idx) 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) 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...") logging.info("Checking Wifi Status after Config Apply...")
for radio in r_data: for radio in r_data:
if not r_data[radio]["up"]: if not r_data[radio]["up"]:
@@ -1088,8 +1137,9 @@ class tip_2x:
# request.addfinalizer(teardown_session) # request.addfinalizer(teardown_session)
# yield status # yield status
if __name__ == '__main__': if __name__ == '__main__':
basic_shivam= { basic_shivam = {
"target": "tip_2x", "target": "tip_2x",
"controller": { "controller": {
"url": "https://sec-qa01.cicd.lab.wlan.tip.build:16001", "url": "https://sec-qa01.cicd.lab.wlan.tip.build:16001",

View File

@@ -5,7 +5,7 @@ import re
import string import string
import sys import sys
import random import random
import datetime
import allure import allure
import pytest import pytest
import json 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( ap_logs = get_target_object.get_dut_library_object().get_logread(
start_ref="start testcase: " + instance_name, start_ref="start testcase: " + instance_name,
stop_ref="stop 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)) 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) 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, ret_val = get_target_object.get_dut_library_object().ubus_call_ucentral_status(idx=i, attach_allure=True,
retry=10) retry=10)
if not ret_val["connected"] or ret_val["connected"] is None: 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() ap_logs = get_target_object.get_dut_library_object().get_dut_logs()
allure.attach(name='Logs - ' + get_testbed_details["device_under_tests"][i]["identifier"], 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"] + allure.attach(name='Device : ' + get_testbed_details["device_under_tests"][i]["identifier"] +
" is connected after Test", body="") " is connected after Test", body="")