diff --git a/.gitignore b/.gitignore index 3b015ab..f4792e8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ bmc_tplpre/taxonomy/ bmc_tplpre/DEV_TEST/ bmc_tplpre/.idea/ *.pyc +*.pyc diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d0cee..7f6f128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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; diff --git a/bmc_tplpre/check.py b/bmc_tplpre/check.py index 03b311f..9682036 100644 --- a/bmc_tplpre/check.py +++ b/bmc_tplpre/check.py @@ -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 diff --git a/bmc_tplpre/check_ide/global_logic.py b/bmc_tplpre/check_ide/global_logic.py index a1c8bb1..6b25023 100644 --- a/bmc_tplpre/check_ide/global_logic.py +++ b/bmc_tplpre/check_ide/global_logic.py @@ -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' @@ -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) diff --git a/bmc_tplpre/check_ide/local_logic.py b/bmc_tplpre/check_ide/local_logic.py index 366d63a..050b2f8 100644 --- a/bmc_tplpre/check_ide/local_logic.py +++ b/bmc_tplpre/check_ide/local_logic.py @@ -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)) @@ -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 + diff --git a/bmc_tplpre/check_ide/upload.py b/bmc_tplpre/check_ide/upload.py index e25362c..f723d08 100644 --- a/bmc_tplpre/check_ide/upload.py +++ b/bmc_tplpre/check_ide/upload.py @@ -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):