From edd393e2ac36b021d88370344b23ad6e683cb2a4 Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 10 Mar 2021 17:36:06 +0530 Subject: [PATCH] Added cloudsdk pytests and directory structuring Signed-off-by: shivam --- libs/cloudsdk/2.4ghz/test_generic.py | 29 - libs/cloudsdk/cloudsdk.py | 184 +- libs/cloudsdk/conftest.py | 78 - libs/cloudsdk/pytest.ini | 29 - libs/cloudsdk/testbed_info.py | 8 +- {libs/cloudsdk => tests}/.pylintrc | 0 tests/Dockerfile | 16 - tests/EXAMPLE-USAGE.txt | 35 - tests/Nightly_Sanity.py | 487 ---- tests/README.md | 2 - tests/Throughput_Test.py | 530 ----- tests/UnitTestBase.py | 406 ---- tests/cicd_sanity/ap_connect.py | 187 -- tests/cicd_sanity/cicd_sanity.py | 2057 ----------------- tests/cicd_sanity/cloud_connect.py | 292 --- tests/cicd_sanity/nola04_test_info.py | 249 -- tests/cicd_sanity/reports/report_template.php | 1838 --------------- tests/cicd_sanity/sanity_status.json | 1 - .../templates/ap_profile_template.json | 1 - .../templates/radius_profile_template.json | 1 - .../templates/ssid_profile_template.json | 1 - tests/cicd_sanity/test_info.py | 276 --- tests/cicd_sanity/testrail.py | 194 -- tests/cloudsdk/test_cloud.py | 26 + .../cloudsdk => tests}/configuration_data.py | 0 tests/conftest.py | 278 +-- tests/eap_connect.py | 354 --- tests/helpers/utils.py | 64 - tests/pytest.ini | 20 +- tests/pytest_utility/conftest.py | 0 tests/pytest_utility/pytest.ini | 0 tests/sanity_status.json | 1 - tests/single_client_throughput.py | 1064 --------- tests/templates/radius_profile_template.json | 1 - tests/templates/report_template.php | 622 ----- tests/templates/ssid_profile_template.json | 1 - tests/test_24ghz.py | 66 - tests/test_utility/reporting.py | 46 - tools/README.md | 2 - tools/USAGE_EXAMPLES.txt | 150 -- tools/debug_nola01.sh | 31 - tools/debug_nola12.sh | 31 - tools/logs/README.md | 1 - tools/query_ap.py | 44 - tools/query_sdk.py | 253 -- tools/sdk_set_profile.py | 219 -- tools/sdk_upgrade_fw.py | 183 -- 47 files changed, 196 insertions(+), 10162 deletions(-) delete mode 100644 libs/cloudsdk/2.4ghz/test_generic.py delete mode 100644 libs/cloudsdk/conftest.py delete mode 100644 libs/cloudsdk/pytest.ini rename {libs/cloudsdk => tests}/.pylintrc (100%) delete mode 100644 tests/Dockerfile delete mode 100644 tests/EXAMPLE-USAGE.txt delete mode 100755 tests/Nightly_Sanity.py delete mode 100644 tests/README.md delete mode 100755 tests/Throughput_Test.py delete mode 100644 tests/UnitTestBase.py delete mode 100644 tests/cicd_sanity/ap_connect.py delete mode 100755 tests/cicd_sanity/cicd_sanity.py delete mode 100755 tests/cicd_sanity/cloud_connect.py delete mode 100644 tests/cicd_sanity/nola04_test_info.py delete mode 100755 tests/cicd_sanity/reports/report_template.php delete mode 100755 tests/cicd_sanity/sanity_status.json delete mode 100644 tests/cicd_sanity/templates/ap_profile_template.json delete mode 100644 tests/cicd_sanity/templates/radius_profile_template.json delete mode 100644 tests/cicd_sanity/templates/ssid_profile_template.json delete mode 100755 tests/cicd_sanity/test_info.py delete mode 100644 tests/cicd_sanity/testrail.py create mode 100644 tests/cloudsdk/test_cloud.py rename {libs/cloudsdk => tests}/configuration_data.py (100%) delete mode 100755 tests/eap_connect.py delete mode 100644 tests/helpers/utils.py delete mode 100644 tests/pytest_utility/conftest.py delete mode 100644 tests/pytest_utility/pytest.ini delete mode 100755 tests/sanity_status.json delete mode 100755 tests/single_client_throughput.py delete mode 100644 tests/templates/radius_profile_template.json delete mode 100755 tests/templates/report_template.php delete mode 100644 tests/templates/ssid_profile_template.json delete mode 100644 tests/test_24ghz.py delete mode 100644 tests/test_utility/reporting.py delete mode 100644 tools/README.md delete mode 100644 tools/USAGE_EXAMPLES.txt delete mode 100755 tools/debug_nola01.sh delete mode 100755 tools/debug_nola12.sh delete mode 100644 tools/logs/README.md delete mode 100755 tools/query_ap.py delete mode 100755 tools/query_sdk.py delete mode 100755 tools/sdk_set_profile.py delete mode 100755 tools/sdk_upgrade_fw.py diff --git a/libs/cloudsdk/2.4ghz/test_generic.py b/libs/cloudsdk/2.4ghz/test_generic.py deleted file mode 100644 index f481c311e..000000000 --- a/libs/cloudsdk/2.4ghz/test_generic.py +++ /dev/null @@ -1,29 +0,0 @@ -import pytest - -@pytest.mark.usefixtures('setup_cloudsdk') -@pytest.mark.usefixtures('update_firmware') -@pytest.mark.UHF # example of a class mark -class Test24ghz(object): - @pytest.mark.wpa2 - def test_single_client_wpa2(self, setup_cloudsdk, update_firmware): - print(setup_cloudsdk) - assert 1 == 0 - - @pytest.mark.open - def test_single_client_open(self, setup_cloudsdk, update_firmware): - print(setup_cloudsdk) - assert 1 == 0 - -@pytest.mark.usefixtures('setup_cloudsdk') -@pytest.mark.usefixtures('update_firmware') -@pytest.mark.SHF # example of a class mark -class Test50ghz(object): - @pytest.mark.wpa2 - def test_single_client_wpa2(self, setup_cloudsdk, update_firmware): - print(setup_cloudsdk) - assert 1 == 0 - - @pytest.mark.open - def test_single_client_open(self, setup_cloudsdk, update_firmware): - print(setup_cloudsdk) - assert 1 == 0 diff --git a/libs/cloudsdk/cloudsdk.py b/libs/cloudsdk/cloudsdk.py index 4cdd3a0ba..a5acb8f67 100644 --- a/libs/cloudsdk/cloudsdk.py +++ b/libs/cloudsdk/cloudsdk.py @@ -54,7 +54,7 @@ class ConfigureCloudSDK: """ - Library for cloudSDK generic usages, it instantiate the bearer and credentials. + Library for cloudsdk generic usages, it instantiate the bearer and credentials. It provides the connectivity to the cloud. """ @@ -64,9 +64,12 @@ class CloudSDK(ConfigureCloudSDK): constructor for cloudsdk library : can be used from pytest framework """ - def __init__(self, testbed=None): + def __init__(self, testbed=None, customer_id=None): super().__init__() - + if customer_id is None: + print("Invalid Customer Id") + exit() + self.customer_id = customer_id # Setting the CloudSDK Client Configuration self.select_testbed(testbed=testbed) self.set_credentials() @@ -85,6 +88,7 @@ class CloudSDK(ConfigureCloudSDK): } self.api_client.configuration.refresh_api_key_hook = self.get_bearer_token() self.ping_response = self.portal_ping() + self.default_profiles = {} # print(self.bearer) if self.ping_response._application_name != 'PortalServer': print("Server not Reachable") @@ -108,14 +112,16 @@ class CloudSDK(ConfigureCloudSDK): Equipment Utilities """ - def get_equipment_by_customer_id(self, customer_id=None, max_items=10): + # Returns a List of All the Equipments that are available + def get_equipment_by_customer_id(self, max_items=10): pagination_context = """{ "model_type": "PaginationContext", - "maxItemsPerPage": """+str(max_items)+""" + "maxItemsPerPage": """ + str(max_items) + """ }""" - print(self.equipment_client.get_equipment_by_customer_id(customer_id=customer_id, - pagination_context=pagination_context)) + equipment_data = self.equipment_client.get_equipment_by_customer_id(customer_id=self.customer_id, + pagination_context=pagination_context) + return equipment_data._items def request_ap_reboot(self): pass @@ -141,57 +147,16 @@ class CloudSDK(ConfigureCloudSDK): Captive-Portal """ - def get_profile_template(self, customer_id=None, profile_name=None): - pagination_context = """{ - "model_type": "PaginationContext", - "maxItemsPerPage": 100 - }""" - profiles = self.profile_client.get_profiles_by_customer_id(customer_id=customer_id, - pagination_context=pagination_context)._items - for i in profiles: - if i._name == profile_name: - return i - return None - def get_profiles_by_customer_id(self, customer_id=None): - pagination_context = """{ - "model_type": "PaginationContext", - "maxItemsPerPage": 100 - }""" - self.default_profiles = {} - print(len((self.profile_client.get_profiles_by_customer_id(customer_id=customer_id, - pagination_context=pagination_context))._items)) - for i in self.profile_client.get_profiles_by_customer_id(customer_id=customer_id, - pagination_context=pagination_context)._items: - print(i._name, i._id) - if i._name == "TipWlan-Cloud-Wifi": - self.default_profiles['ssid'] = i - if i._name == "TipWlan-Cloud-Wifi": - self.default_profiles['ssid'] = i - if i._name == "TipWlan-Cloud-Wifi": - self.default_profiles['ssid'] = i - - def create_profile(self, profile_type=None, customer_id=None, profile_name=None): - if profile_type is None or customer_id is None or profile_name is None: - return "Invalid profile_type/customer_id/profile_name" - - profile_data = { - "profileType": profile_type, # eg. ("equipment_ap", "ssid", "rf", "radius", "captive_portal") - "customerId": customer_id, - "name": profile_name - } - return "Profile Created Successfully!" - - -class APUtils: +class ProfileUtility: """ constructor for Access Point Utility library : can be used from pytest framework to control Access Points """ - def __init__(self, sdk_client=None, testbed=None): + def __init__(self, sdk_client=None, testbed=None, customer_id=None): if sdk_client is None: - sdk_client = CloudSDK(testbed=testbed) + sdk_client = CloudSDK(testbed=testbed, customer_id=customer_id) self.sdk_client = sdk_client self.profile_client = swagger_client.ProfileApi(api_client=self.sdk_client.api_client) self.profile_creation_ids = { @@ -200,14 +165,52 @@ class APUtils: "radius": [], "rf": [] } + self.default_profiles = {} self.profile_ids = [] + def get_profile_by_name(self, profile_name=None): + pagination_context = """{ + "model_type": "PaginationContext", + "maxItemsPerPage": 1000 + }""" + profiles = self.profile_client.get_profiles_by_customer_id(customer_id=self.sdk_client.customer_id, + pagination_context=pagination_context) + + for i in profiles._items: + if i._name == profile_name: + return i + return None + + def get_default_profiles(self): + pagination_context = """{ + "model_type": "PaginationContext", + "maxItemsPerPage": 100 + }""" + items = self.profile_client.get_profiles_by_customer_id(customer_id=self.sdk_client.customer_id, + pagination_context=pagination_context) + + for i in items._items: + # print(i._name, i._id) + if i._name == "TipWlan-Cloud-Wifi": + self.default_profiles['ssid'] = i + if i._name == "TipWlan-3-Radios": + self.default_profiles['equipment_ap_3_radios'] = i + if i._name == "TipWlan-2-Radios": + self.default_profiles['equipment_ap_3_radios'] = i + if i._name == "Captive-Portal": + self.default_profiles['captive_portal'] = i + if i._name == "Radius-Profile": + self.default_profiles['radius'] = i + if i._name == "TipWlan-rf": + self.default_profiles['rf'] = i + """ method call: used to create the rf profile and push set the parameters accordingly and update """ - def select_rf_profile(self, profile_data=None): - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-rf") + def set_rf_profile(self, profile_data=None): + default_profile = self.default_profiles['rf'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-rf") if profile_data is None: self.profile_creation_ids['rf'].append(default_profile._id) # Need to add functionality to add similar Profile and modify accordingly @@ -219,7 +222,8 @@ class APUtils: def create_open_ssid_profile(self, two4g=True, fiveg=True, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") + default_profile = self.default_profiles['ssid'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") default_profile._details['appliedRadios'] = [] if two4g is True: default_profile._details['appliedRadios'].append("is2dot4GHz") @@ -239,7 +243,8 @@ class APUtils: def create_wpa_ssid_profile(self, two4g=True, fiveg=True, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") + default_profile = self.default_profiles['ssid'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") default_profile._details['appliedRadios'] = [] if two4g is True: default_profile._details['appliedRadios'].append("is2dot4GHz") @@ -260,7 +265,8 @@ class APUtils: def create_wpa2_personal_ssid_profile(self, two4g=True, fiveg=True, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") + default_profile = self.default_profiles['ssid'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") default_profile._details['appliedRadios'] = [] if two4g is True: default_profile._details['appliedRadios'].append("is2dot4GHz") @@ -282,7 +288,8 @@ class APUtils: def create_wpa3_personal_ssid_profile(self, two4g=True, fiveg=True, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") + default_profile = self.default_profiles['ssid'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") default_profile._details['appliedRadios'] = [] if two4g is True: default_profile._details['appliedRadios'].append("is2dot4GHz") @@ -303,7 +310,8 @@ class APUtils: def create_wpa2_enterprise_ssid_profile(self, two4g=True, fiveg=True, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") + default_profile = self.default_profiles['ssid'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") default_profile._details['appliedRadios'] = [] if two4g is True: default_profile._details['appliedRadios'].append("is2dot4GHz") @@ -323,7 +331,8 @@ class APUtils: def create_wpa3_enterprise_ssid_profile(self, two4g=True, fiveg=True, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") + default_profile = self.default_profiles['ssid'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-Cloud-Wifi") default_profile._details['appliedRadios'] = [] if two4g is True: default_profile._details['appliedRadios'].append("is2dot4GHz") @@ -348,7 +357,8 @@ class APUtils: def set_ap_profile(self, profile_data=None): if profile_data is None: return False - default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-2-Radios") + default_profile = self.default_profiles['equipment_ap_2_radios'] + # default_profile = self.sdk_client.get_profile_template(customer_id=2, profile_name="TipWlan-2-Radios") default_profile._child_profile_ids = [] for i in self.profile_creation_ids: for j in self.profile_creation_ids[i]: @@ -432,10 +442,44 @@ class APUtils: response = requests.request("PUT", url, headers=headers, data=json.dumps(equipment_info)) +class JFrogUtility: + + def __init__(self, credentials=None): + if credentials is None: + exit() + self.user = credentials["user"] + self.password = credentials["password"] + self.jfrog_url = "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + self.build = "pending" + + def list_revisions(self): + pass + + def get_latest_build(self): + pass + + if __name__ == "__main__": - sdk_client = CloudSDK(testbed="nola-ext-04") - print(sdk_client.get_equipment_by_customer_id(customer_id=2)) - sdk_client.disconnect_cloudsdk() + testbeds = ["nola-01", "nola-02", "nola-04", "nola-ext-01", "nola-ext-02", "nola-ext-03", "nola-ext-04", + "nola-ext-05"] + for i in testbeds: + sdk_client = CloudSDK(testbed=i, customer_id=2) + print(sdk_client.get_equipment_by_customer_id()) + print(sdk_client.portal_ping() is None) + break + # ap_utils = ProfileUtility(sdk_client=sdk_client) + # ap_utils.get_default_profiles() + # for j in ap_utils.default_profiles: + # print(ap_utils.default_profiles[j]._id) + + # data = sdk_client.get_equipment_by_customer_id() + # equipment_ids = [] + # for i in data: + # equipment_ids.append(i) + # print(equipment_ids[0]._details._equipment_model) + sdk_client.disconnect_cloudsdk() + time.sleep(2) + # sdk_client.get_equipment_by_customer_id(customer_id=2) # ap_utils = APUtils(sdk_client=sdk_client) # print(sdk_client.configuration.api_key_prefix) @@ -494,7 +538,6 @@ if __name__ == "__main__": # # # obj.get_profiles_by_customer_id(customer_id=2) # # # print(obj.default_profiles) - # # time.sleep(20) # # # Please change the equipment ID with the respective testbed # #ap_utils.push_profile(equipment_id=11) @@ -504,6 +547,7 @@ if __name__ == "__main__": # ap_utils.delete_profile(profile_id=ap_utils.profile_ids) + def test_open_ssid(): sdk_client = CloudSDK(testbed="nola-ext-04") ap_utils = APUtils(sdk_client=sdk_client) @@ -522,13 +566,23 @@ def test_open_ssid(): ap_utils.push_profile_old_method(equipment_id='12') sdk_client.disconnect_cloudsdk() pass + + def test_wpa_ssid(): pass + + def test_wpa2_personal_ssid(): pass + + def test_wpa3_personal_ssid(): pass + + def test_wpa2_enterprise_ssid(): pass + + def test_wpa3_enterprise_ssid(): - pass \ No newline at end of file + pass diff --git a/libs/cloudsdk/conftest.py b/libs/cloudsdk/conftest.py deleted file mode 100644 index 811b07826..000000000 --- a/libs/cloudsdk/conftest.py +++ /dev/null @@ -1,78 +0,0 @@ -# import files in the current directory -import sys -import os -sys.path.append( - os.path.dirname( - os.path.realpath( __file__ ) - ) -) - -import pytest -from configuration_data import PROFILE_DATA - -def pytest_addoption(parser): - parser.addini("jfrog-base-url", "jfrog base url") - parser.addini("jfrog-user-id", "jfrog username") - parser.addini("jfrog-user-password", "jfrog password") - parser.addini("sdk-base-url", "cloud sdk base url") - parser.addini("sdk-user-id", "cloud sdk username") - parser.addini("sdk-user-password", "cloud sdk user password") - parser.addini("sdk-customer-id", "cloud sdk customer id for the access points") - parser.addini("testrail-base-url", "testrail base url") - parser.addini("testrail-project", "testrail project name to use to generate test reports") - parser.addini("testrail-user-id", "testrail username") - parser.addini("testrail-user-password", "testrail user password") - parser.addini("lanforge-ip-address", "LANforge ip address to connect to") - parser.addini("lanforge-port-number", "LANforge port number to connect to") - parser.addini("lanforge-radio", "LANforge radio to use") - parser.addini("lanforge-ethernet-port", "LANforge ethernet adapter to use") - - # change behaviour - parser.addoption( - "--skip-update-firmware", - action="store_true", - default=False, - help="skip updating firmware on the AP (useful for local testing)" - ) - # this has to be the last argument - # example: --access-points ECW5410 EA8300-EU - parser.addoption( - "--access-points", - nargs="+", - default=[ "ECW5410" ], - help="list of access points to test" - ) - -def pytest_generate_tests(metafunc): - metafunc.parametrize("access_points", metafunc.config.getoption('--access-points'), scope="session") - -# run something after all tests are done regardless of the outcome -def pytest_unconfigure(config): - print("Tests cleanup done") - -@pytest.fixture(scope="function") -def setup_cloudsdk(request, instantiate_cloudsdk): - def fin(): - print(f"Cloud SDK cleanup for {request.node.originalname}") - request.addfinalizer(fin) - yield PROFILE_DATA[request.node.originalname] - -@pytest.fixture(scope="session") -def update_firmware(request, instantiate_jFrog, instantiate_cloudsdk, retrieve_latest_image, access_points): - if request.config.getoption("--skip-update-firmware"): - return - yield "update_firmware" - -@pytest.fixture(scope="session") -def retrieve_latest_image(request, access_points): - if request.config.getoption("--skip-update-firmware"): - return - yield "retrieve_latest_image" - -@pytest.fixture(scope="session") -def instantiate_cloudsdk(request): - yield "instantiate_cloudsdk" - -@pytest.fixture(scope="session") -def instantiate_jFrog(request): - yield "instantiate_jFrog" \ No newline at end of file diff --git a/libs/cloudsdk/pytest.ini b/libs/cloudsdk/pytest.ini deleted file mode 100644 index 12fe0d2c2..000000000 --- a/libs/cloudsdk/pytest.ini +++ /dev/null @@ -1,29 +0,0 @@ -[pytest] -addopts= --junitxml=test_everything.xml -# jFrog parameters -jfrog-base-url=tip.jFrog.io/artifactory/tip-wlan-ap-firmware -jfrog-user-id=tip-read -jfrog-user-password=tip-read -# Cloud SDK parameters -sdk-base-url=wlan-portal-svc.cicd.lab.wlan.tip.build -sdk-user-id=support@example.com -sdk-user-password=support -# Testrails parameters -testrail-base-url=telecominfraproject.testrail.com -testrail-project=opsfleet-wlan -testrail-user-id=gleb@opsfleet.com -testrail-user-password=use_command_line_to_pass_this -# LANforge -lanforge-ip-address=localhost -lanforge-port-number=8080 -lanforge-radio=wiphy4 -lanforge-ethernet-port=eth2 - -# Cloud SDK settings -sdk-customer-id=2 - -markers = - UHF: marks tests as using 2.4 ghz frequency - SHF: marks tests as using 5.0 ghz frequency - open: marks tests as using no security - wpa2: marks tests as using wpa2 security \ No newline at end of file diff --git a/libs/cloudsdk/testbed_info.py b/libs/cloudsdk/testbed_info.py index 0d519cd75..694e517bb 100644 --- a/libs/cloudsdk/testbed_info.py +++ b/libs/cloudsdk/testbed_info.py @@ -1,6 +1,7 @@ """ A set of constants describing cloud controllers properties """ +import os SDK_BASE_URLS = { "nola-01": "https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build", @@ -12,6 +13,11 @@ SDK_BASE_URLS = { } LOGIN_CREDENTIALS = { - "user_id": "support@example.com", + "userId": "support@example.com", "password": "support" +} + +JFROG_CREDENTIALS = { + "userId": os.getenv('JFROG_USER'), + "password": os.getenv('JFROG_PWD') } \ No newline at end of file diff --git a/libs/cloudsdk/.pylintrc b/tests/.pylintrc similarity index 100% rename from libs/cloudsdk/.pylintrc rename to tests/.pylintrc diff --git a/tests/Dockerfile b/tests/Dockerfile deleted file mode 100644 index 328c4c69c..000000000 --- a/tests/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM python:3.8 -WORKDIR /ci - -RUN apt update && apt install vim -y && rm -rf /var/lib/apt/lists/* -RUN pip3 install requests xlsxwriter pandas pytest - -COPY wlan-lanforge-scripts/py-json/LANforge /ci/LANforge/ -COPY wlan-lanforge-scripts/py-json/realm.py /ci/ -COPY wlan-lanforge-scripts/py-json/generic_cx.py /ci/ -COPY wlan-lanforge-scripts/py-scripts/sta_connect2.py /ci/ -COPY wlan-testing/pytest/conftest.py /ci/ -COPY wlan-testing/pytest/test* /ci/ -COPY wlan-testing/pytest/pytest.ini /ci/ -COPY wlan-testing/pytest/helpers /ci/helpers/ - -ENTRYPOINT [ "pytest" ] diff --git a/tests/EXAMPLE-USAGE.txt b/tests/EXAMPLE-USAGE.txt deleted file mode 100644 index 6a9cf30cd..000000000 --- a/tests/EXAMPLE-USAGE.txt +++ /dev/null @@ -1,35 +0,0 @@ -# This assumes you have ssh tunnels set up as suggested in ../tools/USAGE_EXAMPLES.txt - -# Attempt to run pytest against nola-12. Doesn't work, cloud is down, but of course maybe more problems too. - -pytest test_24ghz.py --testrail-user-id NONE --ap-jumphost-address localhost --ap-jumphost-port 8823 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --lanforge-ip-address localhost --lanforge-port-number 8822 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-12c" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge --access-points wf188n - - -# Run nightly against NOLA-01 - -./Nightly_Sanity.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --skip-upgrade True --testbed "NOLA-01h" \ - --lanforge-ip-address localhost --lanforge-port-number 8802 --default_ap_profile TipWlan-2-Radios \ - --skip_radius --lanforge-2g-radio 1.1.wiphy4 --lanforge-5g-radio 1.1.wiphy5 \ - --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build - - -# Run nightly against NOLA-04 from lab-ctlr itself. - -./Nightly_Sanity.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 22 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 --skip-upgrade True --testbed "NOLA-04ben" \ - --lanforge-ip-address lf4 --lanforge-port-number 8080 --default_ap_profile TipWlan-2-Radios \ - --skip_radius --lanforge-2g-radio 1.1.wiphy4 --lanforge-5g-radio 1.1.wiphy5 \ - --sdk-base-url https://wlan-portal-svc-nola-04.cicd.lab.wlan.tip.build - -# Run nightly against NOLA-04 from dev machine with ssh tunnel. - -./Nightly_Sanity.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8813 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 --skip-upgrade True --testbed "NOLA-04ben" \ - --lanforge-ip-address localhost --lanforge-port-number 8812 --default_ap_profile TipWlan-2-Radios \ - --skip_radius --lanforge-2g-radio 1.1.wiphy4 --lanforge-5g-radio 1.1.wiphy5 \ - --sdk-base-url https://wlan-portal-svc-nola-04.cicd.lab.wlan.tip.build diff --git a/tests/Nightly_Sanity.py b/tests/Nightly_Sanity.py deleted file mode 100755 index d8a96489e..000000000 --- a/tests/Nightly_Sanity.py +++ /dev/null @@ -1,487 +0,0 @@ -#!/usr/bin/python3 - -import sys - -if "libs" not in sys.path: - sys.path.append("../libs") - -from UnitTestBase import * - - -class NightlySanity: - - def __init__(self, args=None, base=None, lanforge_data=None, test=None, reporting=None, build=None): - - self.args = args - self.model = self.args.model - self.client: TestRail_Client = TestRail_Client(args) - self.logger = base.logger - self.rid = None - # Get Cloud Bearer Token - self.cloud: CloudSDK = CloudSDK(args) - cloud_type = "v1" - self.bearer = self.cloud.get_bearer(args.sdk_base_url, cloud_type) - self.customer_id = "2" - self.test = test - self.reporting = reporting - self.lanforge_data = lanforge_data - if lanforge_data is None: - exit() - self.cloud_sdk_models = { - "ec420": "EC420-G1", - "ea8300": "EA8300-CA", - "ecw5211": "ECW5211", - "ecw5410": "ECW5410", - "wf188n": "WF188N" - } - self.jfrog_build = build - self.ap_object = None - self.equipment_id = self.args.equipment_id - - self.report_data = dict() - self.ap_cli_info = get_ap_info(self.args) - self.ap_current_fw = self.ap_cli_info['active_fw'] - self.report_data = dict() - self.firmware = {} - - if self.equipment_id == "-1": - eq_id = ap_ssh_ovsh_nodec(args, 'id') - print("EQ Id: %s" % (eq_id)) - - # Now, query equipment to find something that matches. - eq = self.cloud.get_customer_equipment(self.customer_id) - for item in eq: - for e in item['items']: - print(e['id'], " ", e['inventoryId']) - if e['inventoryId'].endswith("_%s" % (eq_id)): - print("Found equipment ID: %s inventoryId: %s", - e['id'], e['inventoryId']) - self.equipment_id = str(e['id']) - if self.equipment_id == "-1": - print("ERROR: Could not find equipment-id.") - exit() - - def configure_dut(self): - - # Check for latest Firmware - latest_fw = self.jfrog_build.check_latest_fw(self.model) - if latest_fw is None: - print("AP Model doesn't match the available Models") - exit() - self.firmware = { - "latest": latest_fw, - "current": self.ap_current_fw - } - - # Create Test session - self.create_test_run_session() - key = self.args.model; # TODO: Not sure about this. - - # Check if AP needs Upgrade - if (self.firmware["current"] is not None) and self.firmware["latest"] != self.firmware["current"]: - do_upgrade = self.cloud.should_upgrade_ap_fw(self.args.force_upgrade, self.args.skip_upgrade, self.report_data, - self.firmware["latest"], - self.args.model, - self.firmware["current"], self.logger, key) - - elif (self.firmware["current"] is not None) and self.firmware["latest"] == self.firmware["current"]: - do_upgrade = False - print("AP ia already having Latest Firmware...") - - else: - print("Skipping this Profile") - exit() - - # Upgrade the Firmware on AP - if do_upgrade: - - cloud_model = self.cloud_sdk_models[self.args.model] - pf = self.cloud.do_upgrade_ap_fw(self.args, self.report_data, test_cases, self.client, - self.firmware["latest"], cloud_model, self.args.model, - self.args.jfrog_user_id, self.args.jfrog_user_password, self.rid, - self.customer_id, self.equipment_id, self.logger) - print(self.report_data) - if not pf: - exit() - - return self.firmware - - def create_test_run_session(self): - today = str(date.today()) - case_ids = list(test_cases.values()) - proj_id = self.client.get_project_id(project_name=self.args.testrail_project) - test_run_name = self.args.testrail_run_prefix + self.model + "_" + today + "_" + self.firmware["latest"] - self.client.create_testrun(name=test_run_name, case_ids=case_ids, project_id=proj_id, - milestone_id=self.args.milestone, - description="Automated Nightly Sanity test run for new firmware build") - self.rid = self.client.get_run_id(test_run_name=self.args.testrail_run_prefix + self.model + "_" + today + "_" + self.firmware["latest"]) - print("TIP run ID is:", self.rid) - - def start_test(self): - if True: - # Check AP Manager Status - manager_status = self.ap_cli_info['state'] - print(manager_status) - """ - if manager_status != "active": - print("Manager status is " + manager_status + "! Not connected to the cloud.") - print("Waiting 30 seconds and re-checking status") - time.sleep(30) - ap_cli_info = ssh_cli_active_fw(self.args) - manager_status = ap_cli_info['state'] - if manager_status != "active": - print("Manager status is", manager_status, "! Not connected to the cloud.") - print("Manager status fails multiple checks - failing test case.") - # fail cloud connectivity testcase - self.client.update_testrail(case_id=test_cases["cloud_connection"], run_id=self.rid, - status_id=5, - msg='CloudSDK connectivity failed') - self.report_data['tests'][self.model][test_cases["cloud_connection"]] = "failed" - print(self.report_data['tests'][self.model]) - - else: - print("Manager status is Active. Proceeding to connectivity testing!") - # TC522 pass in Testrail - self.client.update_testrail(case_id=test_cases["cloud_connection"], run_id=self.rid, status_id=1, - msg='Manager status is Active') - self.report_data['tests'][self.model][test_cases["cloud_connection"]] = "passed" - print(self.report_data['tests'][self.model]) - else: - print("Manager status is Active. Proceeding to connectivity testing!") - # TC5222 pass in testrail - self.client.update_testrail(case_id=test_cases["cloud_connection"], run_id=self.rid, status_id=1, - msg='Manager status is Active') - self.report_data['tests'][self.model][test_cases["cloud_connection"]] = "passed" - print(self.report_data['tests'][self.model]) - # Pass cloud connectivity test case - """ - # Update in reporting - self.reporting.update_json_report(self.report_data) - - self.ap_object = CreateAPProfiles(self.args, cloud=self.cloud, client=self.client, fw_model=self.model) - # - # # Logic to create AP Profiles (Bridge Mode) - nprefix = "%s-Nightly"%(self.args.testbed) - self.ap_object.set_ssid_psk_data(ssid_2g_wpa="%s-SSID-2G-WPA"%(nprefix), - ssid_5g_wpa="%s-SSID-5G-WPA"%(nprefix), - psk_2g_wpa="%s_2g_wpa"%(nprefix), - psk_5g_wpa="%s_5g_wpa"%(nprefix), - ssid_2g_wpa2="%s-SSID-2G-WPA2"%(nprefix), - ssid_5g_wpa2="%s-SSID-5G-WPA2"%(nprefix), - psk_2g_wpa2="%s_2g_wpa2"%(nprefix), - psk_5g_wpa2="%s_5g_wpa2"%(nprefix)) - - print("creating Profiles") - ssid_template = "TipWlan-Cloud-Wifi" - - if not self.args.skip_profiles: - if not self.args.skip_radius: - radius_name = "Automation_Radius_Nightly-01" - radius_template = "templates/radius_profile_template.json" - self.ap_object.create_radius_profile(radius_name=radius_name, radius_template=radius_template, rid=self.rid, - key=self.model) - self.ap_object.create_ssid_profiles(ssid_template=ssid_template, skip_eap=True, mode="bridge") - - print("Create AP with equipment-id: ", self.equipment_id) - self.ap_object.create_ap_profile(eq_id=self.equipment_id, fw_model=self.model, mode="bridge") - self.ap_object.validate_changes(mode="bridge") - - print("Profiles Created") - - self.test_2g(mode="bridge") - self.test_5g(mode="bridge") - - time.sleep(10) - self.reporting.update_json_report(report_data=self.ap_object.report_data) - - self.ap_object = CreateAPProfiles(self.args, cloud=self.cloud, client=self.client, fw_model=self.model) - - # Logic to create AP Profiles (NAT Mode) - self.ap_object.set_ssid_psk_data(ssid_2g_wpa="%s-SSID-NAT-2G-WPA"%(nprefix), - ssid_5g_wpa="%s-SSID-NAT-5G-WPA"%(nprefix), - psk_2g_wpa="%s_2g_nat_wpa"%(nprefix), - psk_5g_wpa="%s_5g_nat_wpa"%(nprefix), - ssid_2g_wpa2="%s-SSID-NAT-2G-WPA2"%(nprefix), - ssid_5g_wpa2="%s-SSID-NAT-5G-WPA2"%(nprefix), - psk_2g_wpa2="%s_2g_nat_wpa2"%(nprefix), - psk_5g_wpa2="%s_5g_nat_wpa2"%(nprefix)) - - print("creating Profiles") - ssid_template = "TipWlan-Cloud-Wifi" - - if not self.args.skip_profiles: - if not self.args.skip_radius: - # Radius Profile needs to be set here - # obj.create_radius_profile(radius_name, rid, key) - pass - self.ap_object.create_ssid_profiles(ssid_template=ssid_template, mode="nat") - - print("Create AP with equipment-id: ", self.equipment_id) - self.ap_object.create_ap_profile(eq_id=self.equipment_id, fw_model=self.model, mode="nat") - self.ap_object.validate_changes(mode="nat") - - self.test_2g(mode="nat") - self.test_5g(mode="nat") - time.sleep(10) - self.reporting.update_json_report(report_data=self.ap_object.report_data) - - def setup_report(self): - - self.report_data["cloud_sdk"] = dict.fromkeys(ap_models, "") - for key in self.report_data["cloud_sdk"]: - self.report_data["cloud_sdk"][key] = { - "date": "N/A", - "commitId": "N/A", - "projectVersion": "N/A" - } - self.report_data["fw_available"] = dict.fromkeys(ap_models, "Unknown") - self.report_data["fw_under_test"] = dict.fromkeys(ap_models, "N/A") - self.report_data['pass_percent'] = dict.fromkeys(ap_models, "") - - self.report_data['tests'] = dict.fromkeys(ap_models, "") - for key in ap_models: - self.report_data['tests'][key] = dict.fromkeys(test_cases.values(), "not run") - - print(self.report_data) - - self.reporting.update_json_report(report_data=self.report_data) - - def test_2g(self, mode="bridge"): - - if not self.args.skip_radius: - # Run Client Single Connectivity Test Cases for Bridge SSIDs - # TC5214 - 2.4 GHz WPA2-Enterprise - test_case = test_cases["2g_eap_" + mode] - radio = command_line_args.lanforge_2g_radio - sta_list = [lanforge_prefix + "5214"] - ssid_name = ssid_2g_eap; - security = "wpa2" - eap_type = "TTLS" - try: - test_result = self.test.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, - identity, ttls_password, test_case, rid, client, logger) - except: - test_result = "error" - self.test.testrail_retest(test_case, rid, ssid_name, client, logger) - pass - report_data['tests'][key][int(test_case)] = test_result - print(report_data['tests'][key]) - - time.sleep(10) - - # Run Client Single Connectivity Test Cases for Bridge SSIDs - # TC - 2.4 GHz WPA2 - test_case = test_cases["2g_wpa2_" + mode] - station = [self.lanforge_data['prefix'] + "2237"] - ssid_name = self.ap_object.ssid_data['2g']['wpa2'][mode] - ssid_psk = self.ap_object.psk_data['2g']['wpa2'][mode] - security = "wpa2" - upstream_port = "eth2" - print(self.lanforge_data['port']) - - try: - test_result = self.test.Single_Client_Connectivity(upstream_port=upstream_port, - radio=self.lanforge_data['2g_radio'], - ssid=ssid_name, - passkey=ssid_psk, - security=security, - station_name=station, test_case=test_case, rid=self.rid, - client=self.client, logger=self.logger) - except: - test_result = "error" - self.test.testrail_retest(test_case, self.rid, ssid_name, self.client, self.logger) - pass - self.report_data['tests'][self.model][int(test_case)] = test_result - print(self.report_data['tests'][self.model]) - - time.sleep(10) - - # TC - 2.4 GHz WPA - test_case = test_cases["2g_wpa_" + mode] - station = [self.lanforge_data['prefix'] + "2420"] - ssid_name = self.ap_object.ssid_data['2g']['wpa'][mode] - ssid_psk = self.ap_object.psk_data['2g']['wpa'][mode] - security = "wpa" - upstream_port = "eth2" - print(self.lanforge_data['port']) - try: - test_result = self.test.Single_Client_Connectivity(upstream_port=upstream_port, - radio=self.lanforge_data['2g_radio'], - ssid=ssid_name, - passkey=ssid_psk, - security=security, - station_name=station, test_case=test_case, rid=self.rid, - client=self.client, logger=self.logger) - except: - test_result = "error" - self.test.testrail_retest(test_case, self.rid, ssid_name, self.client, self.logger) - pass - self.report_data['tests'][self.model][int(test_case)] = test_result - print(self.report_data['tests'][self.model]) - - time.sleep(10) - - def test_5g(self, mode="bridge"): - if not self.args.skip_radius: - # TC - 5 GHz WPA2-Enterprise - test_case = self.test_cases["5g_eap_" + mode] - radio = lanforge_5g_radio - sta_list = [lanforge_prefix + "5215"] - ssid_name = ssid_5g_eap - security = "wpa2" - eap_type = "TTLS" - try: - test_result = Test.Single_Client_EAP(port, sta_list, ssid_name, radio, security, eap_type, - identity, ttls_password, test_case, rid, client, logger) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name, client, logger) - pass - report_data['tests'][key][int(test_case)] = test_result - print(report_data['tests'][key]) - - time.sleep(10) - - # TC 5 GHz WPA2 - test_case = test_cases["5g_wpa2_" + mode] - station = [self.lanforge_data['prefix'] + "2236"] - ssid_name = self.ap_object.ssid_data['5g']['wpa2'][mode] - ssid_psk = self.ap_object.psk_data['5g']['wpa2'][mode] - security = "wpa2" - upstream_port = "eth2" - try: - test_result = self.test.Single_Client_Connectivity(upstream_port=upstream_port, - radio=self.lanforge_data['5g_radio'], - ssid=ssid_name, - passkey=ssid_psk, - security=security, - station_name=station, test_case=test_case, rid=self.rid, - client=self.client, logger=self.logger) - except: - test_result = "error" - self.test.testrail_retest(test_case, self.rid, ssid_name, self.client, self.logger) - pass - self.report_data['tests'][self.model][int(test_case)] = test_result - print(self.report_data['tests'][self.model]) - - time.sleep(10) - - # # TC - 5 GHz WPA - test_case = test_cases["5g_wpa_" + mode] - station = [self.lanforge_data['prefix'] + "2419"] - ssid_name = self.ap_object.ssid_data['5g']['wpa'][mode] - ssid_psk = self.ap_object.psk_data['5g']['wpa'][mode] - security = "wpa" - upstream_port = "eth2" - try: - test_result = self.test.Single_Client_Connectivity(upstream_port=upstream_port, - radio=self.lanforge_data['5g_radio'], - ssid=ssid_name, - passkey=ssid_psk, - security=security, - station_name=station, test_case=test_case, rid=self.rid, - client=self.client, logger=self.logger) - except: - test_result = "error" - self.test.testrail_retest(test_case, self.rid, ssid_name, self.client, self.logger) - pass - self.report_data['tests'][self.model][int(test_case)] = test_result - print(self.report_data['tests'][self.model]) - - time.sleep(10) - - -def main(): - parser = argparse.ArgumentParser(description="Nightly Combined Tests", add_help=False) - parser.add_argument("--default_ap_profile", type=str, - help="Default AP profile to use as basis for creating new ones, typically: TipWlan-2-Radios or TipWlan-3-Radios", - required=True) - parser.add_argument("--skip_radius", dest="skip_radius", action='store_true', - help="Should we skip the RADIUS configs or not") - parser.add_argument("--skip_profiles", dest="skip_profiles", action='store_true', - help="Should we skip applying profiles?") - parser.add_argument("--skip_wpa", dest="skip_wpa", action='store_false', - help="Should we skip applying profiles?") - parser.add_argument("--skip_wpa2", dest="skip_wpa2", action='store_false', - help="Should we skip applying profiles?") - parser.add_argument("--skip_eap", dest="skip_eap", action='store_false', - help="Should we skip applying profiles?") - - reporting = Reporting(reports_root=os.getcwd() + "/reports/") - base = UnitTestBase("query-sdk", parser, reporting) - command_line_args = base.command_line_args - - # cmd line takes precedence over env-vars. - cloudsdk_url = command_line_args.sdk_base_url # was os.getenv('CLOUD_SDK_URL') - - local_dir = command_line_args.local_dir # was os.getenv('SANITY_LOG_DIR') - report_path = command_line_args.report_path # was os.getenv('SANITY_REPORT_DIR') - report_template = command_line_args.report_template # was os.getenv('REPORT_TEMPLATE') - - # TestRail Information - tr_user = command_line_args.testrail_user_id # was os.getenv('TR_USER') - tr_pw = command_line_args.testrail_user_password # was os.getenv('TR_PWD') - milestone_id = command_line_args.milestone # was os.getenv('MILESTONE') - project_id = command_line_args.testrail_project # was os.getenv('PROJECT_ID') - test_run_prefix = command_line_args.testrail_run_prefix # os.getenv('TEST_RUN_PREFIX') - - # Jfrog credentials - jfrog = { - "user": command_line_args.jfrog_user_id, # was os.getenv('JFROG_USER') - "pass": command_line_args.jfrog_user_password # was os.getenv('JFROG_PWD') - } - - # EAP Credentials - eap_cred = { - "identity": command_line_args.eap_id, - "ttls_password": command_line_args.ttls_password - } - - # AP Credentials - ap_cred = { - "username": command_line_args.ap_username - } - - # LANForge Information - lanforge = { - "ip": command_line_args.lanforge_ip_address, - "port": command_line_args.lanforge_port_number, - "prefix": command_line_args.lanforge_prefix, - "2g_radio": command_line_args.lanforge_2g_radio, - "5g_radio": command_line_args.lanforge_5g_radio - } - - build = command_line_args.build_id - - logger = base.logger - hdlr = base.hdlr - - if command_line_args.testbed is None: - print("ERROR: Must specify --testbed argument for this test.") - sys.exit(1) - - print("Start of Sanity Testing...") - print("Testing Latest Build with Tag: " + build) - if command_line_args.skip_upgrade: - print("Will skip upgrading AP firmware...") - - # Testrail Project and Run ID Information - - test = RunTest(lanforge_ip=lanforge["ip"], lanforge_port=lanforge["port"], lanforge_prefix=lanforge["prefix"]) - - build_obj = GetBuild(jfrog['user'], jfrog['pass'], build) - - # sanity_status = json.load(open("sanity_status.json")) - obj = NightlySanity(args=command_line_args, base=base, lanforge_data=lanforge, test=test, reporting=reporting, - build=build_obj) - obj.configure_dut() - - proj_id = obj.client.get_project_id(project_name=project_id) - print("TIP WLAN Project ID is:", proj_id) - logger.info('Start of Nightly Sanity') - obj.setup_report() - obj.start_test() - - -if __name__ == "__main__": - main() diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index 515f4c7e3..000000000 --- a/tests/README.md +++ /dev/null @@ -1,2 +0,0 @@ -## Testcases -This directory contains the automated test cases for the TIP Open Wi-Fi Solution diff --git a/tests/Throughput_Test.py b/tests/Throughput_Test.py deleted file mode 100755 index cffcf93f0..000000000 --- a/tests/Throughput_Test.py +++ /dev/null @@ -1,530 +0,0 @@ -import csv -import sys -import time -import datetime -from datetime import date -import json -import os -import logging - -import single_client_throughput -import cloudsdk -from cloudsdk import CloudSDK -import lab_ap_info - -cloudSDK_url=os.getenv('CLOUD_SDK_URL') -station = ["tput5000"] -runtime = 10 -csv_path=os.getenv('CSV_PATH') -bridge_upstream_port = "eth2" -nat_upstream_port = "eth2" -vlan_upstream_port = "vlan100" - -#EAP Credentials -identity=os.getenv('EAP_IDENTITY') -ttls_password=os.getenv('EAP_PWD') - -local_dir=os.getenv('TPUT_LOG_DIR') -logger = logging.getLogger('Throughput_Test') -hdlr = logging.FileHandler(local_dir+"/Throughput_Testing.log") -formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') -hdlr.setFormatter(formatter) -logger.addHandler(hdlr) -logger.setLevel(logging.INFO) - - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append('../../py-json') - -def throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput): - #parse client_tput list returned from single_client_throughput - udp_ds = client_tput[0].partition(": ")[2] - udp_us = client_tput[1].partition(": ")[2] - tcp_ds = client_tput[2].partition(": ")[2] - tcp_us = client_tput[3].partition(": ")[2] - # Find band for CSV ---> This code is not great, it SHOULD get that info from LANForge! - if "5G" in ssid_name: - frequency = "5 GHz" - elif "2dot4G" in ssid_name: - frequency = "2.4 GHz" - else: - frequency = "Unknown" - # Append row to top of CSV file - row = [ap_model, firmware, frequency, mimo, security, mode, udp_ds, udp_us, tcp_ds, tcp_us] - with open(csv_file, 'r') as readFile: - reader = csv.reader(readFile) - lines = list(reader) - lines.insert(1, row) - with open(csv_file, 'w') as writeFile: - writer = csv.writer(writeFile) - writer.writerows(lines) - readFile.close() - writeFile.close() - -#Import dictionaries for AP Info -from lab_ap_info import equipment_id_dict -from lab_ap_info import profile_info_dict -from lab_ap_info import ap_models -from lab_ap_info import mimo_2dot4g -from lab_ap_info import mimo_5g -from lab_ap_info import customer_id -from lab_ap_info import cloud_type -#import json file to determine if throughput should be run for specific AP model -sanity_status = json.load(open("sanity_status.json")) - -#create CSV file for test run -today = str(date.today()) -csv_file = csv_path+"throughput_test_"+today+".csv" -headers = ['AP Type', 'Firmware','Radio', 'MIMO', 'Security', 'Mode', 'UDP Downstream (Mbps)', 'UDP Upstream (Mbps)', 'TCP Downstream (Mbps)', 'TCP Upstream (Mbps)'] -with open(csv_file, "w") as file: - create = csv.writer(file) - create.writerow(headers) - file.close() - -ap_firmware_dict = { - "ea8300": '', - "ecw5211": '', - "ecw5410": '', - "ec420": '' -} - -logger.info('Start of Throughput Test') - -for key in equipment_id_dict: - if sanity_status['sanity_status'][key] == "passed": - logger.info("Running throughput test on " + key) - ##Get Bearer Token to make sure its valid (long tests can require re-auth) - bearer = CloudSDK.get_bearer(cloudSDK_url, cloud_type) - ###Get Current AP Firmware - equipment_id = equipment_id_dict[key] - ap_fw = CloudSDK.ap_firmware(customer_id, equipment_id, cloudSDK_url, bearer) - fw_model = ap_fw.partition("-")[0] - print("AP MODEL UNDER TEST IS", fw_model) - print('Current AP Firmware:', ap_fw) - ##add current FW to dictionary - ap_firmware_dict[fw_model] = ap_fw - - ########################################################################### - ############## Bridge Throughput Testing ################################# - ########################################################################### - print("Testing for Bridge SSIDs") - logger.info("Starting Brdige SSID tput tests on " + key) - ###Set Proper AP Profile for Bridge SSID Tests - test_profile_id = profile_info_dict[fw_model]["profile_id"] - #print(test_profile_id) - ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer) - ### Wait for Profile Push - print('-----------------PROFILE PUSH -------------------') - time.sleep(180) - - ##Set port for LANForge - port = bridge_upstream_port - - # 5G WPA2 Enterprise UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - sta_list = station - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model]["fiveG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - mode = "Bridge" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port) - print(fw_model, "5 GHz WPA2-EAP throughput:\n", client_tput) - security = "wpa2-eap" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - #5G WPA2 UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model]["fiveG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] - security = "wpa2" - mode = "Bridge" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "5 GHz WPA2 throughput:\n",client_tput) - security = "wpa2-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G WPA UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model]["fiveG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] - security = "wpa" - mode = "Bridge" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "5 GHz WPA throughput:\n",client_tput) - security = "wpa-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G Open UDP DS/US and TCP DS/US - # ap_model = fw_model - # firmware = ap_fw - # radio = lab_ap_info.lanforge_5g - # ssid_name = profile_info_dict[fw_model]["fiveG_OPEN_SSID"] - # ssid_psk = "BLANK" - # security = "open" - #mode = "Bridge" - #mimo = mimo_5g[fw_model] - # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - #print(fw_model, "5 GHz Open throughput:\n",client_tput) - #throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA2 Enterprise UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - sta_list = station - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model]["twoFourG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - mode = "Bridge" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, - ttls_password, port) - print(fw_model, "2.4 GHz WPA2-EAP throughput:\n", client_tput) - security = "wpa2-eap" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA2 UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model]["twoFourG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA2_PSK"] - security = "wpa2" - mode = "Bridge" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "2.4 GHz WPA2 throughput:\n",client_tput) - security = "wpa2-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model]["twoFourG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA_PSK"] - security = "wpa" - mode = "Bridge" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "2.4 GHz WPA throughput:\n",client_tput) - security = "wpa-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G Open UDP DS/US and TCP DS/US - #ap_model = fw_model - #firmware = ap_fw - # radio = lab_ap_info.lanforge_5g - # ssid_name = profile_info_dict[fw_model]["twoFourG_OPEN_SSID"] - # ssid_psk = "BLANK" - # security = "open" - #mode = "Bridge" - #mimo = mimo_2dot4g[fw_model] - #client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - #print(fw_model, "2.4 GHz Open throughput:\n",client_tput) - #throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - ########################################################################### - ################# NAT Mode Throughput Testing ############################ - ########################################################################### - print('Testing for NAT SSIDs') - logger.info("Starting NAT SSID tput tests on " + key) - ###Set Proper AP Profile for NAT SSID Tests - test_profile_id = profile_info_dict[fw_model + '_nat']["profile_id"] - print(test_profile_id) - ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer) - - ### Wait for Profile Push - print('-----------------PROFILE PUSH -------------------') - time.sleep(180) - - ##Set port for LANForge - port = nat_upstream_port - - # 5G WPA2 Enterprise UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - sta_list = station - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model+'_nat']["fiveG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - mode = "NAT" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, - ttls_password, port) - print(fw_model, "5 GHz WPA2-EAP NAT throughput:\n", client_tput) - security = "wpa2-eap" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G WPA2 NAT UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model+'_nat']["fiveG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model+'_nat']["fiveG_WPA2_PSK"] - security = "wpa2" - mode = "NAT" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "5 GHz WPA2 NAT throughput:\n", client_tput) - security = "wpa2-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G WPA UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model+'_nat']["fiveG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model+'_nat']["fiveG_WPA_PSK"] - security = "wpa" - mode = "NAT" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "5 GHz WPA NAT throughput:\n", client_tput) - security = "wpa-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G Open UDP DS/US and TCP DS/US - # ap_model = fw_model - # firmware = ap_fw - # radio = lab_ap_info.lanforge_5g - # ssid_name = profile_info_dict[fw_model+'_nat']["fiveG_OPEN_SSID"] - # ssid_psk = "BLANK" - # security = "open" - # mode = "NAT" - #mimo = mimo_5g[fw_model] - # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - # print(fw_model, "5 GHz Open NAT throughput:\n",client_tput) - # throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA2 Enterprise UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - sta_list = station - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model+'_nat']["twoFourG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - mode = "NAT" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port) - print(fw_model, "2.4 GHz WPA2-EAP NAT throughput:\n", client_tput) - security = "wpa2-eap" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA2 UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model+'_nat']["twoFourG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model+'_nat']["twoFourG_WPA2_PSK"] - security = "wpa2" - mode = "NAT" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "2.4 GHz WPA2 NAT throughput:\n", client_tput) - security = "wpa2-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model+'_nat']["twoFourG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model+'_nat']["twoFourG_WPA_PSK"] - security = "wpa" - mode = "NAT" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "2.4 GHz WPA NAT throughput:\n", client_tput) - security = "wpa-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G Open NAT UDP DS/US and TCP DS/US - # ap_model = fw_model - # firmware = ap_fw - # radio = lab_ap_info.lanforge_5g - # ssid_name = profile_info_dict[fw_model+'_nat']["twoFourG_OPEN_SSID"] - # ssid_psk = "BLANK" - # security = "open" - # mode = "NAT" - #mimo = mimo_2dot4g[fw_model] - # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - # print(fw_model, "2.4 GHz Open NAT throughput:\n",client_tput) - # throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - ########################################################################### - ################# Custom VLAN Mode Throughput Testing ##################### - ########################################################################### - print('Testing for Custom VLAN SSIDs') - logger.info("Starting Custom VLAN SSID tput tests on " + key) - ###Set Proper AP Profile for NAT SSID Tests - test_profile_id = profile_info_dict[fw_model + '_vlan']["profile_id"] - print(test_profile_id) - ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer) - - ### Wait for Profile Push - print('-----------------PROFILE PUSH -------------------') - time.sleep(180) - - ##Set port for LANForge - port = vlan_upstream_port - - # 5G WPA2 Enterprise UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - sta_list = station - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - mode = "VLAN" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port) - print(fw_model, "5 GHz WPA2-EAP VLAN throughput:\n", client_tput) - security = "wpa2-eap" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G WPA2 VLAN UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_PSK"] - security = "wpa2" - mode = "VLAN" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "5 GHz WPA2 VLAN throughput:\n", client_tput) - security = "wpa2-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G WPA UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_5g - ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model + '_vlan']["fiveG_WPA_PSK"] - security = "wpa" - mode = "VLAN" - mimo = mimo_5g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "5 GHz WPA VLAN throughput:\n", client_tput) - security = "wpa-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 5G Open UDP DS/US and TCP DS/US - # ap_model = fw_model - # firmware = ap_fw - # radio = lab_ap_info.lanforge_5g - # ssid_name = profile_info_dict[fw_model+'_vlan']["fiveG_OPEN_SSID"] - # ssid_psk = "BLANK" - # security = "open" - # mode = "VLAN" - # mimo = mimo_5g[fw_model] - # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - # print(fw_model, "5 GHz Open VLAN throughput:\n",client_tput) - # throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA2 Enterprise UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - sta_list = station - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - mode = "VLAN" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, port) - print(fw_model, "2.4 GHz WPA2-EAP VLAN throughput:\n", client_tput) - security = "wpa2-eap" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA2 UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_PSK"] - security = "wpa2" - mode = "VLAN" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "2.4 GHz WPA2 VLAN throughput:\n", client_tput) - security = "wpa2-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G WPA UDP DS/US and TCP DS/US - ap_model = fw_model - firmware = ap_fw - radio = lab_ap_info.lanforge_2dot4g - ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_PSK"] - security = "wpa" - mode = "VLAN" - mimo = mimo_2dot4g[fw_model] - client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - print(fw_model, "2.4 GHz WPA VLAN throughput:\n", client_tput) - security = "wpa-psk" - throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - # 2.4G Open VLAN UDP DS/US and TCP DS/US - # ap_model = fw_model - # firmware = ap_fw - # radio = lab_ap_info.lanforge_5g - # ssid_name = profile_info_dict[fw_model+'_vlan']["twoFourG_OPEN_SSID"] - # ssid_psk = "BLANK" - # security = "open" - # mode = "VLAN" - # mimo = mimo_2dot4g[fw_model] - # client_tput = single_client_throughput.main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, port) - # print(fw_model, "2.4 GHz Open VLAN throughput:\n",client_tput) - # throughput_csv(csv_file, ssid_name, ap_model, mimo, firmware, security, mode, client_tput) - - - #Indicates throughput has been run for AP model - sanity_status['sanity_status'][key] = "tput run" - logger.info("Trhoughput tests complete on " + key) - - elif sanity_status['sanity_status'][key] == "tput run": - print("Throughput test already run on", key) - logger.info("Throughput test already run on "+ key +" for latest AP FW") - - else: - print(key,"did not pass Nightly Sanity. Skipping throughput test on this AP Model") - logger.info(key+" did not pass Nightly Sanity. Skipping throughput test.") - -#Indicate which AP model has had tput test to external json file -with open('sanity_status.json', 'w') as json_file: - json.dump(sanity_status, json_file) - -with open(csv_file, 'r') as readFile: - reader = csv.reader(readFile) - lines = list(reader) - row_count = len(lines) - #print(row_count) - -if row_count <= 1: - os.remove(csv_file) - file.close() - -else: - print("Saving File") - file.close() - -print(" -- Throughput Testing Complete -- ") diff --git a/tests/UnitTestBase.py b/tests/UnitTestBase.py deleted file mode 100644 index d791c9a8a..000000000 --- a/tests/UnitTestBase.py +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/python3 - -import sys - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -for folder in 'py-json', 'py-scripts': - if folder not in sys.path: - sys.path.append(f'../lanforge/lanforge-scripts/{folder}') - -sys.path.append(f'../libs/lanforge') -sys.path.append(f'../libs/testrails') -sys.path.append(f'../libs/apnos') -sys.path.append(f'../libs/cloudsdk') -sys.path.append(f'../libs') -sys.path.append(f'../tests/test_utility/') - -import base64 -import urllib.request -from bs4 import BeautifulSoup -import ssl -import subprocess, os -from artifactory import ArtifactoryPath -import tarfile -import paramiko -from paramiko import SSHClient -from scp import SCPClient -import os -import pexpect -from pexpect import pxssh - -import paramiko -from scp import SCPClient -import pprint -from pprint import pprint -from os import listdir -import re -import requests -import json -import logging -import datetime -import time -from datetime import date -from shutil import copyfile -import argparse -from unittest.mock import Mock -from lf_tests import * -from ap_plus_sdk import * -from lab_ap_info import * -from JfrogHelper import * -from reporting import Reporting - -# For finding files -# https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory -import glob - -# external_results_dir=/var/tmp/lanforge - -# To run this from your home system to NOLA-01 testbed, use this command. This assumes you have set up an ssh tunnel -# logged to the cicd jumphost that can reach the lab. In separate console to set up the ssh tunnel: ssh -C -L -# 7220:lab-ctlr:22 ubuntu@3.130.51.163 On local machine: -# ./query_ssids.py --testrail-user-id NONE --model ecw5410 -# --ap-jumphost-address localhost --ap-jumphost-port 7220 --ap-jumphost-password secret --ap-jumphost-tty /dev/ttyAP1 - - -import testrail_api - -from LANforge.LFUtils import * - -# if you lack __init__.py in this directory you will not find sta_connect module# - -import sta_connect2 -from sta_connect2 import StaConnect2 -import testrail_api -from testrail_api import TestRail_Client -import eap_connect -from eap_connect import EAPConnect -import cloudsdk -from cloudsdk import CloudSDK -from cloudsdk import CreateAPProfiles -import ap_ssh -from ap_ssh import * - -# Import info for lab setup and APs under test -import lab_ap_info -from lab_ap_info import cloud_sdk_models -from lab_ap_info import ap_models -from lab_ap_info import customer_id -from lab_ap_info import cloud_type -from lab_ap_info import test_cases -from lab_ap_info import radius_info - -# keep in sync with that below. -def add_base_parse_args(parser): - parser.add_argument("-b", "--build-id", type=str, - help="FW commit ID (latest pending build on dev is default)", - default="pending") - parser.add_argument("--skip-upgrade", type=bool, help="Skip upgrading firmware", - default=False) - parser.add_argument("--force-upgrade", type=bool, - help="Force upgrading firmware even if it is already current version", - default=False) - parser.add_argument("-m", "--model", type=str, - choices=['ea8300', 'ecw5410', 'ecw5211', 'ec420', 'wf188n', 'eap102', 'eap101', 'cig194c', 'None'], - help="AP model to be run", required=True) - parser.add_argument("--equipment-id", type=str, - help="AP model ID, as exists in the cloud-sdk. -1 to auto-detect.", - default="-1") - parser.add_argument("--object-id", type=str, - help="Used when querying and deleting individual objects.", - default=None) - parser.add_argument("--customer-id", type=str, - help="Specify cloud customer-id, default is 2", - default="2") - parser.add_argument("--testbed", type=str, - help="Testbed name, will be prefixed to profile names and similar", - default=None) - - parser.add_argument("--sdk-base-url", type=str, - help="cloudsdk base url, default: https://wlan-portal-svc.cicd.lab.wlan.tip.build", - default="https://wlan-portal-svc.cicd.lab.wlan.tip.build") - parser.add_argument("--sdk-user-id", type=str, help="cloudsdk user id, default: support@example.conf", - default="support@example.com") - parser.add_argument("--sdk-user-password", type=str, help="cloudsdk user password, default: support", - default="support") - - parser.add_argument("--jfrog-base-url", type=str, help="jfrog base url", - default="tip.jFrog.io/artifactory/tip-wlan-ap-firmware") - parser.add_argument("--jfrog-user-id", type=str, help="jfrog user id", - default="tip-read") - parser.add_argument("--jfrog-user-password", type=str, help="jfrog user password", - default="tip-read") - - parser.add_argument("--testrail-base-url", type=str, help="testrail base url", - # was os.getenv('TESTRAIL_URL') - default="https://telecominfraproject.testrail.com") - parser.add_argument("--testrail-project", type=str, help="testrail project name", - default="opsfleet-wlan") - parser.add_argument("--testrail-user-id", type=str, - help="testrail user id. Use 'NONE' to disable use of testrails.", - default="NONE") - parser.add_argument("--testrail-user-password", type=str, help="testrail user password", - default="password") - parser.add_argument("--testrail-run-prefix", type=str, help="testrail run prefix", - default="prefix-1") - parser.add_argument("--testrail-milestone", dest="milestone", type=str, help="testrail milestone ID", - default="milestone-1") - - parser.add_argument("--lanforge-ip-address", type=str, help="ip address of the lanforge gui", - default="127.0.0.1") - parser.add_argument("--lanforge-port-number", type=str, help="port of the lanforge gui", - default="8080") - parser.add_argument("--lanforge-prefix", type=str, help="LANforge api prefix string", - default="sdk") - parser.add_argument("--lanforge-2g-radio", type=str, help="LANforge 2Ghz radio to use for testing", - default="1.1.wiphy0") - parser.add_argument("--lanforge-5g-radio", type=str, help="LANforge 5Ghz radio to use for testing", - default="1.1.wiphy1") - - parser.add_argument("--local_dir", type=str, help="Sanity logging directory", - default="logs") - parser.add_argument("--report-path", type=str, help="Sanity report directory", - default="reports") - parser.add_argument("--report-template", type=str, help="Sanity report template", - default="reports/report_template.php") - - parser.add_argument("--eap-id", type=str, help="EAP indentity", - default="lanforge") - parser.add_argument("--ttls-password", type=str, help="TTLS password", - default="lanforge") - - parser.add_argument("--ap-ip", type=str, help="AP IP Address, for direct ssh access if not using jumphost", - default="127.0.0.1") - parser.add_argument("--ap-username", type=str, help="AP username", - default="root") - parser.add_argument("--ap-password", type=str, help="AP password", - default="root") - parser.add_argument("--ap-jumphost-address", type=str, - help="IP of system that we can ssh in to get serial console access to AP", - default=None) - parser.add_argument("--ap-jumphost-port", type=str, - help="SSH port to use in case we are using ssh tunneling or other non-standard ports", - default="22") - parser.add_argument("--ap-jumphost-username", type=str, - help="User-ID for system that we can ssh in to get serial console access to AP", - default="lanforge") - parser.add_argument("--ap-jumphost-password", type=str, - help="Passwort for system that we can ssh in to get serial console access to AP", - default="lanforge") - parser.add_argument("--ap-jumphost-wlan-testing", type=str, help="wlan-testing repo dir on the jumphost", - default="git/wlan-testing") - parser.add_argument("--ap-jumphost-tty", type=str, help="Serial port for the AP we wish to talk to", - default="UNCONFIGURED-JUMPHOST-TTY") - - parser.add_argument('--skip-update-firmware', dest='update_firmware', action='store_false') - parser.set_defaults(update_firmware=True) - - parser.add_argument('--verbose', dest='verbose', action='store_true') - parser.set_defaults(verbose=False) - - -# Keep in sync with that above -def add_base_parse_args_pytest(parser): - parser.addoption("--default-ap-profile", type=str, - help="Default AP profile to use as basis for creating new ones, typically: TipWlan-2-Radios or TipWlan-3-Radios", - default="TipWlan-2-Radios") - parser.addoption("--skip-radius", dest="skip_radius", action='store_true', - help="Should we skip the RADIUS configs or not") - parser.addoption("--skip-profiles", dest="skip_profiles", action='store_true', - help="Should we skip applying profiles?") - parser.addoption("--skip-wpa", dest="skip_wpa", action='store_false', - help="Should we skip applying profiles?") - parser.addoption("--skip-wpa2", dest="skip_wpa2", action='store_false', - help="Should we skip applying profiles?") - - parser.addoption("--psk-5g-wpa2", dest="psk_5g_wpa2", type=str, - help="Allow over-riding the 5g-wpa2 PSK value.") - parser.addoption("--psk-5g-wpa", dest="psk_5g_wpa", type=str, - help="Allow over-riding the 5g-wpa PSK value.") - parser.addoption("--psk-2g-wpa2", dest="psk_2g_wpa2", type=str, - help="Allow over-riding the 2g-wpa2 PSK value.") - parser.addoption("--psk-2g-wpa", dest="psk_2g_wpa", type=str, - help="Allow over-riding the 2g-wpa PSK value.") - - parser.addoption("--ssid-5g-wpa2", dest="ssid_5g_wpa2", type=str, - help="Allow over-riding the 5g-wpa2 SSID value.") - parser.addoption("--ssid-5g-wpa", dest="ssid_5g_wpa", type=str, - help="Allow over-riding the 5g-wpa SSID value.") - parser.addoption("--ssid-2g-wpa2", dest="ssid_2g_wpa2", type=str, - help="Allow over-riding the 2g-wpa2 SSID value.") - parser.addoption("--ssid-2g-wpa", dest="ssid_2g_wpa", type=str, - help="Allow over-riding the 2g-wpa SSID value.") - - parser.addoption("--mode", dest="mode", choices=['bridge', 'nat', 'vlan'], type=str, - help="Mode of AP Profile [bridge/nat/vlan]", default="bridge") - - parser.addoption("--build-id", type=str, - help="FW commit ID (latest pending build on dev is default)", - default="pending") - parser.addoption("--skip-upgrade", type=bool, help="Skip upgrading firmware", - default=False) - parser.addoption("--force-upgrade", type=bool, - help="Force upgrading firmware even if it is already current version", - default=False) - # --access-points instead - # parser.addoption("--model", type=str, - # choices=['ea8300', 'ecw5410', 'ecw5211', 'ec420', 'wf188n', 'eap102', 'None'], - # help="AP model to be run", required=True) - parser.addoption("--equipment-id", type=str, - help="AP model ID, as exists in the cloud-sdk. -1 to auto-detect.", - default="-1") - parser.addoption("--object-id", type=str, - help="Used when querying and deleting individual objects.", - default=None) - parser.addoption("--customer-id", type=str, - help="Specify cloud customer-id, default is 2", - default="2") - parser.addoption("--testbed", type=str, - help="Testbed name, will be prefixed to profile names and similar", - default=None) - - parser.addoption("--sdk-base-url", type=str, - help="cloudsdk base url, default: https://wlan-portal-svc.cicd.lab.wlan.tip.build", - default="https://wlan-portal-svc.cicd.lab.wlan.tip.build") - parser.addoption("--sdk-user-id", type=str, help="cloudsdk user id, default: support@example.conf", - default="support@example.com") - parser.addoption("--sdk-user-password", type=str, help="cloudsdk user password, default: support", - default="support") - - parser.addoption("--jfrog-base-url", type=str, help="jfrog base url", - default="tip.jFrog.io/artifactory/tip-wlan-ap-firmware") - parser.addoption("--jfrog-user-id", type=str, help="jfrog user id", - default="tip-read") - parser.addoption("--jfrog-user-password", type=str, help="jfrog user password", - default="tip-read") - - parser.addoption("--testrail-base-url", type=str, help="testrail base url", - # was os.getenv('TESTRAIL_URL') - default="https://telecominfraproject.testrail.com") - parser.addoption("--testrail-project", type=str, help="testrail project name", - default="opsfleet-wlan") - parser.addoption("--testrail-user-id", type=str, - help="testrail user id. Use 'NONE' to disable use of testrails.", - default="NONE") - parser.addoption("--testrail-user-password", type=str, help="testrail user password", - default="password") - parser.addoption("--testrail-run-prefix", type=str, help="testrail run prefix", - default="prefix-1") - parser.addoption("--testrail-milestone", dest="milestone", type=str, help="testrail milestone ID", - default="milestone-1") - - parser.addoption("--lanforge-ip-address", type=str, help="ip address of the lanforge gui", - default="127.0.0.1") - parser.addoption("--lanforge-port-number", type=str, help="port of the lanforge gui", - default="8080") - parser.addoption("--lanforge-prefix", type=str, help="LANforge api prefix string", - default="sdk") - parser.addoption("--lanforge-2g-radio", type=str, help="LANforge 2Ghz radio to use for testing", - default="1.1.wiphy0") - parser.addoption("--lanforge-5g-radio", type=str, help="LANforge 5Ghz radio to use for testing", - default="1.1.wiphy1") - - parser.addoption("--local_dir", type=str, help="Sanity logging directory", - default="logs") - parser.addoption("--report-path", type=str, help="Sanity report directory", - default="reports") - parser.addoption("--report-template", type=str, help="Sanity report template", - default="reports/report_template.php") - - parser.addoption("--eap-id", type=str, help="EAP indentity", - default="lanforge") - parser.addoption("--ttls-password", type=str, help="TTLS password", - default="lanforge") - - parser.addoption("--ap-ip", type=str, help="AP IP Address, for direct ssh access if not using jumphost", - default="127.0.0.1") - parser.addoption("--ap-username", type=str, help="AP username", - default="root") - parser.addoption("--ap-password", type=str, help="AP password", - default="root") - parser.addoption("--ap-jumphost-address", type=str, - help="IP of system that we can ssh in to get serial console access to AP", - default=None) - parser.addoption("--ap-jumphost-port", type=str, - help="SSH port to use in case we are using ssh tunneling or other non-standard ports", - default="22") - parser.addoption("--ap-jumphost-username", type=str, - help="User-ID for system that we can ssh in to get serial console access to AP", - default="lanforge") - parser.addoption("--ap-jumphost-password", type=str, - help="Passwort for system that we can ssh in to get serial console access to AP", - default="lanforge") - parser.addoption("--ap-jumphost-wlan-testing", type=str, help="wlan-testing repo dir on the jumphost", - default="git/wlan-testing") - parser.addoption("--ap-jumphost-tty", type=str, help="Serial port for the AP we wish to talk to", - default="UNCONFIGURED-JUMPHOST-TTY") - - parser.addoption('--skip-update-firmware', dest='update_firmware', action='store_false', default=True) - - parser.addoption('--tip-verbose', dest='verbose', action='store_true', default=False) - - -class UnitTestBase: - - def __init__(self, log_name, args, reporting=None): - self.parser = argparse.ArgumentParser(description="Sanity Testing on Firmware Build", parents=[args]) - - add_base_parse_args(self.parser) - - self.command_line_args = self.parser.parse_args() - - # cmd line takes precedence over env-vars. - self.cloudSDK_url = self.command_line_args.sdk_base_url # was os.getenv('CLOUD_SDK_URL') - self.local_dir = self.command_line_args.local_dir # was os.getenv('SANITY_LOG_DIR') - self.report_path = self.command_line_args.report_path # was os.getenv('SANITY_REPORT_DIR') - self.report_template = self.command_line_args.report_template # was os.getenv('REPORT_TEMPLATE') - - ## TestRail Information - self.tr_user = self.command_line_args.testrail_user_id # was os.getenv('TR_USER') - self.tr_pw = self.command_line_args.testrail_user_password # was os.getenv('TR_PWD') - self.milestoneId = self.command_line_args.milestone # was os.getenv('MILESTONE') - self.projectId = self.command_line_args.testrail_project # was os.getenv('PROJECT_ID') - self.testRunPrefix = self.command_line_args.testrail_run_prefix # os.getenv('TEST_RUN_PREFIX') - - ##Jfrog credentials - self.jfrog_user = self.command_line_args.jfrog_user_id # was os.getenv('JFROG_USER') - self.jfrog_pwd = self.command_line_args.jfrog_user_password # was os.getenv('JFROG_PWD') - - ##EAP Credentials - self.identity = self.command_line_args.eap_id # was os.getenv('EAP_IDENTITY') - self.ttls_password = self.command_line_args.ttls_password # was os.getenv('EAP_PWD') - - ## AP Credentials - self.ap_username = self.command_line_args.ap_username # was os.getenv('AP_USER') - - ##LANForge Information - self.lanforge_ip = self.command_line_args.lanforge_ip_address - self.lanforge_port = self.command_line_args.lanforge_port_number - self.lanforge_prefix = self.command_line_args.lanforge_prefix - - self.build = self.command_line_args.build_id - - - self.logger = logging.getLogger(log_name) - - if not reporting: - self.hdlr = logging.FileHandler("./logs/test_run.log") - else: - self.hdlr = logging.FileHandler(reporting.report_path + "/test_run.log") - self.formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') - self.hdlr.setFormatter(self.formatter) - self.logger.addHandler(self.hdlr) - self.logger.setLevel(logging.INFO) - - ####Use variables other than defaults for running tests on custom FW etc - - self.model_id = self.command_line_args.model - self.equipment_id = self.command_line_args.equipment_id - - ###Get Cloud Bearer Token - self.cloud: CloudSDK = CloudSDK(self.command_line_args) - self.bearer = self.cloud.get_bearer(self.cloudSDK_url, cloud_type) - self.customer_id = self.command_line_args.customer_id - diff --git a/tests/cicd_sanity/ap_connect.py b/tests/cicd_sanity/ap_connect.py deleted file mode 100644 index 628f26101..000000000 --- a/tests/cicd_sanity/ap_connect.py +++ /dev/null @@ -1,187 +0,0 @@ -################################################################################## -# Module contains functions to get specific data from AP CLI using SSH -# -# Used by Nightly_Sanity and Throughput_Test ##################################### -################################################################################## - -import paramiko -from paramiko import SSHClient -import socket -import os -import subprocess - -owrt_args = "--prompt root@OpenAp -s serial --log stdout --user root --passwd openwifi" - -def ssh_cli_active_fw(ap_ip, username, password): - print(ap_ip) - try: - if 'tty' in ap_ip: - print("AP is connected using serial cable") - ap_cmd = '/usr/opensync/bin/ovsh s AWLAN_Node -c | grep FW_IMAGE_ACTIVE' - cmd = "cd ../../lanforge/lanforge-scripts && python3 openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(owrt_args, ap_ip, ap_cmd) - with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) as p: - output, errors = p.communicate() - version_matrix = str(output.decode('utf-8').splitlines()) - version_matrix_split = version_matrix.partition('FW_IMAGE_ACTIVE","')[2] - cli_active_fw = version_matrix_split.partition('"],[')[0] - print(cli_active_fw) - - ap_cmd = '/usr/opensync/bin/ovsh s Manager -c | grep status' - cmd = "cd ../../lanforge/lanforge-scripts && python3 openwrt_ctl.py %s -t %s --action cmd --value \"%s\"" % (owrt_args, ap_ip, ap_cmd) - with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) as p: - output, errors = p.communicate() - status = str(output.decode('utf-8').splitlines()) - - else: - print("AP is accessible by SSH") - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ap_ip, username=username, password=password, timeout=5) - stdin, stdout, stderr = client.exec_command('/usr/opensync/bin/ovsh s AWLAN_Node -c | grep FW_IMAGE_ACTIVE') - version_matrix = str(stdout.read(), 'utf-8') - err = str(stderr.read(), 'utf-8') - #print("version-matrix: %s stderr: %s" % (version_matrix, err)) - version_matrix_split = version_matrix.partition('FW_IMAGE_ACTIVE","')[2] - cli_active_fw = version_matrix_split.partition('"],[')[0] - stdin, stdout, stderr = client.exec_command('/usr/opensync/bin/ovsh s Manager -c | grep status') - status = str(stdout.read(), 'utf-8') - - - print("status: %s" %(status)) - - if "ACTIVE" in status: - # print("AP is in Active state") - state = "active" - elif "BACKOFF" in status: - # print("AP is in Backoff state") - state = "backoff" - else: - # print("AP is not in Active state") - state = "unknown" - - cli_info = { - "state": state, - "active_fw": cli_active_fw - } - - return (cli_info) - - except paramiko.ssh_exception.AuthenticationException: - print("Authentication Error, Check Credentials") - return "ERROR" - except paramiko.SSHException: - print("Cannot SSH to the AP") - return "ERROR" - except socket.timeout: - print("AP Unreachable") - return "ERROR" - -def iwinfo_status(ap_ip, username, password): - try: - if 'tty' in ap_ip: - ap_cmd = 'iwinfo | grep ESSID' - cmd = "cd ../../lanforge/lanforge-scripts && python3 openwrt_ctl.py %s -t %s --action cmd --value \"%s\"" % ( - owrt_args, ap_ip, ap_cmd) - with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) as p: - output, errors = p.communicate() - for line in output.decode('utf-8').splitlines(): - print(line) - - else: - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ap_ip, username=username, password=password, timeout=5) - stdin, stdout, stderr = client.exec_command('iwinfo | grep ESSID') - - for line in stdout.read().splitlines(): - print(line) - - except paramiko.ssh_exception.AuthenticationException: - print("Authentication Error, Check Credentials") - return "ERROR" - except paramiko.SSHException: - print("Cannot SSH to the AP") - return "ERROR" - except socket.timeout: - print("AP Unreachable") - return "ERROR" - -def get_vif_config(ap_ip, username, password): - try: - if 'tty' in ap_ip: - ap_cmd = "/usr/opensync/bin/ovsh s Wifi_VIF_Config -c | grep 'ssid :'" - cmd = "cd ../../lanforge/lanforge-scripts && python3 openwrt_ctl.py %s -t %s --action cmd --value \"%s\"" % ( - owrt_args, ap_ip, ap_cmd) - with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) as p: - output, errors = p.communicate() - ssid_output_raw = output.decode('utf-8').splitlines() - raw = output.decode('utf-8').splitlines() - ssid_output = [] - for line in raw: - if 'ssid :' in line: - ssid_output.append(line) - print(ssid_output) - ssid_list = [s.replace('ssid : ','') for s in ssid_output] - return ssid_list - else: - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ap_ip, username=username, password=password, timeout=5) - stdin, stdout, stderr = client.exec_command( - "/usr/opensync/bin/ovsh s Wifi_VIF_Config -c | grep 'ssid :'") - - output = str(stdout.read(), 'utf-8') - ssid_output = output.splitlines() - - ssid_list = [s.strip('ssid : ') for s in ssid_output] - return ssid_list - - except paramiko.ssh_exception.AuthenticationException: - print("Authentication Error, Check Credentials") - return "ERROR" - except paramiko.SSHException: - print("Cannot SSH to the AP") - return "ERROR" - except socket.timeout: - print("AP Unreachable") - return "ERROR" - -def get_vif_state(ap_ip, username, password): - try: - if 'tty' in ap_ip: - ap_cmd = "/usr/opensync/bin/ovsh s Wifi_VIF_State -c | grep 'ssid :'" - cmd = "cd ../../lanforge/lanforge-scripts && python3 openwrt_ctl.py %s -t %s --action cmd --value \"%s\"" % ( - owrt_args, ap_ip, ap_cmd) - with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) as p: - output, errors = p.communicate() - ssid_output_raw = output.decode('utf-8').splitlines() - raw = output.decode('utf-8').splitlines() - ssid_output = [] - for line in raw: - if 'ssid :' in line: - ssid_output.append(line) - print(ssid_output) - ssid_list = [s.replace('ssid : ','') for s in ssid_output] - return ssid_list - else: - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ap_ip, username=username, password=password, timeout=5) - stdin, stdout, stderr = client.exec_command( - "/usr/opensync/bin/ovsh s Wifi_VIF_State -c | grep 'ssid :'") - - output = str(stdout.read(), 'utf-8') - ssid_output = output.splitlines() - - ssid_list = [s.strip('ssid : ') for s in ssid_output] - return ssid_list - - except paramiko.ssh_exception.AuthenticationException: - print("Authentication Error, Check Credentials") - return "ERROR" - except paramiko.SSHException: - print("Cannot SSH to the AP") - return "ERROR" - except socket.timeout: - print("AP Unreachable") - return "ERROR" diff --git a/tests/cicd_sanity/cicd_sanity.py b/tests/cicd_sanity/cicd_sanity.py deleted file mode 100755 index b928b6b80..000000000 --- a/tests/cicd_sanity/cicd_sanity.py +++ /dev/null @@ -1,2057 +0,0 @@ -#!/usr/bin/python3 - -import base64 -import urllib.request -from bs4 import BeautifulSoup -import ssl -import subprocess, os -from artifactory import ArtifactoryPath -import tarfile -import paramiko -from paramiko import SSHClient -from scp import SCPClient -import os -import pexpect -from pexpect import pxssh -import sys -import paramiko -from scp import SCPClient -import pprint -from pprint import pprint -from os import listdir -import re -import requests -import json -import testrail -import logging -import datetime -import time -from datetime import date -from shutil import copyfile -import argparse -import importlib - -# For finding files -# https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory -import glob - -# external_results_dir=/var/tmp/lanforge - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) -for folder in 'py-json', 'py-scripts': - if folder not in sys.path: - sys.path.append(f'../../lanforge/lanforge-scripts/{folder}') - -sys.path.append(f'../../libs/lanforge') -#sys.path.append(f'../../libs/testrails') -#sys.path.append(f'../../libs/apnos') -#sys.path.append(f'../../libs/cloudsdk') -sys.path.append(f'../../libs') -#sys.path.append(f'../test_utility/') -sys.path.append(f'../') - -from LANforge.LFUtils import * - -# if you lack __init__.py in this directory you will not find sta_connect module# - -if 'py-json' not in sys.path: - sys.path.append('../../py-scripts') - -import sta_connect2 -from sta_connect2 import StaConnect2 -import testrail -from testrail import APIClient -import eap_connect -from eap_connect import EAPConnect -import cloud_connect -from cloud_connect import CloudSDK -import ap_connect -from ap_connect import ssh_cli_active_fw -from ap_connect import iwinfo_status - -###Class for jfrog Interaction -class GetBuild: - def __init__(self): - self.user = jfrog_user - self.password = jfrog_pwd - ssl._create_default_https_context = ssl._create_unverified_context - - def get_latest_image(self, url, build): - 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(url) - req = urllib.request.Request(url, headers=headers) - response = urllib.request.urlopen(req) - html = response.read() - soup = BeautifulSoup(html, features="html.parser") - ##find the last pending link on dev - last_link = soup.find_all('a', href=re.compile(build))[-1] - latest_file = last_link['href'] - latest_fw = latest_file.replace('.tar.gz', '') - return latest_fw - - -###Class for Tests -class RunTest: - def Single_Client_Connectivity(self, port, radio, prefix, ssid_name, ssid_psk, security, station, test_case, rid): - '''SINGLE CLIENT CONNECTIVITY using test_connect2.py''' - staConnect = StaConnect2(lanforge_ip, 8080, debug_=False) - staConnect.sta_mode = 0 - staConnect.upstream_resource = 1 - staConnect.upstream_port = port - staConnect.radio = radio - staConnect.resource = 1 - staConnect.dut_ssid = ssid_name - staConnect.dut_passwd = ssid_psk - staConnect.dut_security = security - staConnect.station_names = station - staConnect.sta_prefix = prefix - staConnect.runtime_secs = 10 - staConnect.bringup_time_sec = 60 - staConnect.cleanup_on_exit = True - # staConnect.cleanup() - staConnect.setup() - staConnect.start() - print("napping %f sec" % staConnect.runtime_secs) - time.sleep(staConnect.runtime_secs) - staConnect.stop() - staConnect.cleanup() - run_results = staConnect.get_result_list() - for result in run_results: - print("test result: " + result) - # result = 'pass' - print("Single Client Connectivity :", staConnect.passes) - if staConnect.passes() == True: - print("Single client connection to", ssid_name, "successful. Test Passed") - client.update_testrail(case_id=test_case, run_id=rid, status_id=1, msg='Client connectivity passed') - logger.info("Client connectivity to " + ssid_name + " Passed") - return ("passed") - else: - client.update_testrail(case_id=test_case, run_id=rid, status_id=5, msg='Client connectivity failed') - print("Single client connection to", ssid_name, "unsuccessful. Test Failed") - logger.warning("Client connectivity to " + ssid_name + " FAILED") - return ("failed") - - def Single_Client_EAP(port, sta_list, ssid_name, radio, sta_prefix, security, eap_type, identity, ttls_password, test_case, - rid): - eap_connect = EAPConnect(lanforge_ip, 8080, _debug_on=False) - eap_connect.upstream_resource = 1 - eap_connect.upstream_port = port - eap_connect.security = security - eap_connect.sta_list = sta_list - eap_connect.station_names = sta_list - eap_connect.sta_prefix = sta_prefix - eap_connect.ssid = ssid_name - eap_connect.radio = radio - eap_connect.eap = eap_type - eap_connect.identity = identity - eap_connect.ttls_passwd = ttls_password - eap_connect.runtime_secs = 10 - eap_connect.setup() - eap_connect.start() - print("napping %f sec" % eap_connect.runtime_secs) - time.sleep(eap_connect.runtime_secs) - eap_connect.stop() - eap_connect.cleanup() - run_results = eap_connect.get_result_list() - for result in run_results: - print("test result: " + result) - # result = 'pass' - print("Single Client Connectivity :", eap_connect.passes) - if eap_connect.passes() == True: - print("Single client connection to", ssid_name, "successful. Test Passed") - client.update_testrail(case_id=test_case, run_id=rid, status_id=1, msg='Client connectivity passed') - logger.info("Client connectivity to " + ssid_name + " Passed") - return ("passed") - else: - client.update_testrail(case_id=test_case, run_id=rid, status_id=5, msg='Client connectivity failed') - print("Single client connection to", ssid_name, "unsuccessful. Test Failed") - logger.warning("Client connectivity to " + ssid_name + " FAILED") - return ("failed") - - def testrail_retest(self, test_case, rid, ssid_name): - client.update_testrail(case_id=test_case, run_id=rid, status_id=4, - msg='Error in Client Connectivity Test. Needs to be Re-run') - print("Error in test for single client connection to", ssid_name) - logger.warning("ERROR testing Client connectivity to " + ssid_name) - -### Directories -local_dir = os.getenv('SANITY_LOG_DIR') -report_path = os.getenv('SANITY_REPORT_DIR') -report_template = os.getenv('REPORT_TEMPLATE') - -## TestRail Information -tr_user = os.getenv('TR_USER') -tr_pw = os.getenv('TR_PWD') -milestoneId = os.getenv('MILESTONE') -projectId = os.getenv('PROJECT_ID') -testRunPrefix = os.getenv('TEST_RUN_PREFIX') - -##Jfrog credentials -jfrog_user = os.getenv('JFROG_USER') -jfrog_pwd = os.getenv('JFROG_PWD') - - -## AP Credentials -ap_username = os.getenv('AP_USER') - -logger = logging.getLogger('Nightly_Sanity') -hdlr = logging.FileHandler(local_dir + "/Nightly_Sanity.log") -formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') -hdlr.setFormatter(formatter) -logger.addHandler(hdlr) -logger.setLevel(logging.INFO) - -testrail_url = os.getenv('TR_URL') -client: APIClient = APIClient(testrail_url) -client.user = tr_user -client.password = tr_pw - -# Command Line Args -parser = argparse.ArgumentParser(description="Sanity Testing on Firmware Build") -parser.add_argument("-b", "--build", type=str, default="pending", - help="FW commit ID (latest pending build on dev is default)") -parser.add_argument("-i", "--ignore", type=str, default='no', choices=['yes', 'no'], - help="Set to 'no' to ignore current running version on AP and run sanity including upgrade") -parser.add_argument("-r", "--report", type=str, default=report_path, help="Report directory path other than default - directory must already exist!") -parser.add_argument("-m", "--model", type=str, choices=['ea8300', 'ecw5410', 'ecw5211', 'ec420', "wf188n", "wf194c", "ex227", "ex447", "eap101", "eap102"], - help="AP model to be run") -parser.add_argument("-f", "--file", type=str, help="Test Info file name", default="test_info") -parser.add_argument("--tr_prefix", type=str, default=testRunPrefix, help="Testrail test run prefix override (default is Env variable)") -parser.add_argument("--skip_upgrade", dest="skip_upgrade", action='store_true', help="Skip Upgrade testing") -parser.set_defaults(skip_eap=False) -parser.add_argument("--skip_eap", dest="skip_eap", action='store_true', help="Skip EAP testing") -parser.set_defaults(skip_eap=False) -parser.add_argument("--skip_bridge", dest="skip_bridge", action='store_true', help="Skip Bridge testing") -parser.set_defaults(skip_bridge=False) -parser.add_argument("--skip_nat", dest="skip_nat", action='store_true', help="Skip NAT testing") -parser.set_defaults(skip_nat=False) -parser.add_argument("--skip_vlan", dest="skip_vlan", action='store_true', help="Skip VLAN testing") -parser.set_defaults(skip_vlan=False) -args = parser.parse_args() - -build = args.build -ignore = args.ignore -report_path = args.report -test_file = args.file - -# Import info for lab setup and APs under test -test_info_module = os.path.splitext(test_file)[0] -test_info = importlib.import_module(test_info_module) - -equipment_id_dict = test_info.equipment_id_dict -equipment_ids = equipment_id_dict -profile_info_dict = test_info.profile_info_dict -cloud_sdk_models = test_info.cloud_sdk_models -equipment_ip_dict = test_info.equipment_ip_dict -equipment_credentials_dict = test_info.equipment_credentials_dict -ap_models = test_info.ap_models -customer_id = test_info.customer_id -cloud_type = test_info.cloud_type -test_cases = test_info.test_cases - -# Set CloudSDK URL -cloudSDK_url = test_info.cloudSDK_url -# CloudSDK credentials -cloud_user = test_info.cloud_user -cloud_password = test_info.cloud_password - -# RADIUS info and EAP credentials -radius_info = test_info.radius_info -identity = test_info.radius_info["eap_identity"] -ttls_password = test_info.radius_info["eap_pwd"] - -if args.model is not None: - model_id = args.model - equipment_ids = { - model_id: equipment_id_dict[model_id] - } - print("User requested test on equipment ID:",equipment_ids) - -if args.tr_prefix is not None: - testRunPrefix = args.tr_prefix - -##LANForge Information -lanforge_ip = test_info.lanforge_ip -#lanforge_prefix = test_info.lanforge_prefix - -print("Start of Sanity Testing...") -print("Test file used will be: "+test_file) -print("TestRail Test Run Prefix is: "+testRunPrefix) -print("Skipping Upgrade Tests? " + str(args.skip_upgrade)) -print("Skipping EAP Tests? " + str(args.skip_eap)) -print("Skipping Bridge Tests? " + str(args.skip_bridge)) -print("Skipping NAT Tests? " + str(args.skip_nat)) -print("Skipping VLAN Tests? " + str(args.skip_vlan)) -print("Testing Latest Build with Tag: " + build) - -if ignore == 'yes': - print("Will ignore if AP is already running build under test and run sanity regardless...") -else: - print("Checking for APs requiring upgrade to latest build...") - -######Testrail Project and Run ID Information ############################## - -Test: RunTest = RunTest() - -projId = client.get_project_id(project_name=projectId) -print("TIP WLAN Project ID is:", projId) - -logger.info('Start of Nightly Sanity') - -###Dictionaries -ap_latest_dict = { - "ec420": "Unknown", - "ea8300": "Unknown", - "ecw5211": "unknown", - "ecw5410": "unknown" -} - -# import json file used by throughput test -sanity_status = json.load(open("sanity_status.json")) - -############################################################################ -#################### Create Report ######################################### -############################################################################ - -# Create Report Folder for Today -today = str(date.today()) -try: - os.mkdir(report_path + today) -except OSError: - print("Creation of the directory %s failed" % report_path) -else: - print("Successfully created the directory %s " % report_path) - -logger.info('Report data can be found here: ' + report_path + today) - -# Copy report template to folder. If template doesn't exist, continue anyway with log -try: - copyfile(report_template, report_path + today + '/report.php') - -except: - print("No report template created. Report data will still be saved. Continuing with tests...") - -##Create report_data dictionary -tc_results = dict.fromkeys(test_cases.values(), "not run") - -report_data = dict() -report_data["cloud_sdk"] = dict.fromkeys(ap_models, "") -for key in report_data["cloud_sdk"]: - report_data["cloud_sdk"][key] = { - "date": "N/A", - "commitId": "N/A", - "projectVersion": "N/A" - } -report_data["fw_available"] = dict.fromkeys(ap_models, "Unknown") -report_data["fw_under_test"] = dict.fromkeys(ap_models, "N/A") -report_data['pass_percent'] = dict.fromkeys(ap_models, "") - -report_data['tests'] = dict.fromkeys(ap_models, "") -for key in ap_models: - report_data['tests'][key] = dict.fromkeys(test_cases.values(), "not run") -print(report_data) - -# write to report_data contents to json file so it has something in case of unexpected fail -with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - -###Get Cloud Bearer Token -bearer = CloudSDK.get_bearer(cloudSDK_url, cloud_type, cloud_user, cloud_password) - -############################################################################ -#################### Jfrog Firmware Check ################################## -############################################################################ - -for model in ap_models: - apModel = model - cloudModel = cloud_sdk_models[apModel] - # print(cloudModel) - ###Check Latest FW on jFrog - jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/' - url = jfrog_url + apModel + "/dev/" - Build: GetBuild = GetBuild() - latest_image = Build.get_latest_image(url, build) - print(model, "Latest FW on jFrog:", latest_image) - ap_latest_dict[model] = latest_image - -print(ap_latest_dict) -#################################################################################### -############ Update FW and Run Test Cases on Each AP Variant ####################### -#################################################################################### -#################################################################################### - -for key in equipment_ids: - ##Get Bearer Token to make sure its valid (long tests can require re-auth) - bearer = CloudSDK.get_bearer(cloudSDK_url, cloud_type, cloud_user, cloud_password) - - ###Get Current AP Firmware and upgrade - equipment_id = equipment_id_dict[key] - ap_ip = equipment_ip_dict[key] - ap_username = "root" - ap_password = equipment_credentials_dict[key] - print("AP MODEL UNDER TEST IS", key) - try: - ap_cli_info = ssh_cli_active_fw(ap_ip, ap_username, ap_password) - ap_cli_fw = ap_cli_info['active_fw'] - except: - ap_cli_info = "ERROR" - print("Cannot Reach AP CLI, will not test this variant") - report_data["pass_percent"][key] = "AP offline" - continue - - fw_model = ap_cli_fw.partition("-")[0] - print('Current Active AP FW from CLI:', ap_cli_fw) - - if ap_cli_info['state'] != "active": - print('Manager Status not Active. Skipping AP Model!') - report_data["pass_percent"][key] = "AP offline" - continue - - else: - print('Manager Status Active. Proceed with tests...') - ###Find Latest FW for Current AP Model and Get FW ID - ##Compare Latest and Current AP FW and Upgrade - latest_ap_image = ap_latest_dict[fw_model] - - if ap_cli_fw == latest_ap_image and ignore == 'no' and args.skip_upgrade != True: - print('FW does not require updating') - report_data['fw_available'][key] = "No" - logger.info(fw_model + " does not require upgrade. Not performing sanity tests for this AP variant") - cloudsdk_cluster_info = { - "date": "N/A", - "commitId": "N/A", - "projectVersion": "N/A" - } - report_data['cloud_sdk'][key] = cloudsdk_cluster_info - - else: - if ap_cli_fw == latest_ap_image and ignore == "yes": - print('AP is already running FW version under test. Ignored based on ignore flag') - report_data['fw_available'][key] = "Yes" - elif args.skip_upgrade == True: - print("User requested to skip upgrade, will use existing version and not upgrade AP") - report_data['fw_available'][key] = "N/A" - report_data['fw_under_test'][key] = ap_cli_fw - latest_ap_image = ap_cli_fw - else: - print('FW needs updating') - report_data['fw_available'][key] = "Yes" - report_data['fw_under_test'][key] = latest_ap_image - - ###Create Test Run - today = str(date.today()) - case_ids = list(test_cases.values()) - - ##Remove unused test cases based on command line arguments - - # Skip upgrade argument - if args.skip_upgrade == True: - case_ids.remove(test_cases["upgrade_api"]) - else: - pass - - # Skip Bridge argument - if args.skip_bridge == True: - for x in test_cases: - if "bridge" in x: - case_ids.remove(test_cases[x]) - else: - pass - - # Skip NAT argument - if args.skip_nat == True: - for x in test_cases: - if "nat" in x: - case_ids.remove(test_cases[x]) - else: - pass - - # Skip VLAN argument - if args.skip_vlan == True: - for x in test_cases: - if "vlan" in x: - case_ids.remove(test_cases[x]) - else: - pass - - # Skip EAP argument - if args.skip_eap == True: - case_ids.remove(test_cases["radius_profile"]) - for x in test_cases: - if "eap" in x and test_cases[x] in case_ids: - case_ids.remove(test_cases[x]) - else: - pass - - test_run_name = testRunPrefix + fw_model + "_" + today + "_" + latest_ap_image - client.create_testrun(name=test_run_name, case_ids=case_ids, project_id=projId, milestone_id=milestoneId, - description="Automated Nightly Sanity test run for new firmware build") - rid = client.get_run_id(test_run_name=testRunPrefix + fw_model + "_" + today + "_" + latest_ap_image) - print("TIP run ID is:", rid) - - ###GetCloudSDK Version - print("Getting CloudSDK version information...") - try: - cluster_ver = CloudSDK.get_cloudsdk_version(cloudSDK_url, bearer) - print("CloudSDK Version Information:") - print("-------------------------------------------") - print(cluster_ver) - print("-------------------------------------------") - - cloudsdk_cluster_info = {} - cloudsdk_cluster_info['date'] = cluster_ver['commitDate'] - cloudsdk_cluster_info['commitId'] = cluster_ver['commitID'] - cloudsdk_cluster_info['projectVersion'] = cluster_ver['projectVersion'] - report_data['cloud_sdk'][key] = cloudsdk_cluster_info - client.update_testrail(case_id=test_cases["cloud_ver"], run_id=rid, status_id=1, - msg='Read CloudSDK version from API successfully') - report_data['tests'][key][test_cases["cloud_ver"]] = "passed" - - except: - cluster_ver = 'error' - print("ERROR: CloudSDK Version Unavailable") - logger.info('CloudSDK version Unavailable') - cloudsdk_cluster_info = { - "date": "unknown", - "commitId": "unknown", - "projectVersion": "unknown" - } - client.update_testrail(case_id=test_cases["cloud_ver"], run_id=rid, status_id=5, - msg='Could not read CloudSDK version from API') - report_data['cloud_sdk'][key] = cloudsdk_cluster_info - report_data['tests'][key][test_cases["cloud_ver"]] = "failed" - - with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - - # Update TR Testrun with CloudSDK info for use in QA portal - sdk_description = cloudsdk_cluster_info["date"]+" (Commit ID: "+cloudsdk_cluster_info["commitId"]+")" - update_test = client.update_testrun(rid,sdk_description) - print(update_test) - - # Test Create Firmware Version - test_id_fw = test_cases["create_fw"] - latest_image = ap_latest_dict[key] - cloudModel = cloud_sdk_models[key] - print(cloudModel) - firmware_list_by_model = CloudSDK.CloudSDK_images(cloudModel, cloudSDK_url, bearer) - print("Available", cloudModel, "Firmware on CloudSDK:", firmware_list_by_model) - - if latest_image in firmware_list_by_model: - print("Latest Firmware", latest_image, "is already on CloudSDK, need to delete to test create FW API") - old_fw_id = CloudSDK.get_firmware_id(latest_image, cloudSDK_url, bearer) - delete_fw = CloudSDK.delete_firmware(str(old_fw_id), cloudSDK_url, bearer) - fw_url = "https://" + jfrog_user + ":" + jfrog_pwd + "@tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + key + "/dev/" + latest_image + ".tar.gz" - commit = latest_image.split("-")[-1] - try: - fw_upload_status = CloudSDK.firwmare_upload(commit, cloudModel, latest_image, fw_url, cloudSDK_url, - bearer) - fw_id = fw_upload_status['id'] - print("Upload Complete.", latest_image, "FW ID is", fw_id) - client.update_testrail(case_id=test_id_fw, run_id=rid, status_id=1, - msg='Create new FW version by API successful') - report_data['tests'][key][test_id_fw] = "passed" - except: - fw_upload_status = 'error' - print("Unable to upload new FW version. Skipping Sanity on AP Model") - client.update_testrail(case_id=test_id_fw, run_id=rid, status_id=5, - msg='Error creating new FW version by API') - report_data['tests'][key][test_id_fw] = "failed" - continue - else: - print("Latest Firmware is not on CloudSDK! Uploading...") - fw_url = "https://" + jfrog_user + ":" + jfrog_pwd + "@tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + key + "/dev/" + latest_image + ".tar.gz" - commit = latest_image.split("-")[-1] - try: - fw_upload_status = CloudSDK.firwmare_upload(commit, cloudModel, latest_image, fw_url, cloudSDK_url, - bearer) - fw_id = fw_upload_status['id'] - print("Upload Complete.", latest_image, "FW ID is", fw_id) - client.update_testrail(case_id=test_id_fw, run_id=rid, status_id=1, - msg='Create new FW version by API successful') - report_data['tests'][key][test_id_fw] = "passed" - except: - fw_upload_status = 'error' - print("Unable to upload new FW version. Skipping Sanity on AP Model") - client.update_testrail(case_id=test_id_fw, run_id=rid, status_id=5, - msg='Error creating new FW version by API') - report_data['tests'][key][test_id_fw] = "failed" - continue - - # Upgrade AP firmware - if args.skip_upgrade == True: - print("User Requested to Not Performing Upgrade, skipping to Connectivity Tests") - else: - print("Upgrading...firmware ID is: ", fw_id) - upgrade_fw = CloudSDK.update_firmware(equipment_id, str(fw_id), cloudSDK_url, bearer) - logger.info("Lab " + fw_model + " Requires FW update") - print(upgrade_fw) - - if "success" in upgrade_fw: - if upgrade_fw["success"] == True: - print("CloudSDK Upgrade Request Success") - report_data['tests'][key][test_cases["upgrade_api"]] = "passed" - client.update_testrail(case_id=test_cases["upgrade_api"], run_id=rid, status_id=1, - msg='Upgrade request using API successful') - logger.info('Firmware upgrade API successfully sent') - else: - print("Cloud SDK Upgrade Request Error!") - # mark upgrade test case as failed with CloudSDK error - client.update_testrail(case_id=test_cases["upgrade_api"], run_id=rid, status_id=5, - msg='Error requesting upgrade via API') - report_data['tests'][key][test_cases["upgrade_api"]] = "failed" - logger.warning('Firmware upgrade API failed to send') - continue - else: - print("Cloud SDK Upgrade Request Error!") - # mark upgrade test case as failed with CloudSDK error - client.update_testrail(case_id=test_cases["upgrade_api"], run_id=rid, status_id=5, - msg='Error requesting upgrade via API') - report_data['tests'][key][test_cases["upgrade_api"]] = "failed" - logger.warning('Firmware upgrade API failed to send') - continue - - time.sleep(300) - - # Check if upgrade success is displayed on CloudSDK - test_id_cloud = test_cases["cloud_fw"] - cloud_ap_fw = CloudSDK.ap_firmware(customer_id, equipment_id, cloudSDK_url, bearer) - print('Current AP Firmware from CloudSDK:', cloud_ap_fw) - logger.info('AP Firmware from CloudSDK: ' + cloud_ap_fw) - if cloud_ap_fw == "ERROR": - print("AP FW Could not be read from CloudSDK") - - elif cloud_ap_fw == latest_ap_image: - print("CloudSDK status shows upgrade successful!") - - else: - print("AP FW from CloudSDK status is not latest build. Will check AP CLI.") - - # Check if upgrade successful on AP CLI - test_id_cli = test_cases["ap_upgrade"] - try: - ap_cli_info = ssh_cli_active_fw(ap_ip, ap_username, ap_password) - ap_cli_fw = ap_cli_info['active_fw'] - print("CLI reporting AP Active FW as:", ap_cli_fw) - logger.info('Firmware from CLI: ' + ap_cli_fw) - except: - ap_cli_info = "ERROR" - print("Cannot Reach AP CLI to confirm upgrade!") - logger.warning('Cannot Reach AP CLI to confirm upgrade!') - client.update_testrail(case_id=test_id_cli, run_id=rid, status_id=4, - msg='Cannot reach AP after upgrade to check CLI - re-test required') - continue - - if cloud_ap_fw == latest_ap_image and ap_cli_fw == latest_ap_image: - print("CloudSDK and AP CLI both show upgrade success, passing upgrade test case") - client.update_testrail(case_id=test_id_cli, run_id=rid, status_id=1, - msg='Upgrade to ' + latest_ap_image + ' successful') - client.update_testrail(case_id=test_id_cloud, run_id=rid, status_id=1, - msg='CLOUDSDK reporting correct firmware version.') - report_data['tests'][key][test_id_cli] = "passed" - report_data['tests'][key][test_id_cloud] = "passed" - print(report_data['tests'][key]) - - elif cloud_ap_fw != latest_ap_image and ap_cli_fw == latest_ap_image: - print("AP CLI shows upgrade success - CloudSDK reporting error!") - ##Raise CloudSDK error but continue testing - client.update_testrail(case_id=test_id_cli, run_id=rid, status_id=1, - msg='Upgrade to ' + latest_ap_image + ' successful.') - client.update_testrail(case_id=test_id_cloud, run_id=rid, status_id=5, - msg='CLOUDSDK reporting incorrect firmware version.') - report_data['tests'][key][test_id_cli] = "passed" - report_data['tests'][key][test_id_cloud] = "failed" - print(report_data['tests'][key]) - - elif cloud_ap_fw == latest_ap_image and ap_cli_fw != latest_ap_image: - print("AP CLI shows upgrade failed - CloudSDK reporting error!") - # Testrail TC fail - client.update_testrail(case_id=test_id_cli, run_id=rid, status_id=5, - msg='AP failed to download or apply new FW. Upgrade to ' + latest_ap_image + ' Failed') - client.update_testrail(case_id=test_id_cloud, run_id=rid, status_id=5, - msg='CLOUDSDK reporting incorrect firmware version.') - report_data['tests'][key][test_id_cli] = "failed" - report_data['tests'][key][test_id_cloud] = "failed" - print(report_data['tests'][key]) - continue - - elif cloud_ap_fw != latest_ap_image and ap_cli_fw != latest_ap_image: - print("Upgrade Failed! Confirmed on CloudSDK and AP CLI. Upgrade test case failed.") - ##fail TR testcase and exit - client.update_testrail(case_id=test_id_cli, run_id=rid, status_id=5, - msg='AP failed to download or apply new FW. Upgrade to ' + latest_ap_image + ' Failed') - report_data['tests'][key][test_id_cli] = "failed" - print(report_data['tests'][key]) - continue - - else: - print("Unable to determine upgrade status. Skipping AP variant") - # update TR testcase as error - client.update_testrail(case_id=test_id_cli, run_id=rid, status_id=4, - msg='Cannot determine upgrade status - re-test required') - report_data['tests'][key][test_id_cli] = "error" - print(report_data['tests'][key]) - continue - - print(report_data) - - ###Check AP Manager Status - manager_status = ap_cli_info['state'] - - if manager_status != "active": - print("Manager status is " + manager_status + "! Not connected to the cloud.") - print("Waiting 30 seconds and re-checking status") - time.sleep(30) - ap_cli_info = ssh_cli_active_fw(ap_ip, ap_username, ap_password) - manager_status = ap_cli_info['state'] - if manager_status != "active": - print("Manager status is", manager_status, "! Not connected to the cloud.") - print("Manager status fails multiple checks - failing test case.") - ##fail cloud connectivity testcase - client.update_testrail(case_id=test_cases["cloud_connection"], run_id=rid, status_id=5, - msg='CloudSDK connectivity failed') - report_data['tests'][key][test_cases["cloud_connection"]] = "failed" - continue - else: - print("Manager status is Active. Proceeding to connectivity testing!") - # TC522 pass in Testrail - client.update_testrail(case_id=test_cases["cloud_connection"], run_id=rid, status_id=1, - msg='Manager status is Active') - report_data['tests'][key][test_cases["cloud_connection"]] = "passed" - else: - print("Manager status is Active. Proceeding to connectivity testing!") - # TC5222 pass in testrail - client.update_testrail(case_id=test_cases["cloud_connection"], run_id=rid, status_id=1, - msg='Manager status is Active') - report_data['tests'][key][test_cases["cloud_connection"]] = "passed" - # Pass cloud connectivity test case - - # Update report json - with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - - # Create List of Created Profiles to Delete After Test - delete_list = [] - - # Create RADIUS profile - used for all EAP SSIDs - if args.skip_eap != True: - radius_template = "templates/radius_profile_template.json" - radius_name = "Automation_RADIUS_"+today - server_ip = radius_info['server_ip'] - secret = radius_info['secret'] - auth_port = radius_info['auth_port'] - try: - radius_profile = CloudSDK.create_radius_profile(cloudSDK_url, bearer, radius_template, radius_name, customer_id, - server_ip, secret, - auth_port) - print("radius profile Id is", radius_profile) - client.update_testrail(case_id=test_cases["radius_profile"], run_id=rid, status_id=1, - msg='RADIUS profile created successfully') - report_data['tests'][key][test_cases["radius_profile"]] = "passed" - # Add created RADIUS profile to list for deletion at end of test - delete_list.append(radius_profile) - except: - radius_profile = 'error' - print("RADIUS Profile Create Error, will use existing profile for tests") - # Set backup profile ID so test can continue - radius_profile = test_info.radius_profile - server_name = "Lab-RADIUS" - client.update_testrail(case_id=test_cases["radius_profile"], run_id=rid, status_id=5, - msg='Failed to create RADIUS profile') - report_data['tests'][key][test_cases["radius_profile"]] = "failed" - else: - print("Skipped creating RADIUS profile based on skip_eap argument") - - # Set RF Profile Id depending on AP capability - if test_info.ap_spec[key] == "wifi5": - rfProfileId = test_info.rf_profile_wifi5 - print("using Wi-Fi5 profile Id") - elif test_info.ap_spec[key] == "wifi6": - rfProfileId = test_info.rf_profile_wifi6 - print("using Wi-Fi6 profile Id") - else: - rfProfileId = 10 - print("Unknown AP radio spec, using default RF profile") - - ########################################################################### - ############## Bridge Mode Client Connectivity ############################ - ########################################################################### - if args.skip_bridge != True: - ### Create SSID Profiles - ssid_template = "templates/ssid_profile_template.json" - child_profiles = [rfProfileId] - - # 5G SSIDs - if args.skip_eap != True: - try: - fiveG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_EAP_' + today, customer_id, profile_info_dict[fw_model]["fiveG_WPA2-EAP_SSID"], None, - radius_profile, - "wpa2OnlyRadius", "BRIDGE", 1, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G EAP SSID created successfully - bridge mode") - client.update_testrail(case_id=test_cases["ssid_5g_eap_bridge"], run_id=rid, status_id=1, - msg='5G EAP SSID created successfully - bridge mode') - report_data['tests'][key][test_cases["ssid_5g_eap_bridge"]] = "passed" - # Add create profile to list for AP profile - child_profiles.append(fiveG_eap) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_eap) - except: - fiveG_eap = "error" - print("5G EAP SSID create failed - bridge mode") - client.update_testrail(case_id=test_cases["ssid_5g_eap_bridge"], run_id=rid, status_id=5, - msg='5G EAP SSID create failed - bridge mode') - report_data['tests'][key][test_cases["ssid_5g_eap_bridge"]] = "failed" - - else: - pass - - try: - fiveG_wpa2 = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_WPA2_' + today, customer_id, - profile_info_dict[fw_model]["fiveG_WPA2_SSID"], - profile_info_dict[fw_model]["fiveG_WPA2_PSK"], - 0, "wpa2OnlyPSK", "BRIDGE", 1, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G WPA2 SSID created successfully - bridge mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa2_bridge"], run_id=rid, status_id=1, - msg='5G WPA2 SSID created successfully - bridge mode') - report_data['tests'][key][test_cases["ssid_5g_wpa2_bridge"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_wpa2) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_wpa2) - except: - fiveG_wpa2 = "error" - print("5G WPA2 SSID create failed - bridge mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa2_bridge"], run_id=rid, status_id=5, - msg='5G WPA2 SSID create failed - bridge mode') - report_data['tests'][key][test_cases["ssid_5g_wpa2_bridge"]] = "failed" - - try: - fiveG_wpa = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_WPA_' + today, customer_id, - profile_info_dict[fw_model]["fiveG_WPA_SSID"], - profile_info_dict[fw_model]["fiveG_WPA_PSK"], - 0, "wpaPSK", "BRIDGE", 1, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G WPA SSID created successfully - bridge mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa_bridge"], run_id=rid, status_id=1, - msg='5G WPA SSID created successfully - bridge mode') - report_data['tests'][key][test_cases["ssid_5g_wpa_bridge"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_wpa) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_wpa) - except: - fiveG_wpa = "error" - print("5G WPA SSID create failed - bridge mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa_bridge"], run_id=rid, status_id=5, - msg='5G WPA SSID create failed - bridge mode') - report_data['tests'][key][test_cases["ssid_5g_wpa_bridge"]] = "failed" - - # 2.4G SSIDs - if args.skip_eap != True: - try: - twoFourG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_EAP_' + today, customer_id, - profile_info_dict[fw_model]["twoFourG_WPA2-EAP_SSID"], - None, - radius_profile, "wpa2OnlyRadius", "BRIDGE", 1, - ["is2dot4GHz"]) - print("2.4G EAP SSID created successfully - bridge mode") - client.update_testrail(case_id=test_cases["ssid_2g_eap_bridge"], run_id=rid, status_id=1, - msg='2.4G EAP SSID created successfully - bridge mode') - report_data['tests'][key][test_cases["ssid_2g_eap_bridge"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_eap) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_eap) - except: - twoFourG_eap = "error" - print("2.4G EAP SSID create failed - bridge mode") - client.update_testrail(case_id=test_cases["ssid_2g_eap_bridge"], run_id=rid, status_id=5, - msg='2.4G EAP SSID create failed - bridge mode') - report_data['tests'][key][test_cases["ssid_2g_eap_bridge"]] = "failed" - else: - pass - - try: - twoFourG_wpa2 = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_WPA2_' + today, customer_id, - profile_info_dict[fw_model]["twoFourG_WPA2_SSID"], - profile_info_dict[fw_model]["twoFourG_WPA2_PSK"], - 0, "wpa2OnlyPSK", "BRIDGE", 1, - ["is2dot4GHz"]) - print("2.4G WPA2 SSID created successfully - bridge mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa2_bridge"], run_id=rid, status_id=1, - msg='2.4G WPA2 SSID created successfully - bridge mode') - report_data['tests'][key][test_cases["ssid_2g_wpa2_bridge"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_wpa2) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_wpa2) - except: - twoFourG_wpa2 = "error" - print("2.4G WPA2 SSID create failed - bridge mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa2_bridge"], run_id=rid, status_id=5, - msg='2.4G WPA2 SSID create failed - bridge mode') - report_data['tests'][key][test_cases["ssid_2g_wpa2_bridge"]] = "failed" - - try: - twoFourG_wpa = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_WPA_' + today, customer_id, - profile_info_dict[fw_model]["twoFourG_WPA_SSID"], - profile_info_dict[fw_model]["twoFourG_WPA_PSK"], - 0, "wpaPSK", "BRIDGE", 1, - ["is2dot4GHz"]) - print("2.4G WPA SSID created successfully - bridge mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa_bridge"], run_id=rid, status_id=1, - msg='2.4G WPA SSID created successfully - bridge mode') - report_data['tests'][key][test_cases["ssid_2g_wpa_bridge"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_wpa) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_wpa) - except: - twoFourG_wpa = "error" - print("2.4G WPA SSID create failed - bridge mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa_bridge"], run_id=rid, status_id=5, - msg='2.4G WPA SSID create failed - bridge mode') - report_data['tests'][key][test_cases["ssid_2g_wpa_bridge"]] = "failed" - - ### Create AP Bridge Profile - print(child_profiles) - - ap_template = "templates/ap_profile_template.json" - name = "Nightly_Sanity_" + fw_model + "_" + today + "_bridge" - - try: - create_ap_profile = CloudSDK.create_ap_profile(cloudSDK_url, bearer, ap_template, name, customer_id, child_profiles) - test_profile_id = create_ap_profile - print("Test Profile ID for Test is:", test_profile_id) - client.update_testrail(case_id=test_cases["ap_bridge"], run_id=rid, status_id=1, - msg='AP profile for bridge tests created successfully') - report_data['tests'][key][test_cases["ap_bridge"]] = "passed" - # Add created profile to list for deletion at end of test - delete_list.append(test_profile_id) - except: - create_ap_profile = "error" - #test_profile_id = profile_info_dict[fw_model]["profile_id"] - print("Error creating AP profile for bridge tests. Will use existing AP profile") - client.update_testrail(case_id=test_cases["ap_bridge"], run_id=rid, status_id=5, - msg='AP profile for bridge tests could not be created using API') - report_data['tests'][key][test_cases["ap_bridge"]] = "failed" - - ### Set Proper AP Profile for Bridge SSID Tests - ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer) - - ### Wait for Profile Push - time.sleep(180) - - ### Check if VIF Config and VIF State reflect AP Profile from CloudSDK - ## VIF Config - if args.skip_eap != True: - ssid_config = profile_info_dict[key]["ssid_list"] - else: - ssid_config = [x for x in profile_info_dict[key]["ssid_list"] if "-EAP" not in x] - try: - print("SSIDs in AP Profile:", ssid_config) - - ssid_list = ap_connect.get_vif_config(ap_ip, ap_username, ap_password) - print("SSIDs in AP VIF Config:", ssid_list) - - if set(ssid_list) == set(ssid_config): - print("SSIDs in Wifi_VIF_Config Match AP Profile Config") - client.update_testrail(case_id=test_cases["bridge_vifc"], run_id=rid, status_id=1, - msg='SSIDs in VIF Config matches AP Profile Config') - report_data['tests'][key][test_cases["bridge_vifc"]] = "passed" - else: - print("SSIDs in Wifi_VIF_Config do not match desired AP Profile Config") - client.update_testrail(case_id=test_cases["bridge_vifc"], run_id=rid, status_id=5, - msg='SSIDs in VIF Config do not match AP Profile Config') - report_data['tests'][key][test_cases["bridge_vifc"]] = "failed" - except: - ssid_list = "ERROR" - print("Error accessing VIF Config from AP CLI") - client.update_testrail(case_id=test_cases["bridge_vifc"], run_id=rid, status_id=4, - msg='Cannot determine VIF Config - re-test required') - report_data['tests'][key][test_cases["bridge_vifc"]] = "error" - # VIF State - try: - ssid_state = ap_connect.get_vif_state(ap_ip, ap_username, ap_password) - print("SSIDs in AP VIF State:", ssid_state) - - if set(ssid_state) == set(ssid_config): - print("SSIDs properly applied on AP") - client.update_testrail(case_id=test_cases["bridge_vifs"], run_id=rid, status_id=1, - msg='SSIDs in VIF Config applied to VIF State') - report_data['tests'][key][test_cases["bridge_vifs"]] = "passed" - else: - print("SSIDs not applied on AP") - client.update_testrail(case_id=test_cases["bridge_vifs"], run_id=rid, status_id=5, - msg='SSIDs in VIF Config not applied to VIF State') - report_data['tests'][key][test_cases["bridge_vifs"]] = "failed" - - except: - ssid_list = "ERROR" - print("Error accessing VIF State from AP CLI") - print("Error accessing VIF Config from AP CLI") - client.update_testrail(case_id=test_cases["bridge_vifs"], run_id=rid, status_id=4, - msg='Cannot determine VIF State - re-test required') - report_data['tests'][key][test_cases["bridge_vifs"]] = "error" - - # Set LANForge port for tests - port = test_info.lanforge_bridge_port - - # print iwinfo for information - iwinfo = iwinfo_status(ap_ip, ap_username, ap_password) - print(iwinfo) - - ###Run Client Single Connectivity Test Cases for Bridge SSIDs - # TC5214 - 2.4 GHz WPA2-Enterprise - if args.skip_eap != True: - test_case = test_cases["2g_eap_bridge"] - radio = test_info.lanforge_2dot4g - #sta_list = [lanforge_prefix + "5214"] - sta_list = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model]["twoFourG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - try: - test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, prefix, security, eap_type, - identity, - ttls_password, test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - else: - pass - - ###Run Client Single Connectivity Test Cases for Bridge SSIDs - # TC - 2.4 GHz WPA2 - test_case = test_cases["2g_wpa2_bridge"] - radio = test_info.lanforge_2dot4g - #station = [lanforge_prefix + "2237"] - station = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model]["twoFourG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA2_PSK"] - security = "wpa2" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 2.4 GHz WPA - test_case = test_cases["2g_wpa_bridge"] - radio = test_info.lanforge_2dot4g - #station = [lanforge_prefix + "2420"] - station = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model]["twoFourG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model]["twoFourG_WPA_PSK"] - security = "wpa" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 5 GHz WPA2-Enterprise - if args.skip_eap != True: - test_case = test_cases["5g_eap_bridge"] - radio = test_info.lanforge_5g - #sta_list = [lanforge_prefix + "5215"] - sta_list = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model]["fiveG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - try: - test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, prefix, security, eap_type, - identity, - ttls_password, test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - else: - pass - - # TC 5 GHz WPA2 - test_case = test_cases["5g_wpa2_bridge"] - radio = test_info.lanforge_5g - #station = [lanforge_prefix + "2236"] - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model]["fiveG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] - security = "wpa2" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 5 GHz WPA - test_case = test_cases["5g_wpa_bridge"] - radio = test_info.lanforge_5g - #station = [lanforge_prefix + "2419"] - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model]["fiveG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] - security = "wpa" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # Update SSID Profile - update_profile_id = str(fiveG_wpa) - update_ssid = key+"_Updated_SSID" - update_auth = "wpa2OnlyPSK" - update_security = "wpa2" - update_psk = "12345678" - update_profile = CloudSDK.update_ssid_profile(cloudSDK_url, bearer, update_profile_id, update_ssid, update_auth, update_psk) - print(update_profile) - time.sleep(90) - - # TC - Update Bridge SSID profile - test_case = test_cases["bridge_ssid_update"] - radio = test_info.lanforge_5g - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, update_ssid, update_psk, - update_security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, update_ssid) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(5) - - print(report_data['tests'][key]) - logger.info("Testing for " + fw_model + "Bridge Mode SSIDs Complete") - with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - else: - print("Skipping Bridge tests at user request...") - pass - - ########################################################################### - ################# NAT Mode Client Connectivity ############################ - ########################################################################### - if args.skip_nat != True: - child_profiles = [rfProfileId] - ### Create SSID Profiles - ssid_template = "templates/ssid_profile_template.json" - - # 5G SSIDs - if args.skip_eap != True: - try: - fiveG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_EAP_NAT_' + today, customer_id, - profile_info_dict[fw_model + '_nat'][ - "fiveG_WPA2-EAP_SSID"], None, - radius_profile, - "wpa2OnlyRadius", "NAT", 1, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G EAP SSID created successfully - NAT mode") - client.update_testrail(case_id=test_cases["ssid_5g_eap_nat"], run_id=rid, status_id=1, - msg='5G EAP SSID created successfully - NAT mode') - report_data['tests'][key][test_cases["ssid_5g_eap_nat"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_eap) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_eap) - - except: - fiveG_eap = "error" - print("5G EAP SSID create failed - NAT mode") - client.update_testrail(case_id=test_cases["ssid_5g_eap_nat"], run_id=rid, status_id=5, - msg='5G EAP SSID create failed - NAT mode') - report_data['tests'][key][test_cases["ssid_5g_eap_nat"]] = "failed" - else: - pass - - try: - fiveG_wpa2 = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_WPA2_NAT_' + today, customer_id, - profile_info_dict[fw_model + '_nat']["fiveG_WPA2_SSID"], - profile_info_dict[fw_model + '_nat']["fiveG_WPA2_PSK"], - 0, "wpa2OnlyPSK", "NAT", 1, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G WPA2 SSID created successfully - NAT mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa2_nat"], run_id=rid, status_id=1, - msg='5G WPA2 SSID created successfully - NAT mode') - report_data['tests'][key][test_cases["ssid_5g_wpa2_nat"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_wpa2) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_wpa2) - except: - fiveG_wpa2 = "error" - print("5G WPA2 SSID create failed - NAT mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa2_nat"], run_id=rid, status_id=5, - msg='5G WPA2 SSID create failed - NAT mode') - report_data['tests'][key][test_cases["ssid_5g_wpa2_nat"]] = "failed" - - try: - fiveG_wpa = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_WPA_NAT_' + today, customer_id, - profile_info_dict[fw_model + '_nat']["fiveG_WPA_SSID"], - profile_info_dict[fw_model + '_nat']["fiveG_WPA_PSK"], - 0, "wpaPSK", "NAT", 1, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G WPA SSID created successfully - NAT mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa_nat"], run_id=rid, status_id=1, - msg='5G WPA SSID created successfully - NAT mode') - report_data['tests'][key][test_cases["ssid_5g_wpa_nat"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_wpa) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_wpa) - except: - fiveG_wpa = "error" - print("5G WPA SSID create failed - NAT mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa_nat"], run_id=rid, status_id=5, - msg='5G WPA SSID create failed - NAT mode') - report_data['tests'][key][test_cases["ssid_5g_wpa_nat"]] = "failed" - - # 2.4G SSIDs - if args.skip_eap != True: - try: - twoFourG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_EAP_NAT_' + today, customer_id, - profile_info_dict[fw_model + '_nat'][ - "twoFourG_WPA2-EAP_SSID"], - None, - radius_profile, "wpa2OnlyRadius", "NAT", 1, ["is2dot4GHz"]) - print("2.4G EAP SSID created successfully - NAT mode") - client.update_testrail(case_id=test_cases["ssid_2g_eap_nat"], run_id=rid, status_id=1, - msg='2.4G EAP SSID created successfully - NAT mode') - report_data['tests'][key][test_cases["ssid_2g_eap_nat"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_eap) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_eap) - except: - twoFourG_eap = "error" - print("2.4G EAP SSID create failed - NAT mode") - client.update_testrail(case_id=test_cases["ssid_2g_eap_nat"], run_id=rid, status_id=5, - msg='2.4G EAP SSID create failed - NAT mode') - report_data['tests'][key][test_cases["ssid_2g_eap_nat"]] = "failed" - else: - pass - - try: - twoFourG_wpa2 = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_WPA2_NAT_' + today, customer_id, - profile_info_dict[fw_model + '_nat']["twoFourG_WPA2_SSID"], - profile_info_dict[fw_model + '_nat']["twoFourG_WPA2_PSK"], - 0, "wpa2OnlyPSK", "NAT", 1, - ["is2dot4GHz"]) - print("2.4G WPA2 SSID created successfully - NAT mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa2_nat"], run_id=rid, status_id=1, - msg='2.4G WPA2 SSID created successfully - NAT mode') - report_data['tests'][key][test_cases["ssid_2g_wpa2_nat"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_wpa2) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_wpa2) - except: - twoFourG_wpa2 = "error" - print("2.4G WPA2 SSID create failed - NAT mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa2_nat"], run_id=rid, status_id=5, - msg='2.4G WPA2 SSID create failed - NAT mode') - report_data['tests'][key][test_cases["ssid_2g_wpa2_nat"]] = "failed" - try: - twoFourG_wpa = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_WPA_NAT_' + today, customer_id, - profile_info_dict[fw_model + '_nat']["twoFourG_WPA_SSID"], - profile_info_dict[fw_model + '_nat']["twoFourG_WPA_PSK"], - 0, "wpaPSK", "NAT", 1, - ["is2dot4GHz"]) - print("2.4G WPA SSID created successfully - NAT mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa_nat"], run_id=rid, status_id=1, - msg='2.4G WPA SSID created successfully - NAT mode') - report_data['tests'][key][test_cases["ssid_2g_wpa_nat"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_wpa) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_wpa) - except: - twoFourG_wpa = "error" - print("2.4G WPA SSID create failed - NAT mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa_nat"], run_id=rid, status_id=5, - msg='2.4G WPA SSID create failed - NAT mode') - report_data['tests'][key][test_cases["ssid_2g_wpa_nat"]] = "failed" - - ### Create AP NAT Profile - print(child_profiles) - ap_template = "templates/ap_profile_template.json" - name = "Nightly_Sanity_" + fw_model + "_" + today + "_nat" - - try: - create_ap_profile = CloudSDK.create_ap_profile(cloudSDK_url, bearer, ap_template, name, customer_id, child_profiles) - test_profile_id = create_ap_profile - print("Test Profile ID for Test is:", test_profile_id) - client.update_testrail(case_id=test_cases["ap_nat"], run_id=rid, status_id=1, - msg='AP profile for NAT tests created successfully') - report_data['tests'][key][test_cases["ap_nat"]] = "passed" - # Add created profile to list for AP profile - # Add created profile to list for deletion at end of test - delete_list.append(test_profile_id) - except: - create_ap_profile = "error" - #test_profile_id = profile_info_dict[fw_model + '_nat']["profile_id"] - print("Error creating AP profile for NAT tests. Will use existing AP profile") - client.update_testrail(case_id=test_cases["ap_nat"], run_id=rid, status_id=5, - msg='AP profile for NAT tests could not be created using API') - report_data['tests'][key][test_cases["ap_nat"]] = "failed" - - ###Set Proper AP Profile for NAT SSID Tests - ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer) - - ### Wait for Profile Push - time.sleep(180) - - ###Check if VIF Config and VIF State reflect AP Profile from CloudSDK - ## VIF Config - if args.skip_eap != True: - ssid_config = profile_info_dict[fw_model + '_nat']["ssid_list"] - else: - ssid_config = [x for x in profile_info_dict[fw_model + '_nat']["ssid_list"] if "-EAP" not in x] - try: - print("SSIDs in AP Profile:", ssid_config) - - ssid_list = ap_connect.get_vif_config(ap_ip, ap_username, ap_password) - print("SSIDs in AP VIF Config:", ssid_list) - - if set(ssid_list) == set(ssid_config): - print("SSIDs in Wifi_VIF_Config Match AP Profile Config") - client.update_testrail(case_id=test_cases["nat_vifc"], run_id=rid, status_id=1, - msg='SSIDs in VIF Config matches AP Profile Config') - report_data['tests'][key][test_cases["nat_vifc"]] = "passed" - else: - print("SSIDs in Wifi_VIF_Config do not match desired AP Profile Config") - client.update_testrail(case_id=test_cases["nat_vifc"], run_id=rid, status_id=5, - msg='SSIDs in VIF Config do not match AP Profile Config') - report_data['tests'][key][test_cases["nat_vifc"]] = "failed" - except: - ssid_list = "ERROR" - print("Error accessing VIF Config from AP CLI") - client.update_testrail(case_id=test_cases["nat_vifc"], run_id=rid, status_id=4, - msg='Cannot determine VIF Config - re-test required') - report_data['tests'][key][test_cases["nat_vifc"]] = "error" - # VIF State - try: - ssid_state = ap_connect.get_vif_state(ap_ip, ap_username, ap_password) - print("SSIDs in AP VIF State:", ssid_state) - - if set(ssid_state) == set(ssid_config): - print("SSIDs properly applied on AP") - client.update_testrail(case_id=test_cases["nat_vifs"], run_id=rid, status_id=1, - msg='SSIDs in VIF Config applied to VIF State') - report_data['tests'][key][test_cases["nat_vifs"]] = "passed" - else: - print("SSIDs not applied on AP") - client.update_testrail(case_id=test_cases["nat_vifs"], run_id=rid, status_id=5, - msg='SSIDs in VIF Config not applied to VIF State') - report_data['tests'][key][test_cases["nat_vifs"]] = "failed" - except: - ssid_list = "ERROR" - print("Error accessing VIF State from AP CLI") - print("Error accessing VIF Config from AP CLI") - client.update_testrail(case_id=test_cases["nat_vifs"], run_id=rid, status_id=4, - msg='Cannot determine VIF State - re-test required') - report_data['tests'][key][test_cases["nat_vifs"]] = "error" - - ### Set LANForge port for tests - port = test_info.lanforge_bridge_port - - # Print iwinfo for logs - iwinfo = iwinfo_status(ap_ip, ap_username, ap_password) - print(iwinfo) - - ###Run Client Single Connectivity Test Cases for NAT SSIDs - # TC - 2.4 GHz WPA2-Enterprise NAT - if args.skip_eap != True: - test_case = test_cases["2g_eap_nat"] - radio = test_info.lanforge_2dot4g - #sta_list = [lanforge_prefix + "5216"] - sta_list = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model + '_nat']["twoFourG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - try: - test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, prefix, security, eap_type, - identity, - ttls_password, test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - else: - pass - - # TC - 2.4 GHz WPA2 NAT - test_case = test_cases["2g_wpa2_nat"] - radio = test_info.lanforge_2dot4g - #station = [lanforge_prefix + "4325"] - station = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model + '_nat']["twoFourG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model + '_nat']["twoFourG_WPA2_PSK"] - security = "wpa2" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 2.4 GHz WPA NAT - test_case = test_cases["2g_wpa_nat"] - radio = test_info.lanforge_2dot4g - #station = [lanforge_prefix + "4323"] - station = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model + '_nat']["twoFourG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model + '_nat']["twoFourG_WPA_PSK"] - security = "wpa" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 5 GHz WPA2-Enterprise NAT - if args.skip_eap != True: - test_case = test_cases["5g_eap_nat"] - radio = test_info.lanforge_5g - #sta_list = [lanforge_prefix + "5217"] - sta_list = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model + '_nat']["fiveG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - try: - test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, prefix, security, eap_type, - identity, - ttls_password, test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 5 GHz WPA2 NAT - test_case = test_cases["5g_wpa2_nat"] - radio = test_info.lanforge_5g - #station = [lanforge_prefix + "4326"] - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model + '_nat']["fiveG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] - security = "wpa2" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 5 GHz WPA NAT - test_case = test_cases["5g_wpa_nat"] - radio = test_info.lanforge_5g - #station = [lanforge_prefix + "4324"] - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model + '_nat']["fiveG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] - security = "wpa" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # Update SSID Profile - update_profile_id = str(fiveG_wpa2) - update_ssid = key + "_Updated_SSID_NAT" - update_auth = "wpaPSK" - update_security = "wpa" - update_psk = "12345678" - update_profile = CloudSDK.update_ssid_profile(cloudSDK_url, bearer, update_profile_id, update_ssid, - update_auth, update_psk) - print(update_profile) - time.sleep(90) - - # TC - Update NAT SSID profile - test_case = test_cases["nat_ssid_update"] - radio = test_info.lanforge_5g - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, update_ssid, update_psk, - update_security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, update_ssid) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(5) - - print(report_data['tests'][key]) - logger.info("Testing for " + fw_model + "NAT Mode SSIDs Complete") - with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - else: - print("Skipping NAT tests at user request...") - pass - - ########################################################################### - ################# Customer VLAN Client Connectivity ####################### - ########################################################################### - if args.skip_vlan != True: - child_profiles = [rfProfileId] - ### Create SSID Profiles - ssid_template = "templates/ssid_profile_template.json" - - # 5G SSIDs - if args.skip_eap != True: - try: - fiveG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_EAP_VLAN' + today, customer_id, - profile_info_dict[fw_model + '_vlan'][ - "fiveG_WPA2-EAP_SSID"], None, - radius_profile, - "wpa2OnlyRadius", "BRIDGE", test_info.vlan, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G EAP SSID created successfully - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_5g_eap_vlan"], run_id=rid, status_id=1, - msg='5G EAP SSID created successfully - Custom VLAN mode') - report_data['tests'][key][test_cases["ssid_5g_eap_vlan"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_eap) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_eap) - - except: - fiveG_eap = "error" - print("5G EAP SSID create failed - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_5g_eap_vlan"], run_id=rid, status_id=5, - msg='5G EAP SSID create failed - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_5g_eap_vlan"]] = "failed" - else: - pass - - try: - fiveG_wpa2 = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_WPA2_VLAN' + today, customer_id, - profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_SSID"], - profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_PSK"], - 0, "wpa2OnlyPSK", "BRIDGE", test_info.vlan, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G WPA2 SSID created successfully - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa2_vlan"], run_id=rid, status_id=1, - msg='5G WPA2 SSID created successfully - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_5g_wpa2_vlan"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_wpa2) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_wpa2) - except: - fiveG_wpa2 = "error" - print("5G WPA2 SSID create failed - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa2_vlan"], run_id=rid, status_id=5, - msg='5G WPA2 SSID create failed - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_5g_wpa2_vlan"]] = "failed" - - try: - fiveG_wpa = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_5G_WPA_VLAN_' + today, customer_id, - profile_info_dict[fw_model + '_vlan']["fiveG_WPA_SSID"], - profile_info_dict[fw_model + '_vlan']["fiveG_WPA_PSK"], - 0, "wpaPSK", "BRIDGE", test_info.vlan, - ["is5GHzU", "is5GHz", "is5GHzL"]) - print("5G WPA SSID created successfully - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa_vlan"], run_id=rid, status_id=1, - msg='5G WPA SSID created successfully - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_5g_wpa_vlan"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(fiveG_wpa) - # Add created profile to list for deletion at end of test - delete_list.append(fiveG_wpa) - except: - fiveG_wpa = "error" - print("5G WPA SSID create failed - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_5g_wpa_vlan"], run_id=rid, status_id=5, - msg='5G WPA SSID create failed - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_5g_wpa_vlan"]] = "failed" - - # 2.4G SSIDs - if args.skip_eap != True: - try: - twoFourG_eap = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_EAP_VLAN_' + today, customer_id, - profile_info_dict[fw_model + '_vlan'][ - "twoFourG_WPA2-EAP_SSID"], - None, - radius_profile, "wpa2OnlyRadius", "BRIDGE", test_info.vlan, - ["is2dot4GHz"]) - print("2.4G EAP SSID created successfully - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_2g_eap_vlan"], run_id=rid, status_id=1, - msg='2.4G EAP SSID created successfully - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_2g_eap_vlan"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_eap) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_eap) - except: - twoFourG_eap = "error" - print("2.4G EAP SSID create failed - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_2g_eap_vlan"], run_id=rid, status_id=5, - msg='2.4G EAP SSID create failed - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_2g_eap_vlan"]] = "failed" - else: - pass - - try: - twoFourG_wpa2 = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_WPA2_VLAN_' + today, customer_id, - profile_info_dict[fw_model + '_vlan'][ - "twoFourG_WPA2_SSID"], - profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_PSK"], - 0, "wpa2OnlyPSK", "BRIDGE", test_info.vlan, - ["is2dot4GHz"]) - print("2.4G WPA2 SSID created successfully - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa2_vlan"], run_id=rid, status_id=1, - msg='2.4G WPA2 SSID created successfully - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_2g_wpa2_vlan"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_wpa2) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_wpa2) - except: - twoFourG_wpa2 = "error" - print("2.4G WPA2 SSID create failed - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa2_vlan"], run_id=rid, status_id=5, - msg='2.4G WPA2 SSID create failed - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_2g_wpa2_vlan"]] = "failed" - - try: - twoFourG_wpa = CloudSDK.create_ssid_profile(cloudSDK_url, bearer, ssid_template, - fw_model + '_2G_WPA_VLAN_' + today, customer_id, - profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_SSID"], - profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_PSK"], - 0, "wpaPSK", "BRIDGE", test_info.vlan, - ["is2dot4GHz"]) - print("2.4G WPA SSID created successfully - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa_vlan"], run_id=rid, status_id=1, - msg='2.4G WPA SSID created successfully - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_2g_wpa_vlan"]] = "passed" - # Add created profile to list for AP profile - child_profiles.append(twoFourG_wpa) - # Add created profile to list for deletion at end of test - delete_list.append(twoFourG_wpa) - except: - twoFourG_wpa = "error" - print("2.4G WPA SSID create failed - custom VLAN mode") - client.update_testrail(case_id=test_cases["ssid_2g_wpa_vlan"], run_id=rid, status_id=5, - msg='2.4G WPA SSID create failed - custom VLAN mode') - report_data['tests'][key][test_cases["ssid_2g_wpa_vlan"]] = "failed" - - ### Create AP VLAN Profile - print(child_profiles) - ap_template = "templates/ap_profile_template.json" - name = "Nightly_Sanity_" + fw_model + "_" + today + "_vlan" - - try: - create_ap_profile = CloudSDK.create_ap_profile(cloudSDK_url, bearer, ap_template, name, customer_id, child_profiles) - test_profile_id = create_ap_profile - print("Test Profile ID for Test is:", test_profile_id) - client.update_testrail(case_id=test_cases["ap_vlan"], run_id=rid, status_id=1, - msg='AP profile for VLAN tests created successfully') - report_data['tests'][key][test_cases["ap_vlan"]] = "passed" - # Add created profile to list for deletion at end of test - delete_list.append(test_profile_id) - except: - create_ap_profile = "error" - #test_profile_id = profile_info_dict[fw_model + '_vlan']["profile_id"] - print("Error creating AP profile for bridge tests. Will use existing AP profile") - client.update_testrail(case_id=test_cases["ap_vlan"], run_id=rid, status_id=5, - msg='AP profile for VLAN tests could not be created using API') - report_data['tests'][key][test_cases["ap_vlan"]] = "failed" - - ### Set Proper AP Profile for VLAN SSID Tests - ap_profile = CloudSDK.set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer) - - ### Wait for Profile Push - time.sleep(180) - - ###Check if VIF Config and VIF State reflect AP Profile from CloudSDK - ## VIF Config - if args.skip_eap != True: - ssid_config = profile_info_dict[fw_model + '_vlan']["ssid_list"] - else: - ssid_config = [x for x in profile_info_dict[fw_model + '_vlan']["ssid_list"] if "-EAP" not in x] - - try: - print("SSIDs in AP Profile:", ssid_config) - - ssid_list = ap_connect.get_vif_config(ap_ip, ap_username, ap_password) - print("SSIDs in AP VIF Config:", ssid_list) - - if set(ssid_list) == set(ssid_config): - print("SSIDs in Wifi_VIF_Config Match AP Profile Config") - client.update_testrail(case_id=test_cases["vlan_vifc"], run_id=rid, status_id=1, - msg='SSIDs in VIF Config matches AP Profile Config') - report_data['tests'][key][test_cases["vlan_vifc"]] = "passed" - else: - print("SSIDs in Wifi_VIF_Config do not match desired AP Profile Config") - client.update_testrail(case_id=test_cases["vlan_vifc"], run_id=rid, status_id=5, - msg='SSIDs in VIF Config do not match AP Profile Config') - report_data['tests'][key][test_cases["vlan_vifc"]] = "failed" - except: - ssid_list = "ERROR" - print("Error accessing VIF Config from AP CLI") - client.update_testrail(case_id=test_cases["vlan_vifc"], run_id=rid, status_id=4, - msg='Cannot determine VIF Config - re-test required') - report_data['tests'][key][test_cases["vlan_vifc"]] = "error" - # VIF State - try: - ssid_state = ap_connect.get_vif_state(ap_ip, ap_username, ap_password) - print("SSIDs in AP VIF State:", ssid_state) - - if set(ssid_state) == set(ssid_config): - print("SSIDs properly applied on AP") - client.update_testrail(case_id=test_cases["vlan_vifs"], run_id=rid, status_id=1, - msg='SSIDs in VIF Config applied to VIF State') - report_data['tests'][key][test_cases["vlan_vifs"]] = "passed" - else: - print("SSIDs not applied on AP") - client.update_testrail(case_id=test_cases["vlan_vifs"], run_id=rid, status_id=5, - msg='SSIDs in VIF Config not applied to VIF State') - report_data['tests'][key][test_cases["vlan_vifs"]] = "failed" - except: - ssid_list = "ERROR" - print("Error accessing VIF State from AP CLI") - print("Error accessing VIF Config from AP CLI") - client.update_testrail(case_id=test_cases["vlan_vifs"], run_id=rid, status_id=4, - msg='Cannot determine VIF State - re-test required') - report_data['tests'][key][test_cases["vlan_vifs"]] = "error" - - ### Set port for LANForge - port = test_info.lanforge_vlan_port - - # Print iwinfo for logs - iwinfo = iwinfo_status(ap_ip, ap_username, ap_password) - print(iwinfo) - - ###Run Client Single Connectivity Test Cases for VLAN SSIDs - # TC- 2.4 GHz WPA2-Enterprise VLAN - if args.skip_eap != True: - test_case = test_cases["2g_eap_vlan"] - radio = test_info.lanforge_2dot4g - #sta_list = [lanforge_prefix + "5253"] - sta_list = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - try: - test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, prefix, security, eap_type, - identity, - ttls_password, test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - else: - pass - # TC - 2.4 GHz WPA2 VLAN - test_case = test_cases["2g_wpa2_vlan"] - radio = test_info.lanforge_2dot4g - #station = [lanforge_prefix + "5251"] - station = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA2_PSK"] - security = "wpa2" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC 4323 - 2.4 GHz WPA VLAN - test_case = test_cases["2g_wpa_vlan"] - radio = test_info.lanforge_2dot4g - #station = [lanforge_prefix + "5252"] - station = [test_info.lanforge_2dot4g_station] - prefix = test_info.lanforge_2dot4g_prefix - ssid_name = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model + '_vlan']["twoFourG_WPA_PSK"] - security = "wpa" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC - 5 GHz WPA2-Enterprise VLAN - if args.skip_eap != True: - test_case = test_cases["5g_eap_vlan"] - radio = test_info.lanforge_5g - #sta_list = [lanforge_prefix + "5250"] - sta_list = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2-EAP_SSID"] - security = "wpa2" - eap_type = "TTLS" - try: - test_result = RunTest.Single_Client_EAP(port, sta_list, ssid_name, radio, prefix, security, eap_type, - identity, - ttls_password, test_case, rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - else: - pass - - # TC - 5 GHz WPA2 VLAN - test_case = test_cases["5g_wpa2_vlan"] - radio = test_info.lanforge_5g - #station = [lanforge_prefix + "5248"] - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA2_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA2_PSK"] - security = "wpa2" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # TC 4324 - 5 GHz WPA VLAN - test_case = test_cases["5g_wpa_vlan"] - radio = test_info.lanforge_5g - #station = [lanforge_prefix + "5249"] - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - ssid_name = profile_info_dict[fw_model + '_vlan']["fiveG_WPA_SSID"] - ssid_psk = profile_info_dict[fw_model]["fiveG_WPA_PSK"] - security = "wpa" - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, ssid_name, ssid_psk, security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, ssid_name) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(10) - - # Update SSID Profile - update_profile_id = str(fiveG_wpa) - update_ssid = key + "_Updated_SSID_NAT" - update_auth = "open" - update_security = "open" - update_psk = "" - update_profile = CloudSDK.update_ssid_profile(cloudSDK_url, bearer, update_profile_id, update_ssid, - update_auth, update_psk) - print(update_profile) - time.sleep(90) - - # TC - Updated VLAN SSID profile - test_case = test_cases["vlan_ssid_update"] - radio = test_info.lanforge_5g - station = [test_info.lanforge_5g_station] - prefix = test_info.lanforge_5g_prefix - try: - test_result = Test.Single_Client_Connectivity(port, radio, prefix, update_ssid, update_psk, - update_security, station, - test_case, - rid) - except: - test_result = "error" - Test.testrail_retest(test_case, rid, update_ssid) - pass - report_data['tests'][key][int(test_case)] = test_result - time.sleep(5) - - print(report_data['tests'][key]) - logger.info("Testing for " + fw_model + "Custom VLAN SSIDs Complete") - else: - print("Skipping VLAN tests at user request...") - pass - - logger.info("Testing for " + fw_model + "Complete") - - # Add indication of complete TC pass/fail to sanity_status for pass to external json used by Throughput Test - x = all(status == "passed" for status in report_data["tests"][key].values()) - print(x) - - if x == True: - sanity_status['sanity_status'][key] = "passed" - - else: - sanity_status['sanity_status'][key] = "failed" - - ##Update sanity_status.json to indicate there has been a test on at least one AP model tonight - sanity_status['sanity_run']['new_data'] = "yes" - - print(sanity_status) - - # write to json file - with open('sanity_status.json', 'w') as json_file: - json.dump(sanity_status, json_file) - - # write to report_data contents to json file so it has something in case of unexpected fail - print(report_data) - with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - - ########################################################################### - ################# Post-test Prfofile Cleanup ############################## - ########################################################################### - - # Set AP to use permanently available profile to allow for deletion of RADIUS, SSID, and AP profiles - print("Cleaning up! Deleting created test profiles") - print("Set AP to profile not created in test") - ap_profile = CloudSDK.set_ap_profile(equipment_id, 6, cloudSDK_url, bearer) - time.sleep(5) - - # Delete profiles in delete_list - for x in delete_list: - delete_profile = CloudSDK.delete_profile(cloudSDK_url, bearer, str(x)) - if delete_profile == "SUCCESS": - print("profile", x, "delete successful") - else: - print("Error deleting profile") - -# Dump all sanity test results to external json file again just to be sure -with open('sanity_status.json', 'w') as json_file: - json.dump(sanity_status, json_file) - -# Calculate percent of tests passed for report -for key in ap_models: - if report_data['fw_available'][key] == "No": - report_data["pass_percent"][key] = "Not Run" - else: - # no_of_tests = len(report_data["tests"][key]) - passed_tests = sum(x == "passed" for x in report_data["tests"][key].values()) - failed_tests = sum(y == "failed" for y in report_data["tests"][key].values()) - error_tests = sum(z == "error" for z in report_data["tests"][key].values()) - no_of_tests = len(case_ids) - if no_of_tests == 0: - print("No tests run for", key) - else: - print("--- Test Data for", key, "---") - print(key, "tests passed:", passed_tests) - print(key, "tests failed:", failed_tests) - print(key, "tests with error:", error_tests) - print(key, "total tests:", no_of_tests) - percent = float(passed_tests / no_of_tests) * 100 - percent_pass = round(percent, 2) - print(key, "pass rate is", str(percent_pass) + "%") - print("---------------------------") - report_data["pass_percent"][key] = str(percent_pass) + '%' - -# write to report_data contents to json file -print(report_data) -with open(report_path + today + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - -print(".....End of Sanity Test.....") -logger.info("End of Sanity Test run") diff --git a/tests/cicd_sanity/cloud_connect.py b/tests/cicd_sanity/cloud_connect.py deleted file mode 100755 index f6a3722ce..000000000 --- a/tests/cicd_sanity/cloud_connect.py +++ /dev/null @@ -1,292 +0,0 @@ -#!/usr/bin/python3 - -################################################################################## -# Module contains functions to interact with CloudSDK using APIs -# Start by calling get_bearer to obtain bearer token, then other APIs can be used -# -# Used by Nightly_Sanity and Throughput_Test ##################################### -################################################################################## - -import base64 -import urllib.request -from bs4 import BeautifulSoup -import ssl -import subprocess, os -from artifactory import ArtifactoryPath -import tarfile -import paramiko -from paramiko import SSHClient -from scp import SCPClient -import os -import pexpect -from pexpect import pxssh -import sys -import paramiko -from scp import SCPClient -import pprint -from pprint import pprint -from os import listdir -import re -import requests -import json -import logging -import datetime -import time - -###Class for CloudSDK Interaction via RestAPI -class CloudSDK: - def get_bearer(cloudSDK_url, cloud_type, user, password): - cloud_login_url = cloudSDK_url+"/management/"+cloud_type+"/oauth2/token" - payload = ''' - { - "userId": "'''+user+'''", - "password": "'''+password+'''" - } - ''' - headers = { - 'Content-Type': 'application/json' - } - try: - token_response = requests.request("POST", cloud_login_url, headers=headers, data=payload) - except requests.exceptions.RequestException as e: - raise SystemExit("Exiting Script! Cloud not get bearer token for reason:",e) - token_data = token_response.json() - bearer_token = token_data['access_token'] - return(bearer_token) - - def ap_firmware(customer_id,equipment_id, cloudSDK_url, bearer): - equip_fw_url = cloudSDK_url+"/portal/status/forEquipment?customerId="+customer_id+"&equipmentId="+equipment_id - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - status_response = requests.request("GET", equip_fw_url, headers=headers, data=payload) - status_code = status_response.status_code - if status_code == 200: - status_data = status_response.json() - #print(status_data) - try: - current_ap_fw = status_data[2]['details']['reportedSwVersion'] - return current_ap_fw - except: - current_ap_fw = "error" - return "ERROR" - - else: - return "ERROR" - - def CloudSDK_images(apModel, cloudSDK_url, bearer): - getFW_url = cloudSDK_url+"/portal/firmware/version/byEquipmentType?equipmentType=AP&modelId=" + apModel - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("GET", getFW_url, headers=headers, data=payload) - ap_fw_details = response.json() - ###return ap_fw_details - fwlist = [] - for version in ap_fw_details: - fwlist.append(version.get('versionName')) - return(fwlist) - #fw_versionNames = ap_fw_details[0]['versionName'] - #return fw_versionNames - - def firwmare_upload(commit, apModel,latest_image,fw_url,cloudSDK_url,bearer): - fw_upload_url = cloudSDK_url+"/portal/firmware/version" - payload = "{\n \"model_type\": \"FirmwareVersion\",\n \"id\": 0,\n \"equipmentType\": \"AP\",\n \"modelId\": \""+apModel+"\",\n \"versionName\": \""+latest_image+"\",\n \"description\": \"\",\n \"filename\": \""+fw_url+"\",\n \"commit\": \""+commit+"\",\n \"validationMethod\": \"MD5_CHECKSUM\",\n \"validationCode\": \"19494befa87eb6bb90a64fd515634263\",\n \"releaseDate\": 1596192028877,\n \"createdTimestamp\": 0,\n \"lastModifiedTimestamp\": 0\n}\n\n" - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + bearer - } - - response = requests.request("POST", fw_upload_url, headers=headers, data=payload) - #print(response) - upload_result = response.json() - return(upload_result) - - def get_firmware_id(latest_ap_image, cloudSDK_url, bearer): - #print(latest_ap_image) - fw_id_url = cloudSDK_url+"/portal/firmware/version/byName?firmwareVersionName="+latest_ap_image - - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("GET", fw_id_url, headers=headers, data=payload) - fw_data = response.json() - latest_fw_id = fw_data['id'] - return latest_fw_id - - def delete_firmware(fw_id, cloudSDK_url, bearer): - url = cloudSDK_url + '/portal/firmware/version?firmwareVersionId=' + fw_id - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("DELETE", url, headers=headers, data=payload) - return(response) - - def update_firmware(equipment_id, latest_firmware_id, cloudSDK_url, bearer): - url = cloudSDK_url+"/portal/equipmentGateway/requestFirmwareUpdate?equipmentId="+equipment_id+"&firmwareVersionId="+latest_firmware_id - - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - - response = requests.request("POST", url, headers=headers, data=payload) - #print(response.text) - return response.json() - - def set_ap_profile(equipment_id, test_profile_id, cloudSDK_url, bearer): - ###Get AP Info - url = cloudSDK_url+"/portal/equipment?equipmentId="+equipment_id - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - - response = requests.request("GET", url, headers=headers, data=payload) - print(response) - - ###Add Lab Profile ID to Equipment - equipment_info = response.json() - #print(equipment_info) - equipment_info["profileId"] = test_profile_id - #print(equipment_info) - - ###Update AP Info with Required Profile ID - url = cloudSDK_url+"/portal/equipment" - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + bearer - } - - response = requests.request("PUT", url, headers=headers, data=json.dumps(equipment_info)) - #print(response) - - def get_cloudsdk_version(cloudSDK_url, bearer): - #print(latest_ap_image) - url = cloudSDK_url+"/ping" - - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("GET", url, headers=headers, data=payload) - cloud_sdk_version = response.json() - return cloud_sdk_version - - def create_ap_profile(cloudSDK_url, bearer, template, name, customer_id, child_profiles): - with open(template, 'r+') as ap_profile: - profile = json.load(ap_profile) - profile["name"] = name - profile['customerId'] = customer_id - profile["childProfileIds"] = child_profiles - - with open(template, 'w') as ap_profile: - json.dump(profile, ap_profile) - - url = cloudSDK_url+"/portal/profile" - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("POST", url, headers=headers, data=open(template, 'rb')) - ap_profile = response.json() - print(ap_profile) - ap_profile_id = ap_profile['id'] - return ap_profile_id - - def create_ssid_profile(cloudSDK_url, bearer, template, name, customer_id, ssid, passkey, radius, security, mode, vlan, radios): - with open(template, 'r+') as ssid_profile: - profile = json.load(ssid_profile) - profile['name'] = name - profile['customerId'] = customer_id - profile['details']['ssid'] = ssid - profile['details']['keyStr'] = passkey - profile['details']['radiusServiceId'] = radius - profile['details']['secureMode'] = security - profile['details']['forwardMode'] = mode - profile['details']['vlanId'] = vlan - profile['details']['appliedRadios'] = radios - if radius != 0: - profile["childProfileIds"] = [radius] - else: - profile["childProfileIds"] = [] - with open(template, 'w') as ssid_profile: - json.dump(profile, ssid_profile) - - url = cloudSDK_url + "/portal/profile" - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("POST", url, headers=headers, data=open(template, 'rb')) - ssid_profile = response.json() - #print(ssid_profile) - ssid_profile_id = ssid_profile['id'] - return ssid_profile_id - - def create_radius_profile(cloudSDK_url, bearer, template, name, customer_id, server_ip, secret, auth_port): - with open(template, 'r+') as radius_profile: - profile = json.load(radius_profile) - - profile['name'] = name - profile['customerId'] = customer_id - profile['details']["primaryRadiusAuthServer"]['ipAddress'] = server_ip - profile['details']["primaryRadiusAuthServer"]['secret'] = secret - profile['details']["primaryRadiusAuthServer"]['port'] = auth_port - - with open(template, 'w') as radius_profile: - json.dump(profile, radius_profile) - - url = cloudSDK_url + "/portal/profile" - headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("POST", url, headers=headers, data=open(template, 'rb')) - radius_profile = response.json() - radius_profile_id = radius_profile['id'] - return radius_profile_id - - def delete_profile(cloudSDK_url, bearer, profile_id): - url = cloudSDK_url + "/portal/profile?profileId="+profile_id - payload = {} - headers = { - 'Authorization': 'Bearer ' + bearer - } - del_profile = requests.request("DELETE", url, headers=headers, data=payload) - status_code = del_profile.status_code - if status_code == 200: - return("SUCCESS") - else: - return ("ERROR") - - def update_ssid_profile(cloudSDK_url, bearer, profile_id, new_ssid, new_secure_mode, new_psk): - get_profile_url = cloudSDK_url + "/portal/profile?profileId="+profile_id - - payload = {} - headers = headers = { - 'Authorization': 'Bearer ' + bearer - } - - response = requests.request("GET", get_profile_url, headers=headers, data=payload) - original_profile = response.json() - print(original_profile) - - original_profile['details']['ssid'] = new_ssid - original_profile['details']['secureMode'] = new_secure_mode - original_profile['details']['keyStr'] = new_psk - - put_profile_url = cloudSDK_url + "/portal/profile" - payload = original_profile - headers = headers = { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + bearer - } - response = requests.request("PUT", put_profile_url, headers=headers, json=payload) - print(response) - updated_profile = response.json() - return updated_profile \ No newline at end of file diff --git a/tests/cicd_sanity/nola04_test_info.py b/tests/cicd_sanity/nola04_test_info.py deleted file mode 100644 index c36fbde5b..000000000 --- a/tests/cicd_sanity/nola04_test_info.py +++ /dev/null @@ -1,249 +0,0 @@ -#!/usr/bin/python3 - -##AP Models Under Test -ap_models = ["ecw5410"] - -##Cloud Type(cloudSDK = v1) -cloud_type = "v1" -cloudSDK_url = "https://wlan-portal-svc-nola-04.cicd.lab.wlan.tip.build" -customer_id = "2" -cloud_user = "support@example.com" -cloud_password = "support" - -# LANForge Info -lanforge_ip = "10.28.3.12" -lanforge_2dot4g = "wiphy4" -lanforge_5g = "wiphy5" -# For single client connectivity use cases, use full station name for prefix to only read traffic from client under test -lanforge_2dot4g_prefix = "test" -lanforge_5g_prefix = "test" -lanforge_2dot4g_station = "test1234" -lanforge_5g_station = "test1234" -# Used for bridge and NAT -lanforge_bridge_port = "eth2" -# VLAN interface on LANForge - must be configured to use alias of "vlan###" to accommodate sta_connect2 library -lanforge_vlan_port = "vlan100" -vlan = 100 - -##Equipment IDs for Lab APs under test -equipment_id_dict = { - "ecw5410": "1", -} -# Equipment IPs for SSH or serial connection information -equipment_ip_dict = { - "ecw5410": "/dev/ttyAP4" -} - -equipment_credentials_dict = { - "ecw5410": "openwifi", -} - -##RADIUS Info -radius_info = { - "server_ip": "10.28.3.100", - "secret": "testing123", - "auth_port": 1812, - "eap_identity": "nolaradius", - "eap_pwd": "nolastart" -} -##AP Models for firmware upload -cloud_sdk_models = { - "ec420": "EC420-G1", - "ea8300": "EA8300-CA", - "ecw5211": "ECW5211", - "ecw5410": "ECW5410", - "wf188n": "WF188N", - "wf194c": "WF194C", - "ex227": "EX227", - "ex447": "EX447", - "eap101": "EAP101", - "eap102": "EAP102" -} - -ap_spec = { - "ec420": "wifi5", - "ea8300": "wifi5", - "ecw5211": "wifi5", - "ecw5410": "wifi5", - "wf188n": "wifi6", - "wf194c": "wifi6", - "ex227": "wifi6", - "ex447": "wifi6", - "eap101": "wifi6", - "eap102": "wifi6" -} - -mimo_5g = { - "ec420": "4x4", - "ea8300": "2x2", - "ecw5211": "2x2", - "ecw5410": "4x4", - "wf188n": "2x2", - "wf194c": "8x8", - "ex227": "", - "ex447": "", - "eap101": "2x2", - "eap102": "4x4" -} - -mimo_2dot4g = { - "ec420": "2x2", - "ea8300": "2x2", - "ecw5211": "2x2", - "ecw5410": "4x4", - "wf188n": "2x2", - "wf194c": "4x4", - "ex227": "", - "ex447": "", - "eap101": "2x2", - "eap102": "4x4" -} - -sanity_status = { - "ea8300": "failed", - "ecw5211": 'passed', - "ecw5410": 'failed', - "ec420": 'failed', - "wf188n": "failed", - "wf194c": "failed", - "ex227": "failed", - "ex447": "failed", - "eap101": "failed", - "eap102": "failed" -} - -##Test Case information - Maps a generic TC name to TestRail TC numbers -test_cases = { - "ap_upgrade": 2233, - "5g_wpa2_bridge": 2236, - "2g_wpa2_bridge": 2237, - "5g_wpa_bridge": 2419, - "2g_wpa_bridge": 2420, - "2g_wpa_nat": 4323, - "5g_wpa_nat": 4324, - "2g_wpa2_nat": 4325, - "5g_wpa2_nat": 4326, - "2g_eap_bridge": 5214, - "5g_eap_bridge": 5215, - "2g_eap_nat": 5216, - "5g_eap_nat": 5217, - "cloud_connection": 5222, - "cloud_fw": 5247, - "5g_wpa2_vlan": 5248, - "5g_wpa_vlan": 5249, - "5g_eap_vlan": 5250, - "2g_wpa2_vlan": 5251, - "2g_wpa_vlan": 5252, - "2g_eap_vlan": 5253, - "cloud_ver": 5540, - "bridge_vifc": 5541, - "nat_vifc": 5542, - "vlan_vifc": 5543, - "bridge_vifs": 5544, - "nat_vifs": 5545, - "vlan_vifs": 5546, - "upgrade_api": 5547, - "create_fw": 5548, - "ap_bridge": 5641, - "ap_nat": 5642, - "ap_vlan": 5643, - "ssid_2g_eap_bridge": 5644, - "ssid_2g_wpa2_bridge": 5645, - "ssid_2g_wpa_bridge": 5646, - "ssid_5g_eap_bridge": 5647, - "ssid_5g_wpa2_bridge": 5648, - "ssid_5g_wpa_bridge": 5649, - "ssid_2g_eap_nat": 5650, - "ssid_2g_wpa2_nat": 5651, - "ssid_2g_wpa_nat": 5652, - "ssid_5g_eap_nat": 5653, - "ssid_5g_wpa2_nat": 5654, - "ssid_5g_wpa_nat": 5655, - "ssid_2g_eap_vlan": 5656, - "ssid_2g_wpa2_vlan": 5657, - "ssid_2g_wpa_vlan": 5658, - "ssid_5g_eap_vlan": 5659, - "ssid_5g_wpa2_vlan": 5660, - "ssid_5g_wpa_vlan": 5661, - "radius_profile": 5808, - "bridge_ssid_update": 8742, - "nat_ssid_update": 8743, - "vlan_ssid_update": 8744 -} - -## Other profiles -radius_profile = 9 -rf_profile_wifi5 = 10 -rf_profile_wifi6 = 762 - -###Testing AP Profile Information -profile_info_dict = { - "ecw5410": { - "fiveG_WPA2_SSID": "ECW5410_5G_WPA2", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "ECW5410_5G_WPA", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "ECW5410_5G_OPEN", - "fiveG_WPA2-EAP_SSID": "ECW5410_5G_WPA2-EAP", - "twoFourG_OPEN_SSID": "ECW5410_2dot4G_OPEN", - "twoFourG_WPA2_SSID": "ECW5410_2dot4G_WPA2", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP", - "ssid_list": [ - "ECW5410_5G_WPA2", - "ECW5410_5G_WPA", - "ECW5410_5G_WPA2-EAP", - "ECW5410_2dot4G_WPA2", - "ECW5410_2dot4G_WPA", - "ECW5410_2dot4G_WPA2-EAP" - ] - }, - - "ecw5410_nat": { - "fiveG_WPA2_SSID": "ECW5410_5G_WPA2_NAT", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "ECW5410_5G_WPA_NAT", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "ECW5410_5G_OPEN_NAT", - "fiveG_WPA2-EAP_SSID": "ECW5410_5G_WPA2-EAP_NAT", - "twoFourG_OPEN_SSID": "ECW5410_2dot4G_OPEN_NAT", - "twoFourG_WPA2_SSID": "ECW5410_2dot4G_WPA2_NAT", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA_NAT", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_NAT", - "ssid_list": [ - "ECW5410_5G_WPA2_NAT", - "ECW5410_5G_WPA_NAT", - "ECW5410_5G_WPA2-EAP_NAT", - "ECW5410_2dot4G_WPA2_NAT", - "ECW5410_2dot4G_WPA_NAT", - "ECW5410_2dot4G_WPA2-EAP_NAT" - ] - }, - - "ecw5410_vlan": { - "fiveG_WPA2_SSID": "ECW5410_5G_WPA2_VLAN", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "ECW5410_5G_WPA_VLAN", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "ECW5410_5G_OPEN_VLAN", - "fiveG_WPA2-EAP_SSID": "ECW5410_5G_WPA2-EAP_VLAN", - "twoFourG_OPEN_SSID": "ECW5410_2dot4G_OPEN_VLAN", - "twoFourG_WPA2_SSID": "ECW5410_2dot4G_WPA2_VLAN", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA_VLAN", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_VLAN", - "ssid_list": [ - "ECW5410_5G_WPA2_VLAN", - "ECW5410_5G_WPA_VLAN", - "ECW5410_5G_WPA2-EAP_VLAN", - "ECW5410_2dot4G_WPA2_VLAN", - "ECW5410_2dot4G_WPA_VLAN", - "ECW5410_2dot4G_WPA2-EAP_VLAN" - ] - } -} \ No newline at end of file diff --git a/tests/cicd_sanity/reports/report_template.php b/tests/cicd_sanity/reports/report_template.php deleted file mode 100755 index 8ceb44161..000000000 --- a/tests/cicd_sanity/reports/report_template.php +++ /dev/null @@ -1,1838 +0,0 @@ - - - - -Testing Report - - - - - - - - -
-

