fms input format changed

Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
shivamcandela
2021-09-11 12:44:01 +05:30
parent 1e5043149d
commit c68b9ebb33
7 changed files with 184 additions and 70 deletions

View File

@@ -11,6 +11,7 @@ from urllib.parse import urlparse
import pytest import pytest
import allure import allure
import requests import requests
from operator import itemgetter
from pathlib import Path from pathlib import Path
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
@@ -75,9 +76,11 @@ class ConfigureController:
if method == "GET": if method == "GET":
resp = requests.get(uri, headers=self.make_headers(), params=params, verify=False, timeout=100) resp = requests.get(uri, headers=self.make_headers(), params=params, verify=False, timeout=100)
elif method == "POST": elif method == "POST":
resp = requests.post(uri, data=payload, verify=False, timeout=100) print(uri, payload, params)
resp = requests.post(uri, params=params, data=payload, headers=self.make_headers(), verify=False,
timeout=100)
elif method == "PUT": elif method == "PUT":
resp = requests.put(uri, data=payload, verify=False, timeout=100) resp = requests.put(uri, params=params, data=payload, verify=False, timeout=100)
elif method == "DELETE": elif method == "DELETE":
resp = requests.delete(uri, headers=self.make_headers(), params=params, verify=False, timeout=100) resp = requests.delete(uri, headers=self.make_headers(), params=params, verify=False, timeout=100)
@@ -182,11 +185,16 @@ class FMSUtils:
self.sdk_client = sdk_client self.sdk_client = sdk_client
def upgrade_firmware(self, serial="", url=""): def upgrade_firmware(self, serial="", url=""):
response = self.sdk_client.request(service="gw", command="device/" + serial + "upgrade/", response = self.sdk_client.request(service="gw", command="device/" + serial + "/upgrade",
method="POST", params="revisionSet=true", method="POST", params="serialNumber=" + serial,
payload="{ \"serialNumber\" : " + serial + " , \"uri\" : " + url + " }") payload="{ \"serialNumber\" : " + "\"" + serial + "\"" +
print(response) " , \"uri\" : " + "\"" + url + "\"" +
pass ", \"when\" : 0" + " }")
print(response.json())
allure.attach(name="REST - firmware upgrade response: ",
body=str(response.status_code) + "\n" +
str(response.json()) + "\n"
)
def ap_model_lookup(self, model=""): def ap_model_lookup(self, model=""):
devices = self.get_device_set() devices = self.get_device_set()
@@ -207,7 +215,7 @@ class FMSUtils:
def get_latest_fw(self, model=""): def get_latest_fw(self, model=""):
device_type = self.ap_model_lookup(model=model) device_type = self.ap_model_lookup(model=model)
print("shivam", device_type)
response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", response = self.sdk_client.request(service="fms", command="firmwares/", method="GET",
params="latestOnly=true&deviceType=" + device_type, params="latestOnly=true&deviceType=" + device_type,
payload="") payload="")
@@ -224,20 +232,21 @@ class FMSUtils:
else: else:
return {} return {}
def get_firmwares(self, limit="", deviceType="", latestonly=""): def get_firmwares(self, limit="", model="cig_wf188", latestonly="", branch="", commit_id=""):
deviceType = self.ap_model_lookup(model=model)
params = "limit=" + limit + "&deviceType=" + deviceType + "&latestonly=" + latestonly params = "limit=" + limit + "&deviceType=" + deviceType + "&latestonly=" + latestonly
response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params=params, payload="") response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params=params, payload="")
print(response)
if response.status_code == 200: if response.status_code == 200:
data = response.json() data = response.json()
print(data) newlist = sorted(data['firmwares'], key=itemgetter('created'))
return newlist
# print(data)
# resp = requests.get(uri, headers=self.sdk_client.make_headers(), verify=False, timeout=100)
# self.sdk_client.check_response("GET", resp, self.sdk_client.make_headers(), "", uri)
# devices = resp.json()
# # resp.close()()
return "devices" return "devices"
@@ -521,17 +530,16 @@ if __name__ == '__main__':
'password': 'openwifi', 'password': 'openwifi',
} }
obj = Controller(controller_data=controller) obj = Controller(controller_data=controller)
fms = FMSUtils(sdk_client=obj) # fms = FMSUtils(sdk_client=obj)
# fms.get_device_set() # fms.get_device_set()
# model = fms.get_latest_fw(model="eap102") # model = fms.get_latest_fw(model="eap102")
# print(model) # print(model)
# profile = UProfileUtility(sdk_client=obj) profile = UProfileUtility(sdk_client=obj)
# profile.set_mode(mode="BRIDGE") profile.set_mode(mode="BRIDGE")
# profile.set_radio_config() profile.set_radio_config()
# ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something", ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something"}
# "vlan": 100} profile.add_ssid(ssid_data=ssid, radius=False)
# profile.add_ssid(ssid_data=ssid, radius=False) profile.push_config(serial_number="903cb39d6918")
# profile.push_config(serial_number="903cb39d6918")
# print(profile.get_ssid_info()) # print(profile.get_ssid_info())
# # print(obj.get_devices()) # # print(obj.get_devices())
obj.logout() obj.logout()

