def main(runtime): with open('testcases_to_run.yml') as yaml_data: testcases_to_run = yaml.safe_load(yaml_data) # provide custom job name for reporting purposes (optional) runtime.job.name = 'Base jobfile' # compute relative location of this file pwd = os.path.dirname(__file__) for testcase in testcases_to_run['testcases']: aeTestFileName = testcase testFilePath = os.path.join(pwd, 'testcases', aeTestFileName) # using run() api to run a task # # syntax # ------ # run(testscript = <testscript path/file>, # runtime = <runtime object>, # max_runtime = None, # taskid = None, # **kwargs) # # any additional arguments (**kwargs) to run() api are propagated # to AEtest as input arguments. # run this script as a task under this job # Note: # if --testbed-file is provided, the corresponding loaded 'testbed' # object will be provided to each script within this job automatically run(testscript=testFilePath)
def main(): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(test_path, 'features_example_script.py') run(testscript=testscript, uids = Not("my_skipped_testcase1", "my_skipped_testcase2"),)
def main(): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(test_path, 'connection_example_script.py') # Execute the testscript run(testscript=testscript)
def main(): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(test_path, 'long_liveview_script_2.py') # Execute the testscript run(testscript=testscript)
def main(): parser = argparse.ArgumentParser() # parser.add_argument('-user_host', type=str, # dest='hostname', # required=True, # help='We need hostname of the device we are connecting from') parser.add_argument( '-user_vm', type=str, dest='username_vm', required=False, default='pyast', help='We need user name of the device we are connecting to') parser.add_argument('-ip_vm', type=str, dest='ip_vm', required=False, default='192.168.242.44', help='We need ip of the device we are connecting to') parser.add_argument('-filename', type=str, dest='filename', required=False, default='test.test', help='We need a name for our testfile') args, sys.argv[1:] = parser.parse_known_args(sys.argv[1:]) easypy.run( testscript='test_script_03.py', # hostname=args.hostname, username_vm=args.username_vm, ip_vm=args.ip_vm, filename=args.filename)
def main(runtime): # parse custom command-line arguments custom_args = parser.parse_known_args()[0] #************************************** #* Log Levels #* #* within the job file main() section, you can set the various logger's #* loglevels for your following testscripts. This allows users to modify #* the logging output within the job file, for various modules & etc, #* without modifying testscript and libraries. # set log levels for various modules # eg, set aetest to INFO, set your library to DEBUG logging.getLogger('pyats.aetest').setLevel('INFO') logging.getLogger('libs').setLevel('DEBUG') #*************************************************************************** #* SCRIPT ARGUMENTS #* #* Aside from standard run() and infrastructure arguments, all other #* keyword arguments (*kwargs) to run() api are effectively script #* parameters. #*************************************************************************** # # run the template script # run(testscript=os.path.join(script_path, 'template_script.py'), runtime=runtime, script_arg_one='value', script_arg_two='value')
def main(runtime): '''job file entrypoint''' # run script run(testscript=os.path.join(SCRIPT_PATH, '{{ cookiecutter.project_name }}.py'), runtime=runtime)
def main(): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) testscript = os.path.join(test_path, 'demo7_trigger_within_pyats.py') # Execute the testscript run(testscript=testscript)
def main(): # run api launches a testscript as an individual task. # run('ntp_check_v2_no_rollback.py', devices=devices, ntp_server=ntp_server) run('ntp_check_v3.py', devices=devices, ntp_server=ntp_server)
def main(): # Find the examples/tests directory where the test script exists test_path = (os.path.dirname(os.path.abspath(__file__))) # Do some logic here to determine which devices to use # and pass these device names as script arguments # ... chosen_uut_device = 'VM-1' stdby_device = 'notreallyadevice' if_name = 'GigabitEthernet0/0' mtu = 1500 # # NOTE: The tabular parse will fail on vIOS platform, because # one of the colums is right-justified while the rest are # left-justified. The tabular parser only supports a # consistent justification setting for all columns in the table. # show_arp_header_fields = [ "Protocol", "Address", "Age \(min\)", "Hardware Addr", "Type", "Interface" ] show_arp_table_parse_index = [1, 5] show_arp_table_title_pattern = None run(testscript=test_path + '/parsergen_demo.py', uut_name=chosen_uut_device, stdby_name=stdby_device, if_name=if_name, mtu=mtu, show_arp_header_fields=show_arp_header_fields, show_arp_table_parse_index=show_arp_table_parse_index, show_arp_table_title_pattern=show_arp_table_title_pattern)
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "testbed_connection.py"), runtime=runtime, taskid="Device Connections", ) run( testscript=os.path.join(SCRIPT_PATH, "interface_mac.py"), runtime=runtime, taskid="Interface_MAC", ) run( testscript=os.path.join(SCRIPT_PATH, "version_check.py"), runtime=runtime, taskid="Version_Check", ) run( testscript=os.path.join(SCRIPT_PATH, "interface_errors.py"), runtime=runtime, taskid="Interface Errors", ) run( testscript=os.path.join(SCRIPT_PATH, "interface_pkts_in.py"), runtime=runtime, taskid="Interface pkts in", )
def main(runtime): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(test_path, 'large_log_script.py') # Execute the testscript run(testscript=testscript)
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "test01_testbed_connection.py"), runtime=runtime, )
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "test02_interface_errors.py"), runtime=runtime, )
def main(): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) testscript = os.path.join(test_path, 'steps_example_script.py') stepDebug = os.path.join(test_path, 'etc','stepsDebug.yaml') run(testscript=testscript, step_debug=stepDebug)
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "half_duplex.py"), runtime=runtime, taskid="Half Duplex", )
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "custom_route_test.py"), runtime=runtime, taskid="Route Checks", )
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "run_vs_start.py"), runtime=runtime, taskid="Running vs. Startup", )
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "core_ping_test.py"), runtime=runtime, taskid="Ping", )
def main(runtime): logging.getLogger().setLevel(logging.INFO) logging.getLogger("unicon").setLevel(logging.ERROR) testscript = os.path.join(_scripts_dir, "regression.py") datafile = os.path.join(_datafile_dir, "regression.yaml") run(runtime=runtime, testscript=testscript, datafile=datafile)
def main(runtime): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(test_path, 'metadata_example.py') runtime.job.release = "1.2.3" runtime.job.image = "image1" run(testscript=testscript) run(testscript=testscript)
def main(): ''' main() function is the default easypy job file entry point. ''' # find the location of the script in relation to the job file script_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(script_path, 'example_testscript.py') # execute the testscript run(testscript=testscript)
def main(runtime): """job file entrypoint""" # parse command line arguments # only parse arguments we know args, _ = parser.parse_known_args() # run script, pass arguments to script as parameters run(testscript=os.path.join(SCRIPT_PATH, "ping_test.py"), runtime=runtime, taskid="Ping", **vars(args))
def main(): # Find the examples/tests directory where the test script exists test_path = (os.path.dirname(os.path.abspath(__file__))) # Do some logic here to determine which devices to use # and pass these device names as script arguments # ... chosen_uut_device = 'VM-4' stdby_device = 'notreallyadevice' if_name = 'mgmt0' mtu = 1500 # #NOTE: Not all fields in "show interface mgmt0" can be parsed by parsergen # nontabular parser in a single pass. # The line "x broadcast packets Y bytes" is # identical in both the "Rx" and "Tx" sections, this is a known # limitation and has been documented. # # In this case, this limitation can be worked around as follows: # - First, the section titles "Rx" and "Tx" would have to be given # their own regex tags and parsed along with other fields. This # gives parsergen a hook into the particular sections of interest. # # - Then, a first-pass parse would be done to get all the fields # except the fields in the "Rx" and "Tx" section. Note that this # would only work for a command such as "show interface mgmt0" # and would not work for a command such as "show interface" # because parsergen would not know where to hook into the output # (multiple interfaces, multiple sections Rx/Tx per interface). # # - Then, a second-pass parse would be done by explicitly specifying # the "Rx" section in oper_fill (to hook into this section). The # user would then assign the generic fields just parsed to # section-specific fields. # # - Then, a third-pass parse would be done similarly against the # "Tx" section. # show_arp_header_fields= [ "Address", "Age", "MAC Address", "Interface" ] show_arp_table_parse_index = [0, 3] show_arp_table_title_pattern = None run(testscript=test_path + '/parsergen_demo.py', uut_name=chosen_uut_device, stdby_name=stdby_device, if_name=if_name, mtu=mtu, show_arp_header_fields=show_arp_header_fields, show_arp_table_parse_index=show_arp_table_parse_index, show_arp_table_title_pattern=show_arp_table_title_pattern)
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join( SCRIPT_PATH, "pyats-netmiko.py" ), # Carregando o script para validar a conexão com os devices runtime=runtime, taskid="Device Connections", ) '''
def main(runtime): logging.getLogger().setLevel(logging.INFO) logging.getLogger("src.environment.google_cloud_setup.builder").setLevel( logging.INFO) parser = argparse.ArgumentParser(description="standalone parser") parser.add_argument("--service-key", dest="service_key") args, sys.argv[1:] = parser.parse_known_args(sys.argv[1:]) testscript = os.path.join(_scripts_dir, "environment_cleanup.py") run(runtime=runtime, testscript=testscript, service_key=args.service_key)
def main(runtime): """job file entrypoint""" # run script job_dict = CustomBits().joblist() for script in job_dict: name = job_dict[script]['name'] taskid = job_dict[script]['taskid'] run( testscript=os.path.join(SCRIPT_PATH, name), runtime=runtime, taskid=taskid, )
def main(runtime): # Find the location of the script in relation to the job file test_path = os.path.dirname(os.path.abspath(__file__)) testscript = os.path.join(test_path, 'large_file_script.py') one_gb = 1024 * 1024 * 1024 # 1GB one_gb = one_gb / 10 one_gb = int(one_gb) with open(os.path.join(runtime.directory, 'large_file'), 'wb') as fout: fout.write(os.urandom(one_gb)) # Execute the testscript run(testscript=testscript)
def main(runtime): my_parser = argparse.ArgumentParser( description="Optional arguments for 'nose'-like tests") my_parser.add_argument('-o', "--operating_system", type=str, help='The OS you wish to filter on', default=None) my_parser.add_argument( '-c', "--class_name", type=str, help="The Class you wish to filter on, (not the Test File)", default=None) my_parser.add_argument( '-t', "--token", type=str, help="The Token associated with the class, such as 'asr1k'", default=None) my_parser.add_argument('-f', "--display_failed", help="Displaying only failed classes", default=None, action='store_true') my_parser.add_argument( '-n', "--number", type=int, help="The specific unittest we want to run, such as '25'", default=None) args, unknown = my_parser.parse_known_args(sys.argv[1:]) _os = args.operating_system _class = args.class_name _token = args.token _display_only_failed = args.display_failed _number = args.number run(testscript='ci_folder_parsing.py', runtime=runtime, _os=_os, _class=_class, _token=_token, _display_only_failed=_display_only_failed, _number=_number)
def main(runtime): """job file entrypoint""" # run script run( testscript=os.path.join(SCRIPT_PATH, "testbed_connection.py"), runtime=runtime, taskid="Device Connections", ) run( testscript=os.path.join(SCRIPT_PATH, "interface_errors.py"), runtime=runtime, taskid="Interface Errors", )