From 5423ff325ee067ff05ae6808867e19870a978272 Mon Sep 17 00:00:00 2001 From: sidheshenator Date: Thu, 7 May 2015 17:03:50 -0400 Subject: [PATCH] additional files with prefixed imagename removed from result folder --- test/script/regression.py | 63 +++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/test/script/regression.py b/test/script/regression.py index 8db5bf0d10..60dcc6ba2e 100755 --- a/test/script/regression.py +++ b/test/script/regression.py @@ -170,14 +170,15 @@ class TestRunner(object): test_data.printerror = Errors.printerror # give solr process time to die. time.sleep(10) + TestRunner._cleanup(test_data) - - # This code was causing errors with paths, so its disabled + + # This code was causing errors with paths, so its disabled #if test_config.jenkins: # copyErrorFiles(Errors.errors_out, test_config) if all([ test_data.overall_passed for test_data in test_data_list ]): - pass + pass else: html = open(test_config.html_log) Errors.add_errors_out(html.name) @@ -242,7 +243,7 @@ class TestRunner(object): print("Html report passed: ", test_data.html_report_passed) print("Errors diff passed: ", test_data.errors_diff_passed) print("DB diff passed: ", test_data.db_diff_passed) - + # run time test only for the specific jenkins test if test_data.main_config.timing: print("Run time test passed: ", test_data.run_time_passed) @@ -432,6 +433,30 @@ class TestRunner(object): theproc.communicate() antout.close() + def _cleanup(test_data): + """ + Delete the additional files. + :param test_data: + :return: + """ + try: + os.remove(test_data.get_sorted_data_path(DBType.OUTPUT)) + except: + pass + try: + os.remove(test_data.get_sorted_errors_path(DBType.OUTPUT)) + except: + pass + try: + os.remove(test_data.get_db_dump_path(DBType.OUTPUT)) + except: + pass + try: + os.remove(test_data.get_run_time_path(DBType.OUTPUT)) + except: + pass + + class TestData(object): """Container for the input and output of a single image. @@ -904,7 +929,7 @@ class TestResultsDiffer(object): def _run_time_diff(test_data, old_time_path): """ Compare run times for this run, and the run previous. - + Args: test_data: the TestData old_time_path: path to the log containing the run time from a previous test @@ -919,14 +944,14 @@ class TestResultsDiffer(object): # avoid dividing by zero below. if oldtime == 0: return True - + newtime = test_data.total_ingest_time - + # write newtime to the file inside the report dir. file = open(test_data.get_run_time_path(DBType.OUTPUT), "w") file.writelines(newtime) file.close() - + newtime = int(newtime[:newtime.find("ms")].replace(',', '')) # run the test, 5% tolerance @@ -937,7 +962,7 @@ class TestResultsDiffer(object): print("This run took: " + str(newtime)) diff = ((newtime / oldtime) * 100) - 100 diff = str(diff)[:str(diff).find('.') + 3] - print("This run took " + diff + "% longer to run than the last run.") + print("This run took " + diff + "% longer to run than the last run.") return False @@ -953,10 +978,10 @@ class Reports(object): Reports._generate_csv(test_data.main_config.global_csv, test_data) else: Reports._generate_csv(test_data.main_config.csv, test_data) - + if test_data.main_config.timing: Reports._write_time(test_data) - + def _generate_html(test_data): """Generate the HTML log file.""" # If the file doesn't exist yet, this is the first test_config to run for @@ -1328,16 +1353,16 @@ class Logs(object): test_data.heap_space = search_logs("Heap memory usage:", test_data)[0].rstrip().split(": ")[1] ingest_line = search_logs("Ingest (including enqueue)", test_data)[0] test_data.total_ingest_time = get_word_at(ingest_line, 6).rstrip() - + message_line_count = find_msg_in_log_set("Ingest messages count:", test_data) test_data.indexed_files = message_line_count - + files_line_count = find_msg_in_log_set("Indexed files count:", test_data) test_data.indexed_files = files_line_count - + chunks_line_count = find_msg_in_log_set("Indexed file chunks count:", test_data) test_data.indexed_chunks = chunks_line_count - + except (OSError, IOError) as e: Errors.print_error("Error: Unable to find the required information to fill test_config data.") Errors.print_error(str(e) + "\n") @@ -1870,7 +1895,7 @@ def find_msg_in_log(log, string, test_data): string: the String to search for. test_data: the TestData containing the log to search. Returns: - a listof_String, the lines on which the String was found. + a listof_String, the lines on which the String was found. """ lines = [] try: @@ -1956,14 +1981,14 @@ def find_file_in_dir(dir, name, ext): def copyErrorFiles(attachments, test_config): """Move email attachments to the location specified in the config file. Used for Jenkins build. - + Args: attachments: a listof_String, the files to be moved test_config: TestConfiguration, used to determine where to move the files to """ call = ['pwd'] subprocess.call(call) - + # remove old diff files filelist = [f for f in os.listdir(test_config.diff_dir) if (f.endswith(".txt") or f.endswith(".html"))] for f in filelist: @@ -1976,7 +2001,7 @@ def copyErrorFiles(attachments, test_config): destination = os.path.join(test_config.diff_dir, filename) call = ['cp', file, destination] subprocess.call(call) - + class OS: LINUX, MAC, WIN, CYGWIN = range(4)