Skip to content

Commit

Permalink
Merge pull request #5 from trianglesis/development_test
Browse files Browse the repository at this point in the history
## 1.1.4 2017-10-11
  • Loading branch information
trianglesis authored Oct 11, 2017
2 parents df16e93 + a8213f4 commit ca3dbf8
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ bmc_tplpre/taxonomy/
bmc_tplpre/DEV_TEST/
bmc_tplpre/.idea/
*.pyc
*.pyc
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.1.4 2017-10-11
- Show warning if no related tests found.

## 1.1.2 2017-09-28
- Additional fixes for logic;
- Simplifying function calls;
Expand Down
2 changes: 1 addition & 1 deletion bmc_tplpre/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def parse_args_f():
common.add_argument("-host_list", type=str, action='store', dest="scan_host_list", default="", help=host_list_h)
common.add_argument("-disco_mode", type=str, action='store', dest="disco_mode", default="", help=disco_mode_h)
common.add_argument("-l", type=str, action='store', dest="log_lvl", default="1", help=l_h)
common.add_argument('--version', action='version', version='%(prog)s 1.1.3')
common.add_argument('--version', action='version', version='%(prog)s 1.1.4')

return parser

Expand Down
2 changes: 2 additions & 0 deletions bmc_tplpre/check_ide/global_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ def test_run_cond(self):

if local_tests_path and os.path.exists(local_tests_path):

# This should be a list with single test, but it use same exec as related tests.
related_tests = []
remote_test_wd = test_wd.replace(self.workspace, self.dev_vm_path).replace('\\', '/')
remote_test_file = remote_test_wd+'/test.py'
Expand All @@ -1199,6 +1200,7 @@ def test_run_cond(self):
related_tests.append(current_pattern_dict)
# print(related_tests)

