Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging changes #264

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion warrior/Actions/CommonActions/common_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ def get_time_delta(self, start_time, end_time=None, time_diff="time_diff", max_t
output_dict = {time_diff: time_delta}
if max_time_diff:
if time_delta > int(max_time_diff):
print_error("The time difference is greater than max time difference so failing the step !")
print_error("The time difference is greater than max time \
difference so failing the step !")
status = False
return status, output_dict
status = True
Expand Down
182 changes: 92 additions & 90 deletions warrior/Actions/NetconfActions/netconf_Actions.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions warrior/Framework/ClassUtils/WNetwork/warrior_cli_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ def send_command(self, command, get_pty=False, *args, **kwargs):
response = response + stderr.read().decode("utf-8")

pNote("[{0}] Command execution completed".format(end_time))
pNote("Response:\n{0}\n".format(response))
print_debug("Response:\n{0}\n".format(response))
status = True
except Exception as exception:
print_exception(exception)
Expand Down Expand Up @@ -1666,7 +1666,7 @@ def send_command(self, command, start_prompt, end_prompt,
else:
response = response + self.target_host.after.decode('utf-8')
if kwargs.get("log", "true") != "false":
pNote("Response:\n{0}\n".format(response))
print_debug("Response:\n{0}\n".format(response))
pNote(msg, "debug")
if status is True:
duration = Utils.datetime_utils.get_time_delta(start_time,
Expand Down
5 changes: 3 additions & 2 deletions warrior/Framework/ClassUtils/netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import paramiko

from warrior.Framework.Utils.testcase_Utils import pNote
from warrior.Framework.Utils.print_Utils import print_info, print_debug

BUF_SIZE = 65536
POLL_INTERVAL = 0.1
Expand Down Expand Up @@ -207,7 +208,7 @@ def __send(self, data):
#
dispdata = data.replace("\n", "")
dispdata = re.sub("> +<", "><", dispdata)
pNote("netconf send: \n" + \
print_debug("netconf send: \n" + \
parseString(dispdata).toprettyxml(indent=" "))

try:
Expand Down Expand Up @@ -311,7 +312,7 @@ def __receive(self):
self.__notification_list_print.append(recv_data)
elif resType == "hello":
self.__hello_buffer = recv_data
pNote(recv_data)
print_debug(recv_data)
cap = recv_dom.getElementsByTagName("capability")
for c in cap:
if c.childNodes[0].data == "urn:ietf:params:netconf:base:1.1":
Expand Down
9 changes: 3 additions & 6 deletions warrior/Framework/Utils/print_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
as it will lead to cyclic imports.

"""


def print_debug(message, *args):
"""Print a debug message to the terminal """
print_type = "-D-"
Expand Down Expand Up @@ -65,7 +63,7 @@ def print_without_logging(message, *args):
if len(args) > 0:
for arg in args:
message += arg + ", "
print_main(message, print_type, logging=False)
print_main(message, print_type, log=False)
return message


Expand Down Expand Up @@ -114,7 +112,7 @@ def print_error(message, *args):
message += arg + ", "
color_message = None
if sys.stdout.isatty():
print_type = "\033[1;31m"+ "-E-" + "\033[0m"
#print_type = "\033[1;31m"+ "-E-" + "\033[0m"
color_message = "\033[1;31m" + str(message) + "\033[0m"
print_main(message, print_type, color_message)
return message
Expand All @@ -137,7 +135,7 @@ def print_warning(message, *args):
message += arg + ", "
color_message = None
if sys.stdout.isatty():
print_type = "\033[1;33m"+ "-W-" + "\033[0m"
#print_type = "\033[1;33m"+ "-W-" + "\033[0m"
color_message = "\033[1;33m" + str(message) + "\033[0m"
print_main(message, print_type, color_message)
return message
Expand All @@ -155,4 +153,3 @@ def print_sub(message, *args):
message = message.format(*args)
print_main(message, print_type)
return message

19 changes: 10 additions & 9 deletions warrior/WarriorCore/Classes/execution_files_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import os
from warrior.Framework.Utils import file_Utils as file_Utils
from warrior.Framework.Utils import xml_Utils as xml_Utils
from warrior.Framework.Utils.print_Utils import print_info, print_warning, print_error, print_exception
from warrior.Framework.Utils.print_Utils import print_info, print_warning, print_error,\
print_exception, print_debug
from warrior.Framework.Utils.data_Utils import get_credentials

class ExecFilesClass(object):
Expand Down Expand Up @@ -121,10 +122,10 @@ def get_log_files(self):
results_location = xml_Utils.getChildTextbyParentTag(self.filepath,
'Details', 'Resultsdir')
#get default logs and results directory
#default_xml = Tools.__path__[0] + os.sep + 'w_settings.xml'
default_xml = os.getenv("WAR_TOOLS_DIR") + os.sep + 'w_settings.xml'
default_logsdir = get_credentials(default_xml, 'def_dir',['Logsdir'], 'Setting')
default_resultsdir = get_credentials(default_xml, 'def_dir',['Resultsdir'], 'Setting')
#default_xml = Tools.__path__[0] + os.sep + 'w_settings.xml'
default_xml = os.getenv("WAR_TOOLS_DIR") + os.sep + 'w_settings.xml'
default_logsdir = get_credentials(default_xml, 'def_dir', ['Logsdir'], 'Setting')
default_resultsdir = get_credentials(default_xml, 'def_dir', ['Resultsdir'], 'Setting')
#use the default directory if user didn't define it in test case/test suite/project
if results_location is None or results_location is False:
if default_resultsdir['Resultsdir'] is not None:
Expand Down Expand Up @@ -235,10 +236,10 @@ def check_get_datafile(self):
elif self.filetype == "proj":
datafile = False
elif str(datafile).strip().upper() == "DEFAULT":
print_info("This testcase will be executed using the default InputDataFile")
print_debug("This testcase will be executed using the default InputDataFile")
datafile = get_default_xml_datafile(self.filepath)
elif str(datafile).strip().upper() == 'NO_DATA':
print_info('This test case will be run without any InputDataFile')
print_debug('This test case will be run without any InputDataFile')
datafile = "NO_DATA"

elif datafile is not None and datafile is not False:
Expand All @@ -247,7 +248,7 @@ def check_get_datafile(self):

if str(datafile).strip().upper() != 'NO_DATA' and datafile is not False:
if not file_Utils.fileExists(datafile):
print_info('\n')
print_debug('\n')
print_error("!!! *** InputDataFile does not exist in provided path:"\
"{0} *** !!!".format(datafile))
return datafile
Expand All @@ -259,7 +260,7 @@ def check_get_datatype(self, datafile):
data_type = xml_Utils.getChildTextbyParentTag(self.filepath, 'Details', 'Datatype')
if str(datafile).upper().strip() == 'NO_DATA':
data_type = 'CUSTOM'
print_info('This test case will be run without any InputDataFile')
print_debug('This test case will be run without any InputDataFile')

elif data_type is None or data_type is False or\
str(data_type).strip() == "":
Expand Down
2 changes: 1 addition & 1 deletion warrior/WarriorCore/Classes/execution_summary_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end of Test Suite or Project Execution """
import os
from warrior.Framework.Utils import xml_Utils
from warrior.Framework.Utils.print_Utils import print_info
from warrior.Framework.Utils.print_Utils import print_info, print_debug


class ExecutionSummary():
Expand Down
2 changes: 1 addition & 1 deletion warrior/WarriorCore/Classes/html_results_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import multiprocessing
from warrior.Framework.Utils import xml_Utils, file_Utils, data_Utils
from warrior.Framework.Utils.testcase_Utils import pNote
from warrior.Framework.Utils.print_Utils import print_info
from warrior.Framework.Utils.print_Utils import print_info, print_debug
from warrior.Framework.Utils.xml_Utils import getElementWithTagAttribValueMatch
import warrior.WarriorCore.Classes.katana_interface_class as katana_interface_class

Expand Down
90 changes: 45 additions & 45 deletions warrior/WarriorCore/Classes/hybrid_driver_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from warrior.Framework.Utils import data_Utils, xml_Utils, config_Utils, \
testcase_Utils, file_Utils
from warrior.Framework.Utils.testcase_Utils import pNote
from warrior.Framework.Utils.print_Utils import print_debug, print_info
from warrior.Framework.Utils.print_Utils import print_debug
from warrior.WarriorCore import step_driver, common_execution_utils
import warrior.WarriorCore.onerror_driver as onerror_driver
import warrior.WarriorCore.exec_type_driver as exec_type_driver
Expand Down Expand Up @@ -178,11 +178,10 @@ def execute_hybrid_mode(self):
def _compute_system_status(self, system_executed):
"""
"""
system_status = testcase_Utils.compute_status_using_impact(
self.step_status_list, self.step_impact_list)
system_resultfile = self.compute_system_resultfile(self.kw_resultfile_list,
self.data_repository['wt_resultsdir'],
system_executed)
system_status = testcase_Utils.compute_status_using_impact(\
self.step_status_list, self.step_impact_list)
system_resultfile = self.compute_system_resultfile(self.kw_resultfile_list,\
self.data_repository['wt_resultsdir'], system_executed)
self.system_status_list.append(system_status)
self.system_resultfile_list.append(system_resultfile)

Expand All @@ -191,11 +190,10 @@ def _compute_system_status(self, system_executed):
def _compute_testcase_status(self):
"""
"""
tc_status = testcase_Utils.compute_status_without_impact(
self.system_status_list)
tc_status = testcase_Utils.compute_status_without_impact(self.system_status_list)
print_debug("Updating Testcase result file...")
testcase_Utils.append_result_files(self.data_repository['wt_resultfile'],
self.system_resultfile_list)
testcase_Utils.append_result_files(self.data_repository['wt_resultfile'],\
self.system_resultfile_list)
return tc_status

def _execute_step_list(self):
Expand All @@ -222,29 +220,29 @@ def _execute_step_list(self):
if not run_current_step:

if trigger_action.upper() in ['ABORT', 'ABORT_AS_ERROR']:
if any([self.iter_type_list[index] == "once_per_tc",
self.iter_type_list[index] == "end_of_tc"]):
pNote("step exectype check failed, fail action is set to {0} and"
"step iter_type={1} hence aborting execution compeletely".\
format(trigger_action.upper(), self.iter_type_list[index]), "debug")
if any([self.iter_type_list[index] == "once_per_tc",\
self.iter_type_list[index] == "end_of_tc"]):
pNote("step exectype check failed, fail action is set to {0} and"\
"step iter_type={1} hence aborting execution compeletely".\
format(trigger_action.upper(), self.iter_type_list[index]),\
"debug")
self.stop_after_current_iteration = True
self.stop_after_current_step = True
else:
pNote("step exectype check failed, fail action is set to {0} and"
"step iter_type={1} hence aborting execution for this system".\
format(trigger_action.upper(), self.iter_type_list[index]), "debug")
format(trigger_action.upper(), self.iter_type_list[index]),\
"debug")
goto_stepnum = False
break
elif trigger_action.upper() in ['SKIP', 'NEXT']:
result = self._update_skip_results(step, self.system_executed,
step_num)
result = self._update_skip_results(step, self.system_executed, step_num)
self.kw_resultfile_list.append(result[1])
continue
# when 'onError:goto' value is less than the current step num,
# change the next iteration point to goto value
elif trigger_action and int(trigger_action) < step_num:
result = self._update_skip_results(step, self.system_executed,
step_num)
result = self._update_skip_results(step, self.system_executed, step_num)
self.kw_resultfile_list.append(result[1])
step_num = int(trigger_action)-1
trigger_action = False
Expand Down Expand Up @@ -277,8 +275,8 @@ def _execute_step_list(self):
goto_stepnum, step_num = self._compute_runmode_goto_operations(step, step_status,
goto_stepnum, step_num)
if (goto_stepnum == 'ABORT'):
if any([self.iter_type_list[index] == "once_per_tc",
self.iter_type_list[index] == "end_of_tc"]):
if any([self.iter_type_list[index] == "once_per_tc",\
self.iter_type_list[index] == "end_of_tc"]):
pNote("step iter_type={0}, and onerror action=ABORT hence aborting execution"
"compeletely".format(self.iter_type_list[index]), "debug")
self.stop_after_current_iteration = True
Expand All @@ -291,6 +289,7 @@ def _execute_step_list(self):
def _compute_runmode_goto_operations(self, step, step_status,
goto_stepnum, step_num):
"""
compute_runmode_goto_operations
"""
runmode, value, _ = common_execution_utils.get_runmode_from_xmlfile(step)

Expand All @@ -304,17 +303,17 @@ def _compute_runmode_goto_operations(self, step, step_status,
elif runmode == "rup" and step_status is True:
goto_stepnum = str(value)
else:
if any([step_status is False,
str(step_status).upper() == "ERROR",
str(step_status).upper() == "EXCEPTION"]):
goto_stepnum = onerror_driver.main(step, self.default_error_action,
self.default_error_value)
if any([step_status is False,\
str(step_status).upper() == "ERROR",\
str(step_status).upper() == "EXCEPTION"]):
goto_stepnum = onerror_driver.main(step, self.default_error_action,\
self.default_error_value)
# if (goto_stepnum == 'ABORT'): break
else:
if any([step_status is False, str(step_status).upper() == "ERROR",
str(step_status).upper() == "EXCEPTION"]):
goto_stepnum = onerror_driver.main(step, self.default_error_action,
self.default_error_value)
if any([step_status is False, str(step_status).upper() == "ERROR",\
str(step_status).upper() == "EXCEPTION"]):
goto_stepnum = onerror_driver.main(step, self.default_error_action,\
self.default_error_value)
if str(goto_stepnum).upper() == 'ABORT':
pass
# when 'onError:goto' value is less than the current step num,
Expand All @@ -333,8 +332,9 @@ def _update_status_items(self, step_status, kw_resultfile, step_impact):

def _execute_step(self, system_executed, step_num, index, goto_stepnum):
"""
execute_step
"""
print_info("\n")
print_debug("\n")
result = (None, None, None, None)

if not self.execute_endoftc:
Expand Down Expand Up @@ -366,8 +366,7 @@ def _execute_step(self, system_executed, step_num, index, goto_stepnum):
system_executed)

# if end_of_tc, skip it
elif all([self.iter_type_list[index] == "end_of_tc",
not goto_stepnum]):
elif all([self.iter_type_list[index] == "end_of_tc", not goto_stepnum]):
self._print_step_details(step_num, self.iter_type_list[index],
system_executed)
pNote("step iter_type={0} and will be executed at the end of "
Expand Down Expand Up @@ -406,6 +405,7 @@ def _execute_step(self, system_executed, step_num, index, goto_stepnum):

def _update_skip_results(self, step, system_name, step_num):
"""
update_skip_results
"""
keyword = step.get('Keyword')
kw_resultfile = step_driver.get_keyword_resultfile(self.data_repository, system_name,
Expand All @@ -414,24 +414,22 @@ def _update_skip_results(self, step, system_name, step_num):
config_Utils.set_resultfile(kw_resultfile)
testcase_Utils.pKeyword(keyword, step.get('Driver'))
testcase_Utils.reportStatus('Skip')
print_info("\n-----------------------------------------------------\n")
self.data_repository['wt_junit_object'].update_count("skipped", "1", "tc",
self.data_repository['wt_tc_timestamp'])
self.data_repository['wt_junit_object'].update_count("keywords", "1", "tc",
self.data_repository['wt_tc_timestamp'])
self.data_repository['wt_junit_object'].add_keyword_result(self.
data_repository['wt_tc_timestamp'],
step_num, keyword, "SKIPPED",
"skipped", "skipped", "skipped",
"skipped", "skipped",
keyword_description)
print_debug("\n-----------------------------------------------------\n")
self.data_repository['wt_junit_object'].update_count("skipped", "1", "tc",\
self.data_repository['wt_tc_timestamp'])
self.data_repository['wt_junit_object'].update_count("keywords", "1", "tc",\
self.data_repository['wt_tc_timestamp'])
self.data_repository['wt_junit_object'].add_keyword_result(\
self.data_repository['wt_tc_timestamp'], step_num, keyword, "SKIPPED",\
"skipped", "skipped", "skipped", "skipped", "skipped", keyword_description)

self.data_repository['step_{}_result'.format(step_num)] = "SKIPPED"
result = ("Skip", kw_resultfile, None, None)
return result

def _get_system_executed(self, index, sys_list=None):
"""
get_system_executed
"""
sys_list = self.kw_sys_list if sys_list is None else sys_list
if sys_list[index] is not None:
Expand Down Expand Up @@ -471,6 +469,7 @@ def _get_iteration_syslist(self, system_node_list, system_name_list):

def _get_executed_list(self, step_list):
"""
get_executed_list
"""
executed_or_not_list = []
for _ in step_list:
Expand Down Expand Up @@ -499,6 +498,7 @@ def _get_kw_system_name_list(self, step_list):

def _get_exec_steps(self, step_list, iter_type_list):
"""
get_exec_steps
"""
end_of_tc_list = []
end_of_tc_kw_syslist = []
Expand Down
Loading