Client Connectivity Fixtures are done, Did some Documentation

Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
shivamcandela
2021-03-17 02:12:45 +05:30
parent 462c450f3c
commit 4668aec1ba
14 changed files with 418 additions and 762 deletions

View File

@@ -1,138 +0,0 @@
# TIP CICD Sanity Scripts
This directory contains scripts and modules designed for automated full-system testing.
# Libraries needed to run this code successfully
sudo pip3 install artifactory
sudo pip3 install xlsxwriter
sudo pip3 install pandas
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
# LANforge scripts repo. This *MUST* be located or linked at wlan-testing/lanforge/lanforge-scripts
git@github.com:Telecominfraproject/wlan-lanforge-scripts.git
# Cloud-services, so that you can find the API document
git@github.com:Telecominfraproject/wlan-cloud-services
# Find the cloud-sdk API document here:
https://github.com/Telecominfraproject/wlan-cloud-services/tree/master/portal-services/src/main/resources/
# You need access to the 'ubuntu' jumphost. Send your public ssh key to greearb@candelatech.com
# and he will add this to the jumphost.
# For ease of use, add this to your /etc/hosts file: 3.130.51.163 orch
# Examples in this code often assume you are using ssh port redirects to log into the testbeds,
# for instance, this is for working on the NOLA-01 testbed. The 3.130.51.163 (aka orch)
# system has its /etc/hosts file updated, so that 'lf1' means LANforg system in testbed NOLA-01
# You can find other testbed info in TIP Confluence
# https://telecominfraproject.atlassian.net/wiki/spaces/WIFI/pages/307888428/TIP+Testbeds
# Please communicate with Ben Greear or Jaspreet Sachdev before accessing a testbed
# at leat until we have a reservation system in place.
# NOLA-01 testbed
ssh -C -L 8800:lf1:4002 -L 8801:lf1:5901 -L 8802:lf1:8080 -L 8803:lab-ctlr:22 ubuntu@orch
# Example of accessing AP over serial console through jumphost
./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port 8803 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 \
-m ecw5410 --cmd "cat /etc/banner"
# Example of accessing NOLA-01's cloud controller (https://wlan-portal-svc.cicd.lab.wlan.tip.build)
./query_sdk.py --testrail-user-id NONE --model ecw5410 --sdk-base-url https://wlan-portal-svc.cicd.lab.wlan.tip.build --sdk-user-id \
support@example.com --sdk-user-password support --equipment_id 3 --type profile --cmd get --brief true
# Configure wpa, wpa2 SSIDs 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 --testbed "NOLA-01" --lanforge-ip-address localhost \
--lanforge-port-number 8802 --default-ap-profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc.cicd.lab.wlan.tip.build \
--skip-radius
# NOLA-04 testbed
# testbed ssh tunnel
ssh -C -L 8810:lf4:4002 -L 8811:lf4:5901 -L 8812:lf4:8080 -L 8813:lab-ctlr:22 ubuntu@orch
# Example of accessing AP over serial console through jumphost
./query_ap.py --ap-jumphost-address localhost --ap-jumphost-port 8813 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP4 -m ecw5410 --cmd "cat /etc/banner"
# NOLA-12 testbed
# testbed ssh tunnel
ssh -C -L 8820:lf12:4002 -L 8821:lf12:5901 -L 8822:lf12:8080 -L 8823:lab-ctlr4:22 ubuntu@orch
# Create profiles.
./sdk_set_profile.py --testrail-user-id NONE --model ecw5410 --ap-jumphost-address localhost --ap-jumphost-port 8823 --ap-jumphost-password pumpkin77 --ap-jumphost-tty /dev/ttyAP1 --testbed "NOLA-12" --lanforge-ip-address localhost --lanforge-port-number 8822 --default_ap_profile TipWlan-2-Radios --sdk-base-url https://wlan-portal-svc-ben-testbed.cicd.lab.wlan.tip.build --skip_radius
Then, you would use port 8802 for connecting to the LANforge-GUI for the python LANforge test logic,
and port 8803 to access the lab jumphost. Port 8800 could connect a locally running LANforge GUI to the
testbed for monitoring the test, and port 8801 will connect VNC to the LANforge machine.
# This automated test logic is found in the wlan-testing/unit_tests directory. These notes
# assume you are in that directory unless otherwise specified.
# Interesting files in this repo
* ap_ssh.py: Library methods to access the AP over direct ssh connection or serial console. For NOLA
testbeds, currently serial console is the only viable way to connect.
* cloudsdk.py: Library methods to access the cloud controller API using REST/JSON. This is how you configure
the AP.
* lab_ap_info.py: Holds some variables related to lab config. I prefer to use this as little as possible.
Instead, use command line arguments, possibly specifying a particular config file on the cmd line if
needed.
* UnitTestBase.py: Base class for all test cases. Handles bulk of command-line-argument processing and importing
of various modules needed for testing. Test cases should normally inherit from this.
* Nightly_Sanity.py: All-in-one script that updates firmware, creates cloud controller profiles, and runs LANforge
tests. This is only partially functional for now. Much of the logic in it needs to be moved to library files
so that other test cases can take advantage of the logic.
* query_ap.py: Calls into ap_ssh.py to do some actions on APs, including running arbitrary commands. This would
be a good example to use as starting point for writing new test cases that need to access the AP.
Try: ./query_ap.py --help for example of how to use.
* query_sdk.py: Calls into cloudsdk.py to do some actions on cloud controller. This would
be a good example to use as starting point for writing new test cases that need to access the cloud controller.
Try: ./query_sdk.py --help for example of how to use.
# This is how the nightly sanity script is launched for the NOLA-01 testbed.
./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 --skip_profiles \
--lanforge-2g-radio 1.1.wiphy4 --lanforge-5g-radio 1.1.wiphy5
## Nightly Sanity details:
This script is used to look for and test new firmware available for the APs. AP equipment IDs and SSID information used in test is stored in the lab_ap_info file
1. Check current CloudSDK version
2. Find latest dev firmware on TIP jfrog and create instances on CloudSDK (if necessary)
3. Create report_data.json file with information about versions and test case pass/fail
4. For each AP model:
1. Check current AP firmware *(If AP already running newest firmware, test will skip)*
2. Create Testrail test run with required test cases included
3. Upgrade AP via CloudSDK API
4. Check if AP upgrade and CloudSDK connection successful
5. For each SSID mode (bridge, NAT and VLAN), marking TestRail and report_data.json with pass/fail:
1. Create SSID Profiles for various security modes and radio types
2. Create AP Profile for SSID mode
3. Apply AP profile to AP
5. Check that SSID have been applied properly on AP
4. Perform client connectivity tests
6. Update sanity_status.json with **overall** pass/fail
## Throughput Test
This script is used to test UDP and TCP throughput on different modes of SSIDs, on multiple AP models. It is designed to run on APs that have successfully passed through Nightly_Sanity test.
For each AP model:
1) Read sanity_status.json to see if throughput should be run, if yes:
1) Run throughput tests on SSIDs modes
2) Record results to CSV file
2) Update sanity_status.json that throughput tests have been run

