Merge pull request #17 from Telecominfraproject/pending

Pending:  WIFI-1325  Fix up bugs that came in with code rebase.
This commit is contained in:
Shivam Thakur
2021-02-22 20:54:55 +05:30
committed by GitHub
23 changed files with 2904 additions and 1052 deletions

View File

@@ -9,6 +9,7 @@ sudo pip3 install paramiko
sudo pip3 install scp
sudo pip3 install pexpect
sudo pip3 install pexpect-serial
sudo yum install pytest
# Clone these repositories to get started:
git@github.com:Telecominfraproject/wlan-testing.git # This repo

View File

@@ -0,0 +1,207 @@
#RF Profile looks like this (as of Feb 10, 2021)
# Default RF profile is 10 currently.
{
"childProfileIds": [],
"createdTimestamp": 0,
"customerId": 2,
"details": {
"model_type": "RfConfiguration",
"profileType": "rf",
"rfConfigMap": {
"is2dot4GHz": {
"activeScanSettings": {
"enabled": true,
"model_type": "ActiveScanSettings",
"scanDurationMillis": 65,
"scanFrequencySeconds": 10
},
"autoChannelSelection": false,
"beaconInterval": 100,
"bestApEnabled": null,
"bestApSettings": {
"dropInSnrPercentage": 20,
"minLoadFactor": 50,
"mlComputed": true,
"model_type": "RadioBestApSettings"
},
"channelBandwidth": "is20MHz",
"channelHopSettings": {
"model_type": "ChannelHopSettings",
"noiseFloorThresholdInDB": -75,
"noiseFloorThresholdTimeInSeconds": 180,
"nonWifiThresholdInPercentage": 50,
"nonWifiThresholdTimeInSeconds": 180,
"obssHopMode": "NON_WIFI"
},
"clientDisconnectThresholdDb": -90,
"eirpTxPower": 18,
"forceScanDuringVoice": "disabled",
"managementRate": "auto",
"maxNumClients": 100,
"mimoMode": "twoByTwo",
"minAutoCellSize": -65,
"model_type": "RfElementConfiguration",
"multicastRate": "auto",
"neighbouringListApConfig": {
"maxAps": 25,
"minSignal": -85,
"model_type": "NeighbouringAPListConfiguration"
},
"perimeterDetectionEnabled": true,
"probeResponseThresholdDb": -90,
"radioMode": "modeN",
"radioType": "is2dot4GHz",
"rf": "TipWlan-rf",
"rtsCtsThreshold": 65535,
"rxCellSizeDb": -90
},
"is5GHz": {
"activeScanSettings": {
"enabled": true,
"model_type": "ActiveScanSettings",
"scanDurationMillis": 65,
"scanFrequencySeconds": 10
},
"autoChannelSelection": false,
"beaconInterval": 100,
"bestApEnabled": null,
"bestApSettings": {
"dropInSnrPercentage": 30,
"minLoadFactor": 40,
"mlComputed": true,
"model_type": "RadioBestApSettings"
},
"channelBandwidth": "is80MHz",
"channelHopSettings": {
"model_type": "ChannelHopSettings",
"noiseFloorThresholdInDB": -75,
"noiseFloorThresholdTimeInSeconds": 180,
"nonWifiThresholdInPercentage": 50,
"nonWifiThresholdTimeInSeconds": 180,
"obssHopMode": "NON_WIFI"
},
"clientDisconnectThresholdDb": -90,
"eirpTxPower": 18,
"forceScanDuringVoice": "disabled",
"managementRate": "auto",
"maxNumClients": 100,
"mimoMode": "twoByTwo",
"minAutoCellSize": -65,
"model_type": "RfElementConfiguration",
"multicastRate": "auto",
"neighbouringListApConfig": {
"maxAps": 25,
"minSignal": -85,
"model_type": "NeighbouringAPListConfiguration"
},
"perimeterDetectionEnabled": true,
"probeResponseThresholdDb": -90,
"radioMode": "modeAC",
"radioType": "is5GHz",
"rf": "TipWlan-rf",
"rtsCtsThreshold": 65535,
"rxCellSizeDb": -90
},
"is5GHzL": {
"activeScanSettings": {
"enabled": true,
"model_type": "ActiveScanSettings",
"scanDurationMillis": 65,
"scanFrequencySeconds": 10
},
"autoChannelSelection": false,
"beaconInterval": 100,
"bestApEnabled": null,
"bestApSettings": {
"dropInSnrPercentage": 30,
"minLoadFactor": 40,
"mlComputed": true,
"model_type": "RadioBestApSettings"
},
"channelBandwidth": "is80MHz",
"channelHopSettings": {
"model_type": "ChannelHopSettings",
"noiseFloorThresholdInDB": -75,
"noiseFloorThresholdTimeInSeconds": 180,
"nonWifiThresholdInPercentage": 50,
"nonWifiThresholdTimeInSeconds": 180,
"obssHopMode": "NON_WIFI"
},
"clientDisconnectThresholdDb": -90,
"eirpTxPower": 18,
"forceScanDuringVoice": "disabled",
"managementRate": "auto",
"maxNumClients": 100,
"mimoMode": "twoByTwo",
"minAutoCellSize": -65,
"model_type": "RfElementConfiguration",
"multicastRate": "auto",
"neighbouringListApConfig": {
"maxAps": 25,
"minSignal": -85,
"model_type": "NeighbouringAPListConfiguration"
},
"perimeterDetectionEnabled": true,
"probeResponseThresholdDb": -90,
"radioMode": "modeAC",
"radioType": "is5GHzL",
"rf": "TipWlan-rf",
"rtsCtsThreshold": 65535,
"rxCellSizeDb": -90
},
"is5GHzU": {
"activeScanSettings": {
"enabled": true,
"model_type": "ActiveScanSettings",
"scanDurationMillis": 65,
"scanFrequencySeconds": 10
},
"autoChannelSelection": false,
"beaconInterval": 100,
"bestApEnabled": null,
"bestApSettings": {
"dropInSnrPercentage": 30,
"minLoadFactor": 40,
"mlComputed": true,
"model_type": "RadioBestApSettings"
},
"channelBandwidth": "is80MHz",
"channelHopSettings": {
"model_type": "ChannelHopSettings",
"noiseFloorThresholdInDB": -75,
"noiseFloorThresholdTimeInSeconds": 180,
"nonWifiThresholdInPercentage": 50,
"nonWifiThresholdTimeInSeconds": 180,
"obssHopMode": "NON_WIFI"
},
"clientDisconnectThresholdDb": -90,
"eirpTxPower": 18,
"forceScanDuringVoice": "disabled",
"managementRate": "auto",
"maxNumClients": 100,
"mimoMode": "twoByTwo",
"minAutoCellSize": -65,
"model_type": "RfElementConfiguration",
"multicastRate": "auto",
"neighbouringListApConfig": {
"maxAps": 25,
"minSignal": -85,
"model_type": "NeighbouringAPListConfiguration"
},
"perimeterDetectionEnabled": true,
"probeResponseThresholdDb": -90,
"radioMode": "modeAC",
"radioType": "is5GHzU",
"rf": "TipWlan-rf",
"rtsCtsThreshold": 65535,
"rxCellSizeDb": -90
}
}
},
"id": 10,
"lastModifiedTimestamp": 0,
"model_type": "Profile",
"name": "TipWlan-rf",
"profileType": "rf"
}

