Wifi 12235 (#784)

* Added ASB two test cases and functionality

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* Resolved chunk error in the ASB API

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* adding tar file in the tests folder

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* sleeping after creating file

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* sleeping after creating file2

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* more info

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* more info2

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* adding full path

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* changed the path

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* added another file

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* modified and added another file

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* Added more logs

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* Fixed issue of attaching tar file to allure ASB

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

* Asb script two testcases added

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>

---------

Signed-off-by: GopiRaga7 <gopi.raga@candelatech.com>
This commit is contained in:
Gopi Raga
2023-02-17 13:13:58 +05:30
committed by GitHub
parent 16c5a10ff2
commit aefa270425
3 changed files with 206 additions and 35 deletions

View File

@@ -135,8 +135,8 @@ class APLIBS:
logging.error("error in converting the ubus call ucentral status output to json" + output)
data = {}
if (data.keys().__contains__("connected") or data.keys().__contains__("disconnected")) and \
data.keys().__contains__("latest") and \
data.keys().__contains__("active"):
data.keys().__contains__("latest") and \
data.keys().__contains__("active"):
break
else:
logging.error("Error in ubus call ucentral status: " + str(output))
@@ -263,7 +263,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):
expected_attachment_type=allure.attachment_type.TEXT, restrictions=False):
input_command = cmd
logging.info("Executing Command on AP: " + cmd)
try:
@@ -279,8 +279,12 @@ class APLIBS:
if self.device_under_tests_data[idx]["method"] == "serial":
owrt_args = "--prompt root@" + self.device_under_tests_data[idx][
"identifier"] + " -s serial --log stdout --user root --passwd openwifi"
cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {owrt_args} -t {self.device_under_tests_data[idx]['serial_tty']} --action " \
f"cmd --value \"{cmd}\" "
if not restrictions:
cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {owrt_args} -t {self.device_under_tests_data[idx]['serial_tty']} --action " \
f"cmd --value \"{cmd}\" "
if restrictions:
cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {owrt_args} -t {self.device_under_tests_data[idx]['serial_tty']} --action " \
f"cmd --value \'{cmd}\' "
if print_log:
logging.info(cmd)
stdin, stdout, stderr = client.exec_command(cmd)
@@ -474,9 +478,51 @@ class APLIBS:
logging.info("Simulate radar logs: " + str(logs))
return logs
def factory_reset(self, idx=0, print_log=True, attach_allure=False):
logging.info("started factory reset")
output = self.run_generic_command(cmd="jffs2reset -y -r",
idx=idx,
print_log=print_log,
attach_allure=attach_allure)
logging.info("Done Factory reset")
# Please wait 1min after doing factory reset
return output
def remove_restrictions(self):
self.run_generic_command(cmd="rm /certificates/restrictions.json",
idx=0, print_log=True,
attach_allure=False)
self.run_generic_command(cmd="rm /etc/ucentral/restrictions.json",
idx=0, print_log=True,
attach_allure=False)
self.factory_reset(print_log=False)
time.sleep(120)
output = self.run_generic_command(cmd='[ -f /etc/ucentral/restrictions.json ] && echo "True" || echo "False"',
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
return output
def add_restrictions(self, restrictions_file, developer_mode):
output = self.run_generic_command(cmd=developer_mode,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT)
output = self.run_generic_command(cmd=restrictions_file,
idx=0,
print_log=True,
attach_allure=False,
expected_attachment_type=allure.attachment_type.TEXT,
restrictions=True)
self.factory_reset(print_log=False)
time.sleep(120)
return output
if __name__ == '__main__':
basic= {
basic = {
"target": "tip_2x",
"controller": {
"url": "https://sec-qa01.cicd.lab.wlan.tip.build:16001",
@@ -557,4 +603,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())

View File

@@ -6,6 +6,7 @@
import datetime
import json
import logging
import os
import sys
import time
from operator import itemgetter
@@ -33,13 +34,13 @@ class ConfigureController:
# self.session = requests.Session()
self.login_resp = self.login()
self.gw_host, self.fms_host, \
self.prov_host, self.owrrm_host, \
self.owanalytics_host, self.owsub_host = self.get_gw_endpoint()
self.prov_host, self.owrrm_host, \
self.owanalytics_host, self.owsub_host = self.get_gw_endpoint()
if self.gw_host == "" or self.fms_host == "" or self.prov_host == "":
time.sleep(60)
self.gw_host, self.fms_host, \
self.prov_host, self.owrrm_host, \
self.owanalytics_host, self.owsub_host = self.get_gw_endpoint()
self.prov_host, self.owrrm_host, \
self.owanalytics_host, self.owsub_host = self.get_gw_endpoint()
if self.gw_host == "" or self.fms_host == "" or self.prov_host == "":
self.logout()
logging.info(self.gw_host, self.fms_host + self.prov_host)
@@ -190,6 +191,7 @@ class ConfigureController:
"Connection": "keep-alive",
"Content-Type": "application/json",
"Keep-Alive": "timeout=10, max=1000"
"conte"
}
return headers
@@ -743,6 +745,49 @@ class Controller(ConfigureController):
self.check_response("PUT", resp, self.make_headers(), payload, uri)
return resp
def check_restrictions(self, serial_number):
uri = self.build_uri("device/" + serial_number + "/capabilities")
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=120)
resp = resp.json()
if 'restrictions' in resp['capabilities'].keys():
return True
else:
return False
def asb_script(self, serial_number, payload):
uri = self.build_uri("device/" + serial_number + "/script")
payload = json.dumps(payload)
resp = requests.post(uri, data=payload, headers=self.make_headers(), verify=False, timeout=120)
resp = resp.json()
resp = resp['UUID']
return resp
def get_file(self, serial_number, uuid):
uri = self.build_uri("file/" + uuid + "?serialNumber=" + serial_number)
logging.info("Sending Command: " + "\n" +
"TimeStamp: " + str(datetime.datetime.utcnow()) + "\n" +
"URI: " + str(uri) + "\n" +
"Headers: " + str(self.make_headers()))
allure.attach(name="Sending Command:", body="Sending Command: " + "\n" +
"TimeStamp: " + str(datetime.datetime.utcnow()) + "\n" +
"URI: " + str(uri) + "\n" +
"Headers: " + str(self.make_headers()))
time.sleep(10)
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=120)
self.check_response("GET", resp, self.make_headers(), "", uri)
if resp.headers.get("Transfer-Encoding") == "chunked":
file = resp.content
with open("gopi.tar.gz", "wb") as f:
for chunk in resp.iter_content(chunk_size=1024):
f.write(chunk)
else:
file = resp.content
logging.info(file)
with open("gopi.tar.gz", "wb") as f:
f.write(file)
allure.attach.file(name="file", source="gopi.tar.gz", extension=".tar")
return resp
class FMSUtils:
@@ -2035,18 +2080,18 @@ class UProfileUtility:
def set_radio_config(self, radio_config={}, open_roaming=False):
if open_roaming:
base_radio_config_2g = {
"band": "2G",
"country": "CA",
"channel-mode": "HT",
"channel-width": 20,
"channel": "auto"
"band": "2G",
"country": "CA",
"channel-mode": "HT",
"channel-width": 20,
"channel": "auto"
}
base_radio_config_5g = {
"band": "5G",
"country": "CA",
"channel-mode": "VHT",
"channel-width": 80,
"channel": "auto"
"band": "5G",
"country": "CA",
"channel-mode": "VHT",
"channel-width": 80,
"channel": "auto"
}
for band in radio_config:
@@ -2201,7 +2246,8 @@ class UProfileUtility:
ssid_info["pass-point"] = pass_point_data
else:
ssid_info = {'name': ssid_data["ssid_name"], "bss-mode": "ap", "wifi-bands": [], "services": ["wifi-frames"]}
ssid_info = {'name': ssid_data["ssid_name"], "bss-mode": "ap", "wifi-bands": [],
"services": ["wifi-frames"]}
for options in ssid_data:
if options == "multi-psk":
ssid_info[options] = ssid_data[options]