diff options
author | 2016-01-31 17:44:56 +0200 | |
---|---|---|
committer | 2016-01-31 17:44:56 +0200 | |
commit | 2509553bb66732dc465ec5e2d9b710f5edabd362 (patch) | |
tree | 11449d11db52ea26d8faaaa58a7c327922414cbb /scripts/automation/regression | |
parent | 3eb4112dafd4ff78ad59cc78f7a4a00fd639e56a (diff) | |
parent | 1a935f2987f2885fc8af29ed866ec0b2125ee85c (diff) |
Merge check x64 bit OS
Diffstat (limited to 'scripts/automation/regression')
-rwxr-xr-x | scripts/automation/regression/CPlatform.py | 10 | ||||
-rwxr-xr-x | scripts/automation/regression/aggregate_results.py | 24 | ||||
-rwxr-xr-x | scripts/automation/regression/hltapi_example.py | 74 | ||||
-rwxr-xr-x | scripts/automation/regression/stateless_example.py | 47 | ||||
-rwxr-xr-x | scripts/automation/regression/unit_tests/trex_general_test.py | 1 |
5 files changed, 102 insertions, 54 deletions
diff --git a/scripts/automation/regression/CPlatform.py b/scripts/automation/regression/CPlatform.py index 09c99566..6741d5c1 100755 --- a/scripts/automation/regression/CPlatform.py +++ b/scripts/automation/regression/CPlatform.py @@ -651,7 +651,7 @@ class CPlatform(object): response = self.cmd_link.run_single_command(command, timeout = 10) if CShowParser.parse_image_existence(response, img_name): self.needed_image_path = '%s:%s' % (search_drive, img_name) - print 'Found image in platform:', self.needed_image_path + print('Found image in platform:', self.needed_image_path) return True return False @@ -707,8 +707,8 @@ class CPlatform(object): progress_thread.start() response = self.cmd_link.run_single_command(cache, timeout = 900, read_until = ['\?', '\#']) - print "RESPONSE:" - print response + print("RESPONSE:") + print(response) progress_thread.join() copy_ok = CShowParser.parse_file_copy(response) @@ -865,7 +865,7 @@ class CStaticRouteConfig(object): def dump_config (self): import yaml - print yaml.dump( self.static_route_dict , default_flow_style=False) + print(yaml.dump( self.static_route_dict , default_flow_style=False)) class CNatConfig(object): @@ -901,7 +901,7 @@ class CNatConfig(object): def dump_config (self): import yaml - print yaml.dump( self.nat_dict , default_flow_style=False) + print(yaml.dump( self.nat_dict , default_flow_style=False)) if __name__ == "__main__": diff --git a/scripts/automation/regression/aggregate_results.py b/scripts/automation/regression/aggregate_results.py index 0ef3b5af..2a21b4be 100755 --- a/scripts/automation/regression/aggregate_results.py +++ b/scripts/automation/regression/aggregate_results.py @@ -17,6 +17,13 @@ ERROR_CATEGORY = 'Error' def pad_tag(text, tag): return '<%s>%s</%s>' % (tag, text, tag) +def add_color_string(text, color, is_bold = False): + string = '<font color=%s>%s</font>' % (color, text) + if is_bold: + return pad_tag(string, 'b') + return string + + def is_functional_test_name(testname): #if testname.startswith(('platform_', 'misc_methods_', 'vm_', 'payload_gen_', 'pkt_builder_')): # return True @@ -316,6 +323,17 @@ if __name__ == '__main__': 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)) + failure_tests_count = int(aggregated_root.attrib.get('failures', 0)) + skipped_tests_count = int(aggregated_root.attrib.get('skip', 0)) + passed_tests_count = total_tests_count - error_tests_count - failure_tests_count - skipped_tests_count + tests_count_string = 'Total: %s, ' % total_tests_count + tests_count_string += add_color_string('Passed: %s' % passed_tests_count, 'green', error_tests_count + failure_tests_count > 0) + ', ' + tests_count_string += add_color_string('Error: %s' % error_tests_count, 'red', error_tests_count > 0) + ', ' + tests_count_string += add_color_string('Failure: %s' % failure_tests_count, 'red', failure_tests_count > 0) + ', ' + tests_count_string += add_color_string('Skipped: %s' % skipped_tests_count, 'blue') + ##### save output xml print('Writing output file: %s' % args.output_xmlfile) @@ -371,8 +389,9 @@ if __name__ == '__main__': with open(start_time_file) as f: start_time = int(f.read()) total_time = int(time.time()) - start_time - html_output += add_th_td('Regression start:', datetime.datetime.fromtimestamp(start_time).strftime('%d/%m/%Y %H:%M:%S')) + html_output += add_th_td('Regression start:', datetime.datetime.fromtimestamp(start_time).strftime('%d/%m/%Y %H:%M')) html_output += add_th_td('Regression duration:', datetime.timedelta(seconds = total_time)) + html_output += add_th_td('Tests count:', tests_count_string) for key in trex_info_dict: if key == 'Git SHA': continue @@ -488,8 +507,9 @@ if __name__ == '__main__': with open(start_time_file) as f: start_time = int(f.read()) total_time = int(time.time()) - start_time - mail_output += add_th_td('Regression start:', datetime.datetime.fromtimestamp(start_time).strftime('%d/%m/%Y %H:%M:%S')) + mail_output += add_th_td('Regression start:', datetime.datetime.fromtimestamp(start_time).strftime('%d/%m/%Y %H:%M')) mail_output += add_th_td('Regression duration:', datetime.timedelta(seconds = total_time)) + mail_output += add_th_td('Tests count:', tests_count_string) for key in trex_info_dict: if key == 'Git SHA': continue diff --git a/scripts/automation/regression/hltapi_example.py b/scripts/automation/regression/hltapi_example.py new file mode 100755 index 00000000..750d7c2b --- /dev/null +++ b/scripts/automation/regression/hltapi_example.py @@ -0,0 +1,74 @@ +#!/router/bin/python + +import outer_packages +from client.trex_hltapi import CTRexHltApi +import traceback +import sys, time +from pprint import pprint + +def check_response(res): + if res['status'] == 0: + print 'Encountered error:\n%s' % res['log'] + sys.exit(1) + +if __name__ == "__main__": + try: + is_verbose = 2 if '--verbose' in sys.argv else 1 + hlt_client = CTRexHltApi(verbose = is_verbose) + + print 'Connecting...' + res = hlt_client.connect(device = 'csi-trex-04', port_list = [0], username = 'danklei', break_locks = True, reset = True) + check_response(res) + port_handle = res['port_handle'] + print 'Connected.' + + res = hlt_client.traffic_config('reset', port_handle = port_handle[:], ip_src_addr='1.1.1.1') + print res + check_response(res) + + res = hlt_client.traffic_config('create', port_handle = port_handle[:], ip_src_addr='1.1.1.1') + print res + check_response(res) + + + res = hlt_client.traffic_config('create', port_handle = port_handle[0], ip_src_addr='2.2.2.2') + check_response(res) + + + res = hlt_client.get_stats() + res = hlt_client.traffic_config('modify', port_handle = port_handle[0], stream_id = 1, ip_src_addr='6.6.6.6') + check_response(res) + #for stream_id, stream_data in hlt_client.get_port_streams(0).iteritems(): + # print '>>>>>>>>> %s: %s' % (stream_id, stream_data) + + + check_response(hlt_client.traffic_config('create', port_handle = port_handle[1], ip_src_addr='3.3.3.3')) + check_response(hlt_client.traffic_config('create', port_handle = port_handle[1], ip_src_addr='4.4.4.4')) + print '2' + check_response(htl_client.traffic_config('create', port_handle = port_handle[:], stream_id = 999, ip_src_addr='5.5.5.5')) + check_response(hlt_client.traffic_config('modify', port_handle = port_handle[0], stream_id = 1, ip_src_addr='6.6.6.6')) + print '3' + check_response(hlt_client.traffic_config('modify', port_handle = port_handle[1], stream_id = 1)) + +# res = hlt_client.traffic_config('create', port_handle = port_handle[1])#, ip_src_addr='2000.2.2') +# if res['status'] == 0: +# fail(res['log']) + + print 'got to running!' + check_response(hlt_client.traffic_control('run', port_handle = port_handle[1], mul = {'type': 'raw', 'op': 'abs', 'value': 10}, duration = 15)) + for i in range(0, 15): + print '.', + time.sleep(1) + + print 'stop the traffic!' + check_response(hlt_client.traffic_control('stop', port_handle = port_handle[1])) + + + except Exception as e: + print traceback.print_exc() + print e + raise + finally: + print 'Done.' + #if hlt_client.trex_client: + # res = hlt_client.teardown() diff --git a/scripts/automation/regression/stateless_example.py b/scripts/automation/regression/stateless_example.py deleted file mode 100755 index 93fb2703..00000000 --- a/scripts/automation/regression/stateless_example.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/router/bin/python - -import outer_packages -from client.trex_hltapi import CTRexHltApi -import traceback -import sys, time - -def fail(reason): - print 'Encountered error:\n%s' % reason - sys.exit(1) - -if __name__ == "__main__": - port_list = [0, 1] - #port_list = 1 - try: - print 'init' - hlt_client = CTRexHltApi() - - print 'connecting' - con = hlt_client.connect("localhost", port_list, "danklei", sync_port = 4501, async_port = 4500, break_locks=True, reset=True)#, port=6666) - print 'connected?', hlt_client.connected - if not hlt_client.trex_client or not hlt_client.connected: - fail(con['log']) - print 'connect result:', con - - res = hlt_client.traffic_config("create", 0)#, ip_src_addr="2000.2.2") - print 'traffic_config result:', res - - res = hlt_client.traffic_config("create", 1)#, ip_src_addr="2000.2.2") - print res - print 'got to running!' - #sys.exit(0) - res = hlt_client.traffic_control("run", 1, mul = {'type': 'raw', 'op': 'abs', 'value': 1}, duration = 15)#, ip_src_addr="2000.2.2") - print res - time.sleep(2) - res = hlt_client.traffic_control("stop", 1)#, ip_src_addr="2000.2.2") - print res - - - - except Exception as e: - raise - finally: - #pass - if hlt_client.trex_client: - res = hlt_client.cleanup_session(port_list) - print res diff --git a/scripts/automation/regression/unit_tests/trex_general_test.py b/scripts/automation/regression/unit_tests/trex_general_test.py index 9bcccaab..170baf84 100755 --- a/scripts/automation/regression/unit_tests/trex_general_test.py +++ b/scripts/automation/regression/unit_tests/trex_general_test.py @@ -54,6 +54,7 @@ class CTRexScenario(): router_image = None trex_version = None scripts_path = None + benchmark = None report_dir = 'reports' # logger = None |