View File

@@ -8,16 +8,30 @@ from lab_ap_info import *
class GetBuild:
def __init__(self, jfrog_user, jfrog_passwd, build):
def __init__(self, jfrog_user, jfrog_passwd, build, url=None):
self.user = jfrog_user
self.password = jfrog_passwd
ssl._create_default_https_context = ssl._create_unverified_context
self.jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/'
if url:
self.jfrog_url = url
else:
self.jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/'
self.build = build
def get_latest_image(self, model):
def get_user(self):
return self.user
def get_passwd(self):
return self.password
def get_latest_image(self, model, for_build=None):
build_name = self.build
if for_build:
build_name = for_build
url = self.jfrog_url + model + "/dev/"
print("JfrogHelper::get_latest_image, url: ", url)
auth = str(
base64.b64encode(
@@ -35,7 +49,7 @@ class GetBuild:
soup = BeautifulSoup(html, features="html.parser")
# find the last pending link on dev
last_link = soup.find_all('a', href=re.compile(self.build))[-1]
last_link = soup.find_all('a', href=re.compile(build_name))[-1]
latest_file = last_link['href']
latest_fw = latest_file.replace('.tar.gz', '')
return latest_fw

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

35
tests/EXAMPLE-USAGE.txt Normal file
View File

@@ -0,0 +1,35 @@
# 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

View File

@@ -49,7 +49,7 @@ class NightlySanity:
print("EQ Id: %s" % (eq_id))
# Now, query equipment to find something that matches.
eq = self.cloud.get_customer_equipment(args.sdk_base_url, self.bearer, self.customer_id)
eq = self.cloud.get_customer_equipment(self.customer_id)
for item in eq:
for e in item['items']:
print(e['id'], " ", e['inventoryId'])
@@ -57,7 +57,7 @@ class NightlySanity:
print("Found equipment ID: %s inventoryId: %s",
e['id'], e['inventoryId'])
self.equipment_id = str(e['id'])
if self.equipment_id == -1:
if self.equipment_id == "-1":
print("ERROR: Could not find equipment-id.")
exit()
@@ -75,13 +75,14 @@ class NightlySanity:
# 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.bearer, self.args, self.report_data,
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)
self.firmware["current"], self.logger, key)
elif (self.firmware["current"] is not None) and self.firmware["latest"] == self.firmware["current"]:
do_upgrade = False
@@ -95,7 +96,7 @@ class NightlySanity:
if do_upgrade:
cloud_model = self.cloud_sdk_models[self.args.model]
pf = self.cloud.do_upgrade_ap_fw(self.bearer, self.args, self.report_data, test_cases, self.client,
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)
@@ -121,7 +122,7 @@ class NightlySanity:
# 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")
@@ -132,7 +133,7 @@ class NightlySanity:
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=self.test_cases["cloud_connection"], run_id=self.rid,
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"
@@ -153,35 +154,37 @@ class NightlySanity:
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)
self.ap_object.set_ssid_psk_data(ssid_2g_wpa="Nightly-SSID-2G-WPA",
ssid_5g_wpa="Nightly-SSID-5G-WPA",
psk_2g_wpa="Nightly_2g_wpa",
psk_5g_wpa="Nightly_5g_wpa",
ssid_2g_wpa2="Nightly-SSID-2G-WPA2",
ssid_5g_wpa2="Nightly-SSID-5G-WPA2",
psk_2g_wpa2="Nightly_2g_wpa2",
psk_5g_wpa2="Nightly_5g_wpa2")
#
# # 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 Profile needs to be set here
# obj.create_radius_profile(radius_name, rid, key)
pass
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_bridge_profile(eq_id=self.equipment_id, fw_model=self.model, mode="bridge")
self.ap_object.validate_changes(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")
@@ -191,15 +194,17 @@ class NightlySanity:
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="Nightly-SSID-NAT-2G-WPA",
ssid_5g_wpa="Nightly-SSID-NAT-5G-WPA",
psk_2g_wpa="Nightly_2g_nat_wpa",
psk_5g_wpa="Nightly_5g_nat_wpa",
ssid_2g_wpa2="Nightly-SSID-NAT-2G-WPA2",
ssid_5g_wpa2="Nightly-SSID-NAT-5G-WPA2",
psk_2g_wpa2="Nightly_2g_nat_wpa2",
psk_5g_wpa2="Nightly_5g_nat_wpa2")
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"
@@ -209,11 +214,11 @@ class NightlySanity:
# 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, skip_eap=True, mode="nat")
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_bridge_profile(eq_id=self.equipment_id, fw_model=self.model, mode="nat")
self.ap_object.validate_changes(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")
@@ -243,16 +248,11 @@ class NightlySanity:
def test_2g(self, mode="bridge"):
if mode == "bridge":
mode_a = "name"
if mode == "nat":
mode_a = "nat"
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 = lanforge_2g_radio
radio = command_line_args.lanforge_2g_radio
sta_list = [lanforge_prefix + "5214"]
ssid_name = ssid_2g_eap;
security = "wpa2"
@@ -273,8 +273,8 @@ class NightlySanity:
# 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_a]
ssid_psk = self.ap_object.psk_data['2g']['wpa2'][mode_a]
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'])
@@ -299,8 +299,8 @@ class NightlySanity:
# 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_a]
ssid_psk = self.ap_object.psk_data['2g']['wpa'][mode_a]
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'])
@@ -322,12 +322,6 @@ class NightlySanity:
time.sleep(10)
def test_5g(self, mode="bridge"):
if mode == "bridge":
mode_a = "name"
if mode == "nat":
mode_a = "nat"
if not self.args.skip_radius:
# TC - 5 GHz WPA2-Enterprise
test_case = self.test_cases["5g_eap_" + mode]
@@ -351,8 +345,8 @@ class NightlySanity:
# 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_a]
ssid_psk = self.ap_object.psk_data['5g']['wpa2'][mode_a]
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:
@@ -375,8 +369,8 @@ class NightlySanity:
# # 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_a]
ssid_psk = self.ap_object.psk_data['5g']['wpa'][mode_a]
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:
@@ -478,7 +472,7 @@ def main():
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,
obj = NightlySanity(args=command_line_args, base=base, lanforge_data=lanforge, test=test, reporting=reporting,
build=build_obj)
obj.configure_dut()

View File

@@ -6,8 +6,6 @@ if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)
import sys
for folder in 'py-json', 'py-scripts':
if folder not in sys.path:
sys.path.append(f'../lanforge/lanforge-scripts/{folder}')
@@ -94,117 +92,262 @@ 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', '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):
def __init__(self, log_name, args, reporting=None):
self.parser = argparse.ArgumentParser(description="Sanity Testing on Firmware Build", parents=[args])
self.parser.add_argument("-b", "--build-id", type=str,
help="FW commit ID (latest pending build on dev is default)",
default="pending")
self.parser.add_argument("--skip-upgrade", type=bool, help="Skip upgrading firmware",
default=False)
self.parser.add_argument("--force-upgrade", type=bool,
help="Force upgrading firmware even if it is already current version",
default=False)
self.parser.add_argument("-m", "--model", type=str,
choices=['ea8300', 'ecw5410', 'ecw5211', 'ec420', 'wf188n', 'eap102', 'None'],
help="AP model to be run", required=True)
self.parser.add_argument("--equipment_id", type=str,
help="AP model ID, as exists in the cloud-sdk. -1 to auto-detect.",
default="-1")
self.parser.add_argument("--object_id", type=str,
help="Used when querying and deleting individual objects.",
default=None)
self.parser.add_argument("--customer-id", type=str,
help="Specify cloud customer-id, default is 2",
default="2")
self.parser.add_argument("--testbed", type=str,
help="Testbed name, will be prefixed to profile names and similar",
default=None)
self.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")
self.parser.add_argument("--sdk-user-id", type=str, help="cloudsdk user id, default: support@example.conf",
default="support@example.com")
self.parser.add_argument("--sdk-user-password", type=str, help="cloudsdk user password, default: support",
default="support")
self.parser.add_argument("--jfrog-base-url", type=str, help="jfrog base url",
default="tip.jFrog.io/artifactory/tip-wlan-ap-firmware")
self.parser.add_argument("--jfrog-user-id", type=str, help="jfrog user id",
default="tip-read")
self.parser.add_argument("--jfrog-user-password", type=str, help="jfrog user password",
default="tip-read")
self.parser.add_argument("--testrail-base-url", type=str, help="testrail base url",
# was os.getenv('TESTRAIL_URL')
default="https://telecominfraproject.testrail.com")
self.parser.add_argument("--testrail-project", type=str, help="testrail project name",
default="opsfleet-wlan")
self.parser.add_argument("--testrail-user-id", type=str,
help="testrail user id. Use 'NONE' to disable use of testrails.",
default="gleb@opsfleet.com")
self.parser.add_argument("--testrail-user-password", type=str, help="testrail user password",
default="password")
self.parser.add_argument("--testrail-run-prefix", type=str, help="testrail run prefix",
default="prefix-1")
self.parser.add_argument("--milestone", type=str, help="testrail milestone ID",
default="milestone-1")
self.parser.add_argument("--lanforge-ip-address", type=str, help="ip address of the lanforge gui",
default="127.0.0.1")
self.parser.add_argument("--lanforge-port-number", type=str, help="port of the lanforge gui",
default="8080")
self.parser.add_argument("--lanforge-prefix", type=str, help="LANforge api prefix string",
default="sdk")
self.parser.add_argument("--lanforge-2g-radio", type=str, help="LANforge 2Ghz radio to use for testing",
default="1.1.wiphy0")
self.parser.add_argument("--lanforge-5g-radio", type=str, help="LANforge 5Ghz radio to use for testing",
default="1.1.wiphy1")
self.parser.add_argument("--local_dir", type=str, help="Sanity logging directory",
default="logs")
self.parser.add_argument("--report-path", type=str, help="Sanity report directory",
default="reports")
self.parser.add_argument("--report-template", type=str, help="Sanity report template",
default="reports/report_template.php")
self.parser.add_argument("--eap-id", type=str, help="EAP indentity",
default="lanforge")
self.parser.add_argument("--ttls-password", type=str, help="TTLS password",
default="lanforge")
self.parser.add_argument("--ap-ip", type=str, help="AP IP Address, for direct ssh access if not using jumphost",
default="127.0.0.1")
self.parser.add_argument("--ap-username", type=str, help="AP username",
default="root")
self.parser.add_argument("--ap-password", type=str, help="AP password",
default="root")
self.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)
self.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")
self.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")
self.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")
self.parser.add_argument("--ap-jumphost-wlan-testing", type=str, help="wlan-testing repo dir on the jumphost",
default="git/wlan-testing")
self.parser.add_argument("--ap-jumphost-tty", type=str, help="Serial port for the AP we wish to talk to",
default="UNCONFIGURED-JUMPHOST-TTY")
self.parser.add_argument('--skip-update-firmware', dest='update_firmware', action='store_false')
self.parser.set_defaults(update_firmware=True)
self.parser.add_argument('--verbose', dest='verbose', action='store_true')
self.parser.set_defaults(verbose=False)
add_base_parse_args(self.parser)
self.command_line_args = self.parser.parse_args()
@@ -239,8 +382,13 @@ class UnitTestBase:
self.build = self.command_line_args.build_id
self.logger = logging.getLogger(log_name)
self.hdlr = logging.FileHandler(reporting.report_path + "/test_run.log")
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)
@@ -255,3 +403,4 @@ class UnitTestBase:
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