CICD Nightly Sanity Report -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Test Results

Scroll Down for Additional AP Models... -
EA8300 ResultECW5211 ResultECW5410 ResultEC420 Result
New FW Available
FW Under Test
CloudSDK Commit Date
CloudSDK Commit ID
CloudSDK Project Version
Test Pass Rate
Test CaseCategoryDescription
5540CloudSDKGet CloudSDK Version with API
5548CloudSDKCreate FW version on CloudSDK using API
5547CloudSDKRequest AP Upgrade using API
2233APAP Upgrade Successful
5247CloudSDKCloudSDK Reports Correct FW
5222CloudSDKAP-CloudSDK Connection Active
5808CloudSDKCreate RADIUS Profile
5644CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Bridge Mode
5645CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Bridge Mode
5646CloudSDKCreate SSID Profile 2.4 GHz WPA - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2 - Bridge Mode
5648CloudSDKCreate SSID Profile 5 GHz WPA - Bridge Mode
5641CloudSDKCreate AP Profile - Bridge Mode
5541CloudSDKCloudSDK Pushes Correct AP Profile - Bridge Mode
5544APAP Applies Correct AP Profile - Bridge Mode
5214APClient connects to 2.4 GHz WPA2-EAP - Bridge Mode
2237APClient connects to 2.4 GHz WPA2 - Bridge Mode
2420APClient connects to 2.4 GHz WPA - Bridge Mode
5215APClient connects to 5 GHz WPA2-EAP - Bridge Mode
2236APClient connects to 5 GHz WPA2 - Bridge Mode
2419APClient connects to 5 GHz WPA - Bridge Mode
8742APClient connects to Updated SSID - Bridge Mode
5650CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - NAT Mode
5651CloudSDKCreate SSID Profile 2.4 GHz WPA2 - NAT Mode
5652CloudSDKCreate SSID Profile 2.4 GHz WPA - NAT Mode
5653CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - NAT Mode
5654CloudSDKCreate SSID Profile 5 GHz WPA2 - NAT Mode
5655CloudSDKCreate SSID Profile 5 GHz WPA - NAT Mode
5642CloudSDKCreate AP Profile - NAT Mode
5542CloudSDKCloudSDK Pushes Correct AP Profile - NAT Mode
5545APAP Applies Correct AP Profile - NAT Mode
5216APClient connects to 2.4 GHz WPA2-EAP - NAT Mode
4325APClient connects to 2.4 GHz WPA2 - NAT Mode
4323APClient connects to 2.4 GHz WPA - NAT Mode
5217APClient connects to 5 GHz WPA2-EAP - NAT Mode
4326APClient connects to 5 GHz WPA2 - NAT Mode
4324APClient connects to 5 GHz WPA - NAT Mode
8743APClient connects to Updated SSID - NAT Mode
5656CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Custom VLAN
5657CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Custom VLAN
5658CloudSDKCreate SSID Profile 2.4 GHz WPA - Custom VLAN
5659CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Custom VLAN
5660CloudSDKCreate SSID Profile 5 GHz WPA2 - Custom VLAN
5661CloudSDKCreate SSID Profile 5 GHz WPA - Custom VLAN
5643CloudSDKCreate AP Profile - Custom VLAN
5543CloudSDKCloudSDK Pushes Correct AP Profile - Custom VLAN
5546APAP Applies Correct AP Profile - Custom VLAN
5253APClient connects to 2.4 GHz WPA2-EAP - Custom VLAN
5251APClient connects to 2.4 GHz WPA2 - Custom VLAN
5252APClient connects to 2.4 GHz WPA - Custom VLAN
5250APClient connects to 5 GHz WPA2-EAP - Custom VLAN
5248APClient connects to 5 GHz WPA2 - Custom VLAN
5249APClient connects to 5 GHz WPA - Custom VLAN
8744APClient connects to Updated SSID - Custom VLAN
WF188N ResultWF194C ResultEX227 ResultEX447 Result
New FW Available
FW Under Test
CloudSDK Commit Date
CloudSDK Commit ID
CloudSDK Project Version
Test Pass Rate
Test CaseCategoryDescription
5540CloudSDKGet CloudSDK Version with API
5548CloudSDKCreate FW version on CloudSDK using API
5547CloudSDKRequest AP Upgrade using API
2233APAP Upgrade Successful
5247CloudSDKCloudSDK Reports Correct FW
5222CloudSDKAP-CloudSDK Connection Active
5808CloudSDKCreate RADIUS Profile
5644CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Bridge Mode
5645CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Bridge Mode
5646CloudSDKCreate SSID Profile 2.4 GHz WPA - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2 - Bridge Mode
5648CloudSDKCreate SSID Profile 5 GHz WPA - Bridge Mode
5641CloudSDKCreate AP Profile - Bridge Mode
5541CloudSDKCloudSDK Pushes Correct AP Profile - Bridge Mode
5544APAP Applies Correct AP Profile - Bridge Mode
5214APClient connects to 2.4 GHz WPA2-EAP - Bridge Mode
2237APClient connects to 2.4 GHz WPA2 - Bridge Mode
2420APClient connects to 2.4 GHz WPA - Bridge Mode
5215APClient connects to 5 GHz WPA2-EAP - Bridge Mode
2236APClient connects to 5 GHz WPA2 - Bridge Mode
2419APClient connects to 5 GHz WPA - Bridge Mode
8742APClient connects to Updated SSID - Bridge Mode
5650CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - NAT Mode
5651CloudSDKCreate SSID Profile 2.4 GHz WPA2 - NAT Mode
5652CloudSDKCreate SSID Profile 2.4 GHz WPA - NAT Mode
5653CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - NAT Mode
5654CloudSDKCreate SSID Profile 5 GHz WPA2 - NAT Mode
5655CloudSDKCreate SSID Profile 5 GHz WPA - NAT Mode
5642CloudSDKCreate AP Profile - NAT Mode
5542CloudSDKCloudSDK Pushes Correct AP Profile - NAT Mode
5545APAP Applies Correct AP Profile - NAT Mode
5216APClient connects to 2.4 GHz WPA2-EAP - NAT Mode
4325APClient connects to 2.4 GHz WPA2 - NAT Mode
4323APClient connects to 2.4 GHz WPA - NAT Mode
5217APClient connects to 5 GHz WPA2-EAP - NAT Mode
4326APClient connects to 5 GHz WPA2 - NAT Mode
8743APClient connects to Updated SSID - NAT Mode
4324APClient connects to 5 GHz WPA - NAT Mode
5656CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Custom VLAN
5657CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Custom VLAN
5658CloudSDKCreate SSID Profile 2.4 GHz WPA - Custom VLAN
5659CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Custom VLAN
5660CloudSDKCreate SSID Profile 5 GHz WPA2 - Custom VLAN
5661CloudSDKCreate SSID Profile 5 GHz WPA - Custom VLAN
5643CloudSDKCreate AP Profile - Custom VLAN
5543CloudSDKCloudSDK Pushes Correct AP Profile - Custom VLAN
5546APAP Applies Correct AP Profile - Custom VLAN
5253APClient connects to 2.4 GHz WPA2-EAP - Custom VLAN
5251APClient connects to 2.4 GHz WPA2 - Custom VLAN
5252APClient connects to 2.4 GHz WPA - Custom VLAN
5250APClient connects to 5 GHz WPA2-EAP - Custom VLAN
5248APClient connects to 5 GHz WPA2 - Custom VLAN
5249APClient connects to 5 GHz WPA - Custom VLAN
8744APClient connects to Updated SSID - VLAN Mode
EAP101 ResultEAP102 Result
New FW Available
FW Under Test
CloudSDK Commit Date
CloudSDK Commit ID
CloudSDK Project Version
Test Pass Rate
Test CaseCategoryDescription
5540CloudSDKGet CloudSDK Version with API
5548CloudSDKCreate FW version on CloudSDK using API
5547CloudSDKRequest AP Upgrade using API
2233APAP Upgrade Successful
5247CloudSDKCloudSDK Reports Correct FW
5222CloudSDKAP-CloudSDK Connection Active
5808CloudSDKCreate RADIUS Profile
5644CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Bridge Mode
5645CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Bridge Mode
5646CloudSDKCreate SSID Profile 2.4 GHz WPA - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2 - Bridge Mode
5648CloudSDKCreate SSID Profile 5 GHz WPA - Bridge Mode
5641CloudSDKCreate AP Profile - Bridge Mode
5541CloudSDKCloudSDK Pushes Correct AP Profile - Bridge Mode
5544APAP Applies Correct AP Profile - Bridge Mode
5214APClient connects to 2.4 GHz WPA2-EAP - Bridge Mode
2237APClient connects to 2.4 GHz WPA2 - Bridge Mode
2420APClient connects to 2.4 GHz WPA - Bridge Mode
5215APClient connects to 5 GHz WPA2-EAP - Bridge Mode
2236APClient connects to 5 GHz WPA2 - Bridge Mode
2419APClient connects to 5 GHz WPA - Bridge Mode
8742APClient connects to Updated SSID - Bridge Mode
5650CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - NAT Mode
5651CloudSDKCreate SSID Profile 2.4 GHz WPA2 - NAT Mode
5652CloudSDKCreate SSID Profile 2.4 GHz WPA - NAT Mode
5653CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - NAT Mode
5654CloudSDKCreate SSID Profile 5 GHz WPA2 - NAT Mode
5655CloudSDKCreate SSID Profile 5 GHz WPA - NAT Mode
5642CloudSDKCreate AP Profile - NAT Mode
5542CloudSDKCloudSDK Pushes Correct AP Profile - NAT Mode
5545APAP Applies Correct AP Profile - NAT Mode
5216APClient connects to 2.4 GHz WPA2-EAP - NAT Mode
4325APClient connects to 2.4 GHz WPA2 - NAT Mode
4323APClient connects to 2.4 GHz WPA - NAT Mode
5217APClient connects to 5 GHz WPA2-EAP - NAT Mode
4326APClient connects to 5 GHz WPA2 - NAT Mode
4324APClient connects to 5 GHz WPA - NAT Mode
8743APClient connects to Updated SSID - NAT Mode
5656CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Custom VLAN
5657CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Custom VLAN
5658CloudSDKCreate SSID Profile 2.4 GHz WPA - Custom VLAN
5659CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Custom VLAN
5660CloudSDKCreate SSID Profile 5 GHz WPA2 - Custom VLAN
5661CloudSDKCreate SSID Profile 5 GHz WPA - Custom VLAN
5643CloudSDKCreate AP Profile - Custom VLAN
5543CloudSDKCloudSDK Pushes Correct AP Profile - Custom VLAN
5546APAP Applies Correct AP Profile - Custom VLAN
5253APClient connects to 2.4 GHz WPA2-EAP - Custom VLAN
5251APClient connects to 2.4 GHz WPA2 - Custom VLAN
5252APClient connects to 2.4 GHz WPA - Custom VLAN
5250APClient connects to 5 GHz WPA2-EAP - Custom VLAN
5248APClient connects to 5 GHz WPA2 - Custom VLAN
5249APClient connects to 5 GHz WPA - Custom VLAN
8744APClient connects to Updated SSID - Custom
- - \ No newline at end of file diff --git a/tests/cicd_sanity/sanity_status.json b/tests/cicd_sanity/sanity_status.json deleted file mode 100755 index a68c377e2..000000000 --- a/tests/cicd_sanity/sanity_status.json +++ /dev/null @@ -1 +0,0 @@ -{"sanity_status": {"ea8300": "passed", "ecw5211": "passed", "ecw5410": "passed", "ec420": "passed", "wf188n": "failed", "wf193c": "failed", "ex227": "passed", "ex447": "failed", "eap101": "failed", "eap102": "failed", "wf194c": "failed"}, "sanity_run": {"new_data": "yes"}} \ No newline at end of file diff --git a/tests/cicd_sanity/templates/ap_profile_template.json b/tests/cicd_sanity/templates/ap_profile_template.json deleted file mode 100644 index 506661942..000000000 --- a/tests/cicd_sanity/templates/ap_profile_template.json +++ /dev/null @@ -1 +0,0 @@ -{"model_type": "Profile", "id": 2, "customerId": "2", "profileType": "equipment_ap", "name": "Nightly_Sanity_wf194c_2021-02-23_vlan", "details": {"model_type": "ApNetworkConfiguration", "networkConfigVersion": "AP-1", "equipmentType": "AP", "vlanNative": true, "vlan": 0, "ntpServer": {"model_type": "AutoOrManualString", "auto": true, "value": null}, "syslogRelay": {"model_type": "SyslogRelay", "enabled": false, "srvHostIp": null, "srvHostPort": 514, "severity": "NOTICE"}, "rtlsSettings": {"model_type": "RtlsSettings", "enabled": false, "srvHostIp": null, "srvHostPort": 0}, "syntheticClientEnabled": false, "ledControlEnabled": true, "equipmentDiscovery": false, "greTunnelName": null, "greParentIfName": null, "greLocalInetAddr": null, "greRemoteInetAddr": null, "greRemoteMacAddr": null, "radioMap": {"is5GHz": {"model_type": "RadioProfileConfiguration", "bestApEnabled": true, "bestAPSteerType": "both"}, "is2dot4GHz": {"model_type": "RadioProfileConfiguration", "bestApEnabled": true, "bestAPSteerType": "both"}, "is5GHzU": {"model_type": "RadioProfileConfiguration", "bestApEnabled": true, "bestAPSteerType": "both"}, "is5GHzL": {"model_type": "RadioProfileConfiguration", "bestApEnabled": true, "bestAPSteerType": "both"}}, "profileType": "equipment_ap"}, "createdTimestamp": 1598524693438, "lastModifiedTimestamp": 1607377963675, "childProfileIds": [762, 1292, 1293, 1294, 1295, 1296, 1297, 1299, 1300, 1301, 1302, 1303, 1304]} \ No newline at end of file diff --git a/tests/cicd_sanity/templates/radius_profile_template.json b/tests/cicd_sanity/templates/radius_profile_template.json deleted file mode 100644 index 6330d1444..000000000 --- a/tests/cicd_sanity/templates/radius_profile_template.json +++ /dev/null @@ -1 +0,0 @@ -{"model_type": "Profile", "id": 129, "customerId": "2", "profileType": "radius", "name": "Automation_RADIUS_2021-02-23", "details": {"model_type": "RadiusProfile", "primaryRadiusAuthServer": {"model_type": "RadiusServer", "ipAddress": "10.10.10.203", "secret": "testing123", "port": 1812, "timeout": 5}, "secondaryRadiusAuthServer": null, "primaryRadiusAccountingServer": null, "secondaryRadiusAccountingServer": null, "profileType": "radius"}, "createdTimestamp": 1602263176599, "lastModifiedTimestamp": 1611708334061, "childProfileIds": []} \ No newline at end of file diff --git a/tests/cicd_sanity/templates/ssid_profile_template.json b/tests/cicd_sanity/templates/ssid_profile_template.json deleted file mode 100644 index cdaf1d6cd..000000000 --- a/tests/cicd_sanity/templates/ssid_profile_template.json +++ /dev/null @@ -1 +0,0 @@ -{"model_type": "Profile", "id": 28, "customerId": "2", "profileType": "ssid", "name": "wf194c_2G_WPA_VLAN_2021-02-23", "details": {"model_type": "SsidConfiguration", "ssid": "WF194C_2dot4G_WPA_VLAN", "appliedRadios": ["is2dot4GHz"], "ssidAdminState": "enabled", "secureMode": "wpaPSK", "vlanId": 100, "keyStr": "Connectus123$", "broadcastSsid": "enabled", "keyRefresh": 0, "noLocalSubnets": false, "radiusServiceName": "Radius-Accounting-Profile", "radiusAccountingServiceName": null, "radiusAcountingServiceInterval": null, "captivePortalId": null, "bandwidthLimitDown": 0, "bandwidthLimitUp": 0, "clientBandwidthLimitDown": 0, "clientBandwidthLimitUp": 0, "videoTrafficOnly": false, "radioBasedConfigs": {"is2dot4GHz": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}, "is5GHz": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}, "is5GHzU": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}, "is5GHzL": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}}, "bonjourGatewayProfileId": null, "enable80211w": null, "wepConfig": null, "forwardMode": "BRIDGE", "profileType": "ssid", "radiusServiceId": 0}, "createdTimestamp": 1598557809816, "lastModifiedTimestamp": 1598557809816, "childProfileIds": []} \ No newline at end of file diff --git a/tests/cicd_sanity/test_info.py b/tests/cicd_sanity/test_info.py deleted file mode 100755 index acde3adac..000000000 --- a/tests/cicd_sanity/test_info.py +++ /dev/null @@ -1,276 +0,0 @@ -#!/usr/bin/python3 - -##AP Models Under Test -ap_models = ["ecw5410"] - -##Cloud Type(cloudSDK = v1) -cloud_type = "v1" -cloudSDK_url = "https://wlan-portal-svc-nola-ext-02.cicd.lab.wlan.tip.build" -customer_id = "2" -cloud_user = "support@example.com" -cloud_password = "support" - -##LANForge Info -lanforge_ip = "10.10.10.201" -lanforge_2dot4g = "wiphy6" -lanforge_5g = "wiphy6" -# For single client connectivity use cases, use full station name for prefix to only read traffic from client under test -lanforge_2dot4g_prefix = "wlan6" -lanforge_5g_prefix = "wlan6" -lanforge_2dot4g_station = "wlan6" -lanforge_5g_station = "wlan6" -lanforge_bridge_port = "eth2" -# VLAN interface on LANForge - must be configured to use alias of "vlan###" to accommodate sta_connect2 library -lanforge_vlan_port = "vlan100" -vlan = 100 - -# Equipment IDs for Lab APs under test - for test to loop through multiple APs put additional keys in the dictionary -equipment_id_dict = { - "ecw5410": "5", -} -# Equipment IPs for SSH or serial connection information -equipment_ip_dict = { - "ecw5410": "10.10.10.105" -} - -equipment_credentials_dict = { - "ecw5410": "openwifi", -} - -##RADIUS Info -radius_info = { - "server_ip": "10.10.10.203", - "secret": "testing123", - "auth_port": 1812, - "eap_identity": "testing", - "eap_pwd": "admin123" -} - -## Other profiles -radius_profile = 9 # used as backup -rf_profile_wifi5 = 10 -rf_profile_wifi6 = 762 - -##AP Models for firmware upload -cloud_sdk_models = { - "ec420": "EC420-G1", - "ea8300": "EA8300-CA", - "ecw5211": "ECW5211", - "ecw5410": "ECW5410", - "wf188n": "WF188N", - "wf194c": "WF194C", - "ex227": "EX227", - "ex447": "EX447", - "eap101": "EAP101", - "eap102": "EAP102" -} - -ap_spec = { - "ec420": "wifi5", - "ea8300": "wifi5", - "ecw5211": "wifi5", - "ecw5410": "wifi5", - "wf188n": "wifi6", - "wf194c": "wifi6", - "ex227": "wifi6", - "ex447": "wifi6", - "eap101": "wifi6", - "eap102": "wifi6" -} - -mimo_5g = { - "ec420": "4x4", - "ea8300": "2x2", - "ecw5211": "2x2", - "ecw5410": "4x4", - "wf188n": "2x2", - "wf194c": "8x8", - "ex227": "", - "ex447": "", - "eap101": "2x2", - "eap102": "4x4" -} - -mimo_2dot4g = { - "ec420": "2x2", - "ea8300": "2x2", - "ecw5211": "2x2", - "ecw5410": "4x4", - "wf188n": "2x2", - "wf194c": "4x4", - "ex227": "", - "ex447": "", - "eap101": "2x2", - "eap102": "4x4" -} - -sanity_status = { - "ea8300": "failed", - "ecw5211": 'passed', - "ecw5410": 'failed', - "ec420": 'failed', - "wf188n": "failed", - "wf194c": "failed", - "ex227": "failed", - "ex447": "failed", - "eap101": "failed", - "eap102": "failed" -} - -##Test Case information - Maps a generic TC name to TestRail TC numbers -test_cases = { - "ap_upgrade": 2233, - "5g_wpa2_bridge": 2236, - "2g_wpa2_bridge": 2237, - "5g_wpa_bridge": 2419, - "2g_wpa_bridge": 2420, - "2g_wpa_nat": 4323, - "5g_wpa_nat": 4324, - "2g_wpa2_nat": 4325, - "5g_wpa2_nat": 4326, - "2g_eap_bridge": 5214, - "5g_eap_bridge": 5215, - "2g_eap_nat": 5216, - "5g_eap_nat": 5217, - "cloud_connection": 5222, - "cloud_fw": 5247, - "5g_wpa2_vlan": 5248, - "5g_wpa_vlan": 5249, - "5g_eap_vlan": 5250, - "2g_wpa2_vlan": 5251, - "2g_wpa_vlan": 5252, - "2g_eap_vlan": 5253, - "cloud_ver": 5540, - "bridge_vifc": 5541, - "nat_vifc": 5542, - "vlan_vifc": 5543, - "bridge_vifs": 5544, - "nat_vifs": 5545, - "vlan_vifs": 5546, - "upgrade_api": 5547, - "create_fw": 5548, - "ap_bridge": 5641, - "ap_nat": 5642, - "ap_vlan": 5643, - "ssid_2g_eap_bridge": 5644, - "ssid_2g_wpa2_bridge": 5645, - "ssid_2g_wpa_bridge": 5646, - "ssid_5g_eap_bridge": 5647, - "ssid_5g_wpa2_bridge": 5648, - "ssid_5g_wpa_bridge": 5649, - "ssid_2g_eap_nat": 5650, - "ssid_2g_wpa2_nat": 5651, - "ssid_2g_wpa_nat": 5652, - "ssid_5g_eap_nat": 5653, - "ssid_5g_wpa2_nat": 5654, - "ssid_5g_wpa_nat": 5655, - "ssid_2g_eap_vlan": 5656, - "ssid_2g_wpa2_vlan": 5657, - "ssid_2g_wpa_vlan": 5658, - "ssid_5g_eap_vlan": 5659, - "ssid_5g_wpa2_vlan": 5660, - "ssid_5g_wpa_vlan": 5661, - "radius_profile": 5808, - "bridge_ssid_update": 8742, - "nat_ssid_update": 8743, - "vlan_ssid_update": 8744 -} - -###Testing AP Profile Information -profile_info_dict = { - "ecw5410": { - "fiveG_WPA2_SSID": "ECW5410_5G_WPA2", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "ECW5410_5G_WPA", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "ECW5410_5G_OPEN", - "fiveG_WPA2-EAP_SSID": "ECW5410_5G_WPA2-EAP", - "twoFourG_OPEN_SSID": "ECW5410_2dot4G_OPEN", - "twoFourG_WPA2_SSID": "ECW5410_2dot4G_WPA2", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP", - "ssid_list": [ - "ECW5410_5G_WPA2", - "ECW5410_5G_WPA", - "ECW5410_5G_WPA2-EAP", - "ECW5410_2dot4G_WPA2", - "ECW5410_2dot4G_WPA", - "ECW5410_2dot4G_WPA2-EAP" - ] - }, - - "ecw5410_nat": { - "fiveG_WPA2_SSID": "ECW5410_5G_WPA2_NAT", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "ECW5410_5G_WPA_NAT", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "ECW5410_5G_OPEN_NAT", - "fiveG_WPA2-EAP_SSID": "ECW5410_5G_WPA2-EAP_NAT", - "twoFourG_OPEN_SSID": "ECW5410_2dot4G_OPEN_NAT", - "twoFourG_WPA2_SSID": "ECW5410_2dot4G_WPA2_NAT", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA_NAT", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_NAT", - "ssid_list": [ - "ECW5410_5G_WPA2_NAT", - "ECW5410_5G_WPA_NAT", - "ECW5410_5G_WPA2-EAP_NAT", - "ECW5410_2dot4G_WPA2_NAT", - "ECW5410_2dot4G_WPA_NAT", - "ECW5410_2dot4G_WPA2-EAP_NAT" - ] - }, - - "ecw5410_vlan": { - "fiveG_WPA2_SSID": "ECW5410_5G_WPA2_VLAN", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "ECW5410_5G_WPA_VLAN", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "ECW5410_5G_OPEN_VLAN", - "fiveG_WPA2-EAP_SSID": "ECW5410_5G_WPA2-EAP_VLAN", - "twoFourG_OPEN_SSID": "ECW5410_2dot4G_OPEN_VLAN", - "twoFourG_WPA2_SSID": "ECW5410_2dot4G_WPA2_VLAN", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "ECW5410_2dot4G_WPA_VLAN", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "ECW5410_2dot4G_WPA2-EAP_VLAN", - "ssid_list": [ - "ECW5410_5G_WPA2_VLAN", - "ECW5410_5G_WPA_VLAN", - "ECW5410_5G_WPA2-EAP_VLAN", - "ECW5410_2dot4G_WPA2_VLAN", - "ECW5410_2dot4G_WPA_VLAN", - "ECW5410_2dot4G_WPA2-EAP_VLAN" - ] - }, - # example for tri-radio AP - "ea8300": { - "fiveG_WPA2_SSID": "EA8300_5G_WPA2", - "fiveG_WPA2_PSK": "Connectus123$", - "fiveG_WPA_SSID": "EA8300_5G_WPA", - "fiveG_WPA_PSK": "Connectus123$", - "fiveG_OPEN_SSID": "EA8300_5G_OPEN", - "fiveG_WPA2-EAP_SSID": "EA8300_5G_WPA2-EAP", - "twoFourG_OPEN_SSID": "EA8300_2dot4G_OPEN", - "twoFourG_WPA2_SSID": "EA8300_2dot4G_WPA2", - "twoFourG_WPA2_PSK": "Connectus123$", - "twoFourG_WPA_SSID": "EA8300_2dot4G_WPA", - "twoFourG_WPA_PSK": "Connectus123$", - "twoFourG_WPA2-EAP_SSID": "EA8300_2dot4G_WPA2-EAP", - # EA8300 has 2x 5GHz SSIDs because it is a tri-radio AP! - "ssid_list": [ - "EA8300_5G_WPA2", - "EA8300_5G_WPA2", - "EA8300_5G_WPA", - "EA8300_5G_WPA", - "EA8300_5G_WPA2-EAP", - "EA8300_5G_WPA2-EAP", - "EA8300_2dot4G_WPA2", - "EA8300_2dot4G_WPA", - "EA8300_2dot4G_WPA2-EAP" - ] - }, -} diff --git a/tests/cicd_sanity/testrail.py b/tests/cicd_sanity/testrail.py deleted file mode 100644 index 6125cf37e..000000000 --- a/tests/cicd_sanity/testrail.py +++ /dev/null @@ -1,194 +0,0 @@ -"""TestRail API binding for Python 3.x. - -""" - -#################################################################### -# Custom version of testrail_api module -# -# Used by Nightly_Sanity ########################################### -#################################################################### - -import base64 -import json - -import requests -from pprint import pprint -import os -tr_user=os.getenv('TR_USER') -tr_pw=os.getenv('TR_PWD') -project = os.getenv('PROJECT_ID') - - -class APIClient: - def __init__(self, base_url): - self.user = tr_user - self.password = tr_pw - if not base_url.endswith('/'): - base_url += '/' - self.__url = base_url + 'index.php?/api/v2/' - - - def send_get(self, uri, filepath=None): - """Issue a GET request (read) against the API. - - Args: - uri: The API method to call including parameters, e.g. get_case/1. - filepath: The path and file name for attachment download; used only - for 'get_attachment/:attachment_id'. - - Returns: - A dict containing the result of the request. - """ - return self.__send_request('GET', uri, filepath) - - def send_post(self, uri, data): - """Issue a POST request (write) against the API. - - Args: - uri: The API method to call, including parameters, e.g. add_case/1. - data: The data to submit as part of the request as a dict; strings - must be UTF-8 encoded. If adding an attachment, must be the - path to the file. - - Returns: - A dict containing the result of the request. - """ - return self.__send_request('POST', uri, data) - - def __send_request(self, method, uri, data): - url = self.__url + uri - - auth = str( - base64.b64encode( - bytes('%s:%s' % (self.user, self.password), 'utf-8') - ), - 'ascii' - ).strip() - headers = {'Authorization': 'Basic ' + auth} - #print("Method =" , method) - - if method == 'POST': - if uri[:14] == 'add_attachment': # add_attachment API method - files = {'attachment': (open(data, 'rb'))} - response = requests.post(url, headers=headers, files=files) - files['attachment'].close() - else: - headers['Content-Type'] = 'application/json' - payload = bytes(json.dumps(data), 'utf-8') - response = requests.post(url, headers=headers, data=payload) - else: - headers['Content-Type'] = 'application/json' - response = requests.get(url, headers=headers) - #print("headers = ", headers) - #print("resonse=", response) - #print("response code =", response.status_code) - - if response.status_code > 201: - - try: - error = response.json() - except: # response.content not formatted as JSON - error = str(response.content) - #raise APIError('TestRail API returned HTTP %s (%s)' % (response.status_code, error)) - print('TestRail API returned HTTP %s (%s)' % (response.status_code, error)) - return - else: - print(uri[:15]) - if uri[:15] == 'get_attachments': # Expecting file, not JSON - try: - print('opening file') - print (str(response.content)) - open(data, 'wb').write(response.content) - print('opened file') - return (data) - except: - return ("Error saving attachment.") - else: - - try: - return response.json() - except: # Nothing to return - return {} - - def get_project_id(self, project_name): - "Get the project ID using project name" - project_id = None - projects = client.send_get('get_projects') - ##pprint(projects) - for project in projects: - if project['name']== project_name: - project_id = project['id'] - # project_found_flag=True - break - print("project Id =",project_id) - return project_id - - def get_run_id(self, test_run_name): - "Get the run ID using test name and project name" - run_id = None - project_id = client.get_project_id(project_name=project) - - try: - test_runs = client.send_get('get_runs/%s' % (project_id)) - #print("------------TEST RUNS----------") - #pprint(test_runs) - - except Exception: - print - 'Exception in update_testrail() updating TestRail.' - return None - else: - for test_run in test_runs: - if test_run['name'] == test_run_name: - run_id = test_run['id'] - #print("run Id in Test Runs=",run_id) - break - return run_id - - - def update_testrail(self, case_id, run_id, status_id, msg): - "Update TestRail for a given run_id and case_id" - update_flag = False - # Get the TestRail client account details - # Update the result in TestRail using send_post function. - # Parameters for add_result_for_case is the combination of runid and case id. - # status_id is 1 for Passed, 2 For Blocked, 4 for Retest and 5 for Failed - #status_id = 1 if result_flag is True else 5 - - print("result status Pass/Fail = ", status_id) - print("case id=", case_id) - print("run id passed to update is ", run_id, case_id) - if run_id is not None: - try: - result = client.send_post( - 'add_result_for_case/%s/%s' % (run_id, case_id), - {'status_id': status_id, 'comment': msg}) - print("result in post",result) - except Exception: - print - 'Exception in update_testrail() updating TestRail.' - - else: - print - 'Updated test result for case: %s in test run: %s with msg:%s' % (case_id, run_id, msg) - - return update_flag - - def create_testrun(self, name, case_ids, project_id, milestone_id, description): - result = client.send_post( - 'add_run/%s' % (project_id), - {'name': name, 'case_ids': case_ids, 'milestone_id': milestone_id, 'description': description, 'include_all': False}) - print("result in post", result) - - def update_testrun(self, runid, description): - result = client.send_post( - 'update_run/%s' % (runid), - {'description': description}) - print("result in post", result) - - -client: APIClient = APIClient(os.getenv('TR_URL')) - - -class APIError(Exception): - pass diff --git a/tests/cloudsdk/test_cloud.py b/tests/cloudsdk/test_cloud.py new file mode 100644 index 000000000..c39914eb8 --- /dev/null +++ b/tests/cloudsdk/test_cloud.py @@ -0,0 +1,26 @@ +import pytest +import sys +if 'cloudsdk' not in sys.path: + sys.path.append(f'../../libs/cloudsdk') +from cloudsdk import CloudSDK + +@pytest.mark.login +class TestLogin: + + def test_token_login(self): + try: + obj = CloudSDK(testbed="nola-ext-04", customer_id=2) + bearer = obj.get_bearer_token() + value = bearer._access_token is None + except: + value = True + assert value == False + + def test_ping(self): + try: + obj = CloudSDK(testbed="nola-ext-04", customer_id=2) + value = obj.portal_ping() is None + except: + value = True + assert value == False + diff --git a/libs/cloudsdk/configuration_data.py b/tests/configuration_data.py similarity index 100% rename from libs/cloudsdk/configuration_data.py rename to tests/configuration_data.py diff --git a/tests/conftest.py b/tests/conftest.py index 5b556ddde..6bef7f3e3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,287 +1,79 @@ -import pytest -from time import sleep, gmtime, strftime - +# import files in the current directory import sys import os -sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers')) - -sys.path.append(f'..') - -for folder in 'py-json', 'py-scripts': - if folder not in sys.path: - sys.path.append(f'../../lanforge/lanforge-scripts/{folder}') - -sys.path.append(f'../../libs/lanforge/') -sys.path.append(f'../../libs/cloudsdk/') -sys.path.append(f'../../libs/apnos/') -sys.path.append(f'../../libs/testrails/') -sys.path.append(f'../../libs/') - -sys.path.append(f'../test_utility/') - -from utils import * -from UnitTestBase import * -from JfrogHelper import * -from cloudsdk import * -from testrail_api import TestRail_Client +sys.path.append( + os.path.dirname( + os.path.realpath( __file__ ) + ) +) +import pytest +from configuration_data import PROFILE_DATA def pytest_addoption(parser): parser.addini("jfrog-base-url", "jfrog base url") parser.addini("jfrog-user-id", "jfrog username") parser.addini("jfrog-user-password", "jfrog password") - - parser.addini("sdk-base-url", "cloud sdk base url") + parser.addini("testbed-name", "cloud sdk base url") parser.addini("sdk-user-id", "cloud sdk username") parser.addini("sdk-user-password", "cloud sdk user password") - parser.addini("customer-id", "cloud sdk customer id for the access points") - parser.addini("equipment-id", "cloud sdk equipment id for the access point") - parser.addini("default-ap-profile", "cloud sdk default AP profile name") - - parser.addini("verbose", "Enable verbose logs?") - - parser.addini("ap-ip", "AP IP address (or can use serial)") - parser.addini("ap-username", "AP username") - parser.addini("ap-password", "AP password") - parser.addini("ap-jumphost-address", "AP jumphost IP address") - parser.addini("ap-jumphost-username", "AP jumphost username") - parser.addini("ap-jumphost-password", "AP jumphost password") - parser.addini("ap-jumphost-port", "AP jumphost port") - parser.addini("ap-jumphost-wlan-testing", "AP jumphost wlan-testing code directory") - parser.addini("ap-jumphost-tty", "AP jumphost TTY") - - parser.addini("build-id", "What build flavor to use, ie 'pending'") - parser.addini("testbed", "Testbed name") - parser.addini("mode", "AP Mode, bridge/vlan/nat") - parser.addini("skip-wpa", "Should we skip setting up WPA?", default=False) - parser.addini("skip-wpa2", "Should we skip setting up WPA2?", default=False) - parser.addini("skip-radius", "Should we skip setting up EAP/Radius?", default=False) - parser.addini("skip-profiles", "Should we skip setting up profiles") - - parser.addini("ssid-2g-wpa", "Configure ssid-2g-wpa") - parser.addini("psk-2g-wpa", "Configure psk-2g-wpa") - parser.addini("ssid-5g-wpa", "Configure ssid-5g-wpa") - parser.addini("psk-5g-wpa", "Configure psk-5g-wpa") - parser.addini("ssid-2g-wpa2", "Configure ssid-2g-wpa2") - parser.addini("psk-2g-wpa2", "Configure psk-2g-wpa2") - parser.addini("ssid-5g-wpa2", "Configure ssid-5g-wpa2") - parser.addini("psk-5g-wpa2", "Configure psk-5g-wpa2") - + parser.addini("sdk-customer-id", "cloud sdk customer id for the access points") parser.addini("testrail-base-url", "testrail base url") parser.addini("testrail-project", "testrail project name to use to generate test reports") parser.addini("testrail-user-id", "testrail username") parser.addini("testrail-user-password", "testrail user password") parser.addini("lanforge-ip-address", "LANforge ip address to connect to") parser.addini("lanforge-port-number", "LANforge port number to connect to") - parser.addini("lanforge-2g-radio", "LANforge radio to use") - parser.addini("lanforge-5g-radio", "LANforge radio to use") + parser.addini("lanforge-radio", "LANforge radio to use") parser.addini("lanforge-ethernet-port", "LANforge ethernet adapter to use") - add_base_parse_args_pytest(parser) - + # change behaviour + parser.addoption( + "--skip-update-firmware", + action="store_true", + default=False, + help="skip updating firmware on the AP (useful for local testing)" + ) # this has to be the last argument # example: --access-points ECW5410 EA8300-EU parser.addoption( "--access-points", - nargs="+", + # nargs="+", default=[ "ECW5410" ], help="list of access points to test" ) def pytest_generate_tests(metafunc): - metafunc.parametrize("access_points", metafunc.config.getoption('--access-points'), scope="session") + if 'access_points' in metafunc.fixturenames: + metafunc.parametrize("access_points", metafunc.config.getoption('--access-points'), scope="session") # run something after all tests are done regardless of the outcome def pytest_unconfigure(config): print("Tests cleanup done") -@pytest.fixture(scope="session") -def setup_testrails(request, instantiate_testrail, access_points): - if request.config.getoption("--testrail-user-id") == "NONE": - yield -1 - return # needed to stop fixture execution - - if request.config.getoption("--skip-update-firmware"): - firmware_update_case = [] - else: - firmware_update_case = [ 2831 ] - seen = {None} - test_data = [] - session = request.node - for item in session.items: - cls = item.getparent(pytest.Class) - if cls not in seen: - if hasattr(cls.obj, "get_test_data"): - test_data.append(cls.obj.get_test_data()) - seen.add(cls) - testrail_project_id = instantiate_testrail.get_project_id(request.config.getini("testrail-project")) - runId = instantiate_testrail.create_testrun( - name=f'Nightly_model_{access_points}_{strftime("%Y-%m-%d", gmtime())}', - case_ids=( [*test_data] + firmware_update_case ), - project_id=testrail_project_id - ) - yield runId - -# TODO: Should not be session wide I think, you will want to run different -# configurations (bridge, nat, vlan, wpa/wpa2/eap, etc -@pytest.fixture(scope="session") -def setup_cloudsdk(request, instantiate_cloudsdk, instantiate_testrail): - # snippet to do cleanup after all the tests are done +@pytest.fixture(scope="function") +def setup_cloudsdk(request, instantiate_cloudsdk): def fin(): - print("Cloud SDK cleanup done") + print(f"Cloud SDK cleanup for {request.node.originalname}") request.addfinalizer(fin) - - # Set up bridged setup by default. - - command_line_args = create_command_line_args(request) - - cloud = instantiate_cloudsdk - - cloud.assert_bad_response = True - - equipment_id = instantiate_cloudsdk.equipment_id - - print("equipment-id: %s" % (equipment_id)) - if equipment_id == "-1": - print("ERROR: Could not find equipment-id.") - sys.exit(1) - - ###Get Current AP info - try: - ap_cli_info = ssh_cli_active_fw(command_line_args) - ap_cli_fw = ap_cli_info['active_fw'] - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - ap_cli_info = "ERROR" - print("FAILED: Cannot Reach AP CLI."); - sys.exit(1) - - # LANForge Information - lanforge = { - "ip": "localhost", - "port": 8806, - # "prefix": command_line_args.lanforge_prefix, - "2g_radio": "wiphy4", - "5g_radio": "wiphy5", - "eth_port": "eth2" - } - - - - - fw_model = ap_cli_fw.partition("-")[0] - - print('Current Active AP FW from CLI:', ap_cli_fw) - - radius_name = "%s-%s-%s" % (command_line_args.testbed, fw_model, "Radius") - - print("Create profiles") - ap_object = CreateAPProfiles(command_line_args, cloud=cloud, client=instantiate_testrail, fw_model=fw_model) - - # Logic to create AP Profiles (Bridge Mode) - - # ap_object.set_ssid_psk_data(ssid_2g_wpa="Pytest-run-2g-wpa", - # ssid_5g_wpa="Pytest-run-2g-wpa", - # psk_2g_wpa="Pytest-run-2g-wpa", - # psk_5g_wpa="Pytest-run-2g-wpa", - # ssid_2g_wpa2="Pytest-run-2g-wpa", - # ssid_5g_wpa2="Pytest-run-2g-wpa", - # psk_2g_wpa2="Pytest-run-2g-wpa", - # psk_5g_wpa2="Pytest-run-2g-wpa") - - print(ap_object) - today = str(date.today()) - rid = instantiate_testrail.get_run_id( - test_run_name=command_line_args.testrail_run_prefix + fw_model + "_" + today + "_" + "ecw5410-2021-02-12-pending-e8bb466") - print("creating Profiles") - ssid_template = "TipWlan-Cloud-Wifi" - - if not command_line_args.skip_profiles: - if not command_line_args.skip_radius: - # Radius Profile needs to be set here - radius_name = "Test-Radius-" + str(time.time()).split(".")[0] - radius_template = "templates/radius_profile_template.json" - ap_object.create_radius_profile(radius_name=radius_name, radius_template=radius_template, rid=rid, - key=fw_model) - ap_object.create_ssid_profiles(ssid_template=ssid_template, skip_eap=True, skip_wpa=True, - skip_wpa2=False, mode="bridge") - - print("Create AP with equipment-id: ", equipment_id) - ap_object.create_ap_profile(eq_id=equipment_id, fw_model=fw_model, mode=command_line_args.mode) - ap_object.validate_changes(mode=command_line_args.mode) - - print("Profiles Created") - data = {"lanforge": lanforge, "ap_object": ap_object} - - yield data + yield PROFILE_DATA[request.node.originalname] @pytest.fixture(scope="session") -def update_firmware(request, setup_testrails, instantiate_jFrog, instantiate_cloudsdk, access_points): +def update_firmware(request, instantiate_jFrog, instantiate_cloudsdk, retrieve_latest_image, access_points): if request.config.getoption("--skip-update-firmware"): - return True + return + yield "update_firmware" - #access_points is really a single AP. - ap = access_points - - if True: - latest_image = instantiate_jFrog.get_latest_image(ap) - if latest_image is None: - print("AP Model: %s doesn't match the available Models"%(ap)) - sys.exit(1) # TODO: How to return error properly here? - - cloudModel = cloud_sdk_models[ap] - logger = None - report_data = None - test_cases = None - testrail_client = None - jfrog_user = instantiate_jFrog.get_user() - jfrog_pwd = instantiate_jFrog.get_passwd() - testrail_rid = 0 - customer_id = request.config.getoption("--customer-id") - equipment_id = instantiate_cloudsdk.equipment_id - pf = instantiate_cloudsdk.do_upgrade_ap_fw(request.config, report_data, test_cases, testrail_client, - latest_image, cloudModel, ap, jfrog_user, jfrog_pwd, testrail_rid, - customer_id, equipment_id, logger) - - return pf +@pytest.fixture(scope="session") +def retrieve_latest_image(request, access_points): + if request.config.getoption("--skip-update-firmware"): + return + yield "retrieve_latest_image" @pytest.fixture(scope="session") def instantiate_cloudsdk(request): - command_line_args = create_command_line_args(request) - rv = CloudSDK(command_line_args) - - equipment_id = request.config.getoption("--equipment-id") - if equipment_id == "-1": - eq_id = ap_ssh_ovsh_nodec(command_line_args, 'id') - print("EQ Id: %s" % (eq_id)) - - # Now, query equipment to find something that matches. - eq = rv.get_customer_equipment(customer_id) - for item in eq: - for e in item['items']: - print(e['id'], " ", e['inventoryId']) - if e['inventoryId'].endswith("_%s" % (eq_id)): - print("Found equipment ID: %s inventoryId: %s" % (e['id'], e['inventoryId'])) - equipment_id = str(e['id']) - - rv.equipment_id = equipment_id - - if equipment_id == "-1": - print("EQ ID invalid: ", equipment_id) - sys.exit(1) - - yield rv - -@pytest.fixture(scope="session") -def instantiate_testrail(request): - yield TestRail_Client(create_command_line_args(request)) + yield "instantiate_cloudsdk" @pytest.fixture(scope="session") def instantiate_jFrog(request): - yield GetBuild( - request.config.getini("jfrog-user-id"), - request.config.getini("jfrog-user-password"), - "pending", # TODO make this optional - url=request.config.getini("jfrog-base-url") - ) + yield "instantiate_jFrog" \ No newline at end of file diff --git a/tests/eap_connect.py b/tests/eap_connect.py deleted file mode 100755 index d5055150b..000000000 --- a/tests/eap_connect.py +++ /dev/null @@ -1,354 +0,0 @@ -#!/usr/bin/env python3 - -######################################################################################################### -# Built to allow connection and test of clients using EAP-TTLS. -# Functions can be called to create a station, create TCP and UDP traffic, run it a short amount of time. -# -# Used by Nightly_Sanity and Throughput_Test ############################################################ -######################################################################################################### - -# This will create a station, create TCP and UDP traffic, run it a short amount of time, -# and verify whether traffic was sent and received. It also verifies the station connected -# to the requested BSSID if bssid is specified as an argument. -# The script will clean up the station and connections at the end of the test. - -import sys - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append('../../py-json') - -import argparse -import LANforge -from LANforge import LFUtils -# from LANforge import LFCliBase -from LANforge import lfcli_base -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -import realm -from realm import Realm -from lf_lib import * -import pprint - -OPEN="open" -WEP="wep" -WPA="wpa" -WPA2="wpa2" -MODE_AUTO=0 - -class EAPConnect(LFCliBase): - def __init__(self, host, port, security=None, ssid=None, sta_list=None, number_template="00000", _debug_on=False, _dut_bssid="", - _exit_on_error=False, _sta_name=None, _resource=1, radio="wiphy0", key_mgmt="WPA-EAP", eap="", identity="", - ttls_passwd="", hessid=None, ttls_realm="", domain="", _sta_prefix='eap', _exit_on_fail=False, _cleanup_on_exit=True): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.ssid = ssid - self.radio = radio - self.security = security - #self.password = password - self.sta_list = sta_list - self.key_mgmt = key_mgmt - self.eap = eap - self.sta_prefix = _sta_prefix - self.identity = identity - self.ttls_passwd = ttls_passwd - self.ttls_realm = ttls_realm - self.domain = domain - self.hessid = hessid - self.dut_bssid = _dut_bssid - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - #Added to test_ipv4_ttls code - self.upstream_url = None # defer construction - self.sta_url_map = None - self.upstream_resource = None - self.upstream_port = "eth2" - self.station_names = [] - if _sta_name is not None: - self.station_names = [_sta_name] - self.localrealm = Realm(lfclient_host=host, lfclient_port=port) - self.resource = _resource - self.cleanup_on_exit = _cleanup_on_exit - self.resulting_stations = {} - self.resulting_endpoints = {} - self.station_profile = None - self.l3_udp_profile = None - self.l3_tcp_profile = None - - # def get_realm(self) -> Realm: # py > 3.6 - def get_realm(self): - return self.localrealm - - def get_station_url(self, sta_name_=None): - if sta_name_ is None: - raise ValueError("get_station_url wants a station name") - if self.sta_url_map is None: - self.sta_url_map = {} - for sta_name in self.station_names: - self.sta_url_map[sta_name] = "port/1/%s/%s" % (self.resource, sta_name) - return self.sta_url_map[sta_name_] - - def get_upstream_url(self): - if self.upstream_url is None: - self.upstream_url = "port/1/%s/%s" % (self.upstream_resource, self.upstream_port) - return self.upstream_url - - # Compare pre-test values to post-test values - def compare_vals(self, name, postVal, print_pass=False, print_fail=True): - # print(f"Comparing {name}") - if postVal > 0: - self._pass("%s %s" % (name, postVal), print_pass) - else: - self._fail("%s did not report traffic: %s" % (name, postVal), print_fail) - - def remove_stations(self): - for name in self.station_names: - LFUtils.removePort(self.resource, name, self.lfclient_url) - - def num_associated(self, bssid): - counter = 0 - # print("there are %d results" % len(self.station_results)) - fields = "_links,port,alias,ip,ap,port+type" - self.station_results = self.localrealm.find_ports_like("%s*"%self.sta_prefix, fields, debug_=False) - if (self.station_results is None) or (len(self.station_results) < 1): - self.get_failed_result_list() - for eid,record in self.station_results.items(): - #print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") - #pprint(eid) - #pprint(record) - if record["ap"] == bssid: - counter += 1 - #print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") - return counter - - def clear_test_results(self): - self.resulting_stations = {} - self.resulting_endpoints = {} - super().clear_test_results() - #super(StaConnect, self).clear_test_results().test_results.clear() - - def setup(self): - self.clear_test_results() - self.check_connect() - upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False) - - if upstream_json is None: - self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True) - return False - - if upstream_json['interface']['ip'] == "0.0.0.0": - if self.debug: - pprint.pprint(upstream_json) - self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True) - return False - - # remove old stations - print("Removing old stations") - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - response = self.json_get(sta_url) - if (response is not None) and (response["interface"] is not None): - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - LFUtils.wait_until_ports_disappear(self.lfclient_url, self.station_names) - - # Create stations and turn dhcp on - self.station_profile = self.localrealm.new_station_profile() - - # Build stations - self.station_profile.use_security(self.security, self.ssid, passwd="[BLANK]") - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.set_wifi_extra(key_mgmt=self.key_mgmt, eap=self.eap, identity=self.identity, - passwd=self.ttls_passwd, - realm=self.ttls_realm, domain=self.domain, - hessid=self.hessid) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug, use_radius=True, hs20_enable=False) - self._pass("PASS: Station build finished") - - self.create_traffic = createTraffic(self.localrealm, self.sta_prefix, self.resource, self.upstream_port) - self.create_traffic.lf_l3_udp_profile() - self.create_traffic.lf_l3_tcp_profile() - - def start(self): - if self.station_profile is None: - self._fail("Incorrect setup") - pprint.pprint(self.station_profile) - if self.station_profile.up is None: - self._fail("Incorrect station profile, missing profile.up") - if self.station_profile.up == False: - print("\nBringing ports up...") - data = {"shelf": 1, - "resource": self.resource, - "port": "ALL", - "probe_flags": 1} - self.json_post("/cli-json/nc_show_ports", data) - self.station_profile.admin_up() - LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names) - - # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) - duration = 0 - maxTime = 60 - ip = "0.0.0.0" - ap = "" - print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="") - connected_stations = {} - while (len(connected_stations.keys()) < len(self.station_names)) and (duration < maxTime): - duration += 3 - time.sleep(3) - print(".", end="") - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - station_info = self.json_get(sta_url + "?fields=port,ip,ap") - - # LFUtils.debug_printer.pprint(station_info) - if (station_info is not None) and ("interface" in station_info): - if "ip" in station_info["interface"]: - ip = station_info["interface"]["ip"] - if "ap" in station_info["interface"]: - ap = station_info["interface"]["ap"] - - if (ap == "Not-Associated") or (ap == ""): - if self.debug: - print(" -%s," % sta_name, end="") - else: - if ip == "0.0.0.0": - if self.debug: - print(" %s (0.0.0.0)" % sta_name, end="") - else: - connected_stations[sta_name] = sta_url - data = { - "shelf":1, - "resource": self.resource, - "port": "ALL", - "probe_flags": 1 - } - self.json_post("/cli-json/nc_show_ports", data) - - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - station_info = self.json_get(sta_url) # + "?fields=port,ip,ap") - if station_info is None: - print("unable to query %s" % sta_url) - self.resulting_stations[sta_url] = station_info - ap = station_info["interface"]["ap"] - ip = station_info["interface"]["ip"] - if (ap != "") and (ap != "Not-Associated"): - print(" %s +AP %s, " % (sta_name, ap), end="") - if self.dut_bssid != "": - if self.dut_bssid.lower() == ap.lower(): - self._pass(sta_name+" connected to BSSID: " + ap) - # self.test_results.append("PASSED: ) - # print("PASSED: Connected to BSSID: "+ap) - else: - self._fail("%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap)) - else: - self._fail(sta_name+" did not connect to AP") - return False - - if ip == "0.0.0.0": - self._fail("%s did not get an ip. Ending test" % sta_name) - else: - self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip)) - - if self.passes() == False: - if self.cleanup_on_exit: - print("Cleaning up...") - self.remove_stations() - return False - - # start cx traffic - print("\nStarting CX Traffic") - - self.create_traffic.l3_udp_profile.start_cx() - self.create_traffic.l3_tcp_profile.start_cx() - time.sleep(1) - self.create_traffic.l3_tcp_profile.refresh_cx() - self.create_traffic.l3_udp_profile.refresh_cx() - - def collect_endp_stats(self, endp_map): - print("Collecting Data") - fields="?fields=name,tx+bytes,rx+bytes" - for (cx_name, endps) in endp_map.items(): - try: - endp_url = "/endp/%s%s" % (endps[0], fields) - endp_json = self.json_get(endp_url) - self.resulting_endpoints[endp_url] = endp_json - ptest_a_tx = endp_json['endpoint']['tx bytes'] - ptest_a_rx = endp_json['endpoint']['rx bytes'] - - #ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"]) - endp_url = "/endp/%s%s" % (endps[1], fields) - endp_json = self.json_get(endp_url) - self.resulting_endpoints[endp_url] = endp_json - - ptest_b_tx = endp_json['endpoint']['tx bytes'] - ptest_b_rx = endp_json['endpoint']['rx bytes'] - - self.compare_vals("testTCP-A TX", ptest_a_tx) - self.compare_vals("testTCP-A RX", ptest_a_rx) - - self.compare_vals("testTCP-B TX", ptest_b_tx) - self.compare_vals("testTCP-B RX", ptest_b_rx) - - except Exception as e: - print("Is this the function having the error?") - self.error(e) - - - def stop(self): - # stop cx traffic - print("Stopping CX Traffic") - self.create_traffic.l3_udp_profile.stop_cx() - self.create_traffic.l3_tcp_profile.stop_cx() - - # Refresh stats - print("\nRefresh CX stats") - self.create_traffic.l3_udp_profile.refresh_cx() - self.create_traffic.l3_tcp_profile.refresh_cx() - - print("Sleeping for 5 seconds") - time.sleep(5) - - # get data for endpoints JSON - self.collect_endp_stats(self.create_traffic.l3_udp_profile.created_cx) - self.collect_endp_stats(self.create_traffic.l3_tcp_profile.created_cx) - # print("\n") - - def cleanup(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.create_traffic.l3_udp_profile.get_cx_names()) - removeCX(self.lfclient_url, self.create_traffic.l3_tcp_profile.get_cx_names()) - for (cx_name, endp_names) in self.create_traffic.l3_udp_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - for (cx_name, endp_names) in self.create_traffic.l3_tcp_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug) - -# ~class - - - -if __name__ == "__main__": - main() diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py deleted file mode 100644 index 16451d23f..000000000 --- a/tests/helpers/utils.py +++ /dev/null @@ -1,64 +0,0 @@ -import re -import requests -import json -import argparse - -# Map firmware directory name to cloud's model name. -cloud_sdk_models = { - "ec420": "EC420-G1", - "ea8300": "EA8300-CA", - "ecw5211": "ECW5211", - "ecw5410": "ECW5410", - "wf188n": "WF188N" - } - -# To better interoperate with libs that want to take a cmd-line-args thing vs -# the pytest request config. -def create_command_line_args(request): - parser = argparse.ArgumentParser(description="Fake") - command_line_args, unknown = parser.parse_known_args() - - # And then overwrite it with whatever pytest is using (which is likely same in many cases) - command_line_args.equipment_id = request.config.getoption("--equipment-id") - command_line_args.customer_id = request.config.getoption("--customer-id") - command_line_args.sdk_base_url = request.config.getoption("--sdk-base-url") - command_line_args.sdk_user_id = request.config.getoption("--sdk-user-id") - command_line_args.sdk_user_password = request.config.getoption("--sdk-user-password") - command_line_args.default_ap_profile = request.config.getoption("--default-ap-profile") - - command_line_args.verbose = request.config.getoption("--verbose") - - command_line_args.ap_ip = request.config.getoption("--ap-ip") - command_line_args.ap_username = request.config.getoption("--ap-username") - command_line_args.ap_password = request.config.getoption("--ap-password") - command_line_args.ap_jumphost_address = request.config.getoption("--ap-jumphost-address") - command_line_args.ap_jumphost_username = request.config.getoption("--ap-jumphost-username") - command_line_args.ap_jumphost_password = request.config.getoption("--ap-jumphost-password") - command_line_args.ap_jumphost_port = request.config.getoption("--ap-jumphost-port") - command_line_args.ap_jumphost_wlan_testing = request.config.getoption("--ap-jumphost-wlan-testing") # directory - command_line_args.ap_jumphost_tty = request.config.getoption("--ap-jumphost-tty") - - command_line_args.build_id = request.config.getoption("--build-id") - command_line_args.testbed = request.config.getoption("--testbed") - command_line_args.mode = request.config.getoption("--mode") - command_line_args.skip_wpa = request.config.getoption("--skip-wpa") - command_line_args.skip_wpa2 = request.config.getoption("--skip-wpa2") - command_line_args.skip_radius = request.config.getoption("--skip-radius") - command_line_args.skip_profiles = request.config.getoption("--skip-profiles") - command_line_args.ssid_2g_wpa = request.config.getoption("--ssid-2g-wpa") - command_line_args.ssid_5g_wpa = request.config.getoption("--ssid-5g-wpa") - command_line_args.psk_2g_wpa = request.config.getoption("--psk-2g-wpa") - command_line_args.psk_5g_wpa = request.config.getoption("--psk-5g-wpa") - command_line_args.ssid_2g_wpa2 = request.config.getoption("--ssid-2g-wpa2") - command_line_args.ssid_5g_wpa2 = request.config.getoption("--ssid-5g-wpa2") - command_line_args.psk_2g_wpa2 = request.config.getoption("--psk-2g-wpa2") - command_line_args.psk_5g_wpa2 = request.config.getoption("--psk-5g-wpa2") - - command_line_args.testrail_base_url = request.config.getoption("--testrail-base-url") - command_line_args.testrail_project = request.config.getoption("--testrail-project") - command_line_args.testrail_user_id = request.config.getoption("--testrail-user-id") - command_line_args.testrail_user_password = request.config.getoption("--testrail-user-password") - command_line_args.testrail_run_prefix = request.config.getoption("--testrail-run-prefix") - command_line_args.testrail_milestone = request.config.getoption("--testrail-milestone") - - return command_line_args diff --git a/tests/pytest.ini b/tests/pytest.ini index acea6fe28..d00f79f77 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,15 +1,15 @@ [pytest] addopts= --junitxml=test_everything.xml # jFrog parameters -jfrog-base-url=https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/ +jfrog-base-url=tip.jFrog.io/artifactory/tip-wlan-ap-firmware jfrog-user-id=tip-read jfrog-user-password=tip-read # Cloud SDK parameters -sdk-base-url=https://wlan-portal-svc.cicd.lab.wlan.tip.build +testbed-name=nola-ext-04 sdk-user-id=support@example.com sdk-user-password=support # Testrails parameters -testrail-base-url=https://telecominfraproject.testrail.com +testrail-base-url=telecominfraproject.testrail.com testrail-project=opsfleet-wlan testrail-user-id=gleb@opsfleet.com testrail-user-password=use_command_line_to_pass_this @@ -20,13 +20,11 @@ lanforge-radio=wiphy4 lanforge-ethernet-port=eth2 # Cloud SDK settings -customer-id=2 -# equipment ID is unique for each AP, have to be told what to use or query it based on other info. -equipment-id=-1 +sdk-customer-id=2 markers = - featureA: marks tests as slow (deselect with '-m "not slow"') - featureB - featureC - featureD - featureE + login: marks cloudsdk login + UHF: marks tests as using 2.4 ghz frequency + SHF: marks tests as using 5.0 ghz frequency + open: marks tests as using no security + wpa2: marks tests as using wpa2 security \ No newline at end of file diff --git a/tests/pytest_utility/conftest.py b/tests/pytest_utility/conftest.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/pytest_utility/pytest.ini b/tests/pytest_utility/pytest.ini deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/sanity_status.json b/tests/sanity_status.json deleted file mode 100755 index a0d9d4c0e..000000000 --- a/tests/sanity_status.json +++ /dev/null @@ -1 +0,0 @@ -{"sanity_status": {"ea8300": "failed", "ecw5211": "failed", "ecw5410": "failed", "ec420": "failed"}, "sanity_run": {"new_data": "yes"}} \ No newline at end of file diff --git a/tests/single_client_throughput.py b/tests/single_client_throughput.py deleted file mode 100755 index 51ab2c9b5..000000000 --- a/tests/single_client_throughput.py +++ /dev/null @@ -1,1064 +0,0 @@ -#!/usr/bin/env python3 - -#################################################################################### -# Script is based off of LANForge sta_connect2.py -# Script built for max throughput testing on a single client -# The main function of the script creates a station, then tests: -# 1. UDP Downstream (AP to STA) -# 2. UDP Upstream (STA to AP) -# 3. TCP Downstream (AP to STA) -# 4. TCP Upstream (STA to AP) -# The script will clean up the station and connections at the end of the test. -# -# Used by Throughput_Test ########################################################### -#################################################################################### - -# Script is based off of sta_connect2.py -# Script built for max throughput testing on a single client -# The main function of the script creates a station, then tests: -# 1. UDP Downstream (AP to STA) -# 2. UDP Upstream (STA to AP) -# 3. TCP Downstream (AP to STA) -# 4. TCP Upstream (STA to AP) -# The script will clean up the station and connections at the end of the test. - -import sys -import csv - -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append('../../py-json') - -import argparse -from LANforge import LFUtils -# from LANforge import LFCliBase -from LANforge import lfcli_base -from LANforge.lfcli_base import LFCliBase -from LANforge.LFUtils import * -import realm -from realm import Realm -import pprint - -OPEN="open" -WEP="wep" -WPA="wpa" -WPA2="wpa2" -MODE_AUTO=0 - -class SingleClient(LFCliBase): - def __init__(self, host, port, _dut_ssid="jedway-open-1", _dut_passwd="NA", _dut_bssid="", - _user="", _passwd="", _sta_mode="0", _radio="wiphy0", - _resource=1, _upstream_resource=1, _upstream_port="eth1", - _sta_name=None, debug_=False, _dut_security=OPEN, _exit_on_error=False, - _cleanup_on_exit=True, _runtime_sec=60, _exit_on_fail=False): - # do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn) - # that is py2 era syntax and will force self into the host variable, making you - # very confused. - super().__init__(host, port, _debug=debug_, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.debug = debug_ - self.dut_security = _dut_security - self.dut_ssid = _dut_ssid - self.dut_passwd = _dut_passwd - self.dut_bssid = _dut_bssid - self.user = _user - self.passwd = _passwd - self.sta_mode = _sta_mode # See add_sta LANforge CLI users guide entry - self.radio = _radio - self.resource = _resource - self.upstream_resource = _upstream_resource - self.upstream_port = _upstream_port - self.runtime_secs = _runtime_sec - self.cleanup_on_exit = _cleanup_on_exit - self.sta_url_map = None # defer construction - self.upstream_url = None # defer construction - self.station_names = [] - if _sta_name is not None: - self.station_names = [ _sta_name ] - # self.localrealm :Realm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6 - self.localrealm = Realm(lfclient_host=host, lfclient_port=port) # py > 3.6 - self.resulting_stations = {} - self.resulting_endpoints = {} - self.station_profile = None - self.l3_udp_profile = None - self.l3_tcp_profile = None - - # def get_realm(self) -> Realm: # py > 3.6 - def get_realm(self): - return self.localrealm - - def get_station_url(self, sta_name_=None): - if sta_name_ is None: - raise ValueError("get_station_url wants a station name") - if self.sta_url_map is None: - self.sta_url_map = {} - for sta_name in self.station_names: - self.sta_url_map[sta_name] = "port/1/%s/%s" % (self.resource, sta_name) - return self.sta_url_map[sta_name_] - - def get_upstream_url(self): - if self.upstream_url is None: - self.upstream_url = "port/1/%s/%s" % (self.upstream_resource, self.upstream_port) - return self.upstream_url - - # Compare pre-test values to post-test values - def compare_vals(self, name, postVal, print_pass=False, print_fail=True): - # print(f"Comparing {name}") - if postVal > 0: - self._pass("%s %s" % (name, postVal), print_pass) - else: - self._fail("%s did not report traffic: %s" % (name, postVal), print_fail) - - def remove_stations(self): - for name in self.station_names: - LFUtils.removePort(self.resource, name, self.lfclient_url) - - def num_associated(self, bssid): - counter = 0 - # print("there are %d results" % len(self.station_results)) - fields = "_links,port,alias,ip,ap,port+type" - self.station_results = self.localrealm.find_ports_like("sta*", fields, debug_=False) - if (self.station_results is None) or (len(self.station_results) < 1): - self.get_failed_result_list() - for eid,record in self.station_results.items(): - #print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") - #pprint(eid) - #pprint(record) - if record["ap"] == bssid: - counter += 1 - #print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") - return counter - - def clear_test_results(self): - self.resulting_stations = {} - self.resulting_endpoints = {} - super().clear_test_results() - #super(StaConnect, self).clear_test_results().test_results.clear() - - def setup(self): - self.clear_test_results() - self.check_connect() - upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False) - - if upstream_json is None: - self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True) - return False - - if upstream_json['interface']['ip'] == "0.0.0.0": - if self.debug: - pprint.pprint(upstream_json) - self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True) - return False - - # remove old stations - print("Removing old stations") - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - response = self.json_get(sta_url) - if (response is not None) and (response["interface"] is not None): - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - LFUtils.wait_until_ports_disappear(self.lfclient_url, self.station_names) - - # Create stations and turn dhcp on - self.station_profile = self.localrealm.new_station_profile() - - if self.dut_security == WPA2: - self.station_profile.use_security(security_type="wpa2", ssid=self.dut_ssid, passwd=self.dut_passwd) - elif self.dut_security == WPA: - self.station_profile.use_security(security_type="wpa", ssid=self.dut_ssid, passwd=self.dut_passwd) - elif self.dut_security == OPEN: - self.station_profile.use_security(security_type="open", ssid=self.dut_ssid, passwd="[BLANK]") - elif self.dut_security == WPA: - self.station_profile.use_security(security_type="wpa", ssid=self.dut_ssid, passwd=self.dut_passwd) - elif self.dut_security == WEP: - self.station_profile.use_security(security_type="wep", ssid=self.dut_ssid, passwd=self.dut_passwd) - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - - print("Adding new stations ", end="") - self.station_profile.create(radio=self.radio, sta_names_=self.station_names, up_=False, debug=self.debug, suppress_related_commands_=True) - LFUtils.wait_until_ports_appear(self.lfclient_url, self.station_names, debug=self.debug) - - def start(self): - if self.station_profile is None: - self._fail("Incorrect setup") - pprint.pprint(self.station_profile) - if self.station_profile.up is None: - self._fail("Incorrect station profile, missing profile.up") - if self.station_profile.up == False: - print("\nBringing ports up...") - data = {"shelf": 1, - "resource": self.resource, - "port": "ALL", - "probe_flags": 1} - self.json_post("/cli-json/nc_show_ports", data) - self.station_profile.admin_up() - LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names) - - # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) - duration = 0 - maxTime = 100 - ip = "0.0.0.0" - ap = "" - print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="") - connected_stations = {} - while (len(connected_stations.keys()) < len(self.station_names)) and (duration < maxTime): - duration += 3 - time.sleep(10) - print(".", end="") - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - station_info = self.json_get(sta_url + "?fields=port,ip,ap") - - # LFUtils.debug_printer.pprint(station_info) - if (station_info is not None) and ("interface" in station_info): - if "ip" in station_info["interface"]: - ip = station_info["interface"]["ip"] - if "ap" in station_info["interface"]: - ap = station_info["interface"]["ap"] - - if (ap == "Not-Associated") or (ap == ""): - if self.debug: - print(" -%s," % sta_name, end="") - else: - if ip == "0.0.0.0": - if self.debug: - print(" %s (0.0.0.0)" % sta_name, end="") - else: - connected_stations[sta_name] = sta_url - data = { - "shelf":1, - "resource": self.resource, - "port": "ALL", - "probe_flags": 1 - } - self.json_post("/cli-json/nc_show_ports", data) - - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - station_info = self.json_get(sta_url) # + "?fields=port,ip,ap") - if station_info is None: - print("unable to query %s" % sta_url) - self.resulting_stations[sta_url] = station_info - ap = station_info["interface"]["ap"] - ip = station_info["interface"]["ip"] - if (ap != "") and (ap != "Not-Associated"): - print(" %s +AP %s, " % (sta_name, ap), end="") - if self.dut_bssid != "": - if self.dut_bssid.lower() == ap.lower(): - self._pass(sta_name+" connected to BSSID: " + ap) - # self.test_results.append("PASSED: ) - # print("PASSED: Connected to BSSID: "+ap) - else: - self._fail("%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap)) - else: - self._fail(sta_name+" did not connect to AP") - return False - - if ip == "0.0.0.0": - self._fail("%s did not get an ip. Ending test" % sta_name) - else: - self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip)) - - if self.passes() == False: - if self.cleanup_on_exit: - print("Cleaning up...") - self.remove_stations() - return False - - def udp_profile(self, side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu): - # Create UDP endpoint - Alex's code! - self.l3_udp_tput_profile = self.localrealm.new_l3_cx_profile() - self.l3_udp_tput_profile.side_a_min_bps = side_a_min_bps - self.l3_udp_tput_profile.side_b_min_bps = side_b_min_bps - self.l3_udp_tput_profile.side_a_min_pdu = side_a_min_pdu - self.l3_udp_tput_profile.side_b_min_pdu = side_b_min_pdu - self.l3_udp_tput_profile.report_timer = 1000 - self.l3_udp_tput_profile.name_prefix = "udp" - self.l3_udp_tput_profile.create(endp_type="lf_udp", - side_a=list(self.localrealm.find_ports_like("tput+")), - side_b="%d.%s" % (self.resource, self.upstream_port), - suppress_related_commands=True) - - def tcp_profile(self, side_a_min_bps, side_b_min_bps): - # Create TCP endpoints - original code! - self.l3_tcp_tput_profile = self.localrealm.new_l3_cx_profile() - self.l3_tcp_tput_profile.side_a_min_bps = side_a_min_bps - self.l3_tcp_tput_profile.side_b_min_bps = side_b_min_bps - self.l3_tcp_tput_profile.name_prefix = "tcp" - self.l3_tcp_tput_profile.report_timer = 1000 - self.l3_tcp_tput_profile.create(endp_type="lf_tcp", - side_a=list(self.localrealm.find_ports_like("tput+")), - side_b="%d.%s" % (self.resource, self.upstream_port), - suppress_related_commands=True) - - # Start UDP Downstream Traffic - def udp_throughput(self): - print("\nStarting UDP Traffic") - self.l3_udp_tput_profile.start_cx() - time.sleep(1) - self.l3_udp_tput_profile.refresh_cx() - - def tcp_throughput(self): - print("\nStarting TCP Traffic") - self.l3_tcp_tput_profile.start_cx() - time.sleep(1) - self.l3_tcp_tput_profile.refresh_cx() - - def udp_stop(self): - # stop cx traffic - print("Stopping CX Traffic") - self.l3_udp_tput_profile.stop_cx() - - # Refresh stats - print("\nRefresh CX stats") - self.l3_udp_tput_profile.refresh_cx() - - print("Sleeping for 5 seconds") - time.sleep(5) - - # get data for endpoints JSON - return self.collect_client_stats(self.l3_udp_tput_profile.created_cx) - # print("\n") - - def tcp_stop(self): - # stop cx traffic - print("Stopping CX Traffic") - self.l3_tcp_tput_profile.stop_cx() - - # Refresh stats - print("\nRefresh CX stats") - self.l3_tcp_tput_profile.refresh_cx() - - print("Sleeping for 5 seconds") - time.sleep(5) - - # get data for endpoints JSON - return self.collect_client_stats(self.l3_tcp_tput_profile.created_cx) - # print("\n") - - # New Endpoint code to print TX and RX numbers - def collect_client_stats(self, endp_map): - print("Collecting Data") - fields="?fields=name,tx+bytes,rx+bytes" - for (cx_name, endps) in endp_map.items(): - try: - endp_url = "/endp/%s%s" % (endps[0], fields) - endp_json = self.json_get(endp_url) - self.resulting_endpoints[endp_url] = endp_json - ptest_a_tx = endp_json['endpoint']['tx bytes'] - ptest_a_rx = endp_json['endpoint']['rx bytes'] - - # ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"]) - endp_url = "/endp/%s%s" % (endps[1], fields) - endp_json = self.json_get(endp_url) - self.resulting_endpoints[endp_url] = endp_json - ptest_b_tx = endp_json['endpoint']['tx bytes'] - ptest_b_rx = endp_json['endpoint']['rx bytes'] - - byte_values = [] - byte_values.append("Station TX: " + str(ptest_a_tx)) - byte_values.append("Station RX: " + str(ptest_a_rx)) - byte_values.append("AP TX: " + str(ptest_b_tx)) - byte_values.append("AP RX: " + str(ptest_b_rx)) - - return byte_values - - except Exception as e: - self.error(e) - - def cleanup_udp(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.l3_udp_tput_profile.get_cx_names()) - for (cx_name, endp_names) in self.l3_udp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug) - - def cleanup_tcp(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.l3_tcp_tput_profile.get_cx_names()) - for (cx_name, endp_names) in self.l3_tcp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug) - - def cleanup(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.l3_tcp_tput_profile.get_cx_names()) - removeCX(self.lfclient_url, self.l3_udp_tput_profile.get_cx_names()) - for (cx_name, endp_names) in self.l3_tcp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - for (cx_name, endp_names) in self.l3_udp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug=self.debug) - - def udp_unidirectional(self, side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu, direction, values_line): - self.udp_profile(side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu) - self.start() - print("Running", direction, "Traffic for %s seconds" % self.runtime_secs) - self.udp_throughput() - print("napping %f sec" % self.runtime_secs) - time.sleep(self.runtime_secs) - values = self.udp_stop() - print(values) - # Get value required for measurement - bytes = values[values_line] - # Get value in Bits and convert to Mbps - bits = (int(bytes.split(": ", 1)[1])) * 8 - mpbs = round((bits / 1000000) / self.runtime_secs, 2) - return mpbs - - def tcp_unidirectional(self, side_a_min_bps, side_b_min_bps, direction, values_line): - self.tcp_profile(side_a_min_bps, side_b_min_bps) - self.start() - print("Running", direction, "Traffic for %s seconds" % self.runtime_secs) - self.tcp_throughput() - print("napping %f sec" % self.runtime_secs) - time.sleep(self.runtime_secs) - values = self.tcp_stop() - print(values) - # Get value required for measurement - bytes = values[values_line] - # Get value in Bits and convert to Mbps - bits = (int(bytes.split(": ", 1)[1])) * 8 - mpbs = round((bits / 1000000) / self.runtime_secs, 2) - return mpbs - - def throughput_csv(csv_file, ssid_name, ap_model, firmware, security, udp_ds, udp_us, tcp_ds, tcp_us): - # Find band for CSV ---> This code is not great, it SHOULD get that info from LANForge! - if "5G" in ssid_name: - frequency = "5 GHz" - - elif "2dot4G" in ssid_name: - frequency = "2.4 GHz" - - else: - frequency = "Unknown" - - # Append row to top of CSV file - row = [ap_model, firmware, frequency, security, udp_ds, udp_us, tcp_ds, tcp_us] - - with open(csv_file, 'r') as readFile: - reader = csv.reader(readFile) - lines = list(reader) - lines.insert(1, row) - - with open(csv_file, 'w') as writeFile: - writer = csv.writer(writeFile) - writer.writerows(lines) - - readFile.close() - writeFile.close() - - -class SingleClientEAP(LFCliBase): - def __init__(self, host, port, security=None, ssid=None, sta_list=None, number_template="00000", _debug_on=False, _dut_bssid="", - _exit_on_error=False, _sta_name=None, _resource=1, radio="wiphy0", key_mgmt="WPA-EAP", eap="", identity="", - ttls_passwd="", hessid=None, ttls_realm="", domain="", _exit_on_fail=False, _cleanup_on_exit=True): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.ssid = ssid - self.radio = radio - self.security = security - #self.password = password - self.sta_list = sta_list - self.key_mgmt = key_mgmt - self.eap = eap - self.identity = identity - self.ttls_passwd = ttls_passwd - self.ttls_realm = ttls_realm - self.domain = domain - self.hessid = hessid - self.dut_bssid = _dut_bssid - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - #Added to test_ipv4_ttls code - self.upstream_url = None # defer construction - self.sta_url_map = None - self.upstream_resource = None - self.upstream_port = None - self.station_names = [] - if _sta_name is not None: - self.station_names = [_sta_name] - self.localrealm = Realm(lfclient_host=host, lfclient_port=port) - self.resource = _resource - self.cleanup_on_exit = _cleanup_on_exit - self.resulting_stations = {} - self.resulting_endpoints = {} - self.station_profile = None - self.l3_udp_profile = None - self.l3_tcp_profile = None - - # def get_realm(self) -> Realm: # py > 3.6 - def get_realm(self): - return self.localrealm - - def get_station_url(self, sta_name_=None): - if sta_name_ is None: - raise ValueError("get_station_url wants a station name") - if self.sta_url_map is None: - self.sta_url_map = {} - for sta_name in self.station_names: - self.sta_url_map[sta_name] = "port/1/%s/%s" % (self.resource, sta_name) - return self.sta_url_map[sta_name_] - - def get_upstream_url(self): - if self.upstream_url is None: - self.upstream_url = "port/1/%s/%s" % (self.upstream_resource, self.upstream_port) - return self.upstream_url - - # Compare pre-test values to post-test values - def compare_vals(self, name, postVal, print_pass=False, print_fail=True): - # print(f"Comparing {name}") - if postVal > 0: - self._pass("%s %s" % (name, postVal), print_pass) - else: - self._fail("%s did not report traffic: %s" % (name, postVal), print_fail) - - def remove_stations(self): - for name in self.station_names: - LFUtils.removePort(self.resource, name, self.lfclient_url) - - def num_associated(self, bssid): - counter = 0 - # print("there are %d results" % len(self.station_results)) - fields = "_links,port,alias,ip,ap,port+type" - self.station_results = self.localrealm.find_ports_like("eap*", fields, debug_=False) - if (self.station_results is None) or (len(self.station_results) < 1): - self.get_failed_result_list() - for eid,record in self.station_results.items(): - #print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") - #pprint(eid) - #pprint(record) - if record["ap"] == bssid: - counter += 1 - #print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ") - return counter - - def clear_test_results(self): - self.resulting_stations = {} - self.resulting_endpoints = {} - super().clear_test_results() - #super(StaConnect, self).clear_test_results().test_results.clear() - - def setup(self): - self.clear_test_results() - self.check_connect() - upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" % self.get_upstream_url(), debug_=False) - - if upstream_json is None: - self._fail(message="Unable to query %s, bye" % self.upstream_port, print_=True) - return False - - if upstream_json['interface']['ip'] == "0.0.0.0": - if self.debug: - pprint.pprint(upstream_json) - self._fail("Warning: %s lacks ip address" % self.get_upstream_url(), print_=True) - return False - - # remove old stations - print("Removing old stations") - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - response = self.json_get(sta_url) - if (response is not None) and (response["interface"] is not None): - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - LFUtils.wait_until_ports_disappear(self.lfclient_url, self.station_names) - - # Create stations and turn dhcp on - self.station_profile = self.localrealm.new_station_profile() - - # Build stations - self.station_profile.use_security(self.security, self.ssid, passwd="[BLANK]") - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.set_wifi_extra(key_mgmt=self.key_mgmt, eap=self.eap, identity=self.identity, - passwd=self.ttls_passwd, - realm=self.ttls_realm, domain=self.domain, - hessid=self.hessid) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug, use_radius=True, hs20_enable=False) - self._pass("PASS: Station build finished") - - def start(self): - if self.station_profile is None: - self._fail("Incorrect setup") - pprint.pprint(self.station_profile) - if self.station_profile.up is None: - self._fail("Incorrect station profile, missing profile.up") - if self.station_profile.up == False: - print("\nBringing ports up...") - data = {"shelf": 1, - "resource": self.resource, - "port": "ALL", - "probe_flags": 1} - self.json_post("/cli-json/nc_show_ports", data) - self.station_profile.admin_up() - LFUtils.waitUntilPortsAdminUp(self.resource, self.lfclient_url, self.station_names) - - # station_info = self.jsonGet(self.mgr_url, "%s?fields=port,ip,ap" % (self.getStaUrl())) - duration = 0 - maxTime = 30 - ip = "0.0.0.0" - ap = "" - print("Waiting for %s stations to associate to AP: " % len(self.station_names), end="") - connected_stations = {} - while (len(connected_stations.keys()) < len(self.station_names)) and (duration < maxTime): - duration += 3 - time.sleep(10) - print(".", end="") - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - station_info = self.json_get(sta_url + "?fields=port,ip,ap") - - # LFUtils.debug_printer.pprint(station_info) - if (station_info is not None) and ("interface" in station_info): - if "ip" in station_info["interface"]: - ip = station_info["interface"]["ip"] - if "ap" in station_info["interface"]: - ap = station_info["interface"]["ap"] - - if (ap == "Not-Associated") or (ap == ""): - if self.debug: - print(" -%s," % sta_name, end="") - else: - if ip == "0.0.0.0": - if self.debug: - print(" %s (0.0.0.0)" % sta_name, end="") - else: - connected_stations[sta_name] = sta_url - data = { - "shelf":1, - "resource": self.resource, - "port": "ALL", - "probe_flags": 1 - } - self.json_post("/cli-json/nc_show_ports", data) - - for sta_name in self.station_names: - sta_url = self.get_station_url(sta_name) - station_info = self.json_get(sta_url) # + "?fields=port,ip,ap") - if station_info is None: - print("unable to query %s" % sta_url) - self.resulting_stations[sta_url] = station_info - ap = station_info["interface"]["ap"] - ip = station_info["interface"]["ip"] - if (ap != "") and (ap != "Not-Associated"): - print(" %s +AP %s, " % (sta_name, ap), end="") - if self.dut_bssid != "": - if self.dut_bssid.lower() == ap.lower(): - self._pass(sta_name+" connected to BSSID: " + ap) - # self.test_results.append("PASSED: ) - # print("PASSED: Connected to BSSID: "+ap) - else: - self._fail("%s connected to wrong BSSID, requested: %s Actual: %s" % (sta_name, self.dut_bssid, ap)) - else: - self._fail(sta_name+" did not connect to AP") - return False - - if ip == "0.0.0.0": - self._fail("%s did not get an ip. Ending test" % sta_name) - else: - self._pass("%s connected to AP: %s With IP: %s" % (sta_name, ap, ip)) - - if self.passes() == False: - if self.cleanup_on_exit: - print("Cleaning up...") - self.remove_stations() - return False - - def udp_profile(self, side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu): - # Create UDP endpoint - Alex's code! - self.l3_udp_tput_profile = self.localrealm.new_l3_cx_profile() - self.l3_udp_tput_profile.side_a_min_bps = side_a_min_bps - self.l3_udp_tput_profile.side_b_min_bps = side_b_min_bps - self.l3_udp_tput_profile.side_a_min_pdu = side_a_min_pdu - self.l3_udp_tput_profile.side_b_min_pdu = side_b_min_pdu - self.l3_udp_tput_profile.report_timer = 1000 - self.l3_udp_tput_profile.name_prefix = "udp" - self.l3_udp_tput_profile.create(endp_type="lf_udp", - side_a=list(self.localrealm.find_ports_like("tput+")), - side_b="%d.%s" % (self.resource, self.upstream_port), - suppress_related_commands=True) - - def tcp_profile(self, side_a_min_bps, side_b_min_bps): - # Create TCP endpoints - original code! - self.l3_tcp_tput_profile = self.localrealm.new_l3_cx_profile() - self.l3_tcp_tput_profile.side_a_min_bps = side_a_min_bps - self.l3_tcp_tput_profile.side_b_min_bps = side_b_min_bps - self.l3_tcp_tput_profile.name_prefix = "tcp" - self.l3_tcp_tput_profile.report_timer = 1000 - self.l3_tcp_tput_profile.create(endp_type="lf_tcp", - side_a=list(self.localrealm.find_ports_like("tput+")), - side_b="%d.%s" % (self.resource, self.upstream_port), - suppress_related_commands=True) - - # Start UDP Downstream Traffic - def udp_throughput(self): - print("\nStarting UDP Traffic") - self.l3_udp_tput_profile.start_cx() - time.sleep(1) - self.l3_udp_tput_profile.refresh_cx() - - def tcp_throughput(self): - print("\nStarting TCP Traffic") - self.l3_tcp_tput_profile.start_cx() - time.sleep(1) - self.l3_tcp_tput_profile.refresh_cx() - - def udp_stop(self): - # stop cx traffic - print("Stopping CX Traffic") - self.l3_udp_tput_profile.stop_cx() - - # Refresh stats - print("\nRefresh CX stats") - self.l3_udp_tput_profile.refresh_cx() - - print("Sleeping for 5 seconds") - time.sleep(5) - - # get data for endpoints JSON - return self.collect_client_stats(self.l3_udp_tput_profile.created_cx) - # print("\n") - - def tcp_stop(self): - # stop cx traffic - print("Stopping CX Traffic") - self.l3_tcp_tput_profile.stop_cx() - - # Refresh stats - print("\nRefresh CX stats") - self.l3_tcp_tput_profile.refresh_cx() - - print("Sleeping for 5 seconds") - time.sleep(5) - - # get data for endpoints JSON - return self.collect_client_stats(self.l3_tcp_tput_profile.created_cx) - # print("\n") - - # New Endpoint code to print TX and RX numbers - def collect_client_stats(self, endp_map): - print("Collecting Data") - fields="?fields=name,tx+bytes,rx+bytes" - for (cx_name, endps) in endp_map.items(): - try: - endp_url = "/endp/%s%s" % (endps[0], fields) - endp_json = self.json_get(endp_url) - self.resulting_endpoints[endp_url] = endp_json - ptest_a_tx = endp_json['endpoint']['tx bytes'] - ptest_a_rx = endp_json['endpoint']['rx bytes'] - - # ptest = self.json_get("/endp/%s?fields=tx+bytes,rx+bytes" % cx_names[cx_name]["b"]) - endp_url = "/endp/%s%s" % (endps[1], fields) - endp_json = self.json_get(endp_url) - self.resulting_endpoints[endp_url] = endp_json - ptest_b_tx = endp_json['endpoint']['tx bytes'] - ptest_b_rx = endp_json['endpoint']['rx bytes'] - - byte_values = [] - byte_values.append("Station TX: " + str(ptest_a_tx)) - byte_values.append("Station RX: " + str(ptest_a_rx)) - byte_values.append("AP TX: " + str(ptest_b_tx)) - byte_values.append("AP RX: " + str(ptest_b_rx)) - - return byte_values - - except Exception as e: - self.error(e) - - def cleanup_udp(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.l3_udp_tput_profile.get_cx_names()) - for (cx_name, endp_names) in self.l3_udp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug) - - def cleanup_tcp(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.l3_tcp_tput_profile.get_cx_names()) - for (cx_name, endp_names) in self.l3_tcp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug= self.debug) - - def cleanup(self): - # remove all endpoints and cxs - if self.cleanup_on_exit: - for sta_name in self.station_names: - LFUtils.removePort(self.resource, sta_name, self.lfclient_url) - curr_endp_names = [] - removeCX(self.lfclient_url, self.l3_tcp_tput_profile.get_cx_names()) - removeCX(self.lfclient_url, self.l3_udp_tput_profile.get_cx_names()) - for (cx_name, endp_names) in self.l3_tcp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - for (cx_name, endp_names) in self.l3_udp_tput_profile.created_cx.items(): - curr_endp_names.append(endp_names[0]) - curr_endp_names.append(endp_names[1]) - removeEndps(self.lfclient_url, curr_endp_names, debug=self.debug) - - def udp_unidirectional(self, side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu, direction, values_line): - self.udp_profile(side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu) - self.start() - print("Running", direction, "Traffic for %s seconds" % self.runtime_secs) - self.udp_throughput() - print("napping %f sec" % self.runtime_secs) - time.sleep(self.runtime_secs) - values = self.udp_stop() - print(values) - # Get value required for measurement - bytes = values[values_line] - # Get value in Bits and convert to Mbps - bits = (int(bytes.split(": ", 1)[1])) * 8 - mpbs = round((bits / 1000000) / self.runtime_secs, 2) - return mpbs - - def tcp_unidirectional(self, side_a_min_bps, side_b_min_bps, direction, values_line): - self.tcp_profile(side_a_min_bps, side_b_min_bps) - self.start() - print("Running", direction, "Traffic for %s seconds" % self.runtime_secs) - self.tcp_throughput() - print("napping %f sec" % self.runtime_secs) - time.sleep(self.runtime_secs) - values = self.tcp_stop() - print(values) - # Get value required for measurement - bytes = values[values_line] - # Get value in Bits and convert to Mbps - bits = (int(bytes.split(": ", 1)[1])) * 8 - mpbs = round((bits / 1000000) / self.runtime_secs, 2) - return mpbs -# ~class - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -########################## Test Code ################################ - -##Main will perform 4 throughput tests on SSID provided by input and return a list with the values - -def main(ap_model, firmware, radio, ssid_name, ssid_psk, security, station, runtime, upstream_port): - ######## Establish Client Connection ######################### - singleClient = SingleClient("10.10.10.201", 8080, debug_=False) - singleClient.sta_mode = 0 - singleClient.upstream_resource = 1 - singleClient.upstream_port = upstream_port - singleClient.radio = radio - singleClient.resource = 1 - singleClient.dut_ssid = ssid_name - singleClient.dut_passwd = ssid_psk - singleClient.dut_security = security - singleClient.station_names = station - singleClient.runtime_secs = runtime - singleClient.cleanup_on_exit = True - - #Create List for Throughput Data - tput_data = [] - - ####### Setup UDP Profile and Run Traffic Downstream (AP to STA) ####################### - singleClient.setup() - side_a_min_bps = 56000 - side_b_min_bps = 500000000 - side_a_min_pdu = 1200 - side_b_min_pdu = 1500 - direction = "Downstream" - values_line = 1 # 1 = Station Rx - try: - udp_ds = singleClient.udp_unidirectional(side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu, direction, values_line) - print("UDP Downstream:", udp_ds, "Mbps") - tput_data.append("UDP Downstream: " + str(udp_ds)) - except: - udp_ds = "error" - print("UDP Downstream Test Error") - tput_data.append("UDP Downstream: Error") - - - ####### Setup UDP Profile and Run Traffic Upstream (STA to AP) ####################### - #singleClient.setup() - side_a_min_bps = 500000000 - side_b_min_bps = 0 - side_a_min_pdu = 1200 - side_b_min_pdu = 1500 - direction = "Upstream" - values_line = 3 # 3 = AP Rx - try: - udp_us = singleClient.udp_unidirectional(side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu, direction, values_line) - print("UDP Upstream:",udp_us,"Mbps") - tput_data.append("UDP Upstream: " + str(udp_us)) - except: - udp_us = "error" - print("UDP Upstream Test Error") - tput_data.append("UDP Upstream: Error") - #Cleanup UDP Endpoints - #singleClient.cleanup_udp() - - - ####### Setup TCP Profile and Run Traffic Downstream (AP to STA) ####################### - #singleClient.setup() - side_a_min_bps = 0 - side_b_min_bps = 500000000 - direction = "Downstream" - values_line = 1 # 1 = Station Rx - try: - tcp_ds = singleClient.tcp_unidirectional(side_a_min_bps, side_b_min_bps, direction, values_line) - print("TCP Downstream:",tcp_ds,"Mbps") - tput_data.append("TCP Downstream: " + str(tcp_ds)) - except: - tcp_ds = "error" - print("TCP Downstream Test Error") - tput_data.append("TCP Downstream: Error") - - ####### Setup TCP Profile and Run Traffic Upstream (STA to AP) ####################### - #singleClient.setup() - side_a_min_bps = 500000000 - side_b_min_bps = 0 - direction = "Upstream" - values_line = 3 # 3 = AP Rx - try: - tcp_us = singleClient.tcp_unidirectional(side_a_min_bps, side_b_min_bps, direction, values_line) - print("TCP Upstream:",tcp_us,"Mbps") - tput_data.append("TCP Upstream: " + str(tcp_us)) - except: - tcp_us = "error" - print("TCP Upstream Test Error") - tput_data.append("TCP Uptream: Error") - - #Cleanup TCP Endpoints - #singleClient.cleanup_tcp() - - #Cleanup Endpoints - singleClient.cleanup() - - return(tput_data) - -def eap_tput(sta_list, ssid_name, radio, security, eap_type, identity, ttls_password, upstream_port): - eap_connect = SingleClientEAP("10.10.10.201", 8080, _debug_on=False) - eap_connect.upstream_resource = 1 - eap_connect.upstream_port = upstream_port - eap_connect.security = security - eap_connect.sta_list = sta_list - eap_connect.station_names = sta_list - eap_connect.ssid = ssid_name - eap_connect.radio = radio - eap_connect.eap = eap_type - eap_connect.identity = identity - eap_connect.ttls_passwd = ttls_password - eap_connect.runtime_secs = 10 - - #Create List for Throughput Data - tput_data = [] - - ####### Setup UDP Profile and Run Traffic Downstream (AP to STA) ####################### - eap_connect.setup() - side_a_min_bps = 56000 - side_b_min_bps = 500000000 - side_a_min_pdu = 1200 - side_b_min_pdu = 1500 - direction = "Downstream" - values_line = 1 # 1 = Station Rx - try: - udp_ds = eap_connect.udp_unidirectional(side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu, direction, values_line) - print("UDP Downstream:", udp_ds, "Mbps") - tput_data.append("UDP Downstream: " + str(udp_ds)) - except: - udp_ds = "error" - print("UDP Downstream Test Error") - tput_data.append("UDP Downstream: Error") - - - ####### Setup UDP Profile and Run Traffic Upstream (STA to AP) ####################### - #singleClient.setup() - side_a_min_bps = 500000000 - side_b_min_bps = 0 - side_a_min_pdu = 1200 - side_b_min_pdu = 1500 - direction = "Upstream" - values_line = 3 # 3 = AP Rx - try: - udp_us = eap_connect.udp_unidirectional(side_a_min_bps, side_b_min_bps, side_a_min_pdu, side_b_min_pdu, direction, values_line) - print("UDP Upstream:",udp_us,"Mbps") - tput_data.append("UDP Upstream: " + str(udp_us)) - except: - udp_us = "error" - print("UDP Upstream Test Error") - tput_data.append("UDP Upstream: Error") - #Cleanup UDP Endpoints - #singleClient.cleanup_udp() - - - ####### Setup TCP Profile and Run Traffic Downstream (AP to STA) ####################### - #singleClient.setup() - side_a_min_bps = 0 - side_b_min_bps = 500000000 - direction = "Downstream" - values_line = 1 # 1 = Station Rx - try: - tcp_ds = eap_connect.tcp_unidirectional(side_a_min_bps, side_b_min_bps, direction, values_line) - print("TCP Downstream:",tcp_ds,"Mbps") - tput_data.append("TCP Downstream: " + str(tcp_ds)) - except: - tcp_ds = "error" - print("TCP Downstream Test Error") - tput_data.append("TCP Downstream: Error") - - ####### Setup TCP Profile and Run Traffic Upstream (STA to AP) ####################### - #singleClient.setup() - side_a_min_bps = 500000000 - side_b_min_bps = 0 - direction = "Upstream" - values_line = 3 # 3 = AP Rx - try: - tcp_us = eap_connect.tcp_unidirectional(side_a_min_bps, side_b_min_bps, direction, values_line) - print("TCP Upstream:",tcp_us,"Mbps") - tput_data.append("TCP Upstream: " + str(tcp_us)) - except: - tcp_us = "error" - print("TCP Upstream Test Error") - tput_data.append("TCP Uptream: Error") - - #Cleanup TCP Endpoints - #singleClient.cleanup_tcp() - - #Cleanup Endpoints - eap_connect.cleanup() - - return(tput_data) diff --git a/tests/templates/radius_profile_template.json b/tests/templates/radius_profile_template.json deleted file mode 100644 index 2af9ee0f8..000000000 --- a/tests/templates/radius_profile_template.json +++ /dev/null @@ -1 +0,0 @@ -{"model_type": "Profile", "id": 129, "customerId": "2", "profileType": "radius", "name": "Automation_Radius_Nightly-01", "details": {"model_type": "RadiusProfile", "primaryRadiusAuthServer": {"model_type": "RadiusServer", "ipAddress": "18.189.25.141", "secret": "testing123", "port": 1812, "timeout": 5}, "secondaryRadiusAuthServer": null, "primaryRadiusAccountingServer": null, "secondaryRadiusAccountingServer": null, "profileType": "radius"}, "createdTimestamp": 1602263176599, "lastModifiedTimestamp": 1611708334061, "childProfileIds": []} \ No newline at end of file diff --git a/tests/templates/report_template.php b/tests/templates/report_template.php deleted file mode 100755 index f25fcda54..000000000 --- a/tests/templates/report_template.php +++ /dev/null @@ -1,622 +0,0 @@ - - - - -Testing Report - - - - - - - - -
-

