mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
Better output when user types in a wrong port in lf_check.py
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
@@ -206,10 +206,10 @@ class GhostRequest:
|
||||
authors,
|
||||
title='custom'):
|
||||
self.upload_images(folder)
|
||||
head = '''<p>This is a custom post created via a script</p>'''
|
||||
head = '''This is a custom post created via a script'''
|
||||
for picture in self.images:
|
||||
head = head + '<img src="%s"></img>' % picture
|
||||
head = head + '''<p>This is the end of the example</p>'''
|
||||
head = head + '''This is the end of the example'''
|
||||
self.create_post(title=title,
|
||||
text=head)
|
||||
|
||||
@@ -492,7 +492,11 @@ class GhostRequest:
|
||||
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
||||
except Exception as err:
|
||||
influx_error = err
|
||||
text += ('<p style="color:red;">InfluxDB Error: %s</p><br />' % influx_error)
|
||||
text += '''InfluxDB Error: %s<br />
|
||||
Influx Host: %s<br />
|
||||
Influx Port: %s<br />
|
||||
Influx Organization: %s<br />
|
||||
Influx Bucket: %s<br />''' % (influx_error, self.influx_host, self.influx_port, self.influx_org, self.influx_bucket)
|
||||
|
||||
raw_test_tags = list()
|
||||
test_tag_table = ''
|
||||
@@ -578,7 +582,11 @@ class GhostRequest:
|
||||
grafana_host, snapshot['key'], '%')
|
||||
except Exception as err:
|
||||
grafana_error = err
|
||||
text = text + '<p style="color:red;">Grafana Error: %s</p><br />' % grafana_error
|
||||
text = text + '''Grafana Error: %s<br />
|
||||
Grafana credentials:<br />
|
||||
Grafana Host: %s<br />
|
||||
Grafana Bucket: %s<br />
|
||||
Grafana Database: %s<br />''' % (grafana_error, grafana_host, grafana_bucket, grafana_datasource)
|
||||
|
||||
text = text + 'Low priority results: %s' % csvreader.to_html(low_priority)
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ Starting LANforge:
|
||||
import datetime
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] != 3:
|
||||
print("This script requires Python3")
|
||||
exit()
|
||||
@@ -78,7 +79,6 @@ import configparser
|
||||
import subprocess
|
||||
import csv
|
||||
import shutil
|
||||
from os import path
|
||||
import shlex
|
||||
import paramiko
|
||||
import pandas as pd
|
||||
@@ -89,11 +89,13 @@ parent_dir_path = os.path.abspath(os.path.join(dir_path,os.pardir))
|
||||
sys.path.insert(0, parent_dir_path)
|
||||
|
||||
from lf_report import lf_report
|
||||
|
||||
sys.path.append('/')
|
||||
|
||||
# setup logging FORMAT
|
||||
FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s'
|
||||
|
||||
|
||||
# lf_check class contains verificaiton configuration and ocastrates the testing.
|
||||
class lf_check():
|
||||
def __init__(self,
|
||||
@@ -188,7 +190,6 @@ class lf_check():
|
||||
self.database_tag = 'testbed CT-US-001' # the test_rig needs to match
|
||||
self.dut_set_name = 'DUT_NAME ASUSRT-AX88U' # note the name will be set as --set DUT_NAME ASUSRT-AX88U, this is not dut_name (see above)
|
||||
|
||||
|
||||
# grafana configuration #dashboard
|
||||
self.dashboard_json = ""
|
||||
self.dashboard_config = "True" # default to False once testing done
|
||||
@@ -208,6 +209,24 @@ class lf_check():
|
||||
|
||||
self.test_run = ""
|
||||
|
||||
def ping(self):
|
||||
queries = dict()
|
||||
queries['Lanforge Manager'] = self.lf_mgr_ip
|
||||
queries['Blog Host'] = self.blog_host
|
||||
queries['Influx Host'] = self.database_host
|
||||
queries['Grafana Host'] = self.dashboard_host
|
||||
results = dict()
|
||||
for key, value in queries.items():
|
||||
ping = subprocess.Popen(
|
||||
["ping", "-c", "4", value],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
)
|
||||
|
||||
out, error = ping.communicate()
|
||||
results[key] = [str(out), value]
|
||||
return results
|
||||
|
||||
def get_scripts_git_sha(self):
|
||||
# get git sha
|
||||
process = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE)
|
||||
@@ -220,7 +239,8 @@ class lf_check():
|
||||
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
||||
# ssh.connect(self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass,
|
||||
allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||
stdin, stdout, stderr = ssh.exec_command('uname -n')
|
||||
lanforge_node_version = stdout.readlines()
|
||||
# print('\n'.join(output))
|
||||
@@ -233,7 +253,8 @@ class lf_check():
|
||||
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
||||
# ssh.connect(self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass,
|
||||
allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||
stdin, stdout, stderr = ssh.exec_command('uname -r')
|
||||
lanforge_kernel_version = stdout.readlines()
|
||||
# print('\n'.join(output))
|
||||
@@ -246,7 +267,8 @@ class lf_check():
|
||||
output = ""
|
||||
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass,
|
||||
allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||
stdin, stdout, stderr = ssh.exec_command('./btserver --version | grep Version')
|
||||
lanforge_gui_version = stdout.readlines()
|
||||
# print('\n'.join(output))
|
||||
@@ -255,7 +277,6 @@ class lf_check():
|
||||
time.sleep(1)
|
||||
return lanforge_gui_version
|
||||
|
||||
|
||||
# NOT complete : will send the email results
|
||||
def send_results_email(self, report_file=None):
|
||||
if (report_file is None):
|
||||
@@ -278,7 +299,8 @@ http://{ip}/{report}
|
||||
Blog:
|
||||
http://{blog}:2368
|
||||
NOTE: for now to see stdout and stderr remove /home/lanforge from path.
|
||||
""".format(hostname=hostname, ip=ip, report=report_url, email_txt=self.email_txt, lf_mgr_ip=self.lf_mgr_ip,blog=self.blog_host)
|
||||
""".format(hostname=hostname, ip=ip, report=report_url, email_txt=self.email_txt, lf_mgr_ip=self.lf_mgr_ip,
|
||||
blog=self.blog_host)
|
||||
|
||||
else:
|
||||
message_txt = """Results from {hostname}:
|
||||
@@ -288,7 +310,8 @@ blog: http://{blog}:2368
|
||||
""".format(hostname=hostname, ip=ip, report=report_url, blog=self.blog_host)
|
||||
|
||||
if (self.email_title_txt != ""):
|
||||
mail_subject = "{} [{hostname}] {date}".format(self.email_title_txt,hostname=hostname, date=datetime.datetime.now())
|
||||
mail_subject = "{} [{hostname}] {date}".format(self.email_title_txt, hostname=hostname,
|
||||
date=datetime.datetime.now())
|
||||
else:
|
||||
mail_subject = "Regression Test [{hostname}] {date}".format(hostname=hostname, date=datetime.datetime.now())
|
||||
try:
|
||||
@@ -309,7 +332,8 @@ blog: http://{blog}:2368
|
||||
address=self.email_list_test)
|
||||
|
||||
print("running:[{}]".format(command))
|
||||
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
# have email on separate timeout
|
||||
process.wait(timeout=int(self.test_timeout))
|
||||
except subprocess.TimeoutExpired:
|
||||
@@ -354,7 +378,6 @@ blog: http://{blog}:2368
|
||||
<br>
|
||||
"""
|
||||
|
||||
|
||||
def read_config(self):
|
||||
if self.use_json:
|
||||
self.read_config_json()
|
||||
@@ -426,7 +449,9 @@ blog: http://{blog}:2368
|
||||
self.test_dict = self.json_data["test_suites"][self.test_suite]
|
||||
# self.logger.info("self.test_dict {}".format(self.test_dict))
|
||||
else:
|
||||
self.logger.info("EXITING test_suite {} Not Present in json test_suites: {}".format(self.test_suite, self.json_data["test_suites"]))
|
||||
self.logger.info("EXITING test_suite {} Not Present in json test_suites: {}".format(self.test_suite,
|
||||
self.json_data[
|
||||
"test_suites"]))
|
||||
exit(1)
|
||||
else:
|
||||
self.logger.info("EXITING test_suites not in json {}".format(self.json_data))
|
||||
@@ -743,10 +768,12 @@ blog: http://{blog}:2368
|
||||
section = config_file[self.test_suite]
|
||||
# for json replace the \n and \r they are invalid json characters, allows for multiple line args
|
||||
try:
|
||||
self.test_dict = json.loads(section.get('TEST_DICT', self.test_dict).replace('\n',' ').replace('\r',' '))
|
||||
self.test_dict = json.loads(
|
||||
section.get('TEST_DICT', self.test_dict).replace('\n', ' ').replace('\r', ' '))
|
||||
self.logger.info("{}: {}".format(self.test_suite, self.test_dict))
|
||||
except:
|
||||
self.logger.info("Excpetion loading {}, is there comma after the last entry? Check syntax".format(self.test_suite))
|
||||
self.logger.info(
|
||||
"Exception loading {}, is there comma after the last entry? Check syntax".format(self.test_suite))
|
||||
else:
|
||||
self.logger.info("EXITING... NOT FOUND Test Suite with name : {}".format(self.test_suite))
|
||||
exit(1)
|
||||
@@ -761,7 +788,8 @@ blog: http://{blog}:2368
|
||||
|
||||
# no spaces after FACTORY_DFLT
|
||||
command = "./{} {}".format("scenario.py", "--load FACTORY_DFLT")
|
||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
# wait for the process to terminate
|
||||
out, err = process.communicate()
|
||||
errcode = process.returncode
|
||||
@@ -775,7 +803,8 @@ blog: http://{blog}:2368
|
||||
|
||||
# no spaces after FACTORY_DFLT
|
||||
command = "./{} {}".format("scenario.py", "--load BLANK")
|
||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
|
||||
def load_custom_db(self, custom_db):
|
||||
try:
|
||||
@@ -785,7 +814,8 @@ blog: http://{blog}:2368
|
||||
|
||||
# no spaces after FACTORY_DFLT
|
||||
command = "./{} {}".format("scenario.py", "--load {}".format(custom_db))
|
||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
# wait for the process to terminate
|
||||
out, err = process.communicate()
|
||||
errcode = process.returncode
|
||||
@@ -803,7 +833,9 @@ blog: http://{blog}:2368
|
||||
# list does not have replace only stings do to args_list will be joined and converted to a string and placed
|
||||
# in args. Then the replace below will work.
|
||||
if self.test_dict[test]['args'] == "":
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(self.test_dict[test]['args'],''.join(self.test_dict[test]['args_list']))
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(self.test_dict[test]['args'],
|
||||
''.join(self.test_dict[test][
|
||||
'args_list']))
|
||||
# Configure Tests
|
||||
# loop through radios
|
||||
for radio in self.radio_dict:
|
||||
@@ -811,11 +843,16 @@ blog: http://{blog}:2368
|
||||
# not "KEY" is just a word to refer to the RADIO define (e.g. RADIO_0_CFG) to get the vlaues
|
||||
# --num_stations needs to be int not string (no double quotes)
|
||||
if self.radio_dict[radio]["KEY"] in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(self.radio_dict[radio]["KEY"],'--radio {} --ssid {} --passwd {} --security {} --num_stations {}'
|
||||
.format(self.radio_dict[radio]['RADIO'],self.radio_dict[radio]['SSID'],self.radio_dict[radio]['PASSWD'],self.radio_dict[radio]['SECURITY'],self.radio_dict[radio]['STATIONS']))
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(
|
||||
self.radio_dict[radio]["KEY"],
|
||||
'--radio {} --ssid {} --passwd {} --security {} --num_stations {}'
|
||||
.format(self.radio_dict[radio]['RADIO'], self.radio_dict[radio]['SSID'],
|
||||
self.radio_dict[radio]['PASSWD'], self.radio_dict[radio]['SECURITY'],
|
||||
self.radio_dict[radio]['STATIONS']))
|
||||
|
||||
if 'HTTP_TEST_IP' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('HTTP_TEST_IP',self.http_test_ip)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('HTTP_TEST_IP',
|
||||
self.http_test_ip)
|
||||
if 'FTP_TEST_IP' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('FTP_TEST_IP', self.ftp_test_ip)
|
||||
if 'TEST_IP' in self.test_dict[test]['args']:
|
||||
@@ -837,11 +874,14 @@ blog: http://{blog}:2368
|
||||
if 'DUT_SERIAL' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_SERIAL', self.dut_serial)
|
||||
if 'DUT_BSSID_2G' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_BSSID_2G',self.dut_bssid_2g)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_BSSID_2G',
|
||||
self.dut_bssid_2g)
|
||||
if 'DUT_BSSID_5G' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_BSSID_5G',self.dut_bssid_5g)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_BSSID_5G',
|
||||
self.dut_bssid_5g)
|
||||
if 'DUT_BSSID_6G' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_BSSID_6G',self.dut_bssid_6g)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_BSSID_6G',
|
||||
self.dut_bssid_6g)
|
||||
|
||||
if 'RADIO_USED' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('RADIO_USED', self.radio_lf)
|
||||
@@ -856,7 +896,8 @@ blog: http://{blog}:2368
|
||||
if 'COL_NAMES' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('COL_NAMES', self.col_names)
|
||||
if 'UPSTREAM_PORT' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('UPSTREAM_PORT',self.upstream_port)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('UPSTREAM_PORT',
|
||||
self.upstream_port)
|
||||
|
||||
# lf_dataplane_test.py and lf_wifi_capacity_test.py use a parameter --local_path for the location
|
||||
# of the reports when the reports are pulled.
|
||||
@@ -869,28 +910,37 @@ blog: http://{blog}:2368
|
||||
|
||||
# database configuration
|
||||
if 'DATABASE_HOST' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_HOST',self.database_host)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_HOST',
|
||||
self.database_host)
|
||||
if 'DATABASE_PORT' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_PORT',self.database_port)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_PORT',
|
||||
self.database_port)
|
||||
if 'DATABASE_TOKEN' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_TOKEN',self.database_token)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_TOKEN',
|
||||
self.database_token)
|
||||
if 'DATABASE_ORG' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_ORG',self.database_org)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_ORG',
|
||||
self.database_org)
|
||||
if 'DATABASE_BUCKET' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_BUCKET',self.database_bucket)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_BUCKET',
|
||||
self.database_bucket)
|
||||
if 'DATABASE_TAG' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_TAG',self.database_tag)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DATABASE_TAG',
|
||||
self.database_tag)
|
||||
if 'DUT_SET_NAME' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_SET_NAME',self.dut_set_name)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DUT_SET_NAME',
|
||||
self.dut_set_name)
|
||||
|
||||
if 'TEST_RIG' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('TEST_RIG', self.test_rig)
|
||||
|
||||
# dashboard configuration
|
||||
if 'DASHBOARD_HOST' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DASHBOARD_HOST',self.dashboard_host)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DASHBOARD_HOST',
|
||||
self.dashboard_host)
|
||||
if 'DASHBOARD_TOKEN' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DASHBOARD_TOKEN',self.dashboard_token)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('DASHBOARD_TOKEN',
|
||||
self.dashboard_token)
|
||||
|
||||
# blog configuration
|
||||
if 'BLOG_HOST' in self.test_dict[test]['args']:
|
||||
@@ -898,13 +948,17 @@ blog: http://{blog}:2368
|
||||
if 'BLOG_TOKEN' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_TOKEN', self.blog_token)
|
||||
if 'BLOG_AUTHORS' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_AUTHORS',self.blog_authors)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_AUTHORS',
|
||||
self.blog_authors)
|
||||
if 'BLOG_CUSTOMER' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_CUSTOMER',self.blog_customer)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_CUSTOMER',
|
||||
self.blog_customer)
|
||||
if 'BLOG_USER_PUSH' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_USER_PUSH',self.blog_user_push)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_USER_PUSH',
|
||||
self.blog_user_push)
|
||||
if 'BLOG_PASSWORD_PUSH' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_PASSWORD_PUSH',self.blog_password_push)
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_PASSWORD_PUSH',
|
||||
self.blog_password_push)
|
||||
if 'BLOG_FLAG' in self.test_dict[test]['args']:
|
||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace('BLOG_FLAG', self.blog_flag)
|
||||
|
||||
@@ -916,11 +970,13 @@ blog: http://{blog}:2368
|
||||
|
||||
if 'load_db' in self.test_dict[test]:
|
||||
self.logger.info("load_db : {}".format(self.test_dict[test]['load_db']))
|
||||
if str(self.test_dict[test]['load_db']).lower() != "none" and str(self.test_dict[test]['load_db']).lower() != "skip":
|
||||
if str(self.test_dict[test]['load_db']).lower() != "none" and str(
|
||||
self.test_dict[test]['load_db']).lower() != "skip":
|
||||
try:
|
||||
self.load_custom_db(self.test_dict[test]['load_db'])
|
||||
except:
|
||||
self.logger.info("custom database failed to load check existance and location: {}".format(self.test_dict[test]['load_db']))
|
||||
self.logger.info("custom database failed to load check existance and location: {}".format(
|
||||
self.test_dict[test]['load_db']))
|
||||
else:
|
||||
self.logger.info("no load_db present in dictionary, load db normally")
|
||||
if self.use_factory_default_db == "TRUE":
|
||||
@@ -935,9 +991,11 @@ blog: http://{blog}:2368
|
||||
try:
|
||||
self.load_custom_db(self.custom_db)
|
||||
sleep(1)
|
||||
self.logger.info("{} loaded between tests with scenario.py --load {}".format(self.custom_db,self.custom_db))
|
||||
self.logger.info("{} loaded between tests with scenario.py --load {}".format(self.custom_db,
|
||||
self.custom_db))
|
||||
except:
|
||||
self.logger.info("custom database failed to load check existance and location: {}".format(self.custom_db))
|
||||
self.logger.info("custom database failed to load check existance and location: {}".format(
|
||||
self.custom_db))
|
||||
else:
|
||||
self.logger.info("no db loaded between tests: {}".format(self.use_custom_db))
|
||||
|
||||
@@ -968,7 +1026,8 @@ blog: http://{blog}:2368
|
||||
command_to_run = shlex.split(command_to_run)
|
||||
print("running {command_to_run}".format(command_to_run=command_to_run))
|
||||
try:
|
||||
process = subprocess.Popen(command_to_run, shell=False, stdout=stdout_log, stderr=stderr_log, universal_newlines=True)
|
||||
process = subprocess.Popen(command_to_run, shell=False, stdout=stdout_log, stderr=stderr_log,
|
||||
universal_newlines=True)
|
||||
# if there is a better solution please propose, the TIMEOUT Result is different then FAIL
|
||||
try:
|
||||
process.wait(timeout=int(self.test_timeout))
|
||||
@@ -980,7 +1039,7 @@ blog: http://{blog}:2368
|
||||
print("No such file or directory with command: {}".format(command))
|
||||
self.logger.info("No such file or directory with command: {}".format(command))
|
||||
|
||||
if(self.test_result != "TIMEOUT"):
|
||||
if self.test_result != "TIMEOUT":
|
||||
stderr_log_size = os.path.getsize(stderr_log_txt)
|
||||
if stderr_log_size > 0:
|
||||
self.logger.info("File: {} is not empty: {}".format(stderr_log_txt, str(stderr_log_size)))
|
||||
@@ -997,8 +1056,8 @@ blog: http://{blog}:2368
|
||||
background = self.background_purple
|
||||
|
||||
# Ghost will put data in stderr
|
||||
if('ghost' in command):
|
||||
if(self.test_result != "TIMEOUT"):
|
||||
if 'ghost' in command:
|
||||
if self.test_result != "TIMEOUT":
|
||||
text = open(stderr_log_txt).read()
|
||||
if 'Error' in text:
|
||||
self.test_result = "Failure"
|
||||
@@ -1007,7 +1066,6 @@ blog: http://{blog}:2368
|
||||
self.test_result = "Success"
|
||||
background = self.background_blue
|
||||
|
||||
|
||||
# stdout_log_link is used for the email reporting to have the corrected path
|
||||
stdout_log_link = str(stdout_log_txt).replace('/home/lanforge', '')
|
||||
stderr_log_link = str(stderr_log_txt).replace('/home/lanforge', '')
|
||||
@@ -1016,9 +1074,11 @@ blog: http://{blog}:2368
|
||||
<td style=""" + str(background) + """>""" + str(self.test_result) + """
|
||||
<td><a href=""" + str(stdout_log_link) + """ target=\"_blank\">STDOUT</a></td>"""
|
||||
if self.test_result == "Failure":
|
||||
self.html_results += """<td><a href=""" + str(stderr_log_link) + """ target=\"_blank\">STDERR</a></td>"""
|
||||
self.html_results += """<td><a href=""" + str(
|
||||
stderr_log_link) + """ target=\"_blank\">STDERR</a></td>"""
|
||||
elif self.test_result == "Time Out":
|
||||
self.html_results += """<td><a href=""" + str(stderr_log_link) + """ target=\"_blank\">STDERR</a></td>"""
|
||||
self.html_results += """<td><a href=""" + str(
|
||||
stderr_log_link) + """ target=\"_blank\">STDERR</a></td>"""
|
||||
else:
|
||||
self.html_results += """<td></td>"""
|
||||
self.html_results += """</tr>"""
|
||||
@@ -1030,9 +1090,11 @@ blog: http://{blog}:2368
|
||||
self.logger.info("test: {} executed".format(test))
|
||||
|
||||
else:
|
||||
self.logger.info("enable value {} invalid for test: {}, test skipped".format(self.test_dict[test]['enabled'],test))
|
||||
self.logger.info(
|
||||
"enable value {} invalid for test: {}, test skipped".format(self.test_dict[test]['enabled'], test))
|
||||
self.finish_html_results()
|
||||
|
||||
|
||||
def main():
|
||||
# arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -1055,13 +1117,17 @@ Example :
|
||||
---------
|
||||
''')
|
||||
|
||||
parser.add_argument('--ini', help="--ini <config.ini file> default lf_check_config.ini", default="lf_check_config.ini")
|
||||
parser.add_argument('--ini', help="--ini <config.ini file> default lf_check_config.ini",
|
||||
default="lf_check_config.ini")
|
||||
parser.add_argument('--json', help="--json <lf_ckeck_config.json file> ", default="lf_check_config.json")
|
||||
parser.add_argument('--use_json', help="--use_json ", action='store_true')
|
||||
parser.add_argument('--suite', help="--suite <suite name> default TEST_DICTIONARY", default="TEST_DICTIONARY")
|
||||
parser.add_argument('--production', help="--production stores true, sends email results to production email list", action='store_true')
|
||||
parser.add_argument('--outfile', help="--outfile <Output Generic Name> used as base name for all files generated", default="")
|
||||
parser.add_argument('--logfile', help="--logfile <logfile Name> logging for output of lf_check.py script", default="lf_check.log")
|
||||
parser.add_argument('--production', help="--production stores true, sends email results to production email list",
|
||||
action='store_true')
|
||||
parser.add_argument('--outfile', help="--outfile <Output Generic Name> used as base name for all files generated",
|
||||
default="")
|
||||
parser.add_argument('--logfile', help="--logfile <logfile Name> logging for output of lf_check.py script",
|
||||
default="lf_check.log")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -1147,11 +1213,19 @@ Example :
|
||||
logger.info("commit_hash: {}".format(commit_hash))
|
||||
logger.info("commit_hash2: {}".format(commit_hash.decode('utf-8', 'ignore')))
|
||||
|
||||
ping_result = check.ping()
|
||||
for key, value in ping_result.items():
|
||||
if 'Destination Host Unreachable' or '100% packet loss' in value:
|
||||
print(UserWarning('Check your %s IP address, %s is unreachable' % (key, value[1])))
|
||||
print(UserWarning(value[0]))
|
||||
else:
|
||||
print('IP address %s accessible' % value[1])
|
||||
|
||||
# read config and run tests
|
||||
check.read_config()
|
||||
check.run_script_test()
|
||||
|
||||
# get sha and lanforge informaiton for results
|
||||
# get sha and lanforge information for results
|
||||
# Need to do this after reading the configuration
|
||||
try:
|
||||
scripts_git_sha = check.get_scripts_git_sha()
|
||||
@@ -1260,7 +1334,6 @@ Example :
|
||||
|
||||
check.send_results_email(report_file=lf_check_html_report)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user