287
tests/conftest.py Normal file
View File

@@ -0,0 +1,287 @@
import pytest
from time import sleep, gmtime, strftime
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
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("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("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-ethernet-port", "LANforge ethernet adapter to use")
add_base_parse_args_pytest(parser)
# 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="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
def fin():
print("Cloud SDK cleanup done")
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
@pytest.fixture(scope="session")
def update_firmware(request, setup_testrails, instantiate_jFrog, instantiate_cloudsdk, access_points):
if request.config.getoption("--skip-update-firmware"):
return True
#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 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))
@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")
)

64
tests/helpers/utils.py Normal file
View File

@@ -0,0 +1,64 @@
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

View File

@@ -1,15 +1,15 @@
[pytest]
addopts= --junitxml=test_everything.xml
# jFrog parameters
jfrog-base-url=tip.jFrog.io/artifactory/tip-wlan-ap-firmware
jfrog-base-url=https://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-base-url=https://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-base-url=https://telecominfraproject.testrail.com
testrail-project=opsfleet-wlan
testrail-user-id=gleb@opsfleet.com
testrail-user-password=use_command_line_to_pass_this
@@ -20,11 +20,13 @@ lanforge-radio=wiphy4
lanforge-ethernet-port=eth2
# Cloud SDK settings
sdk-customer-id=2
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
markers =
featureA: marks tests as slow (deselect with '-m "not slow"')
featureB
featureC
featureD
featureE
featureE

