bridge mode, nat mode all sanity cases working now in open, wpa and wpa2 mode

Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
shivamcandela
2021-03-20 02:57:02 +05:30
parent a714923458
commit 797949e1ce
9 changed files with 483 additions and 278 deletions

View File

@@ -14,6 +14,8 @@ import urllib
import requests
import swagger_client
from swagger_client import FirmwareManagementApi
from swagger_client import EquipmentGatewayApi
from bs4 import BeautifulSoup
from testbed_info import SDK_BASE_URLS
@@ -170,6 +172,7 @@ class CloudSDK(ConfigureCloudSDK):
Library for Profile Utility, Creating Profiles and Pushing and Deleting them
"""
class ProfileUtility:
"""
constructor for Access Point Utility library : can be used from pytest framework
@@ -246,6 +249,7 @@ class ProfileUtility:
print(self.profile_creation_ids)
self.push_profile_old_method(equipment_id=equipment_id)
self.delete_profile(profile_id=delete_ids)
"""
method call: used to create the rf profile and push set the parameters accordingly and update
"""
@@ -494,6 +498,7 @@ class ProfileUtility:
Jfrog Utility for Artifactory Management
"""
class JFrogUtility:
def __init__(self, credentials=None):
@@ -531,3 +536,109 @@ class JFrogUtility:
pass
class FirmwareUtility(JFrogUtility):
def __init__(self, sdk_client=None, jfrog_credentials=None, testbed=None, customer_id=None):
super().__init__(credentials=jfrog_credentials)
if sdk_client is None:
sdk_client = CloudSDK(testbed=testbed, customer_id=customer_id)
self.sdk_client = sdk_client
self.firmware_client = FirmwareManagementApi(api_client=sdk_client.api_client)
self.jfrog_client = JFrogUtility(credentials=jfrog_credentials)
self.equipment_gateway_client = EquipmentGatewayApi(api_client=sdk_client.api_client)
def get_current_fw_version(self, equipment_id=None):
# Write a logic to get the currently loaded firmware on the equipment
self.current_fw = "something"
return self.current_fw
def get_latest_fw_version(self, model="ecw5410"):
# Get The equipment model
self.latest_fw = self.get_latest_build(model=model)
return self.latest_fw
def upload_fw_on_cloud(self, fw_version=None, force_upload=False):
# if fw_latest available and force upload is False -- Don't upload
# if fw_latest available and force upload is True -- Upload
# if fw_latest is not available -- Upload
fw_id = self.is_fw_available(fw_version=fw_version)
if fw_id and (force_upload is False):
print("Force Upload :", force_upload, " Skipping upload")
# Don't Upload the fw
pass
else:
if fw_id and (force_upload is True):
self.firmware_client.delete_firmware_version(firmware_version_id=fw_id)
print("Force Upload :", force_upload, " Deleted current Image")
time.sleep(2)
# if force_upload is true and latest image available, then delete the image
firmware_data = {
"id": 0,
"equipmentType": "AP",
"modelId": fw_version.split("-")[0],
"versionName": fw_version + ".tar.gz",
"description": "ECW5410 FW VERSION TEST",
"filename": "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/" + fw_version.split("-")[
0] + "/dev/" + fw_version + ".tar.gz",
"commit": fw_version.split("-")[5]
}
firmware_id = self.firmware_client.create_firmware_version(body=firmware_data)
print("Force Upload :", force_upload, " Uploaded Image")
return firmware_id._id
def upgrade_fw(self, equipment_id=None, force_upgrade=False, force_upload=False):
if equipment_id is None:
print("No Equipment Id Given")
exit()
if (force_upgrade is True) or (self.should_upgrade_ap_fw(equipment_id=equipment_id)):
model = self.sdk_client.get_model_name(equipment_id=equipment_id).lower()
latest_fw = self.get_latest_fw_version(model=model)
firmware_id = self.upload_fw_on_cloud(fw_version=latest_fw, force_upload=force_upload)
time.sleep(5)
try:
obj = self.equipment_gateway_client.request_firmware_update(equipment_id=equipment_id, firmware_version_id=firmware_id)
except Exception as e:
obj = False
return obj
# Write the upgrade fw logic here
def should_upgrade_ap_fw(self, equipment_id=None):
current_fw = self.get_current_fw_version(equipment_id=equipment_id)
model = self.sdk_client.get_model_name(equipment_id=equipment_id).lower()
latest_fw = self.get_latest_fw_version(model=model)
if current_fw == latest_fw:
return False
else:
return True
def is_fw_available(self, fw_version=None):
if fw_version is None:
exit()
try:
firmware_version = self.firmware_client.get_firmware_version_by_name(
firmware_version_name=fw_version + ".tar.gz")
firmware_version = firmware_version._id
print("Firmware already Available: ", firmware_version)
except Exception as e:
firmware_version = False
print("firmware not available: ", firmware_version)
return firmware_version
# from testbed_info import JFROG_CREDENTIALS
#
# sdk_client = CloudSDK(testbed="nola-ext-05", customer_id=2)
# obj = FirmwareUtility(jfrog_credentials=JFROG_CREDENTIALS, sdk_client=sdk_client)
# obj.upgrade_fw(equipment_id=7, force_upload=False, force_upgrade=False)
"""
Check the ap model
Check latest revision of a model
Check the firmware version on AP
Check if latest version is available on cloud
if not:
Upload to cloud
if yes:
continue
Upgrade the Firmware on AP
"""

View File

@@ -12,24 +12,37 @@
### Note: Run all the tests from "tests" directory
## Examples:
Following are the examples for Running Client Connectivity Test with different Combinations
Following are the examples for Running Client Connectivity Test with different Combinations:
# Run the sanity test in all modes across wpa, wpa2 and eap)
pytest -m "sanity and wpa and wpa2 and eap" -s
# Run the sanity test in all modes across wpa, wpa2)
pytest -m "sanity and wpa and wpa2" -s
# Run the bridge test in all modes across wpa, wpa2 and eap)
pytest -m "bridge and wpa and wpa2 and eap" -s
# Run the bridge test in all modes across wpa, wpa2)
pytest -m "bridge and wpa and wpa2" -s
# Run the nat test in all modes across wpa, wpa2 and eap)
pytest -m "nat and wpa and wpa2 and eap" -s
# Run the nat test in all modes across wpa, wpa2)
pytest -m "nat and wpa and wpa2" -s
pytest -m nightly -s
pytest -m nightly_bridge -s
pytest -m nightly_nat -s
pytest -m nightly_vlan -s
pytest -m bridge_mode_single_client_connectivity -s
pytest -m nat_mode_single_client_connectivity -s
pytest -m vlan_mode_single_client_connectivity -s
pytest -m bridge_mode_client_connectivity -s
pytest -m nat_mode_client_connectivity -s
pytest -m vlan_mode_client_connectivity -s
Following are the examples for cloudSDK standalone tests
pytest -m test_login -s
pytest -m test_bearer_token -s
pytest -m test_portal_ping -s
# Run cloud connection test, it executes the two tests, bearer and ping
pytest -m cloud -s
# Run cloud connection test, gets the bearer
pytest -m bearer -s
# Run cloud connection test, pings the portal
pytest -m ping -s
more to be added ...

View File

@@ -1,44 +1,44 @@
"""
About: It contains some Functional Unit Tests for CloudSDK+APNOS and to run and test them on per unit level
"""
import pytest
# Note: Use Reusable Fixtures, Create SSID Profile, Equipment_AP Profile, Use RF Profile, Radius Profile,
# Push and Verify
@pytest.mark.test_apnos_profiles
class TestProfiles(object):
@pytest.mark.test_apnos_open_ssid
def test_open_ssid(self):
# Write a Test case that creates Open ssid and pushes it to AP, and verifies that profile is applied properly
yield True
@pytest.mark.test_apnos_wpa_ssid
def test_wpa_ssid(self):
# Write a Test case that creates WPA ssid and pushes it to AP, and verifies that profile is applied properly
yield True
@pytest.mark.test_apnos_wpa2_personal_ssid
def test_wpa2_personal_ssid(self):
# Write a Test case that creates WPA2-PERSONAL ssid and pushes it to AP, and verifies that profile is applied
# properly
yield True
@pytest.mark.test_apnos_wpa2_enterprise_ssid
def test_wpa2_enterprise_ssid(self):
# Write a Test case that creates WPA2-ENTERPRISE ssid and pushes it to AP, and verifies that profile is
# applied properly
yield True
@pytest.mark.test_apnos_wpa3_personal_ssid
def test_wpa3_personal_ssid(self):
# Write a Test case that creates WPA3-PERSONAL ssid and pushes it to AP, and verifies that profile is applied
# properly
yield True
@pytest.mark.test_apnos_wpa3_enterprise_ssid
def test_wpa3_enterprise_ssid(self):
# Write a Test case that creates WPA3-ENTERPRISE ssid and pushes it to AP, and verifies that profile is
# applied properly
yield True
# """
# About: It contains some Functional Unit Tests for CloudSDK+APNOS and to run and test them on per unit level
# """
# import pytest
#
#
# # Note: Use Reusable Fixtures, Create SSID Profile, Equipment_AP Profile, Use RF Profile, Radius Profile,
# # Push and Verify
# @pytest.mark.test_apnos_profiles
# class TestProfiles(object):
#
# @pytest.mark.test_apnos_open_ssid
# def test_open_ssid(self):
# # Write a Test case that creates Open ssid and pushes it to AP, and verifies that profile is applied properly
# yield True
#
# @pytest.mark.test_apnos_wpa_ssid
# def test_wpa_ssid(self):
# # Write a Test case that creates WPA ssid and pushes it to AP, and verifies that profile is applied properly
# yield True
#
# @pytest.mark.test_apnos_wpa2_personal_ssid
# def test_wpa2_personal_ssid(self):
# # Write a Test case that creates WPA2-PERSONAL ssid and pushes it to AP, and verifies that profile is applied
# # properly
# yield True
#
# @pytest.mark.test_apnos_wpa2_enterprise_ssid
# def test_wpa2_enterprise_ssid(self):
# # Write a Test case that creates WPA2-ENTERPRISE ssid and pushes it to AP, and verifies that profile is
# # applied properly
# yield True
#
# @pytest.mark.test_apnos_wpa3_personal_ssid
# def test_wpa3_personal_ssid(self):
# # Write a Test case that creates WPA3-PERSONAL ssid and pushes it to AP, and verifies that profile is applied
# # properly
# yield True
#
# @pytest.mark.test_apnos_wpa3_enterprise_ssid
# def test_wpa3_enterprise_ssid(self):
# # Write a Test case that creates WPA3-ENTERPRISE ssid and pushes it to AP, and verifies that profile is
# # applied properly
# yield True