View File

@@ -126,12 +126,12 @@ CONFIGURATION = {
'mode': 'wifi5', 'mode': 'wifi5',
'serial': '001122090801', 'serial': '001122090801',
'jumphost': True, 'jumphost': True,
'ip': "127.0.0.1", 'ip': "10.28.3.100",
'username': "lanforge", 'username': "lanforge",
'password': "pumpkin77", 'password': "pumpkin77",
'port': 8833, 'port': 22,
'jumphost_tty': '/dev/ttyAP3', 'jumphost_tty': '/dev/ttyAP3',
'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/tplink_ec420/20210728-tplink_ec420-uCentral-trunk-12ad0d5-upgrade.bin" 'version': "latest"
} }
], ],
"traffic_generator": { "traffic_generator": {
@@ -198,7 +198,7 @@ CONFIGURATION = {
}, },
'access_point': [ 'access_point': [
{ {
'model': 'wf188n', 'model': 'cig_wf188',
'mode': 'wifi6', 'mode': 'wifi6',
'serial': '0000c1018812', 'serial': '0000c1018812',
'jumphost': True, 'jumphost': True,
@@ -207,7 +207,7 @@ CONFIGURATION = {
'password': "pumpkin77", 'password': "pumpkin77",
'port': 22, 'port': 22,
'jumphost_tty': '/dev/ttyAP1', 'jumphost_tty': '/dev/ttyAP1',
'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/cig_wf188/20210729-cig_wf188-v2.0.0-rc2-ec3662e-upgrade.bin" 'version': "trunk-d6c5e1f"
} }
], ],
"traffic_generator": { "traffic_generator": {
@@ -245,7 +245,7 @@ CONFIGURATION = {
'password': "pumpkin77", 'password': "pumpkin77",
'port': 22, # 22 'port': 22, # 22
'jumphost_tty': '/dev/ttyAP2', 'jumphost_tty': '/dev/ttyAP2',
'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap102/20210625-edgecore_eap102-uCentral-trunk-4225122-upgrade.bin" 'version': "latest"
} }
], ],
"traffic_generator": { "traffic_generator": {
@@ -283,7 +283,8 @@ CONFIGURATION = {
'password': "pumpkin77", 'password': "pumpkin77",
'port': 22, # 22 'port': 22, # 22
'jumphost_tty': '/dev/ttyAP3', 'jumphost_tty': '/dev/ttyAP3',
'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/edgecore_eap101/20210729-edgecore_eap101-v2.0.0-rc2-02244b8-upgrade.bin" 'version': "latest-next",
'version_branch': "trunk-d6c5e1f"
} }
], ],
"traffic_generator": { "traffic_generator": {
@@ -345,11 +346,9 @@ CONFIGURATION = {
"mesh": { "mesh": {
"controller": { "controller": {
'url': "http://wlan-portal-svc-digicert.cicd.lab.wlan.tip.build", # API base url for the controller 'url': 'https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001', # API base url for the controller
'username': 'support@example.com', 'username': "tip@ucentral.com",
'password': 'support', 'password': 'openwifi',
'version': '1.1.0-SNAPSHOT',
'commit_date': "2021-06-01"
}, },
'access_point': [ 'access_point': [
{ {
@@ -362,16 +361,82 @@ CONFIGURATION = {
'password': "pumpkin77", 'password': "pumpkin77",
'port': 22, # 22 'port': 22, # 22
'jumphost_tty': '/dev/ttyAP2', 'jumphost_tty': '/dev/ttyAP2',
'version': "latest"
},
{
'model': 'eap101',
'mode': 'wifi6',
'serial': '34efb6af4903',
'jumphost': True,
'ip': "10.28.3.101", # 10.28.3.103
'username': "lanforge",
'password': "pumpkin77",
'port': 22, # 22
'jumphost_tty': '/dev/ttyAP3',
'version': "latest"
},
{
'model': 'eap101',
'mode': 'wifi6',
'serial': '34efb6af4a7a',
'jumphost': True,
'ip': "10.28.3.101", # 10.28.3.103
'username': "lanforge",
'password': "pumpkin77",
'port': 22, # 22
'jumphost_tty': '/dev/ttyAP4',
'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/eap101/trunk/eap101-1.1.0.tar.gz" 'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/eap101/trunk/eap101-1.1.0.tar.gz"
} }
], ],
"traffic_generator": { "traffic_generator": {
"name": "lanforge", "name": "lanforge",
"details": { "details-mobile-sta": {
"ip": "10.28.3.14", # 10.28.3.34 "ip": "10.28.3.14", # 10.28.3.34
"port": 8080, # 8080 "port": 8080, # 8080
"ssh_port": 22, "ssh_port": 22,
"2.4G-Radio": ["wiphy0", "wiphy2"], "2.4G-Radio": ["1.1.wiphy0", "1.1.wiphy2"],
"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": "wlan0",
"AX-Station-Name": "ax"
},
"details-root": {
"ip": "10.28.3.14", # 10.28.3.34
"port": 8080, # 8080
"ssh_port": 22,
"2.4G-Radio": ["1.1.wiphy0", "1.1.wiphy2"],
"5G-Radio": ["wiphy1", "wiphy3"],
"AX-Radio": ["wiphy4", "wiphy5", "wiphy6", "wiphy7"],
"upstream": "1.1.eth2",
"upstream_subnet": "10.28.2.1/24",
"uplink": "1.1.eth3",
"2.4G-Station-Name": "wlan0",
"5G-Station-Name": "wlan0",
"AX-Station-Name": "ax"
},
"details-node-1": {
"ip": "10.28.3.14", # 10.28.3.34
"port": 8080, # 8080
"ssh_port": 22,
"2.4G-Radio": ["1.1.wiphy0", "1.1.wiphy2"],
"5G-Radio": ["wiphy1", "wiphy3"],
"AX-Radio": ["wiphy4", "wiphy5", "wiphy6", "wiphy7"],
"upstream": "1.1.eth2",
"upstream_subnet": "10.28.2.1/24",
"uplink": "1.1.eth3",
"2.4G-Station-Name": "wlan0",
"5G-Station-Name": "wlan0",
"AX-Station-Name": "ax"
},
"details-node-2": {
"ip": "10.28.3.14", # 10.28.3.34
"port": 8080, # 8080
"ssh_port": 22,
"2.4G-Radio": ["1.1.wiphy0", "1.1.wiphy2"],
"5G-Radio": ["wiphy1", "wiphy3"], "5G-Radio": ["wiphy1", "wiphy3"],
"AX-Radio": ["wiphy4", "wiphy5", "wiphy6", "wiphy7"], "AX-Radio": ["wiphy4", "wiphy5", "wiphy6", "wiphy7"],
"upstream": "1.1.eth2", "upstream": "1.1.eth2",
@@ -381,6 +446,7 @@ CONFIGURATION = {
"5G-Station-Name": "wlan0", "5G-Station-Name": "wlan0",
"AX-Station-Name": "ax" "AX-Station-Name": "ax"
} }
} }
}, # checked }, # checked
"interop-01": { "interop-01": {

View File

@@ -642,7 +642,7 @@ def add_env_properties(get_configuration, get_apnos, fixtures_ver, add_allure_en
add_allure_environment_property('Access-Point-Firmware-Version', add_allure_environment_property('Access-Point-Firmware-Version',
fixtures_ver.get_ap_version(get_apnos, get_configuration)[0].split("\n")[1]) fixtures_ver.get_ap_version(get_apnos, get_configuration)[0].split("\n")[1])
add_allure_environment_property('Cloud-Controller-SDK-URL', get_configuration["controller"]["url"]) add_allure_environment_property('Cloud-Controller-SDK-URL', get_configuration["controller"]["url"])
add_allure_environment_property('AP-Serial-Number', get_configuration["access_point"][0]["serial"]) add_allure_environment_property('AP-Serial-Number', get_configuration["access_point"][0]["serial"] + "\n")
@pytest.fixture(scope="session") @pytest.fixture(scope="session")

View File

@@ -46,6 +46,7 @@ class TestBridgeModeConnectivitySuiteA(object):
pytest -m "client_connectivity and bridge and general and suiteA" pytest -m "client_connectivity and bridge and general and suiteA"
""" """
@pytest.mark.reg
@pytest.mark.open @pytest.mark.open
@pytest.mark.twog @pytest.mark.twog
@allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2809", name="JIRA LINK") @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2809", name="JIRA LINK")

View File

@@ -59,26 +59,88 @@ class Fixtures_2x:
firmware_url = "" firmware_url = ""
ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x")
ap_version = ap_ssh.get_ap_version_ucentral() ap_version = ap_ssh.get_ap_version_ucentral()
if ap['version'] == "latest": response = self.fw_client.get_latest_fw(model=ap["model"])
response = self.fw_client.get_latest_fw(model=ap["model"]) # if the target version specified is latest
if ap['version'].split('-')[1] == "latest":
# get the latest branch
if 'revision' in list(response.keys()): if 'revision' in list(response.keys()):
version_latest = response['revision'] version_latest = response['revision']
print(ap_version, version_latest) ap_v = ""
print(str(ap_version).replace(" ", ""), str(version_latest).replace(" ", ""), latest_v = ""
str(version_latest).replace(" ", "") == 'OpenWrt21.02-SNAPSHOTr16011+75-6fd65c6573/TIP-v2.1.0-rc2-d0a0715') try:
if str(ap_version).replace(" ", "") == str(version_latest).replace(" ", ""): ap_v = str(ap_version).split("/")[1].replace(" ", "").splitlines()[0]
latest_v = str(version_latest).split("/")[1].replace(" ", "")
print(ap_v,
latest_v)
except Exception as e:
pass
print(ap_v == latest_v)
if ap_v == latest_v:
continue continue
else: else:
if 'uri' in list(response.keys()): if 'uri' in list(response.keys()):
firmware_url = response['uri'] firmware_url = response['uri']
self.fw_client.upgrade_firmware(serial=ap['serial'], url=str(firmware_url))
time.sleep(300)
ap_version = ap_ssh.get_ap_version_ucentral()
ap_v = str(ap_version).split("/")[1].replace(" ", "").splitlines()[0]
latest_v = str(version_latest).split("/")[1].replace(" ", "")
if ap_v == latest_v:
print("firmware upgraded to latest: ", latest_v)
continue
# firmware upgrade request
else: else:
# firmware uri is not available
continue continue
pass pass
else:
firmware_list = self.fw_client.get_firmwares(model=ap['model'], branch="", commit_id='')
fw_list = []
for firmware in firmware_list:
if firmware['revision'].split("/")[1].replace(" ", "").split('-')[-1] == ap['version'].split('-')[1]:
fw_list.append(firmware)
if len(fw_list) == 1:
url = fw_list[0]['uri']
current_version = str(ap_version).split("/")[1].replace(" ", "").splitlines()[0]
target_revision = fw_list[0]['revision'].split("/")[1].replace(" ", "")
if current_version == target_revision:
continue
else:
self.fw_client.upgrade_firmware(serial=ap['serial'], url=str(url))
time.sleep(300)
ap_version = ap_ssh.get_ap_version_ucentral()
print(ap_version)
current_version = str(ap_version).split("/")[1].replace(" ", "").splitlines()[0]
print(current_version, target_revision)
if current_version == target_revision:
print("firmware upgraded successfully: ", target_revision)
else: else:
continue pass
version_fms = firmware['uri'].split('-')[-3] + "-" + firmware['uri'].split('-')[-2]
if version_fms == ap['version']:
print(firmware)
# for version in firmware_list:
# if ap['version'] in version['revision']:
# print(version)
# firmware_url = version['uri']
# self.fw_client.upgrade_firmware(serial=ap['serial'], url=str(firmware_url))
# time.sleep(300)
# ap_version = ap_ssh.get_ap_version_ucentral()
# ap_v = str(ap_version).split("/")[1].replace(" ", "").splitlines()[0]
# if ap_v in version['revision']:
# print("firmware upgraded successfully: ", version['revision'])
# for revision_fms in revisions['revisions']:
# print(ap['version'] in revision_fms)
# # print(self.fw_client.get_revisions())
# upgrade to a specified version
# if ap['version'] in response['revision']:
# print("shivam", response['revision'], ap['version'])
# print("shivam", response['revision'], ap['version'])
# "TIP-v2.1.0-rc3-bcd07e4" in response['revision'])
continue
# Compare with the specified one # Compare with the specified one
# if 'latest' # if 'latest'
@@ -285,7 +347,6 @@ class Fixtures_2x:
if x < 19: if x < 19:
print("Config properly applied into AP", config) print("Config properly applied into AP", config)
time_2 = time.time() time_2 = time.time()
time_interval = time_2 - time_1 time_interval = time_2 - time_1
allure.attach(name="Time Took to apply Config: " + str(time_interval), body="") allure.attach(name="Time Took to apply Config: " + str(time_interval), body="")
@@ -293,7 +354,6 @@ class Fixtures_2x:
ap_config_latest = ap_ssh.get_uc_latest_config() ap_config_latest = ap_ssh.get_uc_latest_config()
ap_config_latest["uuid"] = 0 ap_config_latest["uuid"] = 0
ap_config_active = ap_ssh.get_uc_active_config() ap_config_active = ap_ssh.get_uc_active_config()
ap_config_active["uuid"] = 0 ap_config_active["uuid"] = 0
x = 1 x = 1
@@ -330,19 +390,15 @@ class Fixtures_2x:
ap_logs = ap_ssh.logread() ap_logs = ap_ssh.logread()
allure.attach(body=ap_logs, name="AP Logs: ") allure.attach(body=ap_logs, name="AP Logs: ")
try: try:
ssid_info_sdk = instantiate_profile_obj.get_ssid_info() ssid_info_sdk = instantiate_profile_obj.get_ssid_info()
ap_wifi_data = ap_ssh.get_iwinfo() ap_wifi_data = ap_ssh.get_iwinfo()
for p in ap_wifi_data: for p in ap_wifi_data:
for q in ssid_info_sdk: for q in ssid_info_sdk:
if ap_wifi_data[p][0] == q[0] and ap_wifi_data[p][2] == q[3]: if ap_wifi_data[p][0] == q[0] and ap_wifi_data[p][2] == q[3]:
q.append(ap_wifi_data[p][1]) q.append(ap_wifi_data[p][1])
ssid_data = [] ssid_data = []
idx_mapping = {} idx_mapping = {}
for interface in range(len(ssid_info_sdk)): for interface in range(len(ssid_info_sdk)):

View File

@@ -73,4 +73,3 @@ filterwarnings=ignore::UserWarning
markers=sanity: Run the sanity for Client Connectivity test markers=sanity: Run the sanity for Client Connectivity test

View File

@@ -9,26 +9,11 @@ pytestmark = [pytest.mark.test_resources, pytest.mark.sanity,
pytest.mark.sanity_55] pytest.mark.sanity_55]
@pytest.mark.fw @pytest.mark.fw
def test_firmware(firmware_upgrade): def test_firmware(firmware_upgrade):
assert True assert True
@allure.testcase(name="Test Resources", url="") @allure.testcase(name="Test Resources", url="")
class TestResources(object): class TestResources(object):
"""Test Case Class: Test cases to cover resource Connectivity""" """Test Case Class: Test cases to cover resource Connectivity"""
@@ -71,4 +56,3 @@ class TestResources(object):
pytest.exit("LANforgeGUI-5.4.3 is not available") pytest.exit("LANforgeGUI-5.4.3 is not available")
assert traffic_generator_connectivity assert traffic_generator_connectivity