View File

@@ -1,253 +0,0 @@
import pytest
from time import sleep, gmtime, strftime
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers'))
from utils import CloudSDK_Client, TestRail_Client, jFrog_Client
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")
parser.addoption(
"--testrail-user-password",
action="store",
default="password",
help="testrail user password",
type=str
)
# # Cloud SDK
# parser.addoption(
# "--sdk-base-url",
# action="store",
# default="wlan-portal-svc.cicd.lab.wlan.tip.build",
# help="cloudsdk base url",
# type=str
# )
# parser.addoption(
# "--sdk-user-id",
# action="store",
# default="support@example.com",
# help="cloudsdk user id",
# type=str
# )
# parser.addoption(
# "--sdk-user-password",
# action="store",
# default="support",
# help="cloudsdk user password",
# type=str
# )
# # jFrog
# parser.addoption(
# "--jfrog-base-url",
# action="store",
# default="tip.jFrog.io/artifactory/tip-wlan-ap-firmware",
# help="jfrog base url",
# type=str
# )
# parser.addoption(
# "--jfrog-user-id",
# action="store",
# default="tip-read",
# help="jfrog user id",
# type=str
# )
# parser.addoption(
# "--jfrog-user-password",
# action="store",
# default="tip-read",
# help="jfrog user password",
# type=str
# )
# # testrail
# parser.addoption(
# "--testrail-base-url",
# action="store",
# default="telecominfraproject.testrail.com",
# help="testrail base url",
# type=str
# )
# parser.addoption(
# "--testrail-project",
# action="store",
# default="opsfleet-wlan",
# help="testrail project name",
# type=str
# )
# parser.addoption(
# "--testrail-user-id",
# action="store",
# default="gleb@opsfleet.com",
# help="testrail user id",
# type=str
# )
# parser.addoption(
# "--testrail-user-password",
# action="store",
# default="password",
# help="testrail user password",
# type=str
# )
# # lanforge
# parser.addoption(
# "--lanforge-ip-address",
# action="store",
# default="10.28.3.6",
# help="ip address of the lanforge gui",
# type=str
# )
# parser.addoption(
# "--lanforge-port-number",
# action="store",
# default="8080",
# help="port of the lanforge gui",
# type=str
# )
# change behaviour
parser.addoption(
"--skip-update-firmware",
action="store_true",
default=False,
help="skip updating firmware on the AP (useful for local testing)"
)
parser.addoption(
"--no-testrails",
action="store_true",
default=False,
help="do not generate testrails tests"
)
# 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="session")
def setup_testrails(request, instantiate_testrail, access_points):
if request.config.getoption("--no-testrails"):
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
@pytest.fixture(scope="session")
def setup_cloudsdk(request, instantiate_cloudsdk):
# snippet to do cleanup after all the tests are done
def fin():
print("Cloud SDK cleanup done")
request.addfinalizer(fin)
instantiate_cloudsdk.set_ap_profile(3, 6)
yield {
"LANforge": {
"host": request.config.getini("lanforge-ip-address"),
"port": request.config.getini("lanforge-port-number"),
"radio": request.config.getini("lanforge-radio"),
"eth_port": request.config.getini("lanforge-ethernet-port"),
"runtime_duration": 15
},
"24ghz": {
"ssid": "TipWlan-cloud-wifi",
"password": "w1r3l3ss-fr33d0m",
"station_names": [ "sta2237" ]
}
}
@pytest.fixture(scope="session")
def update_firmware(request, setup_testrails, instantiate_jFrog, instantiate_cloudsdk, access_points):
if request.config.getoption("--skip-update-firmware"):
return
latest_image = instantiate_jFrog.get_latest_image(access_points)
if latest_image in instantiate_cloudsdk.get_images(access_points):
model_firmware_id = instantiate_cloudsdk.get_firmware_id(latest_image)
else:
fw_url = instantiate_jFrog.get_latest_image_url(access_points, latest_image)
fw_upload_status = instantiate_cloudsdk.firwmare_upload(access_points, latest_image, fw_url)
model_firmware_id = fw_upload_status['id']
# Get Current AP Firmware and upgrade\run tests if needed
# currently the AP id is hardcoded, but it should be looked up during the tests and not hardcoded in the config files or parameters
ap_fw = instantiate_cloudsdk.ap_firmware(request.config.getini("sdk-customer-id"), 3)
if ap_fw == latest_image:
pytest.skip("Do not need to upgrade firmware")
else:
instantiate_cloudsdk.update_firmware(3, model_firmware_id)
sleep_counter = 0
while True:
sleep_counter += 1
if instantiate_cloudsdk.ap_firmware(2, 3) == latest_image:
return
if sleep_counter > 0:
return
sleep(60)
@pytest.fixture(scope="session")
def instantiate_cloudsdk(request):
yield CloudSDK_Client(
request.config.getini("sdk-base-url"),
request.config.getini("sdk-user-id"),
request.config.getini("sdk-user-password")
)
@pytest.fixture(scope="session")
def instantiate_testrail(request):
yield TestRail_Client(
request.config.getini("testrail-base-url"),
request.config.getini("testrail-user-id"),
request.config.getoption("--testrail-user-password")
)
@pytest.fixture(scope="session")
def instantiate_jFrog(request):
yield jFrog_Client(
request.config.getini("jfrog-base-url"),
request.config.getini("jfrog-user-id"),
request.config.getini("jfrog-user-password")
)

