From c68b9ebb33d3cfb7f26df400699599dc878b81ca Mon Sep 17 00:00:00 2001 From: shivamcandela Date: Sat, 11 Sep 2021 12:44:01 +0530 Subject: [PATCH] fms input format changed Signed-off-by: shivamcandela --- libs/controller/controller_2x/controller.py | 54 ++++++----- tests/configuration.py | 94 ++++++++++++++++--- tests/conftest.py | 2 +- .../test_general_security_modes.py | 1 + tests/fixtures_2x.py | 86 ++++++++++++++--- tests/pytest.ini | 1 - tests/test_connectivity.py | 16 ---- 7 files changed, 184 insertions(+), 70 deletions(-) diff --git a/libs/controller/controller_2x/controller.py b/libs/controller/controller_2x/controller.py index de6e97b93..209049513 100644 --- a/libs/controller/controller_2x/controller.py +++ b/libs/controller/controller_2x/controller.py @@ -11,6 +11,7 @@ from urllib.parse import urlparse import pytest import allure import requests +from operator import itemgetter from pathlib import Path from requests.adapters import HTTPAdapter @@ -75,9 +76,11 @@ class ConfigureController: if method == "GET": resp = requests.get(uri, headers=self.make_headers(), params=params, verify=False, timeout=100) 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": - 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": 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 def upgrade_firmware(self, serial="", url=""): - response = self.sdk_client.request(service="gw", command="device/" + serial + "upgrade/", - method="POST", params="revisionSet=true", - payload="{ \"serialNumber\" : " + serial + " , \"uri\" : " + url + " }") - print(response) - pass + response = self.sdk_client.request(service="gw", command="device/" + serial + "/upgrade", + method="POST", params="serialNumber=" + serial, + payload="{ \"serialNumber\" : " + "\"" + serial + "\"" + + " , \"uri\" : " + "\"" + url + "\"" + + ", \"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=""): devices = self.get_device_set() @@ -207,7 +215,7 @@ class FMSUtils: def get_latest_fw(self, model=""): device_type = self.ap_model_lookup(model=model) - + print("shivam", device_type) response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params="latestOnly=true&deviceType=" + device_type, payload="") @@ -224,20 +232,21 @@ class FMSUtils: else: 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 response = self.sdk_client.request(service="fms", command="firmwares/", method="GET", params=params, payload="") - print(response) + if response.status_code == 200: 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" @@ -521,17 +530,16 @@ if __name__ == '__main__': 'password': 'openwifi', } obj = Controller(controller_data=controller) - fms = FMSUtils(sdk_client=obj) + # fms = FMSUtils(sdk_client=obj) # fms.get_device_set() # model = fms.get_latest_fw(model="eap102") # print(model) - # profile = UProfileUtility(sdk_client=obj) - # profile.set_mode(mode="BRIDGE") - # profile.set_radio_config() - # 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.push_config(serial_number="903cb39d6918") + profile = UProfileUtility(sdk_client=obj) + profile.set_mode(mode="BRIDGE") + profile.set_radio_config() + ssid = {"ssid_name": "ssid_wpa2_2g", "appliedRadios": ["2G", "5G"], "security": "psk", "security_key": "something"} + profile.add_ssid(ssid_data=ssid, radius=False) + profile.push_config(serial_number="903cb39d6918") # print(profile.get_ssid_info()) # # print(obj.get_devices()) obj.logout() diff --git a/tests/configuration.py b/tests/configuration.py index 45ad67674..8d12ada2e 100644 --- a/tests/configuration.py +++ b/tests/configuration.py @@ -126,12 +126,12 @@ CONFIGURATION = { 'mode': 'wifi5', 'serial': '001122090801', 'jumphost': True, - 'ip': "127.0.0.1", + 'ip': "10.28.3.100", 'username': "lanforge", 'password': "pumpkin77", - 'port': 8833, + 'port': 22, '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": { @@ -198,7 +198,7 @@ CONFIGURATION = { }, 'access_point': [ { - 'model': 'wf188n', + 'model': 'cig_wf188', 'mode': 'wifi6', 'serial': '0000c1018812', 'jumphost': True, @@ -207,7 +207,7 @@ CONFIGURATION = { 'password': "pumpkin77", 'port': 22, '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": { @@ -245,7 +245,7 @@ CONFIGURATION = { 'password': "pumpkin77", 'port': 22, # 22 '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": { @@ -283,7 +283,8 @@ CONFIGURATION = { 'password': "pumpkin77", 'port': 22, # 22 '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": { @@ -345,11 +346,9 @@ CONFIGURATION = { "mesh": { "controller": { - 'url': "http://wlan-portal-svc-digicert.cicd.lab.wlan.tip.build", # API base url for the controller - 'username': 'support@example.com', - 'password': 'support', - 'version': '1.1.0-SNAPSHOT', - 'commit_date': "2021-06-01" + 'url': 'https://sec-ucentral-qa01.cicd.lab.wlan.tip.build:16001', # API base url for the controller + 'username': "tip@ucentral.com", + 'password': 'openwifi', }, 'access_point': [ { @@ -362,16 +361,82 @@ CONFIGURATION = { 'password': "pumpkin77", 'port': 22, # 22 '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" } ], "traffic_generator": { "name": "lanforge", - "details": { + "details-mobile-sta": { "ip": "10.28.3.14", # 10.28.3.34 "port": 8080, # 8080 "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"], "AX-Radio": ["wiphy4", "wiphy5", "wiphy6", "wiphy7"], "upstream": "1.1.eth2", @@ -381,6 +446,7 @@ CONFIGURATION = { "5G-Station-Name": "wlan0", "AX-Station-Name": "ax" } + } }, # checked "interop-01": { diff --git a/tests/conftest.py b/tests/conftest.py index 2f5529205..8eea458b6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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', 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('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") diff --git a/tests/e2e/basic/validation_of_operating_modes/bridge_mode/client_connectivity/test_general_security_modes.py b/tests/e2e/basic/validation_of_operating_modes/bridge_mode/client_connectivity/test_general_security_modes.py index 34dac56b6..5b6b51b8a 100644 --- a/tests/e2e/basic/validation_of_operating_modes/bridge_mode/client_connectivity/test_general_security_modes.py +++ b/tests/e2e/basic/validation_of_operating_modes/bridge_mode/client_connectivity/test_general_security_modes.py @@ -46,6 +46,7 @@ class TestBridgeModeConnectivitySuiteA(object): pytest -m "client_connectivity and bridge and general and suiteA" """ + @pytest.mark.reg @pytest.mark.open @pytest.mark.twog @allure.testcase(url="https://telecominfraproject.atlassian.net/browse/WIFI-2809", name="JIRA LINK") diff --git a/tests/fixtures_2x.py b/tests/fixtures_2x.py index ed410887e..2b1f23ec6 100644 --- a/tests/fixtures_2x.py +++ b/tests/fixtures_2x.py @@ -59,26 +59,88 @@ class Fixtures_2x: firmware_url = "" ap_ssh = get_apnos(ap, pwd="../libs/apnos/", sdk="2.x") 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()): version_latest = response['revision'] - print(ap_version, version_latest) - print(str(ap_version).replace(" ", ""), str(version_latest).replace(" ", ""), - str(version_latest).replace(" ", "") == 'OpenWrt21.02-SNAPSHOTr16011+75-6fd65c6573/TIP-v2.1.0-rc2-d0a0715') - if str(ap_version).replace(" ", "") == str(version_latest).replace(" ", ""): + ap_v = "" + latest_v = "" + try: + 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 else: if 'uri' in list(response.keys()): 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: + # firmware uri is not available continue 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: - 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 # if 'latest' @@ -285,7 +347,6 @@ class Fixtures_2x: if x < 19: print("Config properly applied into AP", config) - time_2 = time.time() time_interval = time_2 - time_1 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["uuid"] = 0 - ap_config_active = ap_ssh.get_uc_active_config() ap_config_active["uuid"] = 0 x = 1 @@ -330,19 +390,15 @@ class Fixtures_2x: ap_logs = ap_ssh.logread() allure.attach(body=ap_logs, name="AP Logs: ") - - try: ssid_info_sdk = instantiate_profile_obj.get_ssid_info() ap_wifi_data = ap_ssh.get_iwinfo() - for p in ap_wifi_data: for q in ssid_info_sdk: if ap_wifi_data[p][0] == q[0] and ap_wifi_data[p][2] == q[3]: q.append(ap_wifi_data[p][1]) - ssid_data = [] idx_mapping = {} for interface in range(len(ssid_info_sdk)): diff --git a/tests/pytest.ini b/tests/pytest.ini index ba9068e4c..34bdffb35 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -73,4 +73,3 @@ filterwarnings=ignore::UserWarning markers=sanity: Run the sanity for Client Connectivity test - diff --git a/tests/test_connectivity.py b/tests/test_connectivity.py index 85b6939d6..89d111d88 100644 --- a/tests/test_connectivity.py +++ b/tests/test_connectivity.py @@ -9,26 +9,11 @@ pytestmark = [pytest.mark.test_resources, pytest.mark.sanity, pytest.mark.sanity_55] - - @pytest.mark.fw def test_firmware(firmware_upgrade): assert True - - - - - - - - - - - - - @allure.testcase(name="Test Resources", url="") class TestResources(object): """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") assert traffic_generator_connectivity -