View File

@@ -29,7 +29,7 @@ All code must be written in python 3 and conform to PEP 8 style guide. The test
```bash
├── tests
├── libs
│ ├── cloudsdk
│ ├── cloudsdk_tests
│ ├── apnos
│ ├── lanforge
│ ├── perfecto

View File

@@ -1 +1,4 @@
## AP NOS Library
###apnos.py : This Library Consists of the following-
1. class APNOS : Library to SSH and Pull the information from AP

View File

@@ -1,229 +0,0 @@
##################################################################################
# Module contains functions to get specific data from AP CLI using SSH
#
# Used by Nightly_Sanity and Throughput_Test #####################################
##################################################################################
import paramiko
from paramiko import SSHClient
import socket
import logging
owrt_args = "--prompt root@OpenAp -s serial --log stdout --user root --passwd openwifi"
def ssh_cli_connect(command_line_args):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ap_ip = command_line_args.ap_ip
ap_username = command_line_args.ap_username
ap_password = command_line_args.ap_password
jumphost_ip = command_line_args.ap_jumphost_address
jumphost_username = command_line_args.ap_jumphost_username
jumphost_password = command_line_args.ap_jumphost_password
jumphost_port = command_line_args.ap_jumphost_port
if command_line_args.ap_jumphost_address != None:
print("Connecting to jumphost: %s@%s:%s with password: %s"%(jumphost_username, jumphost_ip, jumphost_port, jumphost_password))
client.connect(jumphost_ip, username=jumphost_username, password=jumphost_password,
port=jumphost_port, timeout=10)
else:
print("Connecting to AP with ssh: %s@%s with password: %s"%(ap_username, ap_ip, jumphost_password))
client.connect(ap_ip, username=ap_username, password=ap_password, timeout=10)
return client
def ssh_cli_active_fw(command_line_args):
try:
client = ssh_cli_connect(command_line_args)
jumphost_wlan_testing = command_line_args.ap_jumphost_wlan_testing
jumphost_tty = command_line_args.ap_jumphost_tty
ap_cmd = "/usr/opensync/bin/ovsh s AWLAN_Node -c | grep FW_IMAGE_ACTIVE"
if command_line_args.ap_jumphost_address != None:
cmd = "cd %s/lanforge/lanforge-scripts/ && ./openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(jumphost_wlan_testing, owrt_args, jumphost_tty, ap_cmd)
stdin, stdout, stderr = client.exec_command(cmd)
else:
stdin, stdout, stderr = client.exec_command(ap_cmd)
version_matrix = str(stdout.read(), 'utf-8')
err = str(stderr.read(), 'utf-8')
print("version-matrix: %s stderr: %s"%(version_matrix, err))
version_matrix_split = version_matrix.partition('FW_IMAGE_ACTIVE","')[2]
cli_active_fw = version_matrix_split.partition('"],[')[0]
#print("Active FW is",cli_active_fw)
ap_cmd = "/usr/opensync/bin/ovsh s Manager -c | grep status"
if command_line_args.ap_jumphost_address != None:
cmd = "cd %s/lanforge/lanforge-scripts/ && ./openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(jumphost_wlan_testing, owrt_args, jumphost_tty, ap_cmd)
stdin, stdout, stderr = client.exec_command(cmd)
else:
stdin, stdout, stderr = client.exec_command(ap_cmd)
status = str(stdout.read(), 'utf-8')
err = str(stderr.read(), 'utf-8')
print("status: %s stderr: %s"%(status, err))
if "ACTIVE" in status:
#print("AP is in Active state")
state = "active"
elif "BACKOFF" in status:
#print("AP is in Backoff state")
state = "backoff"
else:
#print("AP is not in Active state")
state = "unknown"
cli_info = {
"state": state,
"active_fw": cli_active_fw
}
return(cli_info)
except paramiko.ssh_exception.AuthenticationException:
print("Authentication Error, Check Credentials")
return "ERROR"
except paramiko.SSHException:
print("Cannot SSH to the AP")
return "ERROR"
except socket.timeout:
print("AP Unreachable")
return "ERROR"
def iwinfo_status(command_line_args):
try:
client = ssh_cli_connect(command_line_args)
jumphost_wlan_testing = command_line_args.ap_jumphost_wlan_testing
jumphost_tty = command_line_args.ap_jumphost_tty
ap_cmd = "iwinfo | grep ESSID"
if command_line_args.ap_jumphost_address != None:
cmd = "cd %s/lanforge/lanforge-scripts/ && ./openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(jumphost_wlan_testing, owrt_args, jumphost_tty, ap_cmd)
stdin, stdout, stderr = client.exec_command(cmd)
else:
stdin, stdout, stderr = client.exec_command(ap_cmd)
for line in stdout.read().splitlines():
print(line)
except paramiko.ssh_exception.AuthenticationException:
print("Authentication Error, Check Credentials")
return "ERROR"
except paramiko.SSHException:
print("Cannot SSH to the AP")
return "ERROR"
except socket.timeout:
print("AP Unreachable")
return "ERROR"
def ap_ssh_ovsh_nodec(command_line_args, key):
try:
jumphost_wlan_testing = command_line_args.ap_jumphost_wlan_testing
jumphost_tty = command_line_args.ap_jumphost_tty
client = ssh_cli_connect(command_line_args)
ap_cmd = "/usr/opensync/bin/ovsh s AWLAN_Node -c"
if command_line_args.ap_jumphost_address != None:
cmd = "cd %s/lanforge/lanforge-scripts/ && ./openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(jumphost_wlan_testing, owrt_args, jumphost_tty, ap_cmd)
stdin, stdout, stderr = client.exec_command(cmd)
else:
stdin, stdout, stderr = client.exec_command(ap_cmd)
output = str(stdout.read(), 'utf-8')
#print("ovsdh cmd: ", cmd)
#print("ovsh output: ", output)
if key != None:
for line in output.splitlines():
toks = line.split(':', 1)
try:
k = toks[0].strip(' ')
v = toks[1].strip(' ')
if k == 'id':
return v
except Exception as e1:
print(e1)
print(line)
print(toks)
return output
except paramiko.ssh_exception.AuthenticationException:
print("Authentication Error, Check Credentials")
return "ERROR"
except paramiko.SSHException:
print("Cannot SSH to the AP")
return "ERROR"
except socket.timeout:
print("AP Unreachable")
return "ERROR"
def ap_ssh_ovsh_by_key(command_line_args, ovsh_cmd, key):
jumphost_wlan_testing = command_line_args.ap_jumphost_wlan_testing
jumphost_tty = command_line_args.ap_jumphost_tty
client = ssh_cli_connect(command_line_args)
ap_cmd = ovsh_cmd
if command_line_args.ap_jumphost_address != None:
cmd = "cd %s/lanforge/lanforge-scripts/ && ./openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(jumphost_wlan_testing, owrt_args, jumphost_tty, ap_cmd)
stdin, stdout, stderr = client.exec_command(cmd)
else:
stdin, stdout, stderr = client.exec_command(ap_cmd)
output = str(stdout.read(), 'utf-8')
if key != None:
rv = []
for line in output.splitlines():
toks = line.split(':', 1)
if (len(toks) < 2):
#print("ovsh-by-key, ignoring line: %s"%(line))
continue
try:
k = toks[0].strip(' ')
v = toks[1].strip(' ')
#print("ovsh-by-key, k -:%s:- v -:%s:- searching for key -:%s:-"%(k, v, key))
if k == key:
rv.append(v)
except Exception as e1:
print(e1)
print(line)
print(toks)
print("Output:\n", output)
logging.error(logging.traceback.format_exc())
return rv
return output
# This can throw exceptions, calling code beware.
def ap_ssh_cmd(command_line_args, ap_cmd):
jumphost_wlan_testing = command_line_args.ap_jumphost_wlan_testing
jumphost_tty = command_line_args.ap_jumphost_tty
client = ssh_cli_connect(command_line_args)
if command_line_args.ap_jumphost_address != None:
cmd = "cd %s/lanforge/lanforge-scripts/ && ./openwrt_ctl.py %s -t %s --action cmd --value \"%s\""%(jumphost_wlan_testing, owrt_args, jumphost_tty, ap_cmd)
stdin, stdout, stderr = client.exec_command(cmd)
else:
stdin, stdout, stderr = client.exec_command(ap_cmd)
output = str(stdout.read(), 'utf-8')
return output
def get_vif_config(command_line_args):
ap_cmd = "/usr/opensync/bin/ovsh s Wifi_VIF_Config -c"
return ap_ssh_ovsh_by_key(command_line_args, ap_cmd, "ssid")
def get_vif_state(command_line_args):
ap_cmd = "/usr/opensync/bin/ovsh s Wifi_VIF_State -c"
return ap_ssh_ovsh_by_key(command_line_args, ap_cmd, "ssid")

100
libs/cloudsdk/README.md Normal file
View File

@@ -0,0 +1,100 @@
# Cloud SDK Library
###cloudsdk.py : This Library Consists of the following-
1. class ConfigureCloudSDK : Base Configuration Class
2. class CloudSDK(ConfigureCloudSDK) : Main Cloudsdk Class
3. class ProfileUtility : Used to CRUD over CloudSDK Profiles Utility
4. class JFrogUtility : Used for Artifactory Utils, Get latest Build, Upload Firmware etc.
###Note: cloudsdk.py has libraries that uses Swagger Autogenerated Code.
### Setup The Environment For using the cloudsdk library
Using Swagger Autogenerated CloudSDK Library pypi package (implemented with [swagger codegen](https://github.com/swagger-api/swagger-codegen)).
Using [pytest] as the test execution framework.
Using [pylint](http://pylint.pycqa.org) for code quality monitoring.
Using [allure](https://docs.qameta.io/allure/#_about) with Github Pages to report test outcome.
### Follow the setps below to setup the environment for your development Environment
```shell
mkdir ~/.pip
echo "[global]" > ~/.pip/pip.conf
echo "index-url = https://pypi.org/simple" >> ~/.pip/pip.conf
echo "extra-index-url = https://tip-read:tip-read@tip.jfrog.io/artifactory/api/pypi/tip-wlan-python-pypi-local/simple" >> ~/.pip/pip.conf
```
after that do the following in this folder
```shell
pip3 install -r requirements.txt
```
Now your cloud sdk code is downloaded with all of the dependencies and you can start working on the solution
### Docker
Alternatively you can use provided dockerfiles to develop\lint your code:
```shell
docker build -t wlan-cloud-test -f dockerfile .
docker build -t wlan-cloud-lint -f dockerfile-lint .
```
and then you can do something like this to lint your code:
```shell
docker run -it --rm -v %path_to_this_dir%/tests wlan-tip-lint -d protected-access *py # for now
docker run -it --rm -v %path_to_this_dir%/tests wlan-tip-lint *py # for future
```
to have a better output (sorted by line numbers) you can do something like this:
```shell
docker run -it --rm --entrypoint sh -v %path_to_this_dir%/tests wlan-tip-lint -- -c 'pylint *py | sort -t ":" -k 2,2n'
```
and you can use something like this to develop your code:
```shell
docker run -it -v %path_to_this_dir%/tests wlan-tip-test
```
### General guidelines
This testing code adheres to generic [pep8](https://www.python.org/dev/peps/pep-0008/#introduction) style guidelines, most notably:
1. [Documentation strings](https://www.python.org/dev/peps/pep-0008/#documentation-strings)
2. [Naming conventions](https://www.python.org/dev/peps/pep-0008/#prescriptive-naming-conventions)
3. [Sphynx docstring format](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html)
We are using the `pylint` package to do the linting. Documentation for it can be found [here](http://pylint.pycqa.org/en/latest/).
In general, the customizations are possible via the `.pylintrc` file:
1. Line length below 120 characters is fine (search for max-line-length)
2. No new line at the end of file is fine (search for missing-final-newline)
3. Multiple new lines at the end of file are fine (search for trailing-newlines)
4. Indent using 4 spaces (search for indent-string)
5. todo
In future we should enforce a policy, where we cannot merge a code where the pylint scoe goes below 7:
```shell
pylint --fail-under=7 *py
```
the command above would produce a non-zero exit code if the score drops below 7.
### Reporting
Currently the plan is to use pytest integrated with [allure](https://docs.qameta.io/allure/#_pytest) to create visual reports for the test outcomes
### Miscelanneous
1. Do not use old style string formatting: `"Hello %s" % var`; use `f"Hello {var}` instead
2. use `"""` in Docstrings
3. todo
### Useful links
https://docs.pytest.org/en/latest/example/markers.html
https://docs.pytest.org/en/latest/usage.html
http://pythontesting.net/framework/pytest/pytest-introduction/