View File

@@ -1,186 +0,0 @@
import re
import requests
import json
# Class to interact with Testrail
class TestRail_Client:
def __init__(self, url, user, password):
self.user = user
self.password = password
self.__url = f"https://{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
headers = {
"Content-Type": "application/json"
}
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, auth=(self.user, self.password))
files["attachment"].close()
else:
payload = bytes(json.dumps(data), "utf-8")
response = requests.post(url, headers=headers, data=payload, auth=(self.user, self.password))
else:
response = requests.get(url, headers=headers, auth=(self.user, self.password))
if response.status_code > 201:
try:
error = response.json()
except: # response.content not formatted as JSON
error = str(response.content)
return
else:
if uri[:15] == "get_attachments": # Expecting file, not JSON
try:
logging.info (str(response.content))
open(data, "wb").write(response.content)
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"
projects = self.send_get("get_projects")
for project in projects:
if project["name"] == project_name:
return project["id"]
def update_testrail(self, case_id, run_id, status_id, msg):
result = self.send_post(
f"add_result_for_case/{run_id}/{case_id}",
{ "status_id": status_id, "comment": msg }
)
def create_testrun(self, name, case_ids, project_id):
result = self.send_post(
f"add_run/{project_id}",
{"name": name, "case_ids": case_ids, "include_all": False}
)
return result["id"]
# Class for jFrog Interaction
class jFrog_Client:
def __init__(self, url, user, password):
self.user = user
self.password = password
self.baseUrl = f"https://{url}"
def get_latest_image(self, model):
# todo handle auth errors
response = requests.get(f"{self.baseUrl}/{model}/dev/", auth=(self.user, self.password))
return re.findall('href="(.+pending.+).tar.gz"', response.text)[-1]
def get_latest_image_url(self, model, latest_image):
return f"https://{self.user}:{self.password}@{self.baseUrl}/{model}/dev/{latest_image}.tar.gz"
# Class for CloudSDK Interaction via RestAPI
class CloudSDK_Client:
def __init__(self, url, user, password):
self.baseUrl = f"https://{url}"
cloud_login_url = f"{self.baseUrl}/management/v1/oauth2/token"
payload = {
"userId": user,
"password": password
}
headers = {
"Content-Type": "application/json"
}
try:
token_response = requests.post(cloud_login_url, headers=headers, data=json.dumps(payload))
except requests.exceptions.RequestException as e:
raise SystemExit(f"Exiting Script! Cloud not get bearer token for reason: {e}")
token_data = token_response.json()
self.headers = {
"Authorization": f"Bearer {token_data['access_token']}"
}
def ap_firmware(self, customer_id, equipment_id):
equip_fw_url = f"{self.baseUrl}/portal/status/forEquipment?customerId={customer_id}&equipmentId={equipment_id}&statusDataTypes="
status_response = requests.get(equip_fw_url, headers=self.headers)
return (status_response.json())[2]["details"]["reportedSwVersion"]
def get_images(self, apModel):
getFW_url = f"{self.baseUrl}/portal/firmware/version/byEquipmentType?equipmentType=AP&modelId={apModel}"
status_response = requests.get(getFW_url, headers=self.headers)
return([ version.get("versionName") for version in status_response.json()])
def firwmare_upload(self, apModel, latest_image, fw_url):
fw_upload_url = f"{self.baseUrl}/portal/firmware/version"
payload = {
"model_type": "FirmwareVersion",
"id": 0,
"equipmentType": "AP",
"modelId": apModel,
"versionName": latest_image,
"description": "",
"filename": fw_url,
"commit": latest_image.split("-")[-1],
"validationMethod": "MD5_CHECKSUM",
"validationCode": "19494befa87eb6bb90a64fd515634263",
"releaseDate": 1596192028877,
"createdTimestamp": 0,
"lastModifiedTimestamp": 0
}
self.headers["Content-Type"] = "application/json"
response = requests.post(fw_upload_url, headers=self.headers, data=json.dumps(payload))
self.headers.pop("Content-Type", None)
return(response.json())
def get_firmware_id(self, image):
fw_id_url = f"{self.baseUrl}/portal/firmware/version/byName?firmwareVersionName={image}"
response = requests.get(fw_id_url, headers=self.headers)
fw_data = response.json()
return fw_data["id"]
def update_firmware(self, equipment_id, latest_firmware_id):
url = f"{self.baseUrl}/portal/equipmentGateway/requestFirmwareUpdate?equipmentId={equipment_id}&firmwareVersionId={latest_firmware_id}"
response = requests.post(url, headers=self.headers)
def set_ap_profile(self, equipment_id, test_profile_id):
url = f"{self.baseUrl}/portal/equipment?equipmentId={equipment_id}"
response = requests.get(url, headers=self.headers)
# Add Lab Profile ID to Equipment
equipment_info = response.json()
equipment_info["profileId"] = test_profile_id
# Update AP Info with Required Profile ID
url = f"{self.baseUrl}/portal/equipment"
self.headers["Content-Type"] = "application/json"
response = requests.put(url, headers=self.headers, data=json.dumps(equipment_info))
self.headers.pop("Content-Type", None)

