From afefddfa387dad83bbcb15812bd279cf3197f583 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 8 Mar 2016 10:28:20 +0200 Subject: regression: add stateless support (WIP); Scapy builder: fix remove MACs from binary, do not build by default; --- scripts/automation/regression/aggregate_results.py | 104 ++-- .../automation/regression/functional_unit_tests.py | 78 --- scripts/automation/regression/misc_methods.py | 19 +- .../regression/stl/golden/basic_imix_golden.cap | Bin 198474 -> 0 bytes .../regression/stl/golden/basic_imix_vm_golden.cap | Bin 316552 -> 0 bytes .../stl/golden/basic_tuple_gen_golden.cap | Bin 38024 -> 0 bytes .../automation/regression/stl/golden/udp_590.cap | Bin 630 -> 0 bytes scripts/automation/regression/trex.py | 81 ++- scripts/automation/regression/trex_unit_test.py | 306 +++++----- .../automation/regression/unit_tests/__init__.py | 1 - .../unit_tests/functional_tests/config.yaml | 74 --- .../functional_tests/functional_general_test.py | 22 - .../functional_tests/hltapi_stream_builder_test.py | 629 --------------------- .../functional_tests/misc_methods_test.py | 61 -- .../functional_tests/pkt_bld_general_test.py | 28 - .../functional_tests/platform_cmd_cache_test.py | 60 -- .../functional_tests/platform_cmd_link_test.py | 62 -- .../functional_tests/platform_device_cfg_test.py | 20 - .../functional_tests/platform_dual_if_obj_test.py | 31 - .../functional_tests/platform_if_manager_test.py | 40 -- .../functional_tests/platform_if_obj_test.py | 49 -- .../functional_tests/scapy_pkt_builder_test.py | 368 ------------ .../unit_tests/functional_tests/stl_basic_tests.py | 258 --------- .../regression/unit_tests/tests_exceptions.py | 37 -- .../regression/unit_tests/trex_general_test.py | 350 ------------ .../regression/unit_tests/trex_imix_test.py | 202 ------- .../regression/unit_tests/trex_ipv6_test.py | 102 ---- .../regression/unit_tests/trex_nat_test.py | 169 ------ .../regression/unit_tests/trex_nbar_test.py | 193 ------- .../regression/unit_tests/trex_rx_test.py | 275 --------- .../trex_stl_lib/trex_stl_packet_builder_scapy.py | 95 ++-- .../stl/trex_stl_lib/trex_stl_streams.py | 4 +- 32 files changed, 350 insertions(+), 3368 deletions(-) delete mode 100755 scripts/automation/regression/functional_unit_tests.py delete mode 100644 scripts/automation/regression/stl/golden/basic_imix_golden.cap delete mode 100644 scripts/automation/regression/stl/golden/basic_imix_vm_golden.cap delete mode 100644 scripts/automation/regression/stl/golden/basic_tuple_gen_golden.cap delete mode 100644 scripts/automation/regression/stl/golden/udp_590.cap delete mode 100755 scripts/automation/regression/unit_tests/__init__.py delete mode 100644 scripts/automation/regression/unit_tests/functional_tests/config.yaml delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/functional_general_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/hltapi_stream_builder_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/misc_methods_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/pkt_bld_general_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/platform_cmd_cache_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/platform_cmd_link_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/platform_device_cfg_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/platform_dual_if_obj_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/platform_if_manager_test.py delete mode 100755 scripts/automation/regression/unit_tests/functional_tests/platform_if_obj_test.py delete mode 100644 scripts/automation/regression/unit_tests/functional_tests/scapy_pkt_builder_test.py delete mode 100644 scripts/automation/regression/unit_tests/functional_tests/stl_basic_tests.py delete mode 100755 scripts/automation/regression/unit_tests/tests_exceptions.py delete mode 100755 scripts/automation/regression/unit_tests/trex_general_test.py delete mode 100755 scripts/automation/regression/unit_tests/trex_imix_test.py delete mode 100755 scripts/automation/regression/unit_tests/trex_ipv6_test.py delete mode 100755 scripts/automation/regression/unit_tests/trex_nat_test.py delete mode 100755 scripts/automation/regression/unit_tests/trex_nbar_test.py delete mode 100755 scripts/automation/regression/unit_tests/trex_rx_test.py (limited to 'scripts/automation') diff --git a/scripts/automation/regression/aggregate_results.py b/scripts/automation/regression/aggregate_results.py index 01f9ff56..ea782ccf 100755 --- a/scripts/automation/regression/aggregate_results.py +++ b/scripts/automation/regression/aggregate_results.py @@ -27,9 +27,9 @@ def is_functional_test_name(testname): #if testname.startswith(('platform_', 'misc_methods_', 'vm_', 'payload_gen_', 'pkt_builder_')): # return True #return False - if testname.startswith('unit_tests.'): - return False - return True + if testname.startswith('functional_tests.'): + return True + return False def is_good_status(text): return text in ('Successful', 'Fixed', 'Passed', 'True', 'Pass') @@ -56,19 +56,20 @@ def add_th_th(key, value): # returns
with table of tests under given category. # category - string with name of category -# hidden - bool, true =
is hidden by CSS # tests - list of tests, derived from aggregated xml report, changed a little to get easily stdout etc. +# tests_type - stateful or stateless # category_info_dir - folder to search for category info file # expanded - bool, false = outputs (stdout etc.) of tests are hidden by CSS # brief - bool, true = cut some part of tests outputs (useful for errors section with expanded flag) -def add_category_of_tests(category, tests, hidden = False, category_info_dir = None, expanded = False, brief = False): +def add_category_of_tests(category, tests, tests_type = None, category_info_dir = None, expanded = False, brief = False): is_actual_category = category not in (FUNCTIONAL_CATEGORY, ERROR_CATEGORY) - html_output = '
\n' % ('none' if hidden else 'block', category) - + category_id = '_'.join([category, tests_type]) if tests_type else category + category_name = ' '.join([category, tests_type.capitalize()]) if tests_type else category + html_output = '' if is_actual_category: html_output += '
\n' - if category_info_dir: + if category_info_dir and tests_type != 'stateless': category_info_file = '%s/report_%s.info' % (category_info_dir, category) if os.path.exists(category_info_file): with open(category_info_file) as f: @@ -80,6 +81,8 @@ def add_category_of_tests(category, tests, hidden = False, category_info_dir = N else: html_output += add_th_td('Info:', 'No info') print 'add_category_of_tests: no category info %s' % category_info_file + if tests_type: + html_output += add_th_td('Tests type:', tests_type.capitalize()) if len(tests): total_duration = 0.0 for test in tests: @@ -94,7 +97,7 @@ def add_category_of_tests(category, tests, hidden = False, category_info_dir = N if category == ERROR_CATEGORY: html_output += 'Setup\n\n\n' for test in tests: functional_test = is_functional_test_name(test.attrib['name']) @@ -103,7 +106,7 @@ def add_category_of_tests(category, tests, hidden = False, category_info_dir = N if category == ERROR_CATEGORY: test_id = ('err_' + test.attrib['classname'] + test.attrib['name']).replace('.', '_') else: - test_id = (category + test.attrib['name']).replace('.', '_') + test_id = (category_id + test.attrib['name']).replace('.', '_') if expanded: html_output += '\n' - html_output += '\n
Failed tests:' else: - html_output += '%s tests:' % category + html_output += '%s tests:' % category_name html_output += 'Final ResultTime (s)
' else: @@ -128,6 +131,9 @@ def add_category_of_tests(category, tests, hidden = False, category_info_dir = N result, result_text = test.attrib.get('result', ('', '')) if result_text: + start_index_errors_stl = result_text.find('STLError: \n******') + if start_index_errors_stl > 0: + result_text = result_text[start_index_errors_stl:].strip() # cut traceback start_index_errors = result_text.find('Exception: The test is failed, reasons:') if start_index_errors > 0: result_text = result_text[start_index_errors + 10:].strip() # cut traceback @@ -147,7 +153,7 @@ def add_category_of_tests(category, tests, hidden = False, category_info_dir = N else: html_output += 'No output
\n
' + html_output += '\n' return html_output style_css = """ @@ -292,35 +298,40 @@ if __name__ == '__main__': ##### aggregate results to 1 single tree aggregated_root = ET.Element('testsuite') + test_types = ('functional', 'stateful', 'stateless') setups = {} for job in jobs_list: - xml_file = '%s/report_%s.xml' % (args.input_dir, job) - if not os.path.exists(xml_file): - message = '%s referenced in jobs_list.info does not exist!' % xml_file + setups[job] = {} + for test_type in test_types: + xml_file = '%s/report_%s_%s.xml' % (args.input_dir, job, test_type) + if not os.path.exists(xml_file): + continue + if os.path.basename(xml_file) == os.path.basename(args.output_xmlfile): + continue + setups[job][test_type] = [] + print('Processing report: %s.%s' % (job, test_type)) + tree = ET.parse(xml_file) + root = tree.getroot() + for key, value in root.attrib.items(): + if key in aggregated_root.attrib and value.isdigit(): # sum total number of failed tests etc. + aggregated_root.attrib[key] = str(int(value) + int(aggregated_root.attrib[key])) + else: + aggregated_root.attrib[key] = value + tests = root.getchildren() + if not len(tests): # there should be tests: + message = 'No tests in xml %s' % xml_file + print message + #err.append(message) + for test in tests: + setups[job][test_type].append(test) + test.attrib['name'] = test.attrib['classname'] + '.' + test.attrib['name'] + test.attrib['classname'] = job + aggregated_root.append(test) + if not sum([len(x) for x in setups[job].values()]): + message = 'No reports from setup %s!' % job print message err.append(message) continue - if os.path.basename(xml_file) == os.path.basename(args.output_xmlfile): - continue - setups[job] = [] - print('Processing setup: %s' % job) - tree = ET.parse(xml_file) - root = tree.getroot() - for key, value in root.attrib.items(): - if key in aggregated_root.attrib and value.isdigit(): # sum total number of failed tests etc. - aggregated_root.attrib[key] = str(int(value) + int(aggregated_root.attrib[key])) - else: - aggregated_root.attrib[key] = value - tests = root.getchildren() - if not len(tests): # there should be tests: - message = 'No tests in xml %s' % xml_file - print message - err.append(message) - for test in tests: - setups[job].append(test) - test.attrib['name'] = test.attrib['classname'] + '.' + test.attrib['name'] - test.attrib['classname'] = job - aggregated_root.append(test) total_tests_count = int(aggregated_root.attrib.get('tests', 0)) error_tests_count = int(aggregated_root.attrib.get('errors', 0)) @@ -426,7 +437,7 @@ if __name__ == '__main__': if len(error_tests): html_output += '\n'.format(error = ERROR_CATEGORY) # Setups buttons - for category, tests in setups.items(): + for category in setups.keys(): category_arr.append(category) html_output += '\n' % (category_arr[-1], category) # Functional buttons @@ -436,13 +447,22 @@ if __name__ == '__main__': # Adding tests # Error tests if len(error_tests): - html_output += add_category_of_tests(ERROR_CATEGORY, error_tests, hidden=False) + html_output += '
' % ERROR_CATEGORY + html_output += add_category_of_tests(ERROR_CATEGORY, error_tests) + html_output += '
' # Setups tests for category, tests in setups.items(): - html_output += add_category_of_tests(category, tests, hidden=True, category_info_dir=args.input_dir) + html_output += '' # Functional tests if len(functional_tests): - html_output += add_category_of_tests(FUNCTIONAL_CATEGORY, functional_tests.values(), hidden=True) + html_output += '' html_output += '\n\n