# This should be a list with single test, but it use same exec as related tests.
if related_tests:
test_executor_f = self.make_test_run(tests_list=related_tests,
tst_cond=tst_cond)
Expand Down
9 changes: 4 additions & 5 deletions bmc_tplpre/check_ide/local_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,10 @@ def get_related_tests(self, **conditions):
:return: dict
"""

local_cond = conditions['local_cond']
# print(local_cond)

dev_vm_path = conditions['dev_vm_path']
local_cond = conditions['local_cond']
dev_vm_path = conditions['dev_vm_path']
active_pattern = local_cond['file_name']+'.'+local_cond['file_ext']
workspace = local_cond['workspace']
workspace = local_cond['workspace']

log.debug("Step 1. Search related tests with pattern: "+str(active_pattern))

Expand Down Expand Up @@ -1162,3 +1160,4 @@ def tests_to_read(search_path, exclude_dirs, dev_vm_path, workspace):
# No need when searching fot test.py:
# break
return file_candidates

138 changes: 71 additions & 67 deletions bmc_tplpre/check_ide/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,82 +298,86 @@ def tests_executor(self, tests_list, tst_cond):
test_failfast_arg = ' --verbose'
test_args = test_verbose_arg+test_failfast_arg

tests_len = len(tests_list)
if tests_list:
log.info("-==== START TESTS EXECUTION ====-")
tests_len = len(tests_list)
log.info("Tests related to: "+str(tests_list[0]['pattern']))
log.info("All tests len: "+str(tests_len))

# Run test: 0 of 10 | - should be fixed, but I have no workaround.
if progressbar:
widgets = [
'Run test: ', progressbar.SimpleProgress(), ' ',
progressbar.Percentage(), ' ',
progressbar.Bar('#'),
progressbar.Timer(), ' ',
progressbar.ETA(), ' ',
# ' Calculated ',
# progressbar.AdaptiveETA(), ' ',
progressbar.AbsoluteETA(),
'.\n']
bar = progressbar.ProgressBar(widgets=widgets,
max_value=tests_len,
redirect_stdout=True,
redirect_stderr=True
)
else:
log.debug("Module progressbar2 is not installed, will show progress in usual manner.")
pass
# Run test: 0 of 10 | - should be fixed, but I have no workaround.
if progressbar:
widgets = [
'Run test: ',
progressbar.SimpleProgress(), ' ',
progressbar.Percentage(), ' ',
progressbar.Bar('#'),
progressbar.Timer(), ' ',
progressbar.ETA(), ' ',
# ' Calculated ',
# progressbar.AdaptiveETA(), ' ',
progressbar.AbsoluteETA(),
'.\n']
bar = progressbar.ProgressBar(widgets=widgets,
max_value=tests_len,
redirect_stdout=True,
redirect_stderr=True)
else:
log.debug("Module progressbar2 is not installed, will show progress in usual manner.")
pass

log.info("-==== START TESTS EXECUTION ====-")
# TODO: log.debug("Run test for: PLACE HERE NAME OF FOLDER WE TESTING NOW.")
for i, test in enumerate(tests_list):
"""
export TKN_MAIN=/usr/tideway/TKU/addm/tkn_main/
export TKN_CORE=$TKN_MAIN/tku_patterns/CORE
export PYTHONPATH=$PYTHONPATH:$TKN_MAIN/python
"""
i = i + 1
log.info("Start test: " + str(test['rem_test_path'])+test_args)

# TODO: log.debug("Run test for: PLACE HERE NAME OF FOLDER WE TESTING NOW.")
log.info("Tests related to: "+str(tests_list[0]['pattern']))
log.info("All tests len: "+str(tests_len))
pre_cmd = ". ~/.bash_profile;"

for i, test in enumerate(tests_list):
"""
export TKN_MAIN=/usr/tideway/TKU/addm/tkn_main/
export TKN_CORE=$TKN_MAIN/tku_patterns/CORE
export PYTHONPATH=$PYTHONPATH:$TKN_MAIN/python
"""
i = i + 1
log.info("Start test: " + str(test['rem_test_path'])+test_args)
wd_cmd = "cd "+test['rem_test_wd']+";"

pre_cmd = ". ~/.bash_profile;"
cmd_test = "/usr/tideway/bin/python -u "+test['rem_test_path']+test_args
cmd = pre_cmd + wd_cmd + cmd_test
log.debug("Run: "+str(cmd))

wd_cmd = "cd "+test['rem_test_wd']+";"
# Show output and count of running tests and ETAs:
if progressbar:
bar(range(tests_len))
bar.update(i)
# Print simple counter:
else:
log.info("%d test of "+str(tests_len), i)

try:
_, stdout, stderr = self.ssh_cons.exec_command(cmd)
# This pipe is for messages from test_utils and dml...
if stdout:
output = stdout.readlines()
raw_out = "".join(output)
log.debug("-==== DETAILED LOG ====-")
sys.stdout.write('\b')
log.debug("\n"+raw_out)
# This pipe of for unittest output only:
if stderr:
output = stderr.readlines()
raw_out = "".join(output)
sys.stdout.write('\b')
log.info("-==== UNITTEST LOG ====-")
log.info("\n\n"+raw_out)
except:
# Not raise - see what happen with others:
log.error("Test execution command cannot run: "+str(cmd))
if progressbar:
bar.finish() # Close bar, do not forget to.
log.info("-==== END OF TESTS EXECUTION ====-")

cmd_test = "/usr/tideway/bin/python -u "+test['rem_test_path']+test_args
cmd = pre_cmd + wd_cmd + cmd_test
log.debug("Run: "+str(cmd))
else:
log.warning("There are no related tests found for current pattern!")

# Show output and count of running tests and ETAs:
if progressbar:
bar(range(tests_len))
bar.update(i)
# Print simple counter:
else:
log.info("%d test of "+str(tests_len), i)

try:
_, stdout, stderr = self.ssh_cons.exec_command(cmd)
# This pipe is for messages from test_utils and dml...
if stdout:
output = stdout.readlines()
raw_out = "".join(output)
log.debug("-==== DETAILED LOG ====-")
sys.stdout.write('\b')
log.debug("\n"+raw_out)
# This pipe of for unittest output only:
if stderr:
output = stderr.readlines()
raw_out = "".join(output)
sys.stdout.write('\b')
log.info("-==== UNITTEST LOG ====-")
log.info("\n\n"+raw_out)
except:
# Not raise - see what happen with others:
log.error("Test execution command cannot run: "+str(cmd))
if progressbar:
bar.finish() # Close bar, do not forget to.
log.info("-==== END OF TESTS EXECUTION ====-")

@staticmethod
def progress_bar(msg):
Expand Down

0 comments on commit ca3dbf8

Please sign in to comment.