View File

@@ -0,0 +1 @@
{"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": []}

View File

@@ -2,6 +2,8 @@
# 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
@@ -11,22 +13,21 @@ from sta_connect2 import StaConnect2
@pytest.mark.usefixtures('update_firmware')
@pytest.mark.usefixtures('instantiate_testrail')
class Test24ghz(object):
@pytest.mark.featureA
@pytest.mark.client_connectivity
def test_single_client_wpa2(self, setup_testrails, setup_cloudsdk, update_firmware, instantiate_testrail):
lf_config = setup_cloudsdk["LANforge"]
radio_config = setup_cloudsdk["24ghz"]
staConnect = StaConnect2(lf_config["host"], lf_config["port"], debug_ = False)
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["radio"]
staConnect.runtime_secs = lf_config["runtime_duration"]
staConnect.radio = lf_config["2g_radio"]
# staConnect.runtime_secs = lf_config["runtime_duration"]
staConnect.resource = 1
staConnect.dut_ssid = radio_config["ssid"]
staConnect.dut_passwd = radio_config["password"]
staConnect.dut_ssid = "NOLA-01g-ecw5410-2G_WPA2"
staConnect.dut_passwd = "ecw5410-2G_WPA2"
staConnect.dut_security = "wpa2"
staConnect.station_names = radio_config["station_names"]
staConnect.station_names = ['sta0000']
staConnect.bringup_time_sec = 60
staConnect.cleanup_on_exit = True
staConnect.setup()
@@ -39,19 +40,27 @@ class Test24ghz(object):
if setup_testrails > 0:
instantiate_testrail.update_testrail(case_id=2835, run_id=setup_testrails, status_id=1, msg="testing")
@pytest.mark.featureB
def test_feature_b(self):
pass
# @pytest.mark.client_connectivity
# def test_single_client_wpa(self):
# pass
#
# @pytest.mark.client_connectivity
# def test_single_client_eap(self):
# pass
@pytest.mark.featureC
def test_feature_c(self):
assert 1 == 0
#@pytest.mark.featureB
#def test_feature_b(self):
# pass
@pytest.mark.featureD
def test_feature_d(self):
pytest.skip("speedup")
#@pytest.mark.featureC
#def test_feature_c(self):
# assert 1 == 0
@pytest.mark.xfail
@pytest.mark.featureE
def test_feature_e(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

View File

@@ -8,6 +8,7 @@ ssh -C -L 8800:lf1:4002 -L 8801:lf1:5901 -L 8802:lf1:8080 -L 8803:lab-ctlr: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
@@ -20,7 +21,14 @@ The ports are used as:
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.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 --sdk-base-url https://wlan-portal-svc-nola-01.cicd.lab.wlan.tip.build
./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)
@@ -29,33 +37,90 @@ Testbed-09 (perfecto)
./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.cicd.lab.wlan.tip.build \
--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
--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.cicd.lab.wlan.tip.build \
--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
--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.cicd.lab.wlan.tip.build \
--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
--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.cicd.lab.wlan.tip.build \
--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-ben-testbed.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-ben-testbed.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
# Query an ssid
./query_sdk.py --testrail-user-id NONE --model wf188n --sdk-base-url https://wlan-portal-svc-ben-testbed.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
./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
./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

