mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-03 20:38:05 +00:00
cicd-sanity: Enable running this stand-alone.
Update include path so that we don't have to copy LANforge script files to current working directory. Allow running without testrails being enabled. Fix jfrog default use/password to be tip-read Add usage hint at top of file. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -1,4 +1,13 @@
|
|||||||
#!/usr/local/bin/python3
|
#!/usr/local/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if 'py-json' not in sys.path:
|
||||||
|
sys.path.append('../lanforge/lanforge/py-json')
|
||||||
|
|
||||||
|
if 'py-scripts' not in sys.path:
|
||||||
|
sys.path.append('../lanforge/lanforge/py-scripts')
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
@@ -10,6 +19,11 @@ from time import sleep, gmtime, strftime
|
|||||||
from LANforge.LFUtils import *
|
from LANforge.LFUtils import *
|
||||||
from sta_connect2 import StaConnect2
|
from sta_connect2 import StaConnect2
|
||||||
|
|
||||||
|
# Some usage examples.
|
||||||
|
# Run from remote dev machine on ssh tunnel through to LANforge in TIP Lab, without testrails being used.
|
||||||
|
# SSH tunnel created with login to orchestrator with option: -L 10080:lf1:8080
|
||||||
|
# python3 ./nightly.py --skip-update-firmware --no-testrails --lanforge-ip-address localhost --lanforge-port-number 10080
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--sdk-base-url", type=str, help="cloudsdk base url",
|
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")
|
||||||
@@ -20,9 +34,9 @@ parser.add_argument("--sdk-user-password", type=str, help="cloudsdk user passwor
|
|||||||
parser.add_argument("--jfrog-base-url", type=str, help="jfrog base url",
|
parser.add_argument("--jfrog-base-url", type=str, help="jfrog base url",
|
||||||
default="tip.jFrog.io/artifactory/tip-wlan-ap-firmware")
|
default="tip.jFrog.io/artifactory/tip-wlan-ap-firmware")
|
||||||
parser.add_argument("--jfrog-user-id", type=str, help="jfrog user id",
|
parser.add_argument("--jfrog-user-id", type=str, help="jfrog user id",
|
||||||
default="cicd_user")
|
default="tip-read")
|
||||||
parser.add_argument("--jfrog-user-password", type=str, help="jfrog user password",
|
parser.add_argument("--jfrog-user-password", type=str, help="jfrog user password",
|
||||||
default="password")
|
default="tip-read")
|
||||||
parser.add_argument("--testrail-base-url", type=str, help="testrail base url",
|
parser.add_argument("--testrail-base-url", type=str, help="testrail base url",
|
||||||
default="https://telecominfraproject.testrail.com")
|
default="https://telecominfraproject.testrail.com")
|
||||||
parser.add_argument("--testrail-project", type=str, help="testrail project name",
|
parser.add_argument("--testrail-project", type=str, help="testrail project name",
|
||||||
@@ -37,7 +51,9 @@ parser.add_argument("--lanforge-port-number", type=str, help="port of the lanfor
|
|||||||
default="8080")
|
default="8080")
|
||||||
parser.add_argument('--update-firmware', dest='update_firmware', action='store_true')
|
parser.add_argument('--update-firmware', dest='update_firmware', action='store_true')
|
||||||
parser.add_argument('--skip-update-firmware', dest='update_firmware', action='store_false')
|
parser.add_argument('--skip-update-firmware', dest='update_firmware', action='store_false')
|
||||||
|
parser.add_argument('--no-testrails', dest='use_testrails', action='store_false')
|
||||||
parser.set_defaults(update_firmware=True)
|
parser.set_defaults(update_firmware=True)
|
||||||
|
parser.set_defaults(use_testrails=True)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG,
|
logging.basicConfig(level=logging.DEBUG,
|
||||||
@@ -183,6 +199,7 @@ class jFrog_Client:
|
|||||||
# todo handle auth errors
|
# todo handle auth errors
|
||||||
logging.debug(f"searching for the latest firmware on url: {model}")
|
logging.debug(f"searching for the latest firmware on url: {model}")
|
||||||
response = requests.get(f"https://{self.baseUrl}/{model}/dev/", auth=(self.user, self.password))
|
response = requests.get(f"https://{self.baseUrl}/{model}/dev/", auth=(self.user, self.password))
|
||||||
|
print(response.text)
|
||||||
return re.findall('href="(.+pending.+).tar.gz"', response.text)[-1]
|
return re.findall('href="(.+pending.+).tar.gz"', response.text)[-1]
|
||||||
|
|
||||||
def get_latest_image_url(self, model, latest_image):
|
def get_latest_image_url(self, model, latest_image):
|
||||||
@@ -364,8 +381,11 @@ for model in TEST_DATA["ap_models"].keys():
|
|||||||
# }
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create Test Run
|
runId = -1
|
||||||
test_run_name = f'Nightly_model_{fw_model}_firmware_{ap_fw}_{strftime("%Y-%m-%d", gmtime())}'
|
test_run_name = f'Nightly_model_{fw_model}_firmware_{ap_fw}_{strftime("%Y-%m-%d", gmtime())}'
|
||||||
|
|
||||||
|
if args.use_testrails:
|
||||||
|
# Create Test Run
|
||||||
testrail_project_id = testrail.get_project_id(project_name=args.testrail_project)
|
testrail_project_id = testrail.get_project_id(project_name=args.testrail_project)
|
||||||
runId = testrail.create_testrun(name=test_run_name, case_ids=( [*test_cases_data] + firmware_update_case ), project_id=testrail_project_id)
|
runId = testrail.create_testrun(name=test_run_name, case_ids=( [*test_cases_data] + firmware_update_case ), project_id=testrail_project_id)
|
||||||
logging.info(f"Testrail project id: {testrail_project_id}; run ID is: {runId}")
|
logging.info(f"Testrail project id: {testrail_project_id}; run ID is: {runId}")
|
||||||
@@ -383,6 +403,13 @@ for model in TEST_DATA["ap_models"].keys():
|
|||||||
sdk.set_ap_profile(TEST_DATA["ap_models"][model]["id"], test_profile_id)
|
sdk.set_ap_profile(TEST_DATA["ap_models"][model]["id"], test_profile_id)
|
||||||
logging.info(f"Test profile id: test_profile_id")
|
logging.info(f"Test profile id: test_profile_id")
|
||||||
|
|
||||||
|
else:
|
||||||
|
if args.update_firmware:
|
||||||
|
# TODO: Not sure this is correct. --Ben
|
||||||
|
if not (sdk.ap_firmware(TEST_DATA["customer_id"], TEST_DATA["ap_models"][model]["id"]) == latest_ap_image):
|
||||||
|
print("ERROR: Updating firmware faled.")
|
||||||
|
exit(1);
|
||||||
|
|
||||||
# Run Client Single Connectivity Test Cases
|
# Run Client Single Connectivity Test Cases
|
||||||
for testcase in test_cases_data.keys():
|
for testcase in test_cases_data.keys():
|
||||||
logging.info(f"Test parameters are\n radio: {test_cases_data[testcase]['radio']}\n ssid_name: {test_cases_data[testcase]['ssid_name']}\n ssid_psk: {test_cases_data[testcase]['ssid_psk']}\n security: {test_cases_data[testcase]['security']}\n station: {test_cases_data[testcase]['station']}\n testcase: {testcase}\n runId: {runId}")
|
logging.info(f"Test parameters are\n radio: {test_cases_data[testcase]['radio']}\n ssid_name: {test_cases_data[testcase]['ssid_name']}\n ssid_psk: {test_cases_data[testcase]['ssid_psk']}\n security: {test_cases_data[testcase]['security']}\n station: {test_cases_data[testcase]['station']}\n testcase: {testcase}\n runId: {runId}")
|
||||||
@@ -406,8 +433,9 @@ for model in TEST_DATA["ap_models"].keys():
|
|||||||
staConnect.cleanup()
|
staConnect.cleanup()
|
||||||
for result in staConnect.get_result_list():
|
for result in staConnect.get_result_list():
|
||||||
logging.info(f"test result: {result}")
|
logging.info(f"test result: {result}")
|
||||||
results = TESTRAIL[staConnect.passes()]
|
|
||||||
logging.info(f"Single client connection to {test_cases_data[testcase]['ssid_name']} successful. Test {results['message']}")
|
logging.info(f"Single client connection to {test_cases_data[testcase]['ssid_name']} successful. Test {results['message']}")
|
||||||
|
if args.use_testrails:
|
||||||
|
results = TESTRAIL[staConnect.passes()]
|
||||||
testrail.update_testrail(case_id=testcase, run_id=runId, status_id=results["statusCode"], msg="Client connectivity {results['message']}")
|
testrail.update_testrail(case_id=testcase, run_id=runId, status_id=results["statusCode"], msg="Client connectivity {results['message']}")
|
||||||
|
|
||||||
logging.info("----------------------")
|
logging.info("----------------------")
|
||||||
|
|||||||
Reference in New Issue
Block a user