View File

@@ -1,75 +1,68 @@
import pytest
import sys
#
#
# for folder in 'py-json', 'py-scripts':
# if folder not in sys.path:
# sys.path.append(f'../../lanforge/lanforge-scripts/{folder}')
#
#
# 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
for folder in 'py-json', 'py-scripts':
if folder not in sys.path:
sys.path.append(f'../lanforge/lanforge-scripts/{folder}')
from LANforge.LFUtils import *
if 'py-json' not in sys.path:
sys.path.append('../py-scripts')
import sta_connect2
from sta_connect2 import StaConnect2
import time
@pytest.mark.usefixtures('setup_cloudsdk')
@pytest.mark.usefixtures('update_firmware')
@pytest.mark.bridge_mode_client_connectivity
@pytest.mark.usefixtures('upgrade_firmware')
class TestBridgeModeClientConnectivity(object):
@pytest.mark.bridge_mode_single_client_connectivity
@pytest.mark.nightly
@pytest.mark.nightly_bridge
def test_single_client(self, setup_cloudsdk, update_firmware, setup_bridge_mode, disconnect_cloudsdk):
@pytest.mark.sanity
@pytest.mark.bridge
@pytest.mark.open
@pytest.mark.wpa
@pytest.mark.wpa2
@pytest.mark.eap
def test_single_client(self, setup_cloudsdk, upgrade_firmware, setup_bridge_mode, disconnect_cloudsdk, get_lanforge_data):
print("Run Client Connectivity Here - BRIDGE Mode")
for i in setup_bridge_mode:
for j in i:
staConnect = StaConnect2("192.168.200.80", 8080, debug_=False)
staConnect.sta_mode = 0
staConnect.upstream_resource = 1
staConnect.upstream_port = "eth1"
staConnect.radio = "wiphy0"
staConnect.resource = 1
staConnect.dut_ssid = j
staConnect.dut_passwd = "[BLANK]"
staConnect.dut_security = "open"
staConnect.station_names = ["sta0000", "sta0001"]
staConnect.sta_prefix = "sta"
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", staConnect.dut_ssid, "successful. Test Passed")
else:
print("Single client connection to", staConnect.dut_ssid, "unsuccessful. Test Failed")
time.sleep(30)
if setup_bridge_mode[0] == setup_bridge_mode[1]:
assert True
else:
test_result = []
for profile in setup_bridge_mode[3]:
print(profile)
# SSID, Passkey, Security, Run layer3 tcp, udp upstream downstream
staConnect = StaConnect2(get_lanforge_data["lanforge_ip"], 8080, debug_=False)
staConnect.sta_mode = 0
staConnect.upstream_resource = 1
staConnect.upstream_port = get_lanforge_data["lanforge_bridge_port"]
staConnect.radio = get_lanforge_data["lanforge_5g"]
staConnect.resource = 1
staConnect.dut_ssid = profile["ssid_name"]
staConnect.dut_passwd = profile["security_key"]
staConnect.dut_security = profile["security_key"].split("-")[1].split("_")[0].lower()
staConnect.station_names = [get_lanforge_data["lanforge_5g_station"]]
staConnect.sta_prefix = get_lanforge_data["lanforge_5g_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:
test_result.append("PASS")
else:
test_result.append("FAIL")
print(test_result)
if test_result.__contains__("FAIL"):
assert False
@pytest.mark.bridge_mode_multi_client_connectivity
def test_multi_client(self, create_vlan_profile):
print(create_vlan_profile)
assert 1 == 1
else:
assert True

View File

@@ -1,22 +1,69 @@
import pytest
import sys
for folder in 'py-json', 'py-scripts':
if folder not in sys.path:
sys.path.append(f'../lanforge/lanforge-scripts/{folder}')
from LANforge.LFUtils import *
if 'py-json' not in sys.path:
sys.path.append('../py-scripts')
import sta_connect2
from sta_connect2 import StaConnect2
import time
@pytest.mark.usefixtures('setup_cloudsdk')
@pytest.mark.usefixtures('update_firmware')
@pytest.mark.nat_mode_client_connectivity
@pytest.mark.usefixtures('upgrade_firmware')
class TestNATModeClientConnectivity(object):
@pytest.mark.nat_mode_single_client_connectivity
@pytest.mark.nightly
@pytest.mark.nightly_nat
def test_single_client(self, setup_cloudsdk, update_firmware, setup_nat_mode, disconnect_cloudsdk):
@pytest.mark.sanity
@pytest.mark.nat
@pytest.mark.open
@pytest.mark.wpa
@pytest.mark.wpa2
@pytest.mark.eap
def test_single_client(self, setup_cloudsdk, upgrade_firmware, setup_nat_mode, disconnect_cloudsdk, get_lanforge_data):
print("Run Client Connectivity Here - NAT Mode")
time.sleep(30)
if setup_nat_mode[0] == setup_nat_mode[1]:
assert True
else:
test_result = []
for profile in setup_nat_mode[3]:
print(profile)
# SSID, Passkey, Security, Run layer3 tcp, udp upstream downstream
staConnect = StaConnect2(get_lanforge_data["lanforge_ip"], 8080, debug_=False)
staConnect.sta_mode = 0
staConnect.upstream_resource = 1
staConnect.upstream_port = get_lanforge_data["lanforge_bridge_port"]
staConnect.radio = get_lanforge_data["lanforge_5g"]
staConnect.resource = 1
staConnect.dut_ssid = profile["ssid_name"]
staConnect.dut_passwd = profile["security_key"]
staConnect.dut_security = profile["security_key"].split("-")[1].split("_")[0].lower()
staConnect.station_names = [get_lanforge_data["lanforge_5g_station"]]
staConnect.sta_prefix = get_lanforge_data["lanforge_5g_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:
test_result.append("PASS")
else:
test_result.append("FAIL")
print(test_result)
if test_result.__contains__("FAIL"):
assert False
@pytest.mark.nat_mode_multi_client_connectivity
def test_multi_client(self):
pass
else:
assert True

View File

@@ -1,14 +1,15 @@
import pytest
import time
@pytest.mark.usefixtures('setup_cloudsdk')
@pytest.mark.usefixtures('update_firmware')
@pytest.mark.vlan_mode_client_connectivity
@pytest.mark.usefixtures('upgrade_firmware')
class TestVLANModeClientConnectivity(object):
@pytest.mark.vlan_mode_single_client_connectivity
@pytest.mark.nightly
@pytest.mark.nightly_vlan
def test_single_client(self, setup_cloudsdk, update_firmware, setup_vlan_mode, disconnect_cloudsdk):
@pytest.mark.vlan
@pytest.mark.open
@pytest.mark.wpa
@pytest.mark.wpa2
@pytest.mark.eap
def test_single_client(self, setup_cloudsdk, upgrade_firmware, setup_vlan_mode, disconnect_cloudsdk):
print("Run Client Connectivity Here - VLAN Mode")
time.sleep(30)
if setup_vlan_mode[0] == setup_vlan_mode[1]:
@@ -16,7 +17,4 @@ class TestVLANModeClientConnectivity(object):
else:
assert False
@pytest.mark.vlan_mode_multi_client_connectivity
def test_multi_client(self):
pass

View File

@@ -10,12 +10,10 @@ if 'cloudsdk_tests' not in sys.path:
from cloudsdk import CloudSDK
@pytest.mark.userfixtures('get_customer_id')
@pytest.mark.userfixtures('get_testbed_name')
@pytest.mark.test_login
@pytest.mark.cloud
class TestLogin(object):
@pytest.mark.test_bearer_token
@pytest.mark.bearer
def test_token_login(self, get_customer_id, get_testbed_name):
try:
obj = CloudSDK(testbed=get_testbed_name, customer_id=get_customer_id)
@@ -23,97 +21,97 @@ class TestLogin(object):
value = bearer._access_token is None
except:
value = True
assert value == False
assert value is False
@pytest.mark.test_portal_ping
@pytest.mark.ping
def test_ping(self, get_customer_id, get_testbed_name):
try:
obj = CloudSDK(testbed=get_testbed_name, customer_id=get_customer_id)
value = obj.portal_ping() is None
except:
value = True
assert value == False
assert value is False
#
# @pytest.mark.userfixtures('get_customer_id')
# @pytest.mark.userfixtures('get_testbed_name')
# @pytest.mark.ssid_profiles
# class TestSSIDProfiles(object):
#
# @pytest.mark.ssid_open_bridge
# def test_open_bridge(self):
# pass
#
# @pytest.mark.ssid_open_nat
# def test_open_nat(self):
# pass
#
# @pytest.mark.ssid_open_vlan
# def test_open_vlan(self):
# pass
#
# @pytest.mark.ssid_wpa_bridge
# def test_wpa_bridge(self):
# pass
#
# @pytest.mark.ssid_wpa_nat
# def test_wpa_nat(self):
# pass
#
# @pytest.mark.ssid_wpa_vlan
# def test_wpa_vlan(self):
# pass
#
# @pytest.mark.ssid_wpa_personal_bridge
# def test_wpa2_personal_bridge(self):
# pass
#
# @pytest.mark.ssid_wpa_personal_nat
# def test_wpa2_personal_nat(self):
# pass
#
# @pytest.mark.ssid_wpa_personal_vlan
# def test_wpa2_personal_vlan(self):
# pass
#
# @pytest.mark.ssid_wpa2_enterprise_bridge
# def test_wpa2_enterprise_bridge(self):
# pass
#
# @pytest.mark.ssid_wpa2_enterprise_nat
# def test_wpa2_enterprise_nat(self):
# pass
#
# @pytest.mark.ssid_wpa2_enterprise_vlan
# def test_wpa2_enterprise_vlan(self):
# pass
#
# @pytest.mark.ssid_wpa3_personal_bridge
# def test_wpa3_personal_bridge(self):
# pass
#
# @pytest.mark.ssid_wpa3_personal_nat
# def test_wpa3_personal_nat(self):
# pass
#
# @pytest.mark.ssid_wpa3_personal_vlan
# def test_wpa3_personal_vlan(self):
# pass
#
# @pytest.mark.ssid_wpa3_enterprise_bridge
# def test_wpa3_enterprise_bridge(self):
# pass
#
# @pytest.mark.ssid_wpa3_enterprise_nat
# def test_wpa3_enterprise_nat(self):
# pass
#
# @pytest.mark.ssid_wpa3_enterprise_vlan
# def test_wpa3_enterprise_vlan(self):
# pass
@pytest.mark.userfixtures('get_customer_id')
@pytest.mark.userfixtures('get_testbed_name')
@pytest.mark.ssid_profiles
class TestSSIDProfiles(object):
@pytest.mark.ssid_open_bridge
def test_open_bridge(self):
pass
@pytest.mark.ssid_open_nat
def test_open_nat(self):
pass
@pytest.mark.ssid_open_vlan
def test_open_vlan(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa_bridge(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa_nat(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa_vlan(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa2_personal_bridge(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa2_personal_nat(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa2_personal_vlan(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa2_enterprise_bridge(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa2_enterprise_nat(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa2_enterprise_vlan(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa3_personal_bridge(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa3_personal_nat(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa3_personal_vlan(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa3_enterprise_bridge(self):
pass
@pytest.mark.ssid_open_vlan
def test_wpa3_enterprise_nat(self):
pass
@pytest.mark.ssid_wpa3_vlan
def test_wpa3_enterprise_vlan(self):
pass
class TestEquipmentAPProfile(object):
def test_equipment_ap_profile_creation(self):
pass
#
# class TestEquipmentAPProfile(object):
#
# def test_equipment_ap_profile_creation(self):
# pass

View File

@@ -18,11 +18,11 @@ if 'apnos' not in sys.path:
from apnos import APNOS
from cloudsdk import CloudSDK
from cloudsdk import ProfileUtility
from cloudsdk import FirmwareUtility
import pytest
import logging
def pytest_addoption(parser):
parser.addini("jfrog-base-url", "jfrog base url")
parser.addini("jfrog-user-id", "jfrog username")
@@ -86,7 +86,11 @@ def instantiate_cloudsdk(request):
@pytest.fixture(scope="session")
def instantiate_jFrog(request):
yield "instantiate_jFrog"
jfrog_cred = {
"user": request.config.getini("jfrog-user-id"),
"password": request.config.getini("jfrog-user-password")
}
yield jfrog_cred
"""
@@ -104,6 +108,11 @@ def get_customer_id(request):
yield request.config.getini("sdk-customer-id")
@pytest.fixture(scope="session")
def get_equipment_id(request):
yield request.config.getini("sdk-equipment-id")
"""
Fixtures for CloudSDK Utilities
"""
@@ -146,10 +155,14 @@ def setup_cloudsdk(request, instantiate_cloudsdk):
@pytest.fixture(scope="session")
def update_firmware(request, instantiate_jFrog, instantiate_cloudsdk, retrieve_latest_image, access_points):
def upgrade_firmware(request, instantiate_jFrog, instantiate_cloudsdk, retrieve_latest_image, get_equipment_id):
if request.config.getoption("--skip-update-firmware"):
return
yield "update_firmware"
obj = FirmwareUtility(jfrog_credentials=instantiate_jFrog, sdk_client=instantiate_cloudsdk)
status = obj.upgrade_fw(equipment_id=get_equipment_id, force_upload=False, force_upgrade=False)
time.sleep(60)
else:
status = "skip-upgrade"
yield status
@pytest.fixture(scope="session")
@@ -175,7 +188,7 @@ Fixtures to Create Profiles and Push to vif config and delete after the test com
@pytest.fixture(scope="function")
def setup_bridge_mode(request, instantiate_cloudsdk, create_bridge_profile):
def setup_bridge_mode(request, instantiate_cloudsdk, create_bridge_profile, get_equipment_id):
# vif config and vif state logic here
logging.basicConfig(level=logging.DEBUG)
APNOS_CREDENTIAL_DATA = {
@@ -218,41 +231,40 @@ def setup_bridge_mode(request, instantiate_cloudsdk, create_bridge_profile):
profile_data = list(profile_data)
profile_data.sort()
# request.addfinalizer(delete_profiles(profile_data, instantiate_cloudsdk))
yield [profile_data, vif_config, vif_state]
delete_profiles(instantiate_cloudsdk)
yield [profile_data, vif_config, vif_state, create_bridge_profile]
delete_profiles(instantiate_cloudsdk, get_equipment_id)
@pytest.fixture(scope="function")
def create_bridge_profile(request, instantiate_cloudsdk, setup_profile_data, get_testbed_name):
def create_bridge_profile(request, instantiate_cloudsdk, setup_profile_data, get_testbed_name, get_equipment_id, get_markers):
print(setup_profile_data)
# SSID and AP name shall be used as testbed_name and mode
profile_object = ProfileUtility(sdk_client=instantiate_cloudsdk)
profile_object.get_default_profiles()
profile_object.set_rf_profile()
profile_list = []
if request.config.getini("skip-open") == 'False':
if get_markers.__contains__("open"):
profile_data = setup_profile_data['OPEN']['2G']
profile_object.create_open_ssid_profile(profile_data=profile_data, fiveg=False)
profile_list.append(profile_data)
profile_data = setup_profile_data['OPEN']['5G']
profile_object.create_open_ssid_profile(profile_data=profile_data, two4g=False)
profile_list.append(profile_data)
if request.config.getini("skip-wpa") == 'False':
if get_markers.__contains__("wpa"):
profile_data = setup_profile_data['WPA']['2G']
profile_object.create_wpa_ssid_profile(profile_data=profile_data, fiveg=False)
profile_list.append(profile_data)
profile_data = setup_profile_data['WPA']['5G']
profile_object.create_wpa_ssid_profile(profile_data=profile_data, two4g=False)
profile_list.append(profile_data)
if request.config.getini("skip-wpa2") == 'False':
if get_markers.__contains__("wpa2"):
profile_data = setup_profile_data['WPA2']['2G']
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
profile_list.append(profile_data)
profile_data = setup_profile_data['WPA2']['5G']
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
profile_list.append(profile_data)
if request.config.getini("skip-eap") == 'False':
if get_markers.__contains__("eap"):
radius_info = {
"name": get_testbed_name + "-RADIUS-Nightly",
"ip": "192.168.200.75",
@@ -265,12 +277,12 @@ def create_bridge_profile(request, instantiate_cloudsdk, setup_profile_data, get
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", 'BRIDGE'),
}
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
profile_object.push_profile_old_method(equipment_id=get_equipment_id)
yield profile_list
@pytest.fixture(scope="function")
def setup_nat_mode(request, instantiate_cloudsdk, create_nat_profile):
def setup_nat_mode(request, instantiate_cloudsdk, create_nat_profile, get_equipment_id):
# vif config and vif state logic here
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('test_1')
@@ -313,41 +325,40 @@ def setup_nat_mode(request, instantiate_cloudsdk, create_nat_profile):
profile_data = list(profile_data)
profile_data.sort()
# request.addfinalizer(delete_profiles(profile_data, instantiate_cloudsdk))
yield [profile_data, vif_config, vif_state]
delete_profiles(instantiate_cloudsdk)
yield [profile_data, vif_config, vif_state, create_nat_profile]
delete_profiles(instantiate_cloudsdk, get_equipment_id)
@pytest.fixture(scope="function")
def create_nat_profile(request, instantiate_cloudsdk, setup_profile_data, get_testbed_name):
def create_nat_profile(request, instantiate_cloudsdk, setup_profile_data, get_testbed_name, get_equipment_id, get_markers):
print(setup_profile_data)
# SSID and AP name shall be used as testbed_name and mode
profile_object = ProfileUtility(sdk_client=instantiate_cloudsdk)
profile_object.get_default_profiles()
profile_object.set_rf_profile()
profile_list = []
if request.config.getini("skip-open") == 'False':
if get_markers.__contains__("open"):
profile_data = setup_profile_data['OPEN']['2G']
profile_object.create_open_ssid_profile(profile_data=profile_data, fiveg=False)
profile_list.append(profile_data)
profile_data = setup_profile_data['OPEN']['5G']
profile_object.create_open_ssid_profile(profile_data=profile_data, two4g=False)
profile_list.append(profile_data)
if request.config.getini("skip-wpa") == 'False':
if get_markers.__contains__("wpa"):
profile_data = setup_profile_data['WPA']['2G']
profile_object.create_wpa_ssid_profile(profile_data=profile_data, fiveg=False)
profile_list.append(profile_data)
profile_data = setup_profile_data['WPA']['5G']
profile_object.create_wpa_ssid_profile(profile_data=profile_data, two4g=False)
profile_list.append(profile_data)
if request.config.getini("skip-wpa2") == 'False':
if get_markers.__contains__("wpa2"):
profile_data = setup_profile_data['WPA2']['2G']
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
profile_list.append(profile_data)
profile_data = setup_profile_data['WPA2']['5G']
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
profile_list.append(profile_data)
if request.config.getini("skip-eap") == 'False':
if get_markers.__contains__("eap"):
radius_info = {
"name": get_testbed_name + "-RADIUS-Nightly",
"ip": "192.168.200.75",
@@ -359,13 +370,13 @@ def create_nat_profile(request, instantiate_cloudsdk, setup_profile_data, get_te
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", "NAT")
}
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
profile_object.push_profile_old_method(equipment_id=get_equipment_id)
yield profile_list
@pytest.fixture(scope="function")
def setup_vlan_mode(request, instantiate_cloudsdk, create_vlan_profile):
def setup_vlan_mode(request, instantiate_cloudsdk, create_vlan_profile, get_equipment_id):
# vif config and vif state logic here
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('test_1')
@@ -410,12 +421,12 @@ def setup_vlan_mode(request, instantiate_cloudsdk, create_vlan_profile):
profile_data.sort()
# request.addfinalizer(delete_profiles(profile_data, instantiate_cloudsdk))
yield [profile_data, vif_config, vif_state]
delete_profiles(instantiate_cloudsdk)
yield [profile_data, vif_config, vif_state, create_vlan_profile]
delete_profiles(instantiate_cloudsdk, get_equipment_id)
@pytest.fixture(scope="function")
def create_vlan_profile(request, instantiate_cloudsdk, setup_profile_data, get_testbed_name):
def create_vlan_profile(request, instantiate_cloudsdk, setup_profile_data, get_testbed_name, get_equipment_id):
print(setup_profile_data)
# SSID and AP name shall be used as testbed_name and mode
profile_object = ProfileUtility(sdk_client=instantiate_cloudsdk)
@@ -456,7 +467,7 @@ def create_vlan_profile(request, instantiate_cloudsdk, setup_profile_data, get_t
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", 'VLAN')
}
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
profile_object.push_profile_old_method(equipment_id=get_equipment_id)
yield profile_list
@@ -487,9 +498,41 @@ def setup_profile_data(request, get_testbed_name):
profile_data[security][radio]["vlan"] = vlan_id
if security != "OPEN":
profile_data[security][radio]["security_key"] = passkey_string
else:
profile_data[security][radio]["security_key"] = "[BLANK]"
yield profile_data
def delete_profiles(sdk_client=None):
def delete_profiles(sdk_client=None, equipment_id=None):
profile_object = ProfileUtility(sdk_client=sdk_client)
profile_object.delete_current_profile(equipment_id=13)
profile_object.delete_current_profile(equipment_id=equipment_id)
@pytest.fixture(scope="function")
def get_lanforge_data(request):
lanforge_data = {
"lanforge_ip": "192.168.200.80",
"lanforge_2dot4g": "wiphy1",
"lanforge_5g": "wiphy1",
"lanforge_2dot4g_prefix": "wlan1",
"lanforge_5g_prefix": "wlan1",
"lanforge_2dot4g_station": "wlan1",
"lanforge_5g_station": "wlan1",
"lanforge_bridge_port": "eth1",
"lanforge_vlan_port": "vlan100",
"vlan": 100
}
yield lanforge_data
@pytest.fixture(scope="function")
def get_markers(request):
mode = request.config.getoption("-m")
markers = []
for i in request.node.iter_markers():
markers.append(i.name)
a = set(mode.split(" "))
b = set(markers)
markers = a.intersection(b)
yield list(markers)

View File

@@ -7,7 +7,7 @@ jfrog-user-id=tip-read
jfrog-user-password=tip-read
# Cloud SDK parameters
testbed-name=nola-ext-04
testbed-name=nola-ext-03
sdk-user-id=support@example.com
sdk-user-password=support
@@ -31,7 +31,7 @@ lanforge-ethernet-port=eth2
# Cloud SDK settings
sdk-customer-id=2
sdk-equipment-id=12
sdk-equipment-id=21
# Profile
skip-open=True
@@ -41,12 +41,14 @@ skip-eap=False
markers =
login: marks cloudsdk login
nightly_vlan: marks nightly vlan cases
nightly: marks nightly sanity cases
nightly_bridge: marks nightly bridge cases
nightly_nat: marks nightly nat cases
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
sanity: Run the sanity for Client Connectivity test
bridge
nat
vlan
open
wpa
wpa2
eap
cloud
bearer
ping