View File

@@ -12,7 +12,12 @@ 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
./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
@@ -20,6 +25,7 @@ MODEL=ecw5410
# 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"
echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt /tmp/nola-$NOLANUM-sdk-ping.txt"

View File

@@ -5,15 +5,27 @@
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 ecw5410 --sdk-base-url https://wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build --sdk-user-id support@example.com --sdk-user-password support --type profile --cmd get > /tmp/nola-12-profiles.txt
./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 8823 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 -m ecw5410 --cmd "ovsdb-client dump" > /tmp/nola-12-ap.txt
./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 8823 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 -m ecw5410 --cmd "iwinfo && brctl show" > /tmp/nola-12-ap-if.txt
./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-12-profiles.txt /tmp/nola-12-ap.txt /tmp/nola-12-ap-if.txt"
echo "Grab: /tmp/nola-$NOLANUM-profiles.txt /tmp/nola-$NOLANUM-ap.txt /tmp/nola-$NOLANUM-ap-if.txt /tmp/nola-$NOLANUM-sdk-ping.txt"

View File

@@ -15,7 +15,8 @@ parser.add_argument("--cmd", type=str, help="Command-line to run on AP",
parser.add_argument("--ap_ssh", type=str, help="ap_ssh method to execute.",
default = None, choices=["get_vif_config", "get_vif_state"])
base = UnitTestBase("query-ap", parser)
reporting = Reporting(reports_root=os.getcwd() + "/reports/")
base = UnitTestBase("query-ap", parser, reporting)
cmd = base.command_line_args.cmd

View File

@@ -10,7 +10,7 @@ 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', 'all'],
'event', 'firmware', 'ping', 'all'],
default = "all")
parser.add_argument("--cmd", type=str, help="Operation to do, default is 'get'",
choices=['get', 'delete', 'child_of'],
@@ -19,7 +19,9 @@ parser.add_argument("--brief", type=str, help="Show output in brief mode?",
choices=["true", "false"],
default = "false")
base = UnitTestBase("query-sdk", parser)
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
@@ -95,6 +97,17 @@ if qtype == 'all' or qtype == 'customer':
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)
@@ -123,7 +136,7 @@ if qtype == 'all' or qtype == 'equipment':
# Get equipment info
try:
if cmd == "get":
rv = base.cloud.get_customer_equipment(base.cloudSDK_url, base.bearer, base.customer_id)
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:

View File