CICD Nightly Sanity Report -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Test Results

-
EA8300 ResultECW5211 ResultECW5410 ResultEC420 Result
New FW Available
FW Under Test
CloudSDK Commit Date
CloudSDK Commit ID
CloudSDK Project Version
Test Pass Rate
Test CaseCategoryDescription
5540CloudSDKGet CloudSDK Version with API
5548CloudSDKCreate FW version on CloudSDK using API
5547CloudSDKRequest AP Upgrade using API
2233APAP Upgrade Successful
5247CloudSDKCloudSDK Reports Correct FW
5222CloudSDKAP-CloudSDK Connection Active
5808CloudSDKCreate RADIUS Profile
5644CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Bridge Mode
5645CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Bridge Mode
5646CloudSDKCreate SSID Profile 2.4 GHz WPA - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Bridge Mode
5647CloudSDKCreate SSID Profile 5 GHz WPA2 - Bridge Mode
5648CloudSDKCreate SSID Profile 5 GHz WPA - Bridge Mode
5641CloudSDKCreate AP Profile - Bridge Mode
5541CloudSDKCloudSDK Pushes Correct AP Profile - Bridge Mode
5544APAP Applies Correct AP Profile - Bridge Mode
5214APClient connects to 2.4 GHz WPA2-EAP - Bridge Mode
2237APClient connects to 2.4 GHz WPA2 - Bridge Mode
2420APClient connects to 2.4 GHz WPA - Bridge Mode
5215APClient connects to 5 GHz WPA2-EAP - Bridge Mode
2236APClient connects to 5 GHz WPA2 - Bridge Mode
2419APClient connects to 5 GHz WPA - Bridge Mode
5650CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - NAT Mode
5651CloudSDKCreate SSID Profile 2.4 GHz WPA2 - NAT Mode
5652CloudSDKCreate SSID Profile 2.4 GHz WPA - NAT Mode
5653CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - NAT Mode
5654CloudSDKCreate SSID Profile 5 GHz WPA2 - NAT Mode
5655CloudSDKCreate SSID Profile 5 GHz WPA - NAT Mode
5642CloudSDKCreate AP Profile - NAT Mode
5542CloudSDKCloudSDK Pushes Correct AP Profile - NAT Mode
5545APAP Applies Correct AP Profile - NAT Mode
5216APClient connects to 2.4 GHz WPA2-EAP - NAT Mode
4325APClient connects to 2.4 GHz WPA2 - NAT Mode
4323APClient connects to 2.4 GHz WPA - NAT Mode
5217APClient connects to 5 GHz WPA2-EAP - NAT Mode
4326APClient connects to 5 GHz WPA2 - NAT Mode
4324APClient connects to 5 GHz WPA - NAT Mode
5656CloudSDKCreate SSID Profile 2.4 GHz WPA2-EAP - Custom VLAN
5657CloudSDKCreate SSID Profile 2.4 GHz WPA2 - Custom VLAN
5658CloudSDKCreate SSID Profile 2.4 GHz WPA - Custom VLAN
5659CloudSDKCreate SSID Profile 5 GHz WPA2-EAP - Custom VLAN
5660CloudSDKCreate SSID Profile 5 GHz WPA2 - Custom VLAN
5661CloudSDKCreate SSID Profile 5 GHz WPA - Custom VLAN
5643CloudSDKCreate AP Profile - Custom VLAN
5543CloudSDKCloudSDK Pushes Correct AP Profile - Custom VLAN
5546APAP Applies Correct AP Profile - Custom VLAN
5253APClient connects to 2.4 GHz WPA2-EAP - Custom VLAN
5251APClient connects to 2.4 GHz WPA2 - Custom VLAN
5252APClient connects to 2.4 GHz WPA - Custom VLAN
5250APClient connects to 5 GHz WPA2-EAP - Custom VLAN
5248APClient connects to 5 GHz WPA2 - Custom VLAN
5249APClient connects to 5 GHz WPA - Custom VLAN
- - \ No newline at end of file diff --git a/tests/templates/ssid_profile_template.json b/tests/templates/ssid_profile_template.json deleted file mode 100644 index 6dae58662..000000000 --- a/tests/templates/ssid_profile_template.json +++ /dev/null @@ -1 +0,0 @@ -{"model_type": "Profile", "id": 28, "customerId": 2, "profileType": "ssid", "name": "NOLA-01-ecw5410-2G_WPA", "details": {"model_type": "SsidConfiguration", "ssid": "ECW5410_2dot4G_WPA", "appliedRadios": ["is2dot4GHz"], "ssidAdminState": "enabled", "secureMode": "wpaPSK", "vlanId": 1, "keyStr": "Connectus123$", "broadcastSsid": "enabled", "keyRefresh": 0, "noLocalSubnets": false, "radiusServiceName": "Radius-Accounting-Profile", "radiusAccountingServiceName": null, "radiusAcountingServiceInterval": null, "captivePortalId": null, "bandwidthLimitDown": 0, "bandwidthLimitUp": 0, "clientBandwidthLimitDown": 0, "clientBandwidthLimitUp": 0, "videoTrafficOnly": false, "radioBasedConfigs": {"is2dot4GHz": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}, "is5GHz": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}, "is5GHzU": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}, "is5GHzL": {"model_type": "RadioBasedSsidConfiguration", "enable80211r": null, "enable80211k": null, "enable80211v": null}}, "bonjourGatewayProfileId": null, "enable80211w": null, "wepConfig": null, "forwardMode": "BRIDGE", "profileType": "ssid"}, "createdTimestamp": 1598557809816, "lastModifiedTimestamp": 1598557809816, "childProfileIds": []} \ No newline at end of file diff --git a/tests/test_24ghz.py b/tests/test_24ghz.py deleted file mode 100644 index fbe6e8686..000000000 --- a/tests/test_24ghz.py +++ /dev/null @@ -1,66 +0,0 @@ -# https://docs.pytest.org/en/latest/example/markers.html -# https://docs.pytest.org/en/latest/usage.html -# http://pythontesting.net/framework/pytest/pytest-introduction/ - -import sys - -import pytest -from time import sleep, gmtime, strftime -from sta_connect2 import StaConnect2 - -@pytest.mark.usefixtures('setup_testrails') -@pytest.mark.usefixtures('setup_cloudsdk') -@pytest.mark.usefixtures('update_firmware') -@pytest.mark.usefixtures('instantiate_testrail') -class Test24ghz(object): - @pytest.mark.client_connectivity - def test_single_client_wpa2(self, setup_testrails, setup_cloudsdk, update_firmware, instantiate_testrail): - lf_config = setup_cloudsdk["lanforge"] - # ap_profile = setup_cloudsdk["ap_object"] - staConnect = StaConnect2(lf_config["ip"], lf_config["port"], debug_=False) - staConnect.sta_mode = 0 - staConnect.upstream_resource = 1 - staConnect.upstream_port = lf_config["eth_port"] - staConnect.radio = lf_config["2g_radio"] - # staConnect.runtime_secs = lf_config["runtime_duration"] - staConnect.resource = 1 - staConnect.dut_ssid = "NOLA-01g-ecw5410-2G_WPA2" - staConnect.dut_passwd = "ecw5410-2G_WPA2" - staConnect.dut_security = "wpa2" - staConnect.station_names = ['sta0000'] - staConnect.bringup_time_sec = 60 - staConnect.cleanup_on_exit = True - staConnect.setup() - staConnect.start() - sleep(staConnect.runtime_secs) - staConnect.stop() - staConnect.cleanup() - - assert staConnect.passes() - if setup_testrails > 0: - instantiate_testrail.update_testrail(case_id=2835, run_id=setup_testrails, status_id=1, msg="testing") - - # @pytest.mark.client_connectivity - # def test_single_client_wpa(self): - # pass - # - # @pytest.mark.client_connectivity - # def test_single_client_eap(self): - # pass - - #@pytest.mark.featureB - #def test_feature_b(self): - # pass - - #@pytest.mark.featureC - #def test_feature_c(self): - # assert 1 == 0 - - #@pytest.mark.featureD - #def test_feature_d(self): - # pytest.skip("speedup") - - #@pytest.mark.xfail - #@pytest.mark.featureE - #def test_feature_e(self): - # assert 1 == 0 diff --git a/tests/test_utility/reporting.py b/tests/test_utility/reporting.py deleted file mode 100644 index 0517fb001..000000000 --- a/tests/test_utility/reporting.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -from datetime import date, datetime -from shutil import copyfile -import json - - -class Reporting: - - def __init__(self, reports_root="../reports/"): - - self.reports_root = reports_root - self.report_id = self.create_report_id() - self.report_path = self.reports_root + self.report_id - self.templates_root = os.path.abspath(self.reports_root + "../templates") - try: - os.mkdir(self.report_path) - print("Successfully created the directory %s " % self.report_path) - except OSError: - print("Creation of the directory %s failed" % self.report_path) - - try: - copyfile(self.templates_root + "/report_template.php", self.report_path + '/report.php') - except: - print("No report template created. Report data will still be saved. Continuing with tests...") - - def create_report_id(self): - today = str(date.today()) - now = str(datetime.now()).split(" ")[1].split(".")[0].replace(":", "-") - id = today + "-" + now - return id - - def update_json_report(self, report_data): - try: - with open(self.report_path + '/report_data.json', 'w') as report_json_file: - json.dump(report_data, report_json_file) - report_json_file.close() - except Exception as e: - print(e) - - -def main(): - Reporting() - - -if __name__ == '__main__': - main() diff --git a/tools/README.md b/tools/README.md deleted file mode 100644 index b6fce0ede..000000000 --- a/tools/README.md +++ /dev/null @@ -1,2 +0,0 @@ -## Tools -Handy tools made by utliziing the cloud and ap libraries diff --git a/tools/USAGE_EXAMPLES.txt b/tools/USAGE_EXAMPLES.txt deleted file mode 100644 index 007bd48a9..000000000 --- a/tools/USAGE_EXAMPLES.txt +++ /dev/null @@ -1,150 +0,0 @@ - - -All of this assumes you are running on some developer system, with ssh tunnels -into the 'ubuntu' jumphost machine. - -ssh -C -L 8800:lf1:4002 -L 8801:lf1:5901 -L 8802:lf1:8080 -L 8803:lab-ctlr:22 \ - -L 8810:lf4:4002 -L 8811:lf4:5901 -L 8812:lf4:8080 -L 8813:lab-ctlr:22 \ - -L 8850:lf5:4002 -L 8851:lf5:5901 -L 8852:lf5:8080 -L 8853:lab-ctlr2:22 \ - -L 8860:lf6:4002 -L 8861:lf6:5901 -L 8862:lf6:8080 -L 8863:lab-ctlr2:22 \ - -L 8870:lf7:4002 -L 8871:lf7:5901 -L 8872:lf7:8080 -L 8873:lab-ctlr2:22 \ - -L 8880:lf8:4002 -L 8881:lf8:5901 -L 8882:lf8:8080 -L 8883:lab-ctlr2:22 \ - -L 8890:lf9:4002 -L 8891:lf9:5901 -L 8892:lf9:8080 -L 8893:lab-ctlr3:22 \ - -L 8900:lf10:4002 -L 8901:lf10:5901 -L 8902:lf10:8080 -L 8903:lab-ctlr3:22 \ - -L 8910:lf11:4002 -L 8911:lf11:5901 -L 8912:lf11:8080 -L 8913:lab-ctlr3:22 \ - -L 8950:lf15:4002 -L 8951:lf15:5901 -L 8952:lf115:8080 -L 8953:lab-ctlr4:22 \ - -L 8820:lf12:4002 -L 8821:lf12:5901 -L 8822:lf12:8080 -L 8823:lab-ctlr4:22 \ - ubuntu@orch - -The ports are used as: - 4002: LANforge GUI connection to LANforge in the testbed. - 5901: VNC connection to LANforge machine. - 8080: LANforge JSON/API connection. - 22: ssh shell access to lab controller - - Each testbed will have a set of 4 ssh tunnels. Some are duplicated since - lab-controllers are shared. I figure a consistent pattern is worth a few - duplicated tunnels. - -Testbed-01 - -# Set AP profile on NOLA-01 -./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --lanforge-ip-address localhost --lanforge-port-number 8802 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-01" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge - - -./Nightly_Sanity.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed "NOLA-01r" --lanforge-ip-address localhost --lanforge-port-number 8802 --default_ap_profile TipWlan-2-Radios --lanforge-2g-radio 1.1.wiphy4 --lanforge-5g-radio 1.1.wiphy5 --skip-upgrade True --testrail-milestone milestone-1 --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build - - -# Set AP profile on NOLA-06 (eap101) -./sdk_set_profile.py --testrail-user-id NONE --model eap101 --ap-jumphost-address localhost --ap-jumphost-port 8863 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP2 --lanforge-ip-address localhost --lanforge-port-number 8862 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-06" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge - - -./Nightly_Sanity.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed "NOLA-01r" --lanforge-ip-address localhost --lanforge-port-number 8802 --default_ap_profile TipWlan-2-Radios --lanforge-2g-radio 1.1.wiphy4 --lanforge-5g-radio 1.1.wiphy5 --skip-upgrade True --testrail-milestone milestone-1 --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build - - -Testbed-09 (perfecto) - -# Set AP profile (ssid, etc) on 'b' chamber. AP is ttyAP4 -./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8893 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 \ - --lanforge-ip-address localhost --lanforge-port-number 8892 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-09b" \ - --ssid-5g-wpa2 Default-SSID-5gl-perfecto-b --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g-perfecto-b --psk-2g-wpa2 12345678 --mode bridge - -# Upgrade 'b' chamber AP -./sdk_upgrade_fw.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8893 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 --testbed \"NOLA-09b\" \ - --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build --force-upgrade true - -# Set AP profile (ssid, etc) on 'a' chamber. AP is ttyAP1 -./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8893 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 \ - --lanforge-ip-address localhost --lanforge-port-number 8892 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-09a" \ - --ssid-5g-wpa2 Default-SSID-5gl-perfecto --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g-perfecto --psk-2g-wpa2 12345678 --mode bridge - -# Upgrade 'a' chamber AP -./sdk_upgrade_fw.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8893 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed \"NOLA-09a\" \ - --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build --force-upgrade true - - - -Testbed 10 (Advanced setup, 2D turntable chamber plus medium chamber, RF attenuator, etc) - -./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8903 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP2 --lanforge-ip-address localhost --lanforge-port-number 8902 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-10" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge - -# Upgrade AP -./sdk_upgrade_fw.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8903 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP2 --testbed \"NOLA-10\" \ - --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build --force-upgrade true - - -Testbed 11 (Advanced setup, 2D turntable chamber plus medium chamber, RF attenuator, etc) - -./sdk_set_profile.py --testrail-user-id NONE --model eap102 --ap-jumphost-address localhost --ap-jumphost-port 8913 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP3 --lanforge-ip-address localhost --lanforge-port-number 8912 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-11" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge - -# Upgrade AP -./sdk_upgrade_fw.py --testrail-user-id NONE --model eap102 --ap-jumphost-address localhost --ap-jumphost-port 8913 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP3 --testbed \"NOLA-11\" \ - --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build --force-upgrade true - - -Testbed 12 (Basic, wf188n) - -# Upgrade firmware to latest -./sdk_upgrade_fw.py --testrail-user-id NONE --model wf188n --ap-jumphost-address localhost --ap-jumphost-port 8823 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed \"NOLA-12\" \ - --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build --force-upgrade true - -./sdk_set_profile.py --testrail-user-id NONE --model wf188n --ap-jumphost-address localhost --ap-jumphost-port 8823 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --lanforge-ip-address localhost --lanforge-port-number 8822 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-12" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge - -# Query an ssid -./query_sdk.py --testrail-user-id NONE --model wf188n --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build \ - --sdk-user-id support@example.com --sdk-user-password support --equipment_id 3 --type profile --cmd get --object_id 11 - - -Testbed-15 - -# Set AP profile on NOLA-15 (ap-1) -./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8953 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 --lanforge-ip-address localhost --lanforge-port-number 8952 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-15.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-15" --ssid-5g-wpa2 Default-SSID-5gl --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g --psk-2g-wpa2 12345678 --mode bridge - -# Update firmware (ap-1) -./sdk_upgrade_fw.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8953 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 --testbed \"NOLA-15\" \ - --sdk-base-url https://wlan-portal-svc-nola-15.cicd.lab.wlan.tip.build --force-upgrade true - -# Set AP profile on NOLA-15 (ap-2, cig194c) -./sdk_set_profile.py --testrail-user-id NONE --model cig194c --ap-jumphost-address localhost --ap-jumphost-port 8953 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP5 --lanforge-ip-address localhost --lanforge-port-number 8952 \ - --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-nola-15.cicd.lab.wlan.tip.build \ - --skip-radius --skip-wpa --verbose --testbed "NOLA-15b" --ssid-5g-wpa2 Default-SSID-5gl-cig --psk-5g-wpa2 12345678 \ - --ssid-2g-wpa2 Default-SSID-2g-cig --psk-2g-wpa2 12345678 --mode bridge diff --git a/tools/debug_nola01.sh b/tools/debug_nola01.sh deleted file mode 100755 index 1d9644e0e..000000000 --- a/tools/debug_nola01.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Commands to grab debug info off of NOLA-01. Everything is hard-coded assuming you use -# ssh tunnel in the suggested way. Otherwise, you will need to edit things... - -set -x - -NOLANUM=01 -PORTAL=wlan-portal-svc.cicd.lab.wlan.tip.build -APPORT=8803 -APTTY=/dev/ttyAP1 -MODEL=ecw5410 - -# cloud sdk profile dump -./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ - --sdk-user-password support --type profile --cmd get > /tmp/nola-$NOLANUM-profiles.txt - -# cloud version info -./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ - --sdk-user-password support --type ping > /tmp/nola-$NOLANUM-sdk-ping.txt - -# ovsdb-client dump -./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "ovsdb-client dump" > /tmp/nola-$NOLANUM-ap.txt - -# interface info -./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "iwinfo && brctl show" > /tmp/nola-$NOLANUM-ap-if.txt - - -# TODO: Add more things here as we learn what better provides debug info to cloud. - -echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt /tmp/nola-$NOLANUM-sdk-ping.txt" diff --git a/tools/debug_nola12.sh b/tools/debug_nola12.sh deleted file mode 100755 index 648b242ef..000000000 --- a/tools/debug_nola12.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Commands to grab debug info off of NOLA-12. Everything is hard-coded assuming you use -# ssh tunnel in the suggested way. Otherwise, you will need to edit things... - -set -x - -NOLANUM=12 -PORTAL=wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build -APPORT=8823 -APTTY=/dev/ttyAP1 -MODEL=wf188n - -# cloud sdk profile dump -./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ - --sdk-user-password support --type profile --cmd get > /tmp/nola-$NOLANUM-profiles.txt - -# cloud version info -./query_sdk.py --testrail-user-id NONE --model $MODEL --sdk-base-url https://$PORTAL --sdk-user-id support@example.com \ - --sdk-user-password support --type ping > /tmp/nola-$NOLANUM-sdk-ping.txt - -# ovsdb-client dump -./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "ovsdb-client dump" > /tmp/nola-$NOLANUM-ap.txt - -# interface info -./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port $APPORT --ap-jumphost-password pumpkin77 --ap-jumphost-tty $APTTY -m $MODEL --cmd "iwinfo && brctl show" > /tmp/nola-$NOLANUM-ap-if.txt - - -# TODO: Add more things here as we learn what better provides debug info to cloud. - -echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt /tmp/nola-$NOLANUM-sdk-ping.txt" diff --git a/tools/logs/README.md b/tools/logs/README.md deleted file mode 100644 index c1d294cb1..000000000 --- a/tools/logs/README.md +++ /dev/null @@ -1 +0,0 @@ -Logs go here, don't commit them! diff --git a/tools/query_ap.py b/tools/query_ap.py deleted file mode 100755 index 2cb44532a..000000000 --- a/tools/query_ap.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python3 - -# Example command line: -#./query_ap.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --cmd "ifconfig -a" - -import sys - -sys.path.append(f'../tests') - -from UnitTestBase import * - -parser = argparse.ArgumentParser(description="Query AP", add_help=False) -parser.add_argument("--cmd", type=str, help="Command-line to run on AP", - default = "ifconfig -a") -parser.add_argument("--ap_ssh", type=str, help="ap_ssh method to execute.", - default = None, choices=["get_vif_config", "get_vif_state"]) - -reporting = Reporting(reports_root=os.getcwd() + "/reports/") -base = UnitTestBase("query-ap", parser, reporting) - -cmd = base.command_line_args.cmd - -try: - - if base.command_line_args.ap_ssh != None: - ap_cmd = base.command_line_args.ap_ssh - if ap_cmd == "get_vif_config": - print(get_vif_config(base.command_line_args)) - sys.exit(0) - if ap_cmd == "get_vif_state": - print(get_vif_state(base.command_line_args)) - sys.exit(0) - - print("Un-known ap-ssh method: %s"%(ap_cmd)) - sys.exit(1) - - print("Command: %s"%(cmd)) - rv = ap_ssh_cmd(base.command_line_args, cmd) - print("Command Output:\n%s"%(rv)) - -except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to execute command on AP") diff --git a/tools/query_sdk.py b/tools/query_sdk.py deleted file mode 100755 index f67feb40e..000000000 --- a/tools/query_sdk.py +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/python3 - -import sys - -sys.path.append(f'../tests') - -from UnitTestBase import * - -parser = argparse.ArgumentParser(description="Query SDK Objects", add_help=False) -parser.add_argument("--type", type=str, help="Type of thing to query", - choices=['profile', 'customer', 'location', 'equipment', 'portalUser', - 'status', 'client-sessions', 'client-info', 'alarm', 'service-metric', - 'event', 'firmware', 'ping', 'all'], - default = "all") -parser.add_argument("--cmd", type=str, help="Operation to do, default is 'get'", - choices=['get', 'delete', 'child_of'], - default = "get") -parser.add_argument("--brief", type=str, help="Show output in brief mode?", - choices=["true", "false"], - default = "false") - -reporting = Reporting(reports_root=os.getcwd() + "/reports/") - -base = UnitTestBase("query-sdk", parser, reporting) - -qtype = base.command_line_args.type -cmd = base.command_line_args.cmd -brief = False -if base.command_line_args.brief == "true": - brief = True - -def get_profile(url, bearer, cust_id, object_id): - if (object_id == None or object_id.isdigit()): - return base.cloud.get_customer_profiles(url, bearer, cust_id, object_id) - else: - return [base.cloud.get_customer_profile_by_name(url, bearer, cust_id, object_id)] - -if qtype == 'all' or qtype == 'profile': - # Get customer profiles - try: - if cmd == "get": - rv = get_profile(base.cloudSDK_url, base.bearer, base.customer_id, base.command_line_args.object_id) - print("Profiles for customer %s (%i pages):"%(base.customer_id, len(rv))) - #jobj = json.load(ssids) - for r in rv: - if brief: - for p in r['items']: - print("Profile id: %s name: %s type: %s"%(p['id'], p['name'], p['profileType'])) - else: - print(json.dumps(r, indent=4, sort_keys=True)) - - if cmd == "delete": - delid = base.command_line_args.object_id; - if delid.isdigit(): - rv = base.cloud.delete_profile(base.cloudSDK_url, base.bearer, base.command_line_args.object_id) - print("Delete profile for customer %s, id: %s results:"%(base.customer_id, base.command_line_args.object_id)) - print(rv.json()) - else: - # Query object by name to find its ID - targets = get_profile(base.cloudSDK_url, base.bearer, base.customer_id, base.command_line_args.object_id) - for me in targets: - rv = base.cloud.delete_profile(base.cloudSDK_url, base.bearer, str(me['id'])) - print("Delete profile for customer %s, id: %s results:"%(base.customer_id, base.command_line_args.object_id)) - print(rv.json()) - - if cmd == "child_of": - targets = get_profile(base.cloudSDK_url, base.bearer, base.customer_id, base.command_line_args.object_id) - for me in targets: - meid = me['id'] - print("Profiles using profile: %s %s"%(meid, me['name'])) - - # Get all profiles and search - rv = get_profile(base.cloudSDK_url, base.bearer, base.customer_id, None) - #jobj = json.load(ssids) - for r in rv: - for p in r['items']: - #print("profile: %s %s, checking children..."%(p['id'], p['name'])) - if 'childProfileIds' in p: - for child in p['childProfileIds']: - #print("profile: %s %s, checking child: %s my-id: %s"%(p['id'], p['name'], child, meid)) - if child == meid: - print("Used-By: %s %s"%(p['id'], p['name'])) - - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read customer profiles") - -if qtype == 'all' or qtype == 'customer': - try: - rv = base.cloud.get_customer(base.cloudSDK_url, base.bearer, base.customer_id) - print("Customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - print(json.dumps(rv, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %i"%(customer_id)) - -if qtype == 'all' or qtype == 'ping': - try: - rv = base.cloud.ping(base.cloudSDK_url, base.bearer) - print("Cloud Ping %s:"%(base.cloudSDK_url)) - #jobj = json.load(ssids) - print(json.dumps(rv, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Cloud Ping %i"%(base.cloudSDK_url)) - -if qtype == 'all' or qtype == 'firmware': - try: - rv = base.cloud.CloudSDK_images(base.command_line_args.model, base.cloudSDK_url, base.bearer) - print("Firmware for model:", base.command_line_args.model) - #jobj = json.load(ssids) - print(json.dumps(rv, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Firmware") - -if qtype == 'all' or qtype == 'location': - # Get location info - try: - # NOTE: Could also use base.customer_id to get single one that user may have specified. - rv = base.cloud.get_customer_locations(base.cloudSDK_url, base.bearer, base.customer_id) - print("Locations for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - print(json.dumps(rv, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s locations"%(base.customer_id)) - -if qtype == 'all' or qtype == 'equipment': - # Get equipment info - try: - if cmd == "get": - rv = base.cloud.get_customer_equipment(base.customer_id) - print("Equipment for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - if brief: - for eq in e['items']: - print("Equipment id: %s inventoryId: %s profileId: %s type: %s"%(eq['id'], eq['inventoryId'], eq['profileId'], eq['equipmentType'])) - else: - print(json.dumps(e, indent=4, sort_keys=True)) - if cmd == "delete": - delid = base.command_line_args.object_id; - rv = base.cloud.delete_equipment(base.cloudSDK_url, base.bearer, base.command_line_args.object_id) - print("Delete Equipment, id: %s results:"%(base.command_line_args.object_id)) - print(rv.json()) - - - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s equipment"%(base.customer_id)) - -if qtype == 'all' or qtype == 'portalUser': - # Get portalUser info - try: - rv = base.cloud.get_customer_portal_users(base.cloudSDK_url, base.bearer, base.customer_id) - print("PortalUsers for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s portalUsers"%(base.customer_id)) - -if qtype == 'all' or qtype == 'status': - # Get status info - try: - rv = base.cloud.get_customer_status(base.cloudSDK_url, base.bearer, base.customer_id) - print("Status for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s status"%(base.customer_id)) - -if qtype == 'all' or qtype == 'client-sessions': - # Get client sessions info - try: - rv = base.cloud.get_customer_client_sessions(base.cloudSDK_url, base.bearer, base.customer_id) - print("Sessions for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s sessions"%(base.customer_id)) - -if qtype == 'all' or qtype == 'client-info': - # Get clients info - try: - rv = base.cloud.get_customer_clients(base.cloudSDK_url, base.bearer, base.customer_id) - print("Clients for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s clients"%(base.customer_id)) - -if qtype == 'all' or qtype == 'alarm': - # Get alarms info - try: - rv = base.cloud.get_customer_alarms(base.cloudSDK_url, base.bearer, base.customer_id) - print("Alarms for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s alarms"%(base.customer_id)) - -if qtype == 'all' or qtype == 'service-metric': - # Get service metrics - try: - fromTime = "0" - toTime = "%i"%(0xFFFFFFFFFFFF) # something past now, units are msec - rv = base.cloud.get_customer_service_metrics(base.cloudSDK_url, base.bearer, base.customer_id, fromTime, toTime) - print("Service Metrics for customer %s:"%(base.customer_id)) - for e in rv: - #jobj = json.load(ssids) - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s service metrics"%(base.customer_id)) - -if qtype == 'all' or qtype == 'event': - # Get system events - try: - fromTime = "0" - toTime = "%i"%(0xFFFFFFFFFFFF) # something past now, units are msec - rv = base.cloud.get_customer_system_events(base.cloudSDK_url, base.bearer, base.customer_id, fromTime, toTime) - #print("System Events for customer %s:"%(base.customer_id)) - #jobj = json.load(ssids) - for e in rv: - print(json.dumps(e, indent=4, sort_keys=True)) - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - print("Failed to read Customer %s system events"%(base.customer_id)) diff --git a/tools/sdk_set_profile.py b/tools/sdk_set_profile.py deleted file mode 100755 index 1f622195b..000000000 --- a/tools/sdk_set_profile.py +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/python3 -u - -# Example to set profile on NOLA-12 testbed: -# ./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8823 --ap-jumphost-password pumpkin77 \ -# --ap-jumphost-tty /dev/ttyAP1 --testbed "NOLA-12" --lanforge-ip-address localhost --lanforge-port-number 8822 \ -# --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build --skip-radius - -# Example to set profile on NOLA-01 testbed -# ./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 \ -# --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed "NOLA-01" --lanforge-ip-address localhost \ -# --lanforge-port-number 8802 --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc.cicd.lab.wlan.tip.build \ -# --skip-radius - -import sys - -sys.path.append(f'../tests') - -from UnitTestBase import * -from cloudsdk import CreateAPProfiles - -def main(): - parser = argparse.ArgumentParser(description="SDK Set Profile", add_help=False) - parser.add_argument("--default-ap-profile", type=str, - help="Default AP profile to use as basis for creating new ones, typically: TipWlan-2-Radios or TipWlan-3-Radios", - required=True) - parser.add_argument("--skip-radius", dest="skip_radius", action='store_true', - help="Should we skip the RADIUS configs or not", default=False) - parser.add_argument("--skip-wpa", dest="skip_wpa", action='store_true', - help="Should we skip the WPA ssid or not", default=False) - parser.add_argument("--skip-wpa2", dest="skip_wpa2", action='store_true', - help="Should we skip the WPA2 ssid or not", default=False) - parser.add_argument("--skip-profiles", dest="skip_profiles", action='store_true', - help="Should we skip creating new ssid profiles?", default=False) - parser.add_argument("--cleanup-profile", dest="cleanup_profile", action='store_true', - help="Should we clean up profiles after creating them?", default=False) - - parser.add_argument("--psk-5g-wpa2", dest="psk_5g_wpa2", type=str, - help="Allow over-riding the 5g-wpa2 PSK value.") - parser.add_argument("--psk-5g-wpa", dest="psk_5g_wpa", type=str, - help="Allow over-riding the 5g-wpa PSK value.") - parser.add_argument("--psk-2g-wpa2", dest="psk_2g_wpa2", type=str, - help="Allow over-riding the 2g-wpa2 PSK value.") - parser.add_argument("--psk-2g-wpa", dest="psk_2g_wpa", type=str, - help="Allow over-riding the 2g-wpa PSK value.") - - parser.add_argument("--ssid-5g-wpa2", dest="ssid_5g_wpa2", type=str, - help="Allow over-riding the 5g-wpa2 SSID value.") - parser.add_argument("--ssid-5g-wpa", dest="ssid_5g_wpa", type=str, - help="Allow over-riding the 5g-wpa SSID value.") - parser.add_argument("--ssid-2g-wpa2", dest="ssid_2g_wpa2", type=str, - help="Allow over-riding the 2g-wpa2 SSID value.") - parser.add_argument("--ssid-2g-wpa", dest="ssid_2g_wpa", type=str, - help="Allow over-riding the 2g-wpa SSID value.") - - parser.add_argument("--mode", dest="mode", choices=['bridge', 'nat', 'vlan'], type=str, - help="Mode of AP Profile [bridge/nat/vlan]", required=True) - - parser.add_argument("--sleep-after-profile", dest="sleep", type=int, - help="Enter the sleep interval delay in ms between each profile push. Default is 0", required=False, default=0) - # Not implemented yet. - #parser.add_argument("--rf-mode", type=str, - # choices=["modeN", "modeAC", "modeGN", "modeX", "modeA", "modeB", "modeG", "modeAB"], - # help="Allow over-riding the 2g-wpa SSID value.") - - - reporting = Reporting(reports_root=os.getcwd() + "/reports/") - - base = UnitTestBase("skd-set-profile", parser) - - command_line_args = base.command_line_args - print(command_line_args.mode) - - # cmd line takes precedence over env-vars. - cloudSDK_url = command_line_args.sdk_base_url # was os.getenv('CLOUD_SDK_URL') - local_dir = command_line_args.local_dir # was os.getenv('SANITY_LOG_DIR') - report_path = command_line_args.report_path # was os.getenv('SANITY_REPORT_DIR') - report_template = command_line_args.report_template # was os.getenv('REPORT_TEMPLATE') - - ## TestRail Information - tr_user = command_line_args.testrail_user_id # was os.getenv('TR_USER') - tr_pw = command_line_args.testrail_user_password # was os.getenv('TR_PWD') - milestoneId = command_line_args.milestone # was os.getenv('MILESTONE') - projectId = command_line_args.testrail_project # was os.getenv('PROJECT_ID') - testRunPrefix = command_line_args.testrail_run_prefix # os.getenv('TEST_RUN_PREFIX') - - ##Jfrog credentials - jfrog_user = command_line_args.jfrog_user_id # was os.getenv('JFROG_USER') - jfrog_pwd = command_line_args.jfrog_user_password # was os.getenv('JFROG_PWD') - - ##EAP Credentials - identity = command_line_args.eap_id # was os.getenv('EAP_IDENTITY') - ttls_password = command_line_args.ttls_password # was os.getenv('EAP_PWD') - - ## AP Credentials - ap_username = command_line_args.ap_username # was os.getenv('AP_USER') - - ##LANForge Information - lanforge_ip = command_line_args.lanforge_ip_address - lanforge_port = command_line_args.lanforge_port_number - lanforge_prefix = command_line_args.lanforge_prefix - - build = command_line_args.build_id - - logger = base.logger - hdlr = base.hdlr - - if command_line_args.testbed == None: - print("ERROR: Must specify --testbed argument for this test.") - sys.exit(1) - - client: TestRail_Client = TestRail_Client(command_line_args) - - ###Get Cloud Bearer Token - cloud: CloudSDK = CloudSDK(command_line_args) - bearer = cloud.get_bearer(cloudSDK_url, cloud_type) - - cloud.assert_bad_response = True - - model_id = command_line_args.model - equipment_id = command_line_args.equipment_id - - print("equipment-id: %s" % (equipment_id)) - - if equipment_id == "-1": - eq_id = ap_ssh_ovsh_nodec(command_line_args, 'id') - print("EQ Id: %s" % (eq_id)) - - # Now, query equipment to find something that matches. - eq = cloud.get_customer_equipment(customer_id) - for item in eq: - for e in item['items']: - print(e['id'], " ", e['inventoryId']) - if e['inventoryId'].endswith("_%s" % (eq_id)): - print("Found equipment ID: %s inventoryId: %s" % (e['id'], e['inventoryId'])) - equipment_id = str(e['id']) - - if equipment_id == "-1": - print("ERROR: Could not find equipment-id.") - sys.exit(1) - - ###Get Current AP Firmware and upgrade - try: - ap_cli_info = ssh_cli_active_fw(command_line_args) - ap_cli_fw = ap_cli_info['active_fw'] - except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - ap_cli_info = "ERROR" - print("FAILED: Cannot Reach AP CLI."); - sys.exit(1) - - fw_model = ap_cli_fw.partition("-")[0] - - print('Current Active AP FW from CLI:', ap_cli_fw) - - # Create Report Folder for Today - today = str(date.today()) - try: - os.mkdir(report_path + today) - except OSError: - print("Creation of the directory %s failed" % report_path) - else: - print("Successfully created the directory %s " % report_path) - - logger.info('Report data can be found here: ' + report_path + today) - - # Get Bearer Token to make sure its valid (long tests can require re-auth) - bearer = cloud.get_bearer(cloudSDK_url, cloud_type) - radius_name = "%s-%s-%s" % (command_line_args.testbed, fw_model, "Radius") - - sleep = command_line_args.sleep - sleep = sleep/1000 - - args = command_line_args - - print("Profiles Created") - - ap_object = CreateAPProfiles(args, cloud=cloud, client=client, fw_model=fw_model, sleep=sleep) - - # Logic to create AP Profiles (Bridge Mode) - - ap_object.set_ssid_psk_data(ssid_2g_wpa=args.ssid_2g_wpa, - ssid_5g_wpa=args.ssid_5g_wpa, - psk_2g_wpa=args.psk_2g_wpa, - psk_5g_wpa=args.psk_5g_wpa, - ssid_2g_wpa2=args.ssid_2g_wpa2, - ssid_5g_wpa2=args.ssid_5g_wpa2, - psk_2g_wpa2=args.psk_2g_wpa2, - psk_5g_wpa2=args.psk_5g_wpa2) - - print(ap_object) - rid = client.get_run_id(test_run_name=args.testrail_run_prefix + fw_model + "_" + today + "_" + "ecw5410-2021-02-12-pending-e8bb466") - print("creating Profiles") - ssid_template = "TipWlan-Cloud-Wifi" - - if not args.skip_profiles: - if not args.skip_radius: - # Radius Profile needs to be set here - radius_name = "Test-Radius-" + str(time.time()).split(".")[0] - radius_template = "templates/radius_profile_template.json" - ap_object.create_radius_profile(radius_name=radius_name, radius_template=radius_template, rid=rid, key=fw_model) - - ap_object.create_ssid_profiles(ssid_template=ssid_template, skip_eap=args.skip_radius, skip_wpa=args.skip_wpa, - skip_wpa2=args.skip_wpa2, mode=args.mode) - - - print("Create AP with equipment-id: ", equipment_id) - time.sleep(sleep) - ap_object.create_ap_profile(eq_id=equipment_id, fw_model=fw_model, mode=args.mode) - ap_object.validate_changes(mode=args.mode) - if args.cleanup_profile: - time.sleep(5) - print("Removing profile...") - ap_object.cleanup_profile(equipment_id=equipment_id) - print("Profiles Created") - - -main() - diff --git a/tools/sdk_upgrade_fw.py b/tools/sdk_upgrade_fw.py deleted file mode 100755 index edaf9c10b..000000000 --- a/tools/sdk_upgrade_fw.py +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/python3 -u - -# Example to upgrade firmware on NOLA-12 testbed: -""" -./sdk_upgrade_fw.py --testrail-user-id NONE --model wf188n --ap-jumphost-address localhost --ap-jumphost-port 8823 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed \"NOLA-12\" \ - --sdk-base-url https://wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build --force-upgrade true - - # Use specified firmware image, not just the latest. - ./sdk_upgrade_fw.py --testrail-user-id NONE --model wf188n --ap-jumphost-address localhost --ap-jumphost-port 8823 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed \"NOLA-12\" \ - --sdk-base-url https://wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build --ap-image wf188n-2021-02-01-pending-686c4df --verbose - -# Example to upgrade fw on NOLA-01 testbed -./sdk_upgrade_fw.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8803 \ - --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed \"NOLA-01\" \ - --sdk-base-url https://wlan-portal-svc.cicd.lab.wlan.tip.build --verbose - -""" - -import sys - -sys.path.append(f'../tests') - -from UnitTestBase import * -from JfrogHelper import * -from cloudsdk import CreateAPProfiles - -parser = argparse.ArgumentParser(description="SDK Upgrade Firmware", add_help=False) -parser.add_argument("--ap-image", type=str, - help="Specify an AP image to install. Will use latest found on jfrog if this is not specified.", - default=None) -base = UnitTestBase("sdk-upgrade-fw", parser) - -command_line_args = base.command_line_args - - -# cmd line takes precedence over env-vars. -cloudSDK_url = command_line_args.sdk_base_url # was os.getenv('CLOUD_SDK_URL') -local_dir = command_line_args.local_dir # was os.getenv('SANITY_LOG_DIR') -report_path = command_line_args.report_path # was os.getenv('SANITY_REPORT_DIR') -report_template = command_line_args.report_template # was os.getenv('REPORT_TEMPLATE') - -## TestRail Information -tr_user = command_line_args.testrail_user_id # was os.getenv('TR_USER') -tr_pw = command_line_args.testrail_user_password # was os.getenv('TR_PWD') -milestoneId = command_line_args.milestone # was os.getenv('MILESTONE') -projectId = command_line_args.testrail_project # was os.getenv('PROJECT_ID') -testRunPrefix = command_line_args.testrail_run_prefix # os.getenv('TEST_RUN_PREFIX') - -##Jfrog credentials -jfrog_user = command_line_args.jfrog_user_id # was os.getenv('JFROG_USER') -jfrog_pwd = command_line_args.jfrog_user_password # was os.getenv('JFROG_PWD') - -##EAP Credentials -identity = command_line_args.eap_id # was os.getenv('EAP_IDENTITY') -ttls_password = command_line_args.ttls_password # was os.getenv('EAP_PWD') - -## AP Credentials -ap_username = command_line_args.ap_username # was os.getenv('AP_USER') - -##LANForge Information -lanforge_ip = command_line_args.lanforge_ip_address -lanforge_port = command_line_args.lanforge_port_number -lanforge_prefix = command_line_args.lanforge_prefix - -build = command_line_args.build_id - -logger = base.logger -hdlr = base.hdlr - -client: TestRail_Client = TestRail_Client(command_line_args) -rid = 0 # testrails run-id, not actually supported at the moment. - -###Get Cloud Bearer Token -cloud: CloudSDK = CloudSDK(command_line_args) -bearer = cloud.get_bearer(cloudSDK_url, cloud_type) - -cloud.assert_bad_response = True - -model_id = command_line_args.model -equipment_id = command_line_args.equipment_id - -print("equipment-id: %s"%(equipment_id)) - -if equipment_id == "-1": - eq_id = ap_ssh_ovsh_nodec(command_line_args, 'id') - print("EQ Id: %s"%(eq_id)) - - # Now, query equipment to find something that matches. - eq = cloud.get_customer_equipment(customer_id) - for item in eq: - for e in item['items']: - print(e['id'], " ", e['inventoryId']) - if e['inventoryId'].endswith("_%s"%(eq_id)): - print("Found equipment ID: %s inventoryId: %s"%(e['id'], e['inventoryId'])) - equipment_id = str(e['id']) - -if equipment_id == "-1": - print("ERROR: Could not find equipment-id.") - sys.exit(1) - -###Get Current AP Firmware and upgrade -try: - ap_cli_info = ssh_cli_active_fw(command_line_args) - ap_cli_fw = ap_cli_info['active_fw'] -except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - ap_cli_info = "ERROR" - print("FAILED: Cannot Reach AP CLI."); - sys.exit(1) - -fw_model = ap_cli_fw.partition("-")[0] -print('Current Active AP FW from CLI:', ap_cli_fw) - -############################################################################ -#################### Create Report ######################################### -############################################################################ - -# Create Report Folder for Today -today = str(date.today()) -try: - os.mkdir(report_path + today) -except OSError: - print("Creation of the directory %s failed" % report_path) -else: - print("Successfully created the directory %s " % report_path) - -logger.info('Report data can be found here: ' + report_path + today) - -###Dictionaries -ap_image = command_line_args.ap_image - -############################################################################ -#################### Jfrog Firmware Check ################################## -############################################################################ - -apModel = model_id -cloudModel = cloud_sdk_models[apModel] -build = command_line_args.build_id # ie, pending - -if not ap_image: - # then get latest from jfrog - Build: GetBuild = GetBuild(jfrog_user, jfrog_pwd, build) - ap_image = Build.get_latest_image(apModel) - -##Get Bearer Token to make sure its valid (long tests can require re-auth) -bearer = cloud.get_bearer(cloudSDK_url, cloud_type) - -print("AP MODEL UNDER TEST IS", model_id) -try: - ap_cli_info = ssh_cli_active_fw(command_line_args) - ap_cli_fw = ap_cli_info['active_fw'] -except Exception as ex: - print(ex) - logging.error(logging.traceback.format_exc()) - ap_cli_info = "ERROR" - print("Cannot Reach AP CLI, will not test this variant"); - sys.exit(1) - -fw_model = ap_cli_fw.partition("-")[0] -print('Current Active AP FW from CLI:', ap_cli_fw) -###Find Latest FW for Current AP Model and Get FW ID - -##Compare Latest and Current AP FW and Upgrade -report_data = None -key = None # model name I think, if we are doing reporting? - -do_upgrade = cloud.should_upgrade_ap_fw(command_line_args.force_upgrade, command_line_args.skip_upgrade, - report_data, ap_image, fw_model, ap_cli_fw, logger, key) - -cloudModel = cloud_sdk_models[model_id] -pf = cloud.do_upgrade_ap_fw(command_line_args, report_data, test_cases, client, - ap_image, cloudModel, model_id, jfrog_user, jfrog_pwd, rid, - customer_id, equipment_id, logger) - -if pf: - sys.exit(0) - -sys.exit(1) - -