diff --git a/libs/apnos/apnos.py b/libs/apnos/apnos.py index 77ffa7147..67da615ea 100644 --- a/libs/apnos/apnos.py +++ b/libs/apnos/apnos.py @@ -13,10 +13,13 @@ Currently Having Methods: import paramiko from scp import SCPClient import os +import allure + class APNOS: def __init__(self, credentials=None, pwd=os.getcwd()): + allure.attach(name="APNOS LIbrary: ", body=str(credentials)) self.owrt_args = "--prompt root@OpenAp -s serial --log stdout --user root --passwd openwifi" if credentials is None: print("No credentials Given") @@ -39,13 +42,16 @@ class APNOS: if str(stdout.read()).__contains__("False"): print("Copying openwrt_ctl serial control Script...") with SCPClient(client.get_transport()) as scp: - scp.put(pwd+'openwrt_ctl.py', '~/cicd-git/openwrt_ctl.py') # Copy my_file.txt to the server + scp.put(pwd + 'openwrt_ctl.py', '~/cicd-git/openwrt_ctl.py') # Copy my_file.txt to the server cmd = '[ -f ~/cicd-git/openwrt_ctl.py ] && echo "True" || echo "False"' stdin, stdout, stderr = client.exec_command(cmd) var = str(stdout.read()) + print(var) if var.__contains__("True"): + allure.attach(name="openwrt_ctl Setup", body=str(var)) print("APNOS Serial Setup OK") else: + allure.attach(name="openwrt_ctl Setup", body=str(var)) print("APNOS Serial Setup Fail") # Method to connect AP-CLI/ JUMPHOST-CLI @@ -61,6 +67,7 @@ class APNOS: def reboot(self): client = self.ssh_cli_connect() + cmd = "reboot" if self.mode: cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ @@ -68,6 +75,7 @@ class APNOS: stdin, stdout, stderr = client.exec_command(cmd) output = stdout.read() client.close() + allure.attach(name="AP Reboot", body=str(output)) return output # Method to get the iwinfo status of AP using AP-CLI/ JUMPHOST-CLI @@ -80,6 +88,8 @@ class APNOS: stdin, stdout, stderr = client.exec_command(cmd) output = stdout.read() client.close() + allure.attach(name="iwinfo Output Msg: ", body=str(output)) + allure.attach(name="iwinfo config Err Msg: ", body=str(stderr)) return output # Method to get the vif_config of AP using AP-CLI/ JUMPHOST-CLI @@ -92,6 +102,9 @@ class APNOS: stdin, stdout, stderr = client.exec_command(cmd) output = stdout.read() client.close() + allure.attach(name="vif config Output Msg: ", body=str(output)) + allure.attach(name="vif config Err Msg: ", body=str(stderr)) + return output # Method to get the vif_state of AP using AP-CLI/ JUMPHOST-CLI @@ -104,6 +117,8 @@ class APNOS: stdin, stdout, stderr = client.exec_command(cmd) output = stdout.read() client.close() + allure.attach(name="vif state Output Msg: ", body=str(output)) + allure.attach(name="vif state Err Msg: ", body=str(stderr)) return output # Method to get the vif_config ssid's of AP using AP-CLI/ JUMPHOST-CLI @@ -114,6 +129,7 @@ class APNOS: ssid = str(i).replace(" ", "").split(".") if ssid[0].split(":")[0] == "b'ssid": ssid_list.append(ssid[0].split(":")[1].replace("'", "")) + allure.attach(name="get_vif_config_ssids ", body=str(ssid_list)) return ssid_list # Method to get the vif_state ssid's of AP using AP-CLI/ JUMPHOST-CLI @@ -124,6 +140,7 @@ class APNOS: ssid = str(i).replace(" ", "").split(".") if ssid[0].split(":")[0] == "b'ssid": ssid_list.append(ssid[0].split(":")[1].replace("'", "")) + allure.attach(name="get_vif_state_ssids ", body=str(ssid_list)) return ssid_list # Method to get the active firmware of AP using AP-CLI/ JUMPHOST-CLI @@ -143,7 +160,9 @@ class APNOS: client.close() except Exception as e: print(e) + allure.attach(name="get_active_firmware - Exception ", body=str(e)) cli_active_fw = "Error" + allure.attach(name="get_active_firmware ", body=str(cli_active_fw)) return cli_active_fw # Method to get the manager state of AP using AP-CLI/ JUMPHOST-CLI @@ -161,5 +180,86 @@ class APNOS: client.close() except Exception as e: print(e) + allure.attach(name="get_active_firmware - Exception ", body=str(e)) status = "Error" + allure.attach(name="get_active_firmware ", body=str(status)) return status + + def get_serial_number(self): + try: + client = self.ssh_cli_connect() + cmd = "node | grep serial_number" + if self.mode: + cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ + f"cmd --value \"{cmd}\" " + stdin, stdout, stderr = client.exec_command(cmd) + output = stdout.read() + output = output.decode('utf-8').splitlines() + allure.attach(name="get_serial_number output ", body=str(stderr)) + serial = output[1].replace(" ", "").split("|")[1] + client.close() + except Exception as e: + print(e) + allure.attach(name="get_serial_number - Exception ", body=str(e)) + serial = "Error" + allure.attach(name="get_serial_number ", body=str(serial)) + return serial + + def get_redirector(self): + try: + client = self.ssh_cli_connect() + cmd = "node | grep redirector_addr" + if self.mode: + cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ + f"cmd --value \"{cmd}\" " + stdin, stdout, stderr = client.exec_command(cmd) + output = stdout.read() + status = output.decode('utf-8').splitlines() + allure.attach(name="get_redirector output ", body=str(stderr)) + redirector = status[1].replace(" ", "").split("|")[1] + client.close() + except Exception as e: + print(e) + allure.attach(name="get_redirector - Exception ", body=str(e)) + redirector = "Error" + allure.attach(name="get_redirector ", body=redirector) + return redirector + + def run_generic_command(self, cmd=""): + allure.attach(name="run_generic_command ", body=cmd) + try: + client = self.ssh_cli_connect() + cmd = cmd + if self.mode: + cmd = f"cd ~/cicd-git/ && ./openwrt_ctl.py {self.owrt_args} -t {self.tty} --action " \ + f"cmd --value \"{cmd}\" " + stdin, stdout, stderr = client.exec_command(cmd) + input = stdin.read().decode('utf-8').splitlines() + output = stdout.read().decode('utf-8').splitlines() + error = stderr.read().decode('utf-8').splitlines() + client.close() + except Exception as e: + print(e) + allure.attach(name="run_generic_command - Exception ", body=str(e)) + input = "Error" + output = "Error" + error = "Error" + allure.attach(name="run_generic_command ", body=input) + allure.attach(name="run_generic_command ", body=str(output)) + allure.attach(name="run_generic_command ", body=error) + return [input, output, error] + + +if __name__ == '__main__': + obj = { + 'jumphost': True, + 'ip': "192.168.200.230", + 'username': "lanforge", + 'password': "lanforge", + 'port': 22, + 'jumphost_tty': '/dev/ttyAP1', + + } + var = APNOS(credentials=obj) + r = var.get_redirector() + print(r) \ No newline at end of file diff --git a/libs/controller/controller.py b/libs/controller/controller.py index 0ad3e9ab3..966ab451e 100644 --- a/libs/controller/controller.py +++ b/libs/controller/controller.py @@ -4,8 +4,6 @@ 1. controller_data/sdk_base_url 2. login credentials """ -import base64 -import datetime import json import re import ssl @@ -14,9 +12,9 @@ import urllib import requests import swagger_client -from swagger_client import FirmwareManagementApi -from swagger_client import EquipmentGatewayApi from bs4 import BeautifulSoup +from swagger_client import EquipmentGatewayApi +from swagger_client import FirmwareManagementApi class ConfigureController: @@ -163,8 +161,9 @@ class Controller(ConfigureController): # Get the equipment id, of a equipment with a serial number def get_equipment_id(self, serial_number=None): equipment_data = self.get_equipment_by_customer_id(max_items=100) - print(len(equipment_data)) + # print(equipment_data) for equipment in equipment_data: + print(equipment._id) if equipment._serial == serial_number: return equipment._id @@ -197,7 +196,7 @@ class Controller(ConfigureController): current_ap_fw = status_data[2]['details']['reportedSwVersion'] print(current_ap_fw) return current_ap_fw - except: + except Exception as e: current_ap_fw = "error" return False @@ -719,8 +718,6 @@ class JFrogUtility: def __init__(self, credentials=None): if credentials is None: exit() - self.user = credentials["username"] - self.password = credentials["password"] self.jfrog_url = credentials["jfrog-base-url"] self.build = credentials["build"] self.branch = credentials["branch"] @@ -728,29 +725,25 @@ class JFrogUtility: def get_build(self, model=None, version=None): jfrog_url = self.jfrog_url + "/" + model + "/" + self.branch + "/" - auth = str( - base64.b64encode( - bytes('%s:%s' % (self.user, self.password), 'utf-8') - ), - 'ascii' - ).strip() - headers = {'Authorization': 'Basic ' + auth} ''' FIND THE LATEST FILE NAME''' print(jfrog_url) - req = urllib.request.Request(jfrog_url, headers=headers) + req = urllib.request.Request(jfrog_url) response = urllib.request.urlopen(req) # print(response) html = response.read() soup = BeautifulSoup(html, features="html.parser") + if self.branch == "trunk": + self.build = model last_link = soup.find_all('a', href=re.compile(self.build)) latest_fw = None for i in last_link: + if str(i['href']).__contains__(version): latest_fw = i['href'] - # latest_file = last_link['href'] latest_fw = latest_fw.replace('.tar.gz', '') + print("Using Firmware Image: ", latest_fw) return latest_fw @@ -788,6 +781,8 @@ class FirmwareUtility(JFrogUtility): return self.latest_fw def upload_fw_on_cloud(self, fw_version=None, force_upload=False): + print("shivam", fw_version) + # force_upload = True # if fw_latest available and force upload is False -- Don't upload # if fw_latest available and force upload is True -- Upload # if fw_latest is not available -- Upload @@ -809,10 +804,9 @@ class FirmwareUtility(JFrogUtility): "modelId": fw_version.split("-")[0], "versionName": fw_version + ".tar.gz", "description": fw_version + " FW VERSION", - "filename": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + fw_version.split("-")[ - 0] + "/dev/" + fw_version + ".tar.gz", - "commit": fw_version.split("-")[5] + "filename": self.jfrog_url + "/" + self.model + "/" + self.branch + "/" + fw_version + ".tar.gz", } + print(firmware_data["filename"]) firmware_id = self.firmware_client.create_firmware_version(body=firmware_data) print("Force Upload :", force_upload, " Uploaded the Image") return firmware_id._id @@ -829,9 +823,11 @@ class FirmwareUtility(JFrogUtility): try: obj = self.equipment_gateway_client.request_firmware_update(equipment_id=equipment_id, firmware_version_id=firmware_id) + print("Request firmware upgrade Success! waiting for 300 sec") time.sleep(300) except Exception as e: + print(e) obj = False return obj # Write the upgrade fw logic here @@ -853,7 +849,24 @@ class FirmwareUtility(JFrogUtility): firmware_version_name=fw_version + ".tar.gz") firmware_version = firmware_version._id print("Firmware ID: ", firmware_version) - except: + except Exception as e: + print(e) firmware_version = False print("firmware not available: ", firmware_version) return firmware_version + + +if __name__ == '__main__': + """ + Examples to Try Out + """ + controller = { + 'url': "https://wlan-portal-svc-nola-ext-03.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-04-27" + } + sdk_client = Controller(controller_data=controller) + # Use Library/ Method Here + sdk_client.disconnect_Controller() diff --git a/tests/conftest.py b/tests/conftest.py index 50e0be8ad..0326a236f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -76,6 +76,41 @@ def pytest_addoption(parser): default=False, help="Stop using Testrails" ) + parser.addoption( + "--exit-on-fail", + action="store_true", + default=False, + help="use to stop execution if failure" + ) + + # Perfecto Parameters + parser.addini("perfectoURL", "Cloud URL") + parser.addini("securityToken", "Security Token") + parser.addini("platformName-iOS", "iOS Platform") + parser.addini("platformName-android", "Android Platform") + parser.addini("model-iOS", "iOS Devices") + parser.addini("model-android", "Android Devices") + parser.addini("bundleId-iOS", "iOS Devices") + parser.addini("bundleId-iOS-Settings", "iOS Settings App") + parser.addini("appPackage-android", "Android Devices") + parser.addini("wifi-SSID-5gl-Pwd", "Wifi 5g Password") + parser.addini("wifi-SSID-2g-Pwd", "Wifi 2g Password") + parser.addini("Default-SSID-5gl-perfecto-b", "Wifi 5g AP Name") + parser.addini("Default-SSID-2g-perfecto-b", "Wifi 2g AP Name") + parser.addini("Default-SSID-perfecto-b", "Wifi AP Name") + parser.addini("bundleId-iOS-Ping", "Ping Bundle ID") + parser.addini("browserType-iOS", "Mobile Browser Name") + parser.addini("projectName", "Project Name") + parser.addini("projectVersion", "Project Version") + parser.addini("jobName", "CI Job Name") + parser.addini("jobNumber", "CI Job Number") + parser.addini("reportTags", "Report Tags") + parser.addoption( + "--access-points-perfecto", + # nargs="+", + default=["Perfecto"], + help="list of access points to test" + ) """ @@ -159,11 +194,15 @@ def instantiate_project(request, instantiate_testrail, testbed, get_latest_firmw @pytest.fixture(scope="session") -def check_lanforge_connectivity(testbed): - # Check port +def setup_lanforge(): yield True +@pytest.fixture(scope="session") +def exit_on_fail(request): + yield request.config.getoption("--exit-on-fail") + + @pytest.fixture(scope="session") def setup_perfecto_devices(request): yield True @@ -174,6 +213,11 @@ def test_cases(): yield TEST_CASES +@pytest.fixture(scope="session") +def apnos_obj(get_configuration, testbed): + yield APNOS(get_configuration[testbed]['access_point'][0]) + + @pytest.fixture(scope="session") def instantiate_access_point(testbed): APNOS(CONFIGURATION[testbed]['access_point'][0], pwd="../libs/apnos/") @@ -181,16 +225,30 @@ def instantiate_access_point(testbed): @pytest.fixture(scope="function") -def test_access_point(testbed, instantiate_access_point): - ap_ssh = APNOS(CONFIGURATION[testbed]['access_point'][0]) - ap_ssh.reboot() - time.sleep(100) - status = ap_ssh.get_manager_state() +def access_point_connectivity(apnos_obj, get_configuration, testbed): + ap_conn = {} + config_serial = get_configuration[testbed]['access_point'][0]['serial'] + ap_serial = apnos_obj.get_serial_number() + ap_conn["serial"] = True + if ap_serial != config_serial: + ap_conn["serial"] = False + + ap_conn["redir"] = False + ap_redir = apnos_obj.get_redirector() + + # Compare with something ... + + ap_conn["mgr"] = False + status = apnos_obj.get_manager_state() if "ACTIVE" not in status: + apnos_obj.run_generic_command(cmd="service opensync restart") time.sleep(30) - ap_ssh = APNOS(CONFIGURATION[testbed]['access_point'][0]) - status = ap_ssh.get_manager_state() - yield status + status = apnos_obj.get_manager_state() + if "ACTIVE" in status: + ap_conn["mgr"] = True + else: + ap_conn["mgr"] = True + yield ap_conn @pytest.fixture(scope="session") @@ -273,3 +331,8 @@ def check_ap_firmware_ssh(testbed): @pytest.fixture(scope="session") def radius_info(): yield RADIUS_SERVER_DATA + + +@pytest.fixture(scope="session") +def get_configuration(): + yield CONFIGURATION diff --git a/tests/e2e/basic/client_connectivity_test/test_bridge_mode.py b/tests/e2e/basic/client_connectivity_test/test_bridge_mode.py index 99331b7fa..1797b9c8e 100644 --- a/tests/e2e/basic/client_connectivity_test/test_bridge_mode.py +++ b/tests/e2e/basic/client_connectivity_test/test_bridge_mode.py @@ -48,7 +48,7 @@ class TestBridgeModeClientConnectivity(object): @pytest.mark.wpa @pytest.mark.twog def test_client_wpa_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_testrail, - instantiate_project, test_cases): + instantiate_controller, instantiate_project, test_cases, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -66,7 +66,7 @@ class TestBridgeModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_2dot4g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -74,6 +74,8 @@ class TestBridgeModeClientConnectivity(object): staConnect.start() print("napping %f sec" % staConnect.runtime_secs) time.sleep(staConnect.runtime_secs) + if exit_on_fail and staConnect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") staConnect.stop() staConnect.cleanup() run_results = staConnect.get_result_list() @@ -89,13 +91,15 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_wpa_bridge"], run_id=instantiate_project, status_id=5, msg='2G WPA Client Connectivity Failed - bridge mode' + str(run_results)) + + instantiate_controller.refresh_instance() assert staConnect.passes() # C2420 @pytest.mark.wpa @pytest.mark.fiveg def test_client_wpa_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, test_cases): + instantiate_controller, instantiate_testrail, test_cases, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -112,7 +116,7 @@ class TestBridgeModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -120,6 +124,8 @@ class TestBridgeModeClientConnectivity(object): staConnect.start() print("napping %f sec" % staConnect.runtime_secs) time.sleep(staConnect.runtime_secs) + if exit_on_fail and staConnect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") staConnect.stop() staConnect.cleanup() run_results = staConnect.get_result_list() @@ -135,13 +141,15 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_wpa_bridge"], run_id=instantiate_project, status_id=5, msg='5G WPA Client Connectivity Failed - bridge mode' + str(run_results)) + + instantiate_controller.refresh_instance() assert staConnect.passes() # C2419 @pytest.mark.wpa2_personal @pytest.mark.twog def test_client_wpa2_personal_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, test_cases): + instantiate_controller, instantiate_testrail, test_cases, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA2_P"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -158,7 +166,7 @@ class TestBridgeModeClientConnectivity(object): staConnect.dut_security = "wpa2" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_2dot4g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -166,6 +174,8 @@ class TestBridgeModeClientConnectivity(object): staConnect.start() print("napping %f sec" % staConnect.runtime_secs) time.sleep(staConnect.runtime_secs) + if exit_on_fail and staConnect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") staConnect.stop() staConnect.cleanup() run_results = staConnect.get_result_list() @@ -181,13 +191,15 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_wpa2_bridge"], run_id=instantiate_project, status_id=5, msg='2G WPA2 Client Connectivity Failed - bridge mode' + str(run_results)) + + instantiate_controller.refresh_instance() assert staConnect.passes() # C2237 @pytest.mark.wpa2_personal @pytest.mark.fiveg def test_client_wpa2_personal_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, test_cases): + instantiate_controller, instantiate_testrail, test_cases, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA2_P"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -204,7 +216,7 @@ class TestBridgeModeClientConnectivity(object): staConnect.dut_security = "wpa2" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -212,6 +224,8 @@ class TestBridgeModeClientConnectivity(object): staConnect.start() print("napping %f sec" % staConnect.runtime_secs) time.sleep(staConnect.runtime_secs) + if exit_on_fail and staConnect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") staConnect.stop() staConnect.cleanup() run_results = staConnect.get_result_list() @@ -227,6 +241,7 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_wpa2_bridge"], run_id=instantiate_project, status_id=5, msg='5G WPA2 Client Connectivity Failed - bridge mode' + str(run_results)) + instantiate_controller.refresh_instance() assert staConnect.passes() # C2236 @@ -234,7 +249,7 @@ class TestBridgeModeClientConnectivity(object): @pytest.mark.twog @pytest.mark.radius def test_client_wpa2_enterprise_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, radius_info, test_cases): + instantiate_controller, instantiate_testrail, radius_info, test_cases, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA2_E"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -251,15 +266,16 @@ class TestBridgeModeClientConnectivity(object): eap_connect.eap = "TTLS" eap_connect.identity = radius_info["user"] eap_connect.ttls_passwd = radius_info["password"] - eap_connect.runtime_secs = 10 + eap_connect.runtime_secs = 40 eap_connect.setup() eap_connect.start() print("napping %f sec" % eap_connect.runtime_secs) time.sleep(eap_connect.runtime_secs) + if exit_on_fail and eap_connect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") eap_connect.stop() try: eap_connect.cleanup() - eap_connect.cleanup() except: pass run_results = eap_connect.get_result_list() @@ -276,6 +292,7 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_eap_bridge"], run_id=instantiate_project, status_id=5, msg='5G WPA2 ENTERPRISE Client Connectivity Failed - bridge mode' + str(run_results)) + instantiate_controller.refresh_instance() assert eap_connect.passes() # C5214 @@ -283,7 +300,7 @@ class TestBridgeModeClientConnectivity(object): @pytest.mark.fiveg @pytest.mark.radius def test_client_wpa2_enterprise_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, radius_info, test_cases): + instantiate_controller, instantiate_testrail, radius_info, test_cases, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA2_E"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -300,14 +317,16 @@ class TestBridgeModeClientConnectivity(object): eap_connect.eap = "TTLS" eap_connect.identity = radius_info["user"] eap_connect.ttls_passwd = radius_info["password"] - eap_connect.runtime_secs = 10 + eap_connect.runtime_secs = 40 eap_connect.setup() eap_connect.start() print("napping %f sec" % eap_connect.runtime_secs) time.sleep(eap_connect.runtime_secs) + if exit_on_fail and eap_connect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") eap_connect.stop() try: - eap_connect.cleanup() + eap_connect.cleanup() except: pass @@ -325,6 +344,8 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_eap_bridge"], run_id=instantiate_project, status_id=5, msg='5G WPA2 ENTERPRISE Client Connectivity Failed - bridge mode' + str(run_results)) + + instantiate_controller.refresh_instance() assert eap_connect.passes() @pytest.mark.modify_ssid @@ -334,7 +355,7 @@ class TestBridgeModeClientConnectivity(object): indirect=True ) def test_modify_ssid(self, request, update_ssid, get_lanforge_data, setup_profile_data, instantiate_testrail, - instantiate_project, test_cases, instantiate_controller): + instantiate_project, test_cases, instantiate_controller, exit_on_fail): profile_data = setup_profile_data["BRIDGE"]["WPA"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -351,7 +372,7 @@ class TestBridgeModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -359,6 +380,8 @@ class TestBridgeModeClientConnectivity(object): staConnect.start() print("napping %f sec" % staConnect.runtime_secs) time.sleep(staConnect.runtime_secs) + if exit_on_fail and staConnect.passes(): + pytest.exit("Test Case Failed! exit_on_fail Exit") staConnect.stop() staConnect.cleanup() run_results = staConnect.get_result_list() @@ -375,5 +398,6 @@ class TestBridgeModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["bridge_ssid_update"], run_id=instantiate_project, status_id=5, msg='5G WPA Client Connectivity Failed - bridge mode updated ssid' + str(run_results)) + instantiate_controller.refresh_instance() assert staConnect.passes() diff --git a/tests/e2e/basic/client_connectivity_test/test_nat_mode.py b/tests/e2e/basic/client_connectivity_test/test_nat_mode.py index 5106f26ef..c2b0ee7df 100644 --- a/tests/e2e/basic/client_connectivity_test/test_nat_mode.py +++ b/tests/e2e/basic/client_connectivity_test/test_nat_mode.py @@ -47,7 +47,7 @@ class TestNatModeClientConnectivity(object): @pytest.mark.wpa @pytest.mark.twog def test_client_wpa_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_testrail, - instantiate_project, test_cases): + instantiate_controller, instantiate_project, test_cases, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -65,7 +65,7 @@ class TestNatModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_2dot4g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -88,13 +88,16 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_wpa_nat"], run_id=instantiate_project, status_id=5, msg='2G WPA Client Connectivity Failed - nat mode' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") + instantiate_controller.refresh_instance() assert staConnect.passes() # C2420 @pytest.mark.wpa @pytest.mark.fiveg def test_client_wpa_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, test_cases): + instantiate_controller, instantiate_testrail, test_cases, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -111,7 +114,7 @@ class TestNatModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -134,13 +137,16 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_wpa_nat"], run_id=instantiate_project, status_id=5, msg='5G WPA Client Connectivity Failed - nat mode' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") + instantiate_controller.refresh_instance() assert staConnect.passes() # C2419 @pytest.mark.wpa2_personal @pytest.mark.twog def test_client_wpa2_personal_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, test_cases): + instantiate_controller, instantiate_testrail, test_cases, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA2_P"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -157,7 +163,7 @@ class TestNatModeClientConnectivity(object): staConnect.dut_security = "wpa2" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_2dot4g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -180,13 +186,16 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_wpa2_nat"], run_id=instantiate_project, status_id=5, msg='2G WPA2 Client Connectivity Failed - nat mode' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") + instantiate_controller.refresh_instance() assert staConnect.passes() # C2237 @pytest.mark.wpa2_personal @pytest.mark.fiveg def test_client_wpa2_personal_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, test_cases): + instantiate_controller, instantiate_testrail, test_cases, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA2_P"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -203,7 +212,7 @@ class TestNatModeClientConnectivity(object): staConnect.dut_security = "wpa2" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -226,6 +235,9 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_wpa2_nat"], run_id=instantiate_project, status_id=5, msg='5G WPA2 Client Connectivity Failed - nat mode' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") + instantiate_controller.refresh_instance() assert staConnect.passes() # C2236 @@ -233,7 +245,7 @@ class TestNatModeClientConnectivity(object): @pytest.mark.twog @pytest.mark.radius def test_client_wpa2_enterprise_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, radius_info, test_cases): + instantiate_controller, instantiate_testrail, radius_info, test_cases, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA2_E"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -250,7 +262,7 @@ class TestNatModeClientConnectivity(object): eap_connect.eap = "TTLS" eap_connect.identity = radius_info["user"] eap_connect.ttls_passwd = radius_info["password"] - eap_connect.runtime_secs = 10 + eap_connect.runtime_secs = 40 eap_connect.setup() eap_connect.start() print("napping %f sec" % eap_connect.runtime_secs) @@ -275,6 +287,9 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_eap_nat"], run_id=instantiate_project, status_id=5, msg='5G WPA2 ENTERPRISE Client Connectivity Failed - nat mode' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") + instantiate_controller.refresh_instance() assert eap_connect.passes() # C5214 @@ -282,7 +297,7 @@ class TestNatModeClientConnectivity(object): @pytest.mark.fiveg @pytest.mark.radius def test_client_wpa2_enterprise_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, radius_info, test_cases): + instantiate_controller, instantiate_testrail, radius_info, test_cases, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA2_E"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -299,7 +314,7 @@ class TestNatModeClientConnectivity(object): eap_connect.eap = "TTLS" eap_connect.identity = radius_info["user"] eap_connect.ttls_passwd = radius_info["password"] - eap_connect.runtime_secs = 10 + eap_connect.runtime_secs = 40 eap_connect.setup() eap_connect.start() print("napping %f sec" % eap_connect.runtime_secs) @@ -324,6 +339,9 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_eap_nat"], run_id=instantiate_project, status_id=5, msg='5G WPA2 ENTERPRISE Client Connectivity Failed - nat mode' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") + instantiate_controller.refresh_instance() assert eap_connect.passes() @pytest.mark.modify_ssid @@ -333,7 +351,7 @@ class TestNatModeClientConnectivity(object): indirect=True ) def test_modify_ssid(self, request, update_ssid, get_lanforge_data, setup_profile_data, instantiate_testrail, - instantiate_project, test_cases, instantiate_controller): + instantiate_project, test_cases, instantiate_controller, exit_on_fail): profile_data = setup_profile_data["NAT"]["WPA"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -350,7 +368,7 @@ class TestNatModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -374,5 +392,7 @@ class TestNatModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["nat_ssid_update"], run_id=instantiate_project, status_id=5, msg='5G WPA Client Connectivity Failed - nat mode updated ssid' + str(run_results)) + if exit_on_fail: + pytest.exit("Test Case Failed! exit_on_fail Exit") instantiate_controller.refresh_instance() assert staConnect.passes() diff --git a/tests/e2e/basic/client_connectivity_test/test_vlan_mode.py b/tests/e2e/basic/client_connectivity_test/test_vlan_mode.py index 534fc9755..27c01dfc3 100644 --- a/tests/e2e/basic/client_connectivity_test/test_vlan_mode.py +++ b/tests/e2e/basic/client_connectivity_test/test_vlan_mode.py @@ -46,7 +46,7 @@ class TestVlanModeClientConnectivity(object): @pytest.mark.wpa @pytest.mark.twog def test_client_wpa_2g(self, request, get_lanforge_data, setup_profile_data, - instantiate_testrail, instantiate_project, test_cases): + instantiate_controller, instantiate_testrail, instantiate_project, test_cases): profile_data = setup_profile_data["VLAN"]["WPA"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -64,7 +64,7 @@ class TestVlanModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_2dot4g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True staConnect.setup() @@ -86,13 +86,14 @@ class TestVlanModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_wpa_vlan"], run_id=instantiate_project, status_id=5, msg='2G WPA Client Connectivity Failed - vlan mode' + str(run_results)) + instantiate_controller.refresh_instance() assert staConnect.passes() # C2420 @pytest.mark.wpa @pytest.mark.fiveg def test_client_wpa_5g(self, request, get_lanforge_data, setup_profile_data, - instantiate_project, instantiate_testrail, test_cases): + instantiate_controller, instantiate_project, instantiate_testrail, test_cases): profile_data = setup_profile_data["VLAN"]["WPA"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -109,7 +110,7 @@ class TestVlanModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -132,13 +133,14 @@ class TestVlanModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_wpa_vlan"], run_id=instantiate_project, status_id=5, msg='5G WPA Client Connectivity Failed - vlan mode' + str(run_results)) + instantiate_controller.refresh_instance() assert staConnect.passes() # C2419 @pytest.mark.wpa2_personal @pytest.mark.twog def test_client_wpa2_personal_2g(self, request, get_lanforge_data, setup_profile_data, - instantiate_project, instantiate_testrail, test_cases): + instantiate_controller, instantiate_project, instantiate_testrail, test_cases): profile_data = setup_profile_data["VLAN"]["WPA2_P"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -155,7 +157,7 @@ class TestVlanModeClientConnectivity(object): staConnect.dut_security = "wpa2" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_2dot4g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -178,13 +180,14 @@ class TestVlanModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_wpa2_vlan"], run_id=instantiate_project, status_id=5, msg='2G WPA2 Client Connectivity Failed - vlan mode' + str(run_results)) + instantiate_controller.refresh_instance() assert staConnect.passes() # C2237 @pytest.mark.wpa2_personal @pytest.mark.fiveg def test_client_wpa2_personal_5g(self, request, get_lanforge_data, setup_profile_data, - instantiate_project, instantiate_testrail, test_cases): + instantiate_controller, instantiate_project, instantiate_testrail, test_cases): profile_data = setup_profile_data["VLAN"]["WPA2_P"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -201,7 +204,7 @@ class TestVlanModeClientConnectivity(object): staConnect.dut_security = "wpa2" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() @@ -224,6 +227,7 @@ class TestVlanModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_wpa2_vlan"], run_id=instantiate_project, status_id=5, msg='5G WPA2 Client Connectivity Failed - vlan mode' + str(run_results)) + instantiate_controller.refresh_instance() assert staConnect.passes() # C2236 @@ -231,7 +235,7 @@ class TestVlanModeClientConnectivity(object): @pytest.mark.twog @pytest.mark.radius def test_client_wpa2_enterprise_2g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, radius_info, test_cases): + instantiate_controller, instantiate_testrail, radius_info, test_cases): profile_data = setup_profile_data["VLAN"]["WPA2_E"]["2G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -248,7 +252,7 @@ class TestVlanModeClientConnectivity(object): eap_connect.eap = "TTLS" eap_connect.identity = radius_info["user"] eap_connect.ttls_passwd = radius_info["password"] - eap_connect.runtime_secs = 10 + eap_connect.runtime_secs = 40 eap_connect.setup() eap_connect.start() print("napping %f sec" % eap_connect.runtime_secs) @@ -273,6 +277,7 @@ class TestVlanModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["2g_eap_vlan"], run_id=instantiate_project, status_id=5, msg='5G WPA2 ENTERPRISE Client Connectivity Failed - vlan mode' + str(run_results)) + instantiate_controller.refresh_instance() assert eap_connect.passes() # C5214 @@ -280,7 +285,7 @@ class TestVlanModeClientConnectivity(object): @pytest.mark.fiveg @pytest.mark.radius def test_client_wpa2_enterprise_5g(self, request, get_lanforge_data, setup_profile_data, instantiate_project, - instantiate_testrail, radius_info, test_cases): + instantiate_controller, instantiate_testrail, radius_info, test_cases): profile_data = setup_profile_data["VLAN"]["WPA2_E"]["5G"] station_names = [] for i in range(0, int(request.config.getini("num_stations"))): @@ -297,7 +302,7 @@ class TestVlanModeClientConnectivity(object): eap_connect.eap = "TTLS" eap_connect.identity = radius_info["user"] eap_connect.ttls_passwd = radius_info["password"] - eap_connect.runtime_secs = 10 + eap_connect.runtime_secs = 40 eap_connect.setup() eap_connect.start() print("napping %f sec" % eap_connect.runtime_secs) @@ -322,6 +327,7 @@ class TestVlanModeClientConnectivity(object): instantiate_testrail.update_testrail(case_id=test_cases["5g_eap_vlan"], run_id=instantiate_project, status_id=5, msg='5G WPA2 ENTERPRISE Client Connectivity Failed - vlan mode' + str(run_results)) + instantiate_controller.refresh_instance() assert eap_connect.passes() @pytest.mark.modify_ssid @@ -340,7 +346,7 @@ class TestVlanModeClientConnectivity(object): debug_=False) staConnect.sta_mode = 0 staConnect.upstream_resource = 1 - staConnect.upstream_port = get_lanforge_data["lanforge_bridge_port"] + staConnect.upstream_port = get_lanforge_data["lanforge_vlan_port"] staConnect.radio = get_lanforge_data["lanforge_5g"] staConnect.resource = 1 staConnect.dut_ssid = profile_data["ssid_name"] @@ -348,7 +354,7 @@ class TestVlanModeClientConnectivity(object): staConnect.dut_security = "wpa" staConnect.station_names = station_names staConnect.sta_prefix = get_lanforge_data["lanforge_5g_prefix"] - staConnect.runtime_secs = 10 + staConnect.runtime_secs = 40 staConnect.bringup_time_sec = 60 staConnect.cleanup_on_exit = True # staConnect.cleanup() diff --git a/tests/e2e/basic/conftest.py b/tests/e2e/basic/conftest.py index 1ff8b379b..f847fe39f 100644 --- a/tests/e2e/basic/conftest.py +++ b/tests/e2e/basic/conftest.py @@ -77,7 +77,7 @@ def get_lanforge_data(testbed): def instantiate_profile(instantiate_controller): try: profile_object = ProfileUtility(sdk_client=instantiate_controller) - except: + except Exception as e: profile_object = False yield profile_object @@ -88,6 +88,7 @@ def get_equipment_id(instantiate_controller, testbed): if len(CONFIGURATION[testbed]['access_point']) == 1: equipment_id = instantiate_controller.get_equipment_id( serial_number=CONFIGURATION[testbed]['access_point'][0]['serial']) + print(equipment_id) yield equipment_id @@ -142,8 +143,9 @@ def setup_profiles(request, create_profiles, instantiate_profile, get_equipment_ mode = str(request.param[0]).lower() try: instantiate_profile.push_profile_old_method(equipment_id=get_equipment_id) - except: - print("failed to create AP Profile") + except Exception as e: + print(e) + print("failed to Push Profile") ap_ssh = APNOS(CONFIGURATION[testbed]['access_point'][0], pwd="../libs/apnos/") get_current_profile_cloud.sort() # This loop will check the VIF Config with cloud profile @@ -190,7 +192,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia instantiate_profile.get_default_profiles() profile_data = { "name": "RF-Profile-" + CONFIGURATION[testbed]['access_point'][0]['mode'] + - CONFIGURATION[testbed]['access_point'][0]['model'] + mode + CONFIGURATION[testbed]['access_point'][0]['model'] + "_" + mode + "_" + testbed } instantiate_profile.delete_profile_by_name(profile_name=profile_data['name']) instantiate_profile.set_rf_profile(profile_data=profile_data, @@ -202,7 +204,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia try: instantiate_profile.create_radius_profile(radius_info=radius_info) test_cases['radius_profile'] = True - except: + except Exception as e: test_cases['radius_profile'] = False for i in get_security_flags: if get_markers[i] and i == "open": @@ -213,7 +215,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_2g_open_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_2g_open_' + mode.lower()] = False if get_markers["fiveg"]: profile_data = setup_profile_data[mode]["OPEN"]["5G"] @@ -222,7 +224,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_5g_open_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_5g_open_' + mode.lower()] = False if get_markers[i] and i == "wpa": if get_markers["twog"]: @@ -231,7 +233,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia id = instantiate_profile.create_wpa_ssid_profile(two4g=True, fiveg=False, profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_2g_wpa_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_5g_wpa_' + mode.lower()] = False if get_markers["fiveg"]: profile_data = setup_profile_data[mode]["WPA"]["5G"] @@ -239,7 +241,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia id = instantiate_profile.create_wpa_ssid_profile(two4g=False, fiveg=True, profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_5g_wpa_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_5g_wpa_' + mode.lower()] = False if get_markers[i] and i == "wpa2_personal": if get_markers["twog"]: @@ -249,7 +251,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_2g_wpa2_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_2g_wpa2_' + mode.lower()] = False if get_markers["fiveg"]: profile_data = setup_profile_data[mode]["WPA2_P"]["5G"] @@ -258,7 +260,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_5g_wpa2_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_5g_wpa2_' + mode.lower()] = False if get_markers[i] and i == "wpa2_enterprise": if get_markers["twog"]: @@ -268,7 +270,7 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_2g_eap_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_2g_eap_' + mode.lower()] = False if get_markers["fiveg"]: profile_data = setup_profile_data[mode]["WPA2_E"]["5G"] @@ -277,11 +279,9 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia profile_data=profile_data) profile_id["ssid"].append(profile_data['ssid_name']) test_cases['ssid_5g_eap_' + mode.lower()] = True - except: + except Exception as e: test_cases['ssid_5g_eap_' + mode.lower()] = False - - # Create Equipment AP Profile Here profile_data = { "profile_name": testbed + "-Equipment-AP-" + mode @@ -289,8 +289,16 @@ def create_profiles(request, testbed, get_security_flags, get_markers, instantia try: instantiate_profile.set_ap_profile(profile_data=profile_data) test_cases['ap_' + mode.lower()] = True - except: + except Exception as e: + print(e) test_cases['ap_' + mode.lower()] = False + + def teardown_profiles(): + print("\nRemoving Profiles") + instantiate_profile.delete_profile_by_name(profile_name=profile_data['profile_name']) + time.sleep(20) + + request.addfinalizer(teardown_profiles) yield test_cases @@ -307,23 +315,3 @@ def update_ssid(request, instantiate_profile, setup_profile_data): time.sleep(90) yield status - -@pytest.fixture(scope="package") -def configure_lanforge(instantiate_dut): - # Scenario build - # - scenario_obj = Class() - yield scenario_obj - - -@pytest.fixture(scope="package") -def instantiate_dut(): - dut_obj = DUT("") - dut_obj.update() - # - yield dut_obj - -@pytest.fixture(scope="package") -def setup_vlan(scenario_obj): - scenario_obj.create_vlan() - yield scenario_obj \ No newline at end of file diff --git a/tests/test_connectivity.py b/tests/test_connectivity.py index 4a7b6be41..7e5b282db 100644 --- a/tests/test_connectivity.py +++ b/tests/test_connectivity.py @@ -31,13 +31,13 @@ def test_controller_connectivity(instantiate_controller, instantiate_testrail, i @pytest.mark.nat @pytest.mark.vlan @pytest.mark.test_access_points_connectivity -def test_access_points_connectivity(test_access_point, instantiate_testrail, instantiate_project, test_cases): - if "ACTIVE" not in test_access_point: +def test_access_points_connectivity(access_point_connectivity, instantiate_testrail, instantiate_project, test_cases, exit_on_fail): + if not access_point_connectivity["serial"] and not access_point_connectivity["mgr"]: instantiate_testrail.update_testrail(case_id=test_cases["cloud_connection"], run_id=instantiate_project, status_id=5, msg='CloudSDK connectivity failed') status = False - sys.exit() + pytest.exit("Access Point is not Properly Connected: Sanity Failed") else: instantiate_testrail.update_testrail(case_id=test_cases["cloud_connection"], run_id=instantiate_project, status_id=1, @@ -47,19 +47,19 @@ def test_access_points_connectivity(test_access_point, instantiate_testrail, ins assert status -@pytest.mark.sanity -@pytest.mark.bridge -@pytest.mark.nat -@pytest.mark.vlan -@pytest.mark.test_lanforge_connectivity -def test_lanforge_connectivity(check_lanforge_connectivity): - assert "instantiate_cloudsdk" - - -@pytest.mark.sanity -@pytest.mark.bridge -@pytest.mark.nat -@pytest.mark.vlan -@pytest.mark.test_perfecto_connectivity -def test_perfecto_connectivity(setup_perfecto_devices): - assert "instantiate_cloudsdk" +# @pytest.mark.sanity +# @pytest.mark.bridge +# @pytest.mark.nat +# @pytest.mark.vlan +# @pytest.mark.test_lanforge_connectivity +# def test_lanforge_connectivity(check_lanforge_connectivity): +# assert "instantiate_cloudsdk" +# +# +# @pytest.mark.sanity +# @pytest.mark.bridge +# @pytest.mark.nat +# @pytest.mark.vlan +# @pytest.mark.test_perfecto_connectivity +# def test_perfecto_connectivity(setup_perfecto_devices): +# assert "instantiate_cloudsdk"