@@ -18,57 +18,55 @@ 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")
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")
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")
parser.set_defaults(skip_radius=False)
parser.set_defaults(skip_wpa=False)
parser.set_defaults(skip_wpa2=False)
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?")
parser.set_defaults(skip_profiles=False)
help="Should we skip creating new ssid profiles?", default=False)
parser.add_argument("--psk-5g-wpa2", type=str,
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", type=str,
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", type=str,
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", type=str,
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", type=str,
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", type=str,
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", type=str,
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", type=str,
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 between each profile push", required=False, default=5000)
# 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')
@@ -98,8 +96,6 @@ def main():
lanforge_ip = command_line_args.lanforge_ip_address
lanforge_port = command_line_args.lanforge_port_number
lanforge_prefix = command_line_args.lanforge_prefix
lanforge_2g_radio = command_line_args.lanforge_2g_radio
lanforge_5g_radio = command_line_args.lanforge_5g_radio
build = command_line_args.build_id
@@ -128,7 +124,7 @@ def main():
print("EQ Id: %s" % (eq_id))
# Now, query equipment to find something that matches.
eq = cloud.get_customer_equipment(cloudSDK_url, bearer, customer_id)
eq = cloud.get_customer_equipment(customer_id)
for item in eq:
for e in item['items']:
print(e['id'], " ", e['inventoryId'])
@@ -153,15 +149,8 @@ def main():
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
############################################################################
#################### Create Report #########################################
############################################################################
# Create Report Folder for Today
today = str(date.today())
try:
@@ -173,62 +162,54 @@ def main():
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)
# 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")
obj = CreateAPProfiles(command_line_args, cloud=cloud, client=client, fw_model=fw_model)
sleep = command_line_args.sleep
sleep = sleep/1000
# Allow cmd-line to override
if command_line_args.psk_5g_wpa2:
obj.psk_data["5g"]["wpa2"]["name"] = command_line_args.psk_5g_wpa2
obj.psk_data["5g"]["wpa2"]["nat"] = command_line_args.psk_5g_wpa2
obj.psk_data["5g"]["wpa2"]["vlan"] = command_line_args.psk_5g_wpa2
if command_line_args.psk_5g_wpa:
obj.psk_data["5g"]["wpa"]["name"] = command_line_args.psk_5g_wpa
obj.psk_data["5g"]["wpa"]["nat"] = command_line_args.psk_5g_wpa
obj.psk_data["5g"]["wpa"]["vlan"] = command_line_args.psk_5g_wpa
if command_line_args.psk_2g_wpa2:
obj.psk_data["2g"]["wpa2"]["name"] = command_line_args.psk_2g_wpa2
obj.psk_data["2g"]["wpa2"]["nat"] = command_line_args.psk_2g_wpa2
obj.psk_data["2g"]["wpa2"]["vlan"] =command_line_args.psk_2g_wpa2
if command_line_args.psk_2g_wpa:
obj.psk_data["2g"]["wpa"]["name"] = command_line_args.psk_2g_wpa
obj.psk_data["2g"]["wpa"]["nat"] = command_line_args.psk_2g_wpa
obj.psk_data["2g"]["wpa"]["nat"] = command_line_args.psk_2g_wpa
if command_line_args.ssid_5g_wpa2:
obj.ssid_data["5g"]["wpa2"]["name"] = command_line_args.ssid_5g_wpa2
obj.ssid_data["5g"]["wpa2"]["nat"] = command_line_args.ssid_5g_wpa2
obj.ssid_data["5g"]["wpa2"]["vlan"] = command_line_args.ssid_5g_wpa2
if command_line_args.ssid_5g_wpa:
obj.ssid_data["5g"]["wpa"]["name"] = command_line_args.ssid_5g_wpa
obj.ssid_data["5g"]["wpa"]["nat"] = command_line_args.ssid_5g_wpa
obj.ssid_data["5g"]["wpa"]["vlan"] = command_line_args.ssid_5g_wpa
if command_line_args.ssid_2g_wpa2:
obj.ssid_data["2g"]["wpa2"]["name"] = command_line_args.ssid_2g_wpa2
obj.ssid_data["2g"]["wpa2"]["nat"] = command_line_args.ssid_2g_wpa2
obj.ssid_data["2g"]["wpa2"]["vlan"] = command_line_args.ssid_2g_wpa2
if command_line_args.ssid_2g_wpa:
obj.ssid_data["2g"]["wpa"]["name"] = command_line_args.ssid_2g_wpa
obj.ssid_data["2g"]["wpa"]["nat"] = command_line_args.ssid_2g_wpa
obj.ssid_data["2g"]["wpa"]["vlan"] = command_line_args.ssid_2g_wpa
print("creating Profiles")
ssid_template = "TipWlan-Cloud-Wifi"
if not command_line_args.skip_profiles:
if not command_line_args.skip_radius:
obj.create_radius_profile(radius_name, rid, key)
obj.create_ssid_profiles(ssid_template=ssid_template, skip_wpa2=command_line_args.skip_wpa2,
skip_wpa=command_line_args.skip_wpa, skip_eap=command_line_args.skip_radius)
print("Create AP with equipment-id: ", equipment_id)
obj.create_ap_bridge_profile(eq_id=equipment_id, fw_model=fw_model)
obj.validate_changes()
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)
time.sleep(5)
ap_object.cleanup_profile(equipment_id=equipment_id)
print("Profiles Created")
main()

View File

@@ -88,7 +88,7 @@ if equipment_id == "-1":
print("EQ Id: %s"%(eq_id))
# Now, query equipment to find something that matches.
eq = cloud.get_customer_equipment(cloudSDK_url, bearer, customer_id)
eq = cloud.get_customer_equipment(customer_id)
for item in eq:
for e in item['items']:
print(e['id'], " ", e['inventoryId'])
@@ -96,7 +96,7 @@ if equipment_id == "-1":
print("Found equipment ID: %s inventoryId: %s"%(e['id'], e['inventoryId']))
equipment_id = str(e['id'])
if equipment_id == -1:
if equipment_id == "-1":
print("ERROR: Could not find equipment-id.")
sys.exit(1)
@@ -138,15 +138,12 @@ ap_image = command_line_args.ap_image
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
# print(cloudModel)
jfrog_url = 'https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/'
url = jfrog_url + apModel + "/dev/"
Build: GetBuild = GetBuild(jfrog_user, jfrog_pwd)
latest_image = Build.get_latest_image(url, build)
print(apModel, "Latest FW on jFrog:", latest_image)
ap_image = latest_image
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)
@@ -168,12 +165,13 @@ print('Current Active AP FW from CLI:', ap_cli_fw)
##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(bearer, command_line_args, report_data, ap_image, fw_model, ap_cli_fw,
logger)
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(bearer, command_line_args, report_data, test_cases, client,
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)