View File

@@ -166,6 +166,10 @@ class CloudSDK(ConfigureCloudSDK):
"""
"""
Library for Profile Utility, Creating Profiles and Pushing and Deleting them
"""
class ProfileUtility:
"""
constructor for Access Point Utility library : can be used from pytest framework
@@ -198,17 +202,10 @@ class ProfileUtility:
if i._name == profile_name:
return i
return None
def get_profile_by_id(self, profile_id=None):
# pagination_context = """{
# "model_type": "PaginationContext",
# "maxItemsPerPage": 10
# }"""
profiles = self.profile_client.get_profile_by_id(profile_id=profile_id)
print(profiles)
# for i in profiles._items:
# if i._name == profile_name:
# return i
# return None
def get_default_profiles(self):
pagination_context = """{
@@ -233,6 +230,22 @@ class ProfileUtility:
if i._name == "TipWlan-rf":
self.default_profiles['rf'] = i
def delete_current_profile(self, equipment_id=None):
equipment_data = self.sdk_client.equipment_client.get_equipment_by_id(equipment_id=equipment_id)
data = self.profile_client.get_profile_with_children(profile_id=equipment_data._profile_id)
delete_ids = []
for i in data:
if i._name == "TipWlan-rf":
continue
else:
delete_ids.append(i._id)
print(delete_ids)
self.get_default_profiles()
self.profile_creation_ids['ap'] = self.default_profiles['equipment_ap_3_radios']._id
print(self.profile_creation_ids)
self.push_profile_old_method(equipment_id=equipment_id)
self.delete_profile(profile_id=delete_ids)
"""
method call: used to create the rf profile and push set the parameters accordingly and update
"""
@@ -261,6 +274,7 @@ class ProfileUtility:
default_profile._details['appliedRadios'].append("is5GHz")
default_profile._details['appliedRadios'].append("is5GHzL")
default_profile._name = profile_data['profile_name']
default_profile._details['vlanId'] = profile_data['vlan']
default_profile._details['ssid'] = profile_data['ssid_name']
default_profile._details['forwardMode'] = profile_data['mode']
default_profile._details['secureMode'] = 'open'
@@ -282,6 +296,7 @@ class ProfileUtility:
default_profile._details['appliedRadios'].append("is5GHz")
default_profile._details['appliedRadios'].append("is5GHzL")
default_profile._name = profile_data['profile_name']
default_profile._details['vlanId'] = profile_data['vlan']
default_profile._details['ssid'] = profile_data['ssid_name']
default_profile._details['keyStr'] = profile_data['security_key']
default_profile._details['forwardMode'] = profile_data['mode']
@@ -304,6 +319,7 @@ class ProfileUtility:
default_profile._details['appliedRadios'].append("is5GHz")
default_profile._details['appliedRadios'].append("is5GHzL")
default_profile._name = profile_data['profile_name']
default_profile._details['vlanId'] = profile_data['vlan']
default_profile._details['ssid'] = profile_data['ssid_name']
default_profile._details['keyStr'] = profile_data['security_key']
default_profile._details['forwardMode'] = profile_data['mode']
@@ -327,6 +343,7 @@ class ProfileUtility:
default_profile._details['appliedRadios'].append("is5GHz")
default_profile._details['appliedRadios'].append("is5GHzL")
default_profile._name = profile_data['profile_name']
default_profile._details['vlanId'] = profile_data['vlan']
default_profile._details['ssid'] = profile_data['ssid_name']
default_profile._details['keyStr'] = profile_data['security_key']
default_profile._details['forwardMode'] = profile_data['mode']
@@ -349,6 +366,7 @@ class ProfileUtility:
default_profile._details['appliedRadios'].append("is5GHz")
default_profile._details['appliedRadios'].append("is5GHzL")
default_profile._name = profile_data['profile_name']
default_profile._details['vlanId'] = profile_data['vlan']
default_profile._details['ssid'] = profile_data['ssid_name']
default_profile._details['forwardMode'] = profile_data['mode']
default_profile._details['secureMode'] = 'wpa2OnlyRadius'
@@ -370,6 +388,7 @@ class ProfileUtility:
default_profile._details['appliedRadios'].append("is5GHz")
default_profile._details['appliedRadios'].append("is5GHzL")
default_profile._name = profile_data['profile_name']
default_profile._details['vlanId'] = profile_data['vlan']
default_profile._details['ssid'] = profile_data['ssid_name']
default_profile._details['keyStr'] = profile_data['security_key']
default_profile._details['forwardMode'] = profile_data['mode']
@@ -450,13 +469,12 @@ class ProfileUtility:
def delete_profile(self, profile_id=None):
for i in profile_id:
self.profile_client.delete_profile(profile_id=i)
pass
# Need to be depreciated by using push_profile method
def push_profile_old_method(self, equipment_id=None):
if equipment_id is None:
return 0
url = self.sdk_client.configuration.host + "/portal/equipment?equipmentId=" + equipment_id
url = self.sdk_client.configuration.host + "/portal/equipment?equipmentId=" + str(equipment_id)
payload = {}
headers = self.sdk_client.configuration.api_key_prefix
response = requests.request("GET", url, headers=headers, data=payload)
@@ -471,6 +489,10 @@ class ProfileUtility:
response = requests.request("PUT", url, headers=headers, data=json.dumps(equipment_info))
"""
Jfrog Utility for Artifactory Management
"""
class JFrogUtility:
def __init__(self, credentials=None):
@@ -507,182 +529,3 @@ class JFrogUtility:
def get_revisions(self, model=None):
pass
def create_bridge_profile(get_testbed_name="nola-ext-04"):
# SSID and AP name shall be used as testbed_name and mode
sdk_client = CloudSDK(testbed=get_testbed_name, customer_id=2)
profile_object = ProfileUtility(sdk_client=sdk_client)
profile_object.get_default_profiles()
profile_object.set_rf_profile()
ssid_list = []
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_BR'),
"mode": "BRIDGE",
"security_key": "%s-%s" % ("ecw5410", "5G_WPA2_BR")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_BR'),
"mode": "BRIDGE",
"security_key": "%s-%s" % ("ecw5410", "2G_WPA2_BR")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
ssid_list.append(profile_data["profile_name"])
# Create a wpa2 profile
pass
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", 'BRIDGE'),
}
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
# create an equipment ap profile
return ssid_list
def vif(profile_data=[]):
import sys
if 'apnos' not in sys.path:
sys.path.append(f'../apnos')
from apnos import APNOS
APNOS_CREDENTIAL_DATA = {
'jumphost_ip': "192.168.200.80",
'jumphost_username': "lanforge",
'jumphost_password': "lanforge",
'jumphost_port': 22
}
obj = APNOS(APNOS_CREDENTIAL_DATA)
# data = obj.get_vif_config_ssids()
cur_time = datetime.datetime.now()
print(profile_data)
for i in range(18):
vif_config = list(obj.get_vif_config_ssids())
vif_config.sort()
vif_state = list(obj.get_vif_state_ssids())
vif_state.sort()
profile_data = list(profile_data)
profile_data.sort()
print("create_bridge_profile: ", profile_data)
print("vif config data: ", vif_config)
print("vif state data: ", vif_state)
if profile_data == vif_config:
print("matched")
if vif_config == vif_state:
status = True
print("matched 1")
break
else:
print("matched 2")
status = False
else:
status = False
time.sleep(10)
def main():
# credentials = {
# "user": "tip-read",
# "password": "tip-read"
# }
# obj = JFrogUtility(credentials=credentials)
# print(obj.get_latest_build(model="ecw5410"))
# sdk_client = CloudSDK(testbed="nola-ext-04", customer_id=2)
# ap_utils = ProfileUtility(sdk_client=sdk_client)
# ap_utils.get_profile_by_id(profile_id=5)
# # sdk_client.get_model_name()
# sdk_client.disconnect_cloudsdk()
cur_time = datetime.datetime.now()
data = create_bridge_profile()
vif(profile_data=data)
print(cur_time)
if __name__ == "__main__":
main()
# testbeds = ["nola-01", "nola-02", "nola-04", "nola-ext-01", "nola-ext-02", "nola-ext-03", "nola-ext-04",
# "nola-ext-05"]
# for i in testbeds:
# sdk_client = CloudSDK(testbed=i, customer_id=2)
# print(sdk_client.get_equipment_by_customer_id())
# print(sdk_client.portal_ping() is None)
# break
# # ap_utils = ProfileUtility(sdk_client=sdk_client)
# ap_utils.get_default_profiles()
# for j in ap_utils.default_profiles:
# print(ap_utils.default_profiles[j]._id)
# data = sdk_client.get_equipment_by_customer_id()
# equipment_ids = []
# for i in data:
# equipment_ids.append(i)
# print(equipment_ids[0]._details._equipment_model)
# sdk_client.disconnect_cloudsdk()
# time.sleep(2)
# sdk_client.get_equipment_by_customer_id(customer_id=2)
# ap_utils = APUtils(sdk_client=sdk_client)
# print(sdk_client.configuration.api_key_prefix)
# ap_utils.select_rf_profile(profile_data=None)
# profile_data = {
# "profile_name": "test-ssid-open",
# "ssid_name": "test_open",
# "mode": "BRIDGE"
# }
# ap_utils.create_open_ssid_profile(profile_data=profile_data)
# profile_data = {
# "profile_name": "test-ssid-wpa",
# "ssid_name": "test_wpa_test",
# "mode": "BRIDGE",
# "security_key": "testing12345"
# }
# ap_utils.create_wpa_ssid_profile(profile_data=profile_data, fiveg=False)
# profile_data = {
# "profile_name": "test-ap-profile",
# }
# ap_utils.set_ap_profile(profile_data=profile_data)
# ap_utils.push_profile_old_method(equipment_id='12')
# sdk_client.get_profile_template()
# ap_utils.select_rf_profile(profile_data=None)
# # radius_info = {
# # "name": "Radius-Profile-" + str(datetime.datetime.now()),
# # "ip": "192.168.200.75",
# # "port": 1812,
# # "secret": "testing123"
# # }
# #
# # ap_utils.set_radius_profile(radius_info=radius_info)
# # profile_data = {
# # "profile_name": "test-ssid-open",
# # "ssid_name": "test_open",
# # "mode": "BRIDGE"
# # }
# #
# # # ap_utils.create_open_ssid_profile(profile_data=profile_data)
# profile_data = {
# "profile_name": "test-ssid-wpa",
# "ssid_name": "test_wpa",
# "mode": "BRIDGE",
# "security_key": "testing12345"
# }
# # #
# ap_utils.create_wpa_ssid_profile(profile_data=profile_data)
# #
# # # Change the profile data if ssid/profile already exists
# # #
# # # obj.portal_ping()
# # # obj.get_equipment_by_customer_id(customer_id=2)
# # # obj.get_profiles_by_customer_id(customer_id=2)
# # # print(obj.default_profiles)
# # time.sleep(20)
# # # Please change the equipment ID with the respective testbed
# #ap_utils.push_profile(equipment_id=11)
# # ap ssh
# ap_utils.push_profile_old_method(equipment_id='12')
# time.sleep(1)
# ap_utils.delete_profile(profile_id=ap_utils.profile_ids)

View File

@@ -1,40 +0,0 @@
import pytest
@pytest.mark.usefixtures('setup_cloudsdk')
@pytest.mark.usefixtures('update_firmware')
@pytest.mark.UHF # example of a class mark
class Test24ghz(object):
@pytest.mark.wpa2
def test_single_client_wpa2(self, setup_cloudsdk, update_firmware):
print(setup_cloudsdk)
assert 1 == 1
@pytest.mark.open
def test_single_client_open(self, setup_cloudsdk, update_firmware):
print(setup_cloudsdk)
assert 1 == 1
@pytest.mark.usefixtures('setup_cloudsdk')
@pytest.mark.usefixtures('update_firmware')
@pytest.mark.SHF # example of a class mark
class Test50ghz(object):
@pytest.mark.wpa2
def test_single_client_wpa2(self, setup_cloudsdk, update_firmware):
print(setup_cloudsdk)
assert 1 == 0
@pytest.mark.open
def test_single_client_open(self, setup_cloudsdk, update_firmware):
print(setup_cloudsdk)
assert 1 == 0

View File

@@ -1,90 +1,10 @@
## Cloud SDK Library
Using Swagger Autogenerated CloudSDK Library pypi package (implemented with [swagger codegen](https://github.com/swagger-api/swagger-codegen)).
Using [pytest] as the test execution framework.
Using [pylint](http://pylint.pycqa.org) for code quality monitoring.
Using [allure](https://docs.qameta.io/allure/#_about) with Github Pages to report test outcome.
# Pytest Framework
## Perform Unit Tests in TIP Community Testbeds
### Follow the setps below to setup the environment for your development Environment
### Fixtures :
#### conftest.py
### Unit Tests :
#### Structured around multiple Directories
### Markers :
#### Categorized the Test across different Markers
```shell
mkdir ~/.pip
echo "[global]" > ~/.pip/pip.conf
echo "index-url = https://pypi.org/simple" >> ~/.pip/pip.conf
echo "extra-index-url = https://tip-read:tip-read@tip.jfrog.io/artifactory/api/pypi/tip-wlan-python-pypi-local/simple" >> ~/.pip/pip.conf
```
after that do the following in this folder
```shell
pip3 install -r requirements.txt
```
Now your cloud sdk code is downloaded with all of the dependencies and you can start working on the solution
### Docker
Alternatively you can use provided dockerfiles to develop\lint your code:
```shell
docker build -t wlan-cloud-test -f dockerfile .
docker build -t wlan-cloud-lint -f dockerfile-lint .
```
and then you can do something like this to lint your code:
```shell
docker run -it --rm -v %path_to_this_dir%/tests wlan-tip-lint -d protected-access *py # for now
docker run -it --rm -v %path_to_this_dir%/tests wlan-tip-lint *py # for future
```
to have a better output (sorted by line numbers) you can do something like this:
```shell
docker run -it --rm --entrypoint sh -v %path_to_this_dir%/tests wlan-tip-lint -- -c 'pylint *py | sort -t ":" -k 2,2n'
```
and you can use something like this to develop your code:
```shell
docker run -it -v %path_to_this_dir%/tests wlan-tip-test
```
### General guidelines
This testing code adheres to generic [pep8](https://www.python.org/dev/peps/pep-0008/#introduction) style guidelines, most notably:
1. [Documentation strings](https://www.python.org/dev/peps/pep-0008/#documentation-strings)
2. [Naming conventions](https://www.python.org/dev/peps/pep-0008/#prescriptive-naming-conventions)
3. [Sphynx docstring format](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html)
We are using the `pylint` package to do the linting. Documentation for it can be found [here](http://pylint.pycqa.org/en/latest/).
In general, the customizations are possible via the `.pylintrc` file:
1. Line length below 120 characters is fine (search for max-line-length)
2. No new line at the end of file is fine (search for missing-final-newline)
3. Multiple new lines at the end of file are fine (search for trailing-newlines)
4. Indent using 4 spaces (search for indent-string)
5. todo
In future we should enforce a policy, where we cannot merge a code where the pylint scoe goes below 7:
```shell
pylint --fail-under=7 *py
```
the command above would produce a non-zero exit code if the score drops below 7.
### Reporting
Currently the plan is to use pytest integrated with [allure](https://docs.qameta.io/allure/#_pytest) to create visual reports for the test outcomes
### Miscelanneous
1. Do not use old style string formatting: `"Hello %s" % var`; use `f"Hello {var}` instead
2. use `"""` in Docstrings
3. todo
### Useful links
https://docs.pytest.org/en/latest/example/markers.html
https://docs.pytest.org/en/latest/usage.html
http://pythontesting.net/framework/pytest/pytest-introduction/

View File

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

View File

@@ -10,30 +10,13 @@ class TestBridgeModeClientConnectivity(object):
@pytest.mark.nightly
@pytest.mark.nightly_bridge
def test_single_client(self, setup_cloudsdk, update_firmware, setup_bridge_mode, disconnect_cloudsdk):
print("I am Iron Man")
assert setup_bridge_mode is True
print("Run Client Connectivity Here - BRIDGE Mode")
if setup_bridge_mode[0] == setup_bridge_mode[1]:
assert True
else:
assert False
@pytest.mark.bridge_mode_multi_client_connectivity
def test_multi_client(self):
pass
# """
# Bridge mode:
# testbed name, customer_id, equipment_id, jfrog-credentials, cloudsdk_tests-credentials, skip-open, skip-wpa, skip-wpa2, skip-radius
# Create a CloudSDK Instance and verify login
# Get Equipment by Id
# upgrade firmware if not latest
# create bridge mode ssid's
# LANforge Tests
#
# NAT mode:
#
# """
# """
#
# Cloudsdk and AP Test cases are seperate
#
# Bridge Mode:
# WPA, WPA2-PERSONAL, WPA2-ENTERPRISE
# 2.4/5, 2.4/5, 2.4/5
# """
assert 1 == 1

View File

@@ -8,8 +8,12 @@ class TestNATModeClientConnectivity(object):
@pytest.mark.nat_mode_single_client_connectivity
@pytest.mark.nightly
@pytest.mark.nightly_nat
def test_single_client(self, setup_cloudsdk, update_firmware, setup_bridge_profile, disconnect_cloudsdk):
assert setup_cloudsdk != -1
def test_single_client(self, setup_cloudsdk, update_firmware, setup_nat_mode, disconnect_cloudsdk):
print("Run Client Connectivity Here - NAT Mode")
if setup_nat_mode[0] == setup_nat_mode[1]:
assert True
else:
assert False
@pytest.mark.nat_mode_multi_client_connectivity
def test_multi_client(self):

View File

@@ -8,8 +8,12 @@ class TestVLANModeClientConnectivity(object):
@pytest.mark.vlan_mode_single_client_connectivity
@pytest.mark.nightly
@pytest.mark.nightly_vlan
def test_single_client(self, setup_cloudsdk, update_firmware, setup_bridge_profile, disconnect_cloudsdk):
assert setup_cloudsdk != -1
def test_single_client(self, setup_cloudsdk, update_firmware, setup_vlan_mode, disconnect_cloudsdk):
print("Run Client Connectivity Here - VLAN Mode")
if setup_vlan_mode[0] == setup_vlan_mode[1]:
assert True
else:
assert False
@pytest.mark.vlan_mode_multi_client_connectivity
def test_multi_client(self):

View File

@@ -1,3 +1,8 @@
"""
About: It contains some Functional Unit Tests for CloudSDK and to run and test them on per unit level
"""
import pytest
import sys
@@ -6,6 +11,7 @@ if 'cloudsdk_tests' not in sys.path:
from cloudsdk import CloudSDK
@pytest.mark.userfixtures('get_customer_id')
@pytest.mark.userfixtures('get_testbed_name')
@pytest.mark.login
@@ -29,6 +35,10 @@ class TestLogin(object):
assert value == False
@pytest.mark.userfixtures('get_customer_id')
@pytest.mark.userfixtures('get_testbed_name')
@pytest.mark.ssid_profiles
@@ -111,9 +121,3 @@ class TestEquipmentAPProfile(object):
def test_equipment_ap_profile_creation(self):
pass

View File

@@ -164,6 +164,7 @@ def disconnect_cloudsdk(instantiate_cloudsdk):
instantiate_cloudsdk.disconnect_cloudsdk()
@pytest.fixture(scope="function")
def setup_bridge_mode(request, instantiate_cloudsdk, setup_profile_data, create_bridge_profile):
# vif config and vif state logic here
@@ -206,16 +207,9 @@ def setup_bridge_mode(request, instantiate_cloudsdk, setup_profile_data, create_
profile_data = list(profile_data)
profile_data.sort()
def delete_profile(profile_data, sdk_client):
print(f"Cloud SDK cleanup for {request.node.originalname}, {profile_data}")
delete_profiles(profile_names=profile_data, sdk_client=sdk_client)
request.addfinalizer(delete_profile(profile_data, instantiate_cloudsdk))
# request.addfinalizer(delete_profiles(profile_data, instantiate_cloudsdk))
yield [profile_data, vif_config, vif_state]
@pytest.fixture(scope="function")
def setup_profile_data(request):
# logic to setup bridge mode ssid and parameters
yield True
delete_profiles(instantiate_cloudsdk)
@pytest.fixture(scope="function")
@@ -229,6 +223,7 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_O_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_O_BR'),
"vlan": 1,
"mode": "BRIDGE"
}
profile_object.create_open_ssid_profile(profile_data=profile_data, fiveg=False)
@@ -236,6 +231,7 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_O_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_O_BR'),
"vlan": 1,
"mode": "BRIDGE"
}
profile_object.create_open_ssid_profile(profile_data=profile_data, two4g=False)
@@ -246,6 +242,7 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA_BR'),
"mode": "BRIDGE",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "2G_WPA_BR")
}
profile_object.create_wpa_ssid_profile(profile_data=profile_data, fiveg=False)
@@ -254,6 +251,7 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA_BR'),
"mode": "BRIDGE",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "5G_WPA_BR")
}
profile_object.create_wpa_ssid_profile(profile_data=profile_data, two4g=False)
@@ -265,6 +263,7 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_BR'),
"mode": "BRIDGE",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "5G_WPA2_BR")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
@@ -273,6 +272,7 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_BR'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_BR'),
"mode": "BRIDGE",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "2G_WPA2_BR")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
@@ -293,65 +293,121 @@ def create_bridge_profile(request, instantiate_cloudsdk, get_testbed_name):
}
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
# create an equipment ap profile
yield ssid_list
@pytest.fixture(scope="function")
def setup_nat_profile(request, instantiate_cloudsdk, get_testbed_name):
def setup_nat_mode(request, instantiate_cloudsdk, setup_profile_data, create_nat_profile):
# vif config and vif state logic here
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('test_1')
APNOS_CREDENTIAL_DATA = {
'jumphost_ip': request.config.getini("jumphost_ip"),
'jumphost_username': request.config.getini("jumphost_username"),
'jumphost_password': request.config.getini("jumphost_password"),
'jumphost_port': request.config.getini("jumphost_port")
}
obj = APNOS(APNOS_CREDENTIAL_DATA)
profile_data = create_nat_profile
vif_config = list(obj.get_vif_config_ssids())
vif_config.sort()
vif_state = list(obj.get_vif_state_ssids())
vif_state.sort()
profile_data = list(profile_data)
profile_data.sort()
for i in range(18):
print("profiles pushed: ", profile_data)
print("vif config data: ", vif_config)
print("vif state data: ", vif_state)
if profile_data == vif_config:
print("matched")
if vif_config == vif_state:
status = True
print("matched 1")
break
else:
print("matched 2")
status = False
else:
status = False
time.sleep(10)
vif_config = list(obj.get_vif_config_ssids())
vif_config.sort()
vif_state = list(obj.get_vif_state_ssids())
vif_state.sort()
profile_data = list(profile_data)
profile_data.sort()
# request.addfinalizer(delete_profiles(profile_data, instantiate_cloudsdk))
yield [profile_data, vif_config, vif_state]
delete_profiles(instantiate_cloudsdk)
@pytest.fixture(scope="function")
def create_nat_profile(request, instantiate_cloudsdk, get_testbed_name):
# SSID and AP name shall be used as testbed_name and mode
profile_object = ProfileUtility(sdk_client=instantiate_cloudsdk)
profile_object.get_default_profiles()
profile_object.set_rf_profile()
ssid_list = []
if request.config.getini("skip-open") == 'False':
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_O_NAT'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_O_NAT'),
"vlan": 1,
"mode": "NAT"
}
profile_object.create_open_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_O_NAT'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_O_NAT'),
"vlan": 1,
"mode": "NAT"
}
profile_object.create_open_ssid_profile(profile_data=profile_data, two4g=False)
# Create an open ssid profile
ssid_list.append(profile_data["profile_name"])
if request.config.getini("skip-wpa") == 'False':
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA_NAT'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA_NAT'),
"mode": "NAT",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "2G_WPA_NAT")
}
profile_object.create_wpa_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA_NAT'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA_NAT'),
"mode": "NAT",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "5G_WPA_NAT")
}
profile_object.create_wpa_ssid_profile(profile_data=profile_data, two4g=False)
# Create a wpa profile
pass
ssid_list.append(profile_data["profile_name"])
if request.config.getini("skip-wpa2") == 'False':
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_NAT'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_NAT'),
"mode": "NAT",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "5G_WPA2_NAT")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_NAT'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_NAT'),
"mode": "NAT",
"vlan": 1,
"security_key": "%s-%s" % ("ecw5410", "2G_WPA2_NAT")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
# Create a wpa2 profile
pass
ssid_list.append(profile_data["profile_name"])
if request.config.getini("skip-eap") == 'False':
radius_info = {
"name": get_testbed_name + "-RADIUS-Nightly",
@@ -367,41 +423,143 @@ def setup_nat_profile(request, instantiate_cloudsdk, get_testbed_name):
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
# create an equipment ap profile
yield profile_object
yield ssid_list
@pytest.fixture(scope="function")
def setup_vlan_profile(request, instantiate_cloudsdk):
def setup_profile_data(request):
# logic to setup bridge mode ssid and parameters
yield True
@pytest.fixture(scope="function")
def setup_vlan_mode(request, instantiate_cloudsdk, setup_profile_data, create_vlan_profile):
# vif config and vif state logic here
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('test_1')
APNOS_CREDENTIAL_DATA = {
'jumphost_ip': request.config.getini("jumphost_ip"),
'jumphost_username': request.config.getini("jumphost_username"),
'jumphost_password': request.config.getini("jumphost_password"),
'jumphost_port': request.config.getini("jumphost_port")
}
obj = APNOS(APNOS_CREDENTIAL_DATA)
profile_data = create_vlan_profile
vif_config = list(obj.get_vif_config_ssids())
vif_config.sort()
vif_state = list(obj.get_vif_state_ssids())
vif_state.sort()
profile_data = list(profile_data)
profile_data.sort()
for i in range(18):
print("profiles pushed: ", profile_data)
print("vif config data: ", vif_config)
print("vif state data: ", vif_state)
if profile_data == vif_config:
print("matched")
if vif_config == vif_state:
status = True
print("matched 1")
break
else:
print("matched 2")
status = False
else:
status = False
time.sleep(10)
vif_config = list(obj.get_vif_config_ssids())
vif_config.sort()
vif_state = list(obj.get_vif_state_ssids())
vif_state.sort()
profile_data = list(profile_data)
profile_data.sort()
# request.addfinalizer(delete_profiles(profile_data, instantiate_cloudsdk))
yield [profile_data, vif_config, vif_state]
delete_profiles(instantiate_cloudsdk)
@pytest.fixture(scope="function")
def create_vlan_profile(request, instantiate_cloudsdk, get_testbed_name):
# SSID and AP name shall be used as testbed_name and mode
profile_object = ProfileUtility(sdk_client=instantiate_cloudsdk)
# profile_object.select_rf_profile(profile_data=None)
if request.config.getini("skip-open") is False:
# Create an open ssid profile
pass
if request.config.getini("skip-wpa") is False:
# Create a wpa profile
pass
if request.config.getini("skip-wpa2") is False:
# Create a wpa2 profile
pass
if request.config.getini("skip-eap") is False:
# create a radius profile
profile_object.get_default_profiles()
profile_object.set_rf_profile()
ssid_list = []
if request.config.getini("skip-open") == 'False':
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_O_VLAN'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_O_VLAN'),
"vlan": 100,
"mode": "BRIDGE"
}
profile_object.create_open_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_O_VLAN'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_O_VLAN'),
"vlan": 100,
"mode": "BRIDGE"
}
profile_object.create_open_ssid_profile(profile_data=profile_data, two4g=False)
ssid_list.append(profile_data["profile_name"])
if request.config.getini("skip-wpa") == 'False':
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA_VLAN'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA_VLAN'),
"mode": "BRIDGE",
"vlan": 100,
"security_key": "%s-%s" % ("ecw5410", "2G_WPA_VLAN")
}
profile_object.create_wpa_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA_VLAN'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA_VLAN'),
"mode": "BRIDGE",
"vlan": 100,
"security_key": "%s-%s" % ("ecw5410", "5G_WPA_VLAN")
}
profile_object.create_wpa_ssid_profile(profile_data=profile_data, two4g=False)
ssid_list.append(profile_data["profile_name"])
if request.config.getini("skip-wpa2") == 'False':
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_VLAN'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '5G_WPA2_VLAN'),
"mode": "BRIDGE",
"vlan": 100,
"security_key": "%s-%s" % ("ecw5410", "5G_WPA2_VLAN")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, fiveg=False)
ssid_list.append(profile_data["profile_name"])
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_VLAN'),
"ssid_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", '2G_WPA2_VLAN'),
"mode": "BRIDGE",
"vlan": 100,
"security_key": "%s-%s" % ("ecw5410", "2G_WPA2_VLAN")
}
profile_object.create_wpa2_personal_ssid_profile(profile_data=profile_data, two4g=False)
ssid_list.append(profile_data["profile_name"])
if request.config.getini("skip-eap") == 'False':
radius_info = {
"name": get_testbed_name + "-RADIUS-Nightly",
"ip": "192.168.200.75",
"port": 1812,
"secret": "testing123"
}
# create a eap profile
pass
# create an equipment ap profile
yield profile_object
@pytest.fixture(scope="function")
def apply_default_profile(instantiate_cloudsdk):
profile_object = ProfileUtility(sdk_client=instantiate_cloudsdk)
profile_object.get_default_profiles()
profile_object.profile_creation_ids['ap'] = profile_object.default_profiles['equipment_ap_3_radios']
profile_data = {
"profile_name": "%s-%s-%s" % (get_testbed_name, "ecw5410", 'VLAN'),
}
profile_object.set_ap_profile(profile_data=profile_data)
profile_object.push_profile_old_method(equipment_id='13')
# create an equipment ap profile
yield ssid_list
def delete_profiles(profile_names, sdk_client=None):
def delete_profiles(sdk_client=None):
profile_object = ProfileUtility(sdk_client=sdk_client)
profile_object.get_default_profiles()
profile_object.profile_creation_ids['ap'] = profile_object.default_profiles['equipment_ap_3_radios']
profile_object.push_profile_old_method()
profile_object.delete_current_profile(equipment_id=13)