mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
lf_check.py : first steps in adding a logger lf_check_config.ini : updates to .ini
Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
@@ -19,7 +19,9 @@ if sys.version_info[0] != 3:
|
||||
print("This script requires Python3")
|
||||
exit()
|
||||
|
||||
|
||||
import os
|
||||
import pexpect
|
||||
import logging
|
||||
import time
|
||||
from time import sleep
|
||||
@@ -29,28 +31,31 @@ from json import load
|
||||
import configparser
|
||||
from pprint import *
|
||||
import subprocess
|
||||
import sys
|
||||
import re
|
||||
import csv
|
||||
|
||||
#from ..lf_report import lf_report
|
||||
sys.path.append('../')
|
||||
# lf_report is from the parent of the current file
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
parent_dir_path = os.path.abspath(os.path.join(dir_path,os.pardir))
|
||||
sys.path.insert(0, parent_dir_path)
|
||||
|
||||
#sys.path.append('../')
|
||||
from lf_report import lf_report
|
||||
sys.path.append('/')
|
||||
|
||||
CONFIG_FILE = os.getcwd() + '/lf_check_config.ini'
|
||||
RUN_CONDITION = 'ENABLE'
|
||||
|
||||
# see https://stackoverflow.com/a/13306095/11014343
|
||||
class FileAdapter(object):
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
def write(self, data):
|
||||
# NOTE: data can be a partial line, multiple lines
|
||||
data = data.strip() # ignore leading/trailing whitespace
|
||||
if data: # non-blank
|
||||
self.logger.info(data)
|
||||
def flush(self):
|
||||
pass # leave it to logging to flush properly
|
||||
# setup logging
|
||||
FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s'
|
||||
#logger = logging.getLogger('Throughput_Test')
|
||||
#logger.setLevel(logging.INFO)
|
||||
#hdlr = logging.FileHandler(local_dir+"/Throughput_Testing.log")
|
||||
#formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
|
||||
#hdlr.setFormatter(formatter)
|
||||
#logger.addHandler(hdlr)
|
||||
#logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class lf_check():
|
||||
def __init__(self,
|
||||
@@ -88,6 +93,7 @@ class lf_check():
|
||||
self.csv_results_file = ""
|
||||
self.csv_results_writer = ""
|
||||
self.csv_results_column_headers = ""
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
def get_csv_results(self):
|
||||
return self.csv_file.name
|
||||
@@ -129,12 +135,14 @@ class lf_check():
|
||||
|
||||
# Functions in this section are/can be overridden by descendants
|
||||
def read_config_contents(self):
|
||||
print("read_config_contents {}".format(CONFIG_FILE))
|
||||
self.logger.info("read_config_contents {}".format(CONFIG_FILE))
|
||||
config_file = configparser.ConfigParser()
|
||||
success = True
|
||||
success = config_file.read(CONFIG_FILE)
|
||||
print("{}".format(success))
|
||||
print("{}".format(config_file))
|
||||
#print("{}".format(success))
|
||||
#print("{}".format(config_file))
|
||||
self.logger.info("logger worked")
|
||||
exit(1)
|
||||
|
||||
if 'LF_MGR' in config_file.sections():
|
||||
section = config_file['LF_MGR']
|
||||
@@ -351,6 +359,7 @@ for running scripts listed in lf_check_config.ini
|
||||
''')
|
||||
|
||||
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()
|
||||
|
||||
@@ -374,9 +383,21 @@ for running scripts listed in lf_check_config.ini
|
||||
(commit_hash, err) = process.communicate()
|
||||
exit_code = process.wait()
|
||||
git_sha = commit_hash.decode('utf-8','ignore')
|
||||
#print("commit_hash: {}".format(commit_hash))
|
||||
#print("commit_hash2: {}".format(commit_hash.decode('utf-8','ignore')))
|
||||
|
||||
# set up logging
|
||||
logfile = args.logfile
|
||||
logfile = report.file_add_path(logfile)
|
||||
formatter = logging.Formatter(FORMAT)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
file_handler = logging.FileHandler(logfile, "w")
|
||||
file_handler.setFormatter(formatter)
|
||||
logger.addHandler(file_handler)
|
||||
logger.addHandler(logging.StreamHandler(sys.stdout)) # allows to logging to file and stderr
|
||||
|
||||
|
||||
logger.info("commit_hash: {}".format(commit_hash))
|
||||
logger.info("commit_hash2: {}".format(commit_hash.decode('utf-8','ignore')))
|
||||
|
||||
check.read_config_contents() # CMR need mode to just print out the test config and not run
|
||||
check.run_script_test()
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST_TIMEOUT = "120"
|
||||
|
||||
# TEST_DICTIONARY used by lf_check, Other section names will be ignored so can save other test lists
|
||||
# USE TEST_DICTIONARY_NOT_RUN to ignore tests
|
||||
[TEST_DICTIONARY_NOT]
|
||||
[TEST_DICTIONARY]
|
||||
TEST_DICT: {
|
||||
"create_vr.py":{"enabled":"TRUE","command":"create_vr.py","args":"--vr_name 2.vr0 --ports 2.br0,2.vap2 --services"},
|
||||
"create_l3":{"enabled":"TRUE","command":"create_l3.py","args":"RADIO_0_CFG --debug"},
|
||||
@@ -54,7 +54,7 @@ TEST_DICT: {
|
||||
|
||||
# CHANGE above TEST_DICTIONARY to TEST_DICIONARY_NOT_RUN and TEST_DICTIONARY_NOT_RUN below to TEST_DICTIONARY
|
||||
# Feature update pass in the DICTIONARY name to be run
|
||||
[TEST_DICTIONARY]
|
||||
[TEST_DICTIONARY_NOT]
|
||||
TEST_DICT: {
|
||||
"example_security_connection0":{"enabled":"TRUE","command":"example_security_connection.py","args":"RADIO_0_CFG --debug"},
|
||||
"example_security_connection1":{"enabled":"TRUE","command":"example_security_connection.py","args":"RADIO_2_CFG --debug"},
|
||||
@@ -67,7 +67,7 @@ TEST_DICT: {
|
||||
"test_generic2":{"enabled":"TRUE","command":"test_generic.py","args":"RADIO_1_CFG --type lfping --dest TEST_IP --debug"},
|
||||
"test_generic3":{"enabled":"TRUE","command":"test_generic.py","args":"RADIO_1_CFG --type lfping --dest TEST_IP --debug"},
|
||||
"testgroup":{"enabled":"FALSE","command":"testgroup.py","args":"--group_name group1 --add_group --list_groups --debug"},
|
||||
"test_ipv4_connection":{"enabled":"TRUE","command":"test_ipv4_connection.py","args":"RADIO_0_CFG --debug"},
|
||||
"test_ipv4_connection":{"enabled":"FALSE","command":"test_ipv4_connection.py","args":"RADIO_0_CFG --debug"},
|
||||
"test_ipv4_l4_urls_per_ten":{"enabled":"TRUE","command":"test_ipv4_l4_urls_per_ten.py","args":"RADIO_0_CFG --num_tests 1 --requests_per_ten 600 --target_per_ten 600 --debug"},
|
||||
"test_ipv4_l4_wifi":{"enabled":"TRUE","command":"test_ipv4_l4_wifi.py","args":"RADIO_0_CFG --test_duration 15s --debug"},
|
||||
"test_ipv4_l4":{"enabled":"TRUE","command":"test_ipv4_l4.py","args":"RADIO_0_CFG --test_duration 15s --debug"},
|
||||
@@ -78,7 +78,7 @@ TEST_DICT: {
|
||||
"create_l4":{"enabled":"TRUE","command":"create_l4.py","args":"RADIO_1_CFG --debug"},
|
||||
"create_macvlan":{"enabled":"TRUE","command":"create_macvlan.py","args":"--radio RADIO_USED --macvlan_parent UPSTREAM_PORT --debug"},
|
||||
"create_station":{"enabled":"TRUE","command":"create_station.py","args":"--radio RADIO_USED --ssid SSID_USED --passwd SSID_PW_USED --security SECURITY_USED --debug"},
|
||||
"create_vap":{"enabled":"TRUE","command":"create_vap.py","args":" --radio RADIO_USED --ssid SSID_USED --passwd SSID_PW_USED --security SECURITY_USED --debug"},
|
||||
"create_vap":{"enabled":"FALSE","command":"create_vap.py","args":" --radio RADIO_USED --ssid SSID_USED --passwd SSID_PW_USED --security SECURITY_USED --debug"},
|
||||
"test_fileio":{"enabled":"TRUE","command":"test_fileio.py","args":"--macvlan_parent eth2 --num_ports 3 --use_macvlans --first_mvlan_ip 192.168.92.13 --netmask 255.255.255.0 --gateway 192.168.92.1 --test_duration 30s"},
|
||||
"test_ipv6_connection":{"enabled":"TRUE","command":"test_ipv6_connection.py","args":"RADIO_0_CFG --debug"},
|
||||
"test_ipv6_variable_time":{"enabled":"TRUE","command":"test_ipv6_variable_time.py","args":"RADIO_0_CFG --test_duration 15s --cx_type tcp6 --debug"},
|
||||
@@ -91,7 +91,7 @@ TEST_DICT: {
|
||||
"test_status_msg":{"enabled":"TRUE","command":"test_status_msg.py","args":"--action run_test"},
|
||||
"test_wanlink":{"enabled":"TRUE","command":"test_wanlink.py","args":"--debug"},
|
||||
"sta_connect_example":{"enabled":"FALSE","command":"sta_connect_example.py","args":"RADIO_0_CFG --upstream_port UPSTREAM_PORT"},
|
||||
"create_vr.py":{"enabled":"TRUE","command":"create_vr.py","args":"--vr_name 2.vr0 --ports 2.br0,2.vap2 --services"},
|
||||
"create_vr.py":{"enabled":"FALSE","command":"create_vr.py","args":"--vr_name 2.vr0 --ports 2.br0,2.vap2 --services"},
|
||||
"wlan_capacity_calculator1":{"enabled":"TRUE","command":"./wlan_capacity_calculator.py","args":"-sta 11abg -t Voice -p 48 -m 106 -e WEP -q Yes -b 1 2 5.5 11 -pre Long -s N/A -co G.711 -r Yes -c Yes"},
|
||||
"wlan_capacity_calculator2":{"enabled":"TRUE","command":"./wlan_capacity_calculator.py","args":"-sta 11n -t Voice -d 17 -ch 40 -gu 800 -high 9 -e WEP -q Yes -ip 5 -mc 42 -b 6 9 12 24 -m 1538 -co G.729 -pl Greenfield -cw 15 -r Yes -c Yes"},
|
||||
"wlan_capacity_calculator3":{"enabled":"TRUE","command":"./wlan_capacity_calculator.py","args":"-sta 11ac -t Voice -d 9 -spa 3 -ch 20 -gu 800 -high 1 -e TKIP -q Yes -ip 3 -mc 0 -b 6 12 24 54 -m 1518 -co Greenfield -cw 15 -rc Yes"}
|
||||
|
||||
Reference in New Issue
Block a user