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('ats.aetest').setLevel('INFO')
    logging.getLogger('testscripts.libs').setLevel('DEBUG')

    if custom_args.only_global:
        # only run Test{{ cookiecutter.testcase_class}}

        script_path = os.path.join(os.path.dirname(__file__), 'testscripts')
        testscript = os.path.join(script_path,
                                  'Test{{ cookiecutter.testcase_class}}.py')
        run(testscript=testscript,
            datafile='data/datafile.yaml',
            runtime=runtime,
            uids=Or('{{ cookiecutter.testcase_class }}'))

    # limit tests to a specific group
    elif custom_args.group:
        for script in get_testscripts():
            run(testscript=script,
                runtime=runtime,
                labels=labels,
                routers=routers,
                links=links,
                tgns=tgns,
                groups = Or(custom_args.group),
                **vars(custom_args))

    else:

        for script in get_testscripts():
            run(testscript=script,
                runtime=runtime,
                labels=labels,
                routers=routers,
                links=links,
                tgns=tgns,
                **vars(custom_args))
Ejemplo n.º 2
0
    def genie_run_trigger_alias_context(self, name, device, alias, context):
        '''Call any trigger defined in the trigger datafile on device
        using a specific alias with a context (cli, xml, yang, ...)
        '''

        if not self.loaded_yamls:
            self.builtin.fail("Could not load the yaml files - Make sure you "
                              "have an uut device")

        # Set the variables to find the trigger
        device_handle = self._search_device(device)

        self.testscript.trigger_uids = Or(name + '$')
        self.testscript.trigger_groups = None
        self.testscript.triggers = deepcopy(self.trigger_datafile)
        self.testscript.verifications = None

        # Modify the parameters to include context
        self._add_abstraction_datafiles(datafile=self.testscript.triggers,
                                        name=name,
                                        context=context,
                                        device=device_handle)

        self._run_genie_trigger_verification(name=name,
                                             alias=alias,
                                             device=device,
                                             context=context)
Ejemplo n.º 3
0
    def genie_run_verification_alias_context(self, name, device, alias,
                                             context):
        '''Call any verification defined in the verification datafile
           on device using a specific alias with a context (cli, xml, yang, ...)
        '''
        # Set the variables to find the verification
        self.testscript.verification_uids = Or(name)
        self.testscript.verification_groups = None
        self.testscript.verifications = deepcopy(self.verification_datafile)
        self.testscript.triggers = None

        # Modify the parameters to include context
        if name in self.testscript.verifications:
            # Add new parameters named context
            # No need to revert, as a deepcopy was taken, and after discovery
            # nothing is done with the datafiles after
            if 'devices' in self.testscript.verifications[name]:
                # For each device add context
                for dev in self.testscript.verifications[name]['devices']:
                    if self.testscript.verifications[name]['devices'][dev] == \
                       'None':
                        self.testscript.verifications[name]['devices'][
                            dev] = {}
                    self.testscript.verifications[name]['devices'][dev]\
                                                 ['context'] = context

        self._run_genie_trigger_verification(name=name,
                                             alias=alias,
                                             device=device,
                                             context=context)
Ejemplo n.º 4
0
def main():
    """Segment routing script run"""
    run(testscript='/ws/mastarke-sjc/my_local_git/segment_routing/sr.py',
    uids=Or('common_setup',
            And('Sr_te_path_sr'),
            And('Sr_te_path_dynamic_sr'),
            And('Sr_te_path_exp_node_sid'),
            And('Sr_te_path_exp_adj_sid_via_main_intf'),
            And('Sr_te_path_exp_adj_sid_via_sub_intf'),
            And('Sr_te_path_exp_adj_sid_via_bundle_intf'),
            And('Rsp_failover_fail_back'),
            And('Process_restarts_rsp'),
            And('Process_restarts_lc'),
            And('Lc_reload'),
            And('Interface_flap_tunnel'),
            And('Remove_add_config_loopback'),
            And('Remove_add_config_l2vpn'),
            And('Remove_add_config_igp'),
            And('Interface_flap_main_interface'),
            And('Interface_flap_bundle'),
            And('Interface_flap_bundle_members'),
            And('Bundle_add_remove_members'),
            And('Ti_lfa_path_switch'),
            And('Prefered_path'),
            And('Prefered_path_change_tunnel_config'),
            And('Prefered_path_with_flow_label'),
            And('Sr_flow_label_64_Ecmp'),
            And('L2vpn_control_word'),
            Not('.*'),
            'common_cleanup')
        )
Ejemplo n.º 5
0
    def test_genie_testbed_2(self):

        pyats_testbed = ats.topology.loader.load(os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'pyats_topology1.yaml'))

        self.assertCountEqual(pyats_testbed.devices.keys(), [
            'router1',
            'router2',
            'router3',
            'router4',
            'ixia',
            ])

        genie_testbed = genie.conf.base.loader.load(os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'pyats_topology1.yaml'))

        self.assertCountEqual(
                genie_testbed.devices.keys(),
                pyats_testbed.devices.keys())

        self.assertTrue(len(genie_testbed.find_devices()) ==
            len(pyats_testbed.devices.values()))

        self.assertCountEqual(
                genie_testbed.find_devices(),
                genie_testbed.devices.values())

        router1 = genie_testbed.devices['router1']
        self.assertEqual(router1.name, 'router1')
        self.assertEqual(router1.os, 'iosxr')

        self.assertCountEqual(
                genie_testbed.find_devices(),
                genie_testbed.devices.values())

        self.assertIn(
                router1,
                genie_testbed.find_devices(os=Or('iosxr')))

        self.assertSetEqual(
                set([device.os for device in genie_testbed.find_devices(os=Or('iosxr'))]),
                set(['iosxr']))
Ejemplo n.º 6
0
def main():
    """Segment routing script run"""
    run(testscript='/ws/mastarke-sjc/my_local_git/segment_routing/sr.py',
        uids=Or('common_setup', And('SanityTraffic'), And('SrLoopback'),
                And('SrFeatureInteraction'), And('Rsp_failover_fail_back'),
                And('Process_restarts_rsp'), And('Process_restarts_lc'),
                And('Lc_reload'), And('Remove_add_config_loopback'),
                And('Remove_add_config_igp'),
                And('Interface_flap_main_interface'),
                And('Interface_flap_bundle'),
                And('Interface_flap_bundle_members'),
                And('Bundle_add_remove_members'), And('Sr_Ecmp'), Not('.*'),
                'common_cleanup'))
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--local_users',
                        dest='expected_local_users',
                        nargs='+',
                        default=['cisco'])
    args, unknown = parser.parse_known_args()
    # Find the location of the script in relation to the job file
    local_user_check = os.path.join('./local_user_check.py')
    # Execute the testscript
    run(testscript=local_user_check,
        taskid="Local User Check",
        **vars(args),
        groups=Or('golden_config', 'bar'))
Ejemplo n.º 8
0
    def genie_run_verification_alias_context(self, name, device, alias,
                                             context):
        '''Call any verification defined in the verification datafile
           on device using a specific alias with a context (cli, xml, yang, ...)
        '''
        if not self.loaded_yamls:
            self.builtin.fail("Could not load the yaml files - Make sure you "
                              "have an uut device")

        # Set the variables to find the verification
        self.testscript.verification_uids = Or(name + '$')
        self.testscript.verification_groups = None
        self.testscript.verifications = deepcopy(self.verification_datafile)
        self.testscript.triggers = None

        # Modify the parameters to include context
        if name in self.testscript.verifications:
            # Add new parameters named context
            # No need to revert, as a deepcopy was taken, and after discovery
            # nothing is done with the datafiles after
            if 'devices' in self.testscript.verifications[name]:
                # For each device add context
                for dev in self.testscript.verifications[name]['devices']:
                    # To shorten the variable
                    verf = self.testscript.verifications[name]
                    if 'devices_attributes' not in verf or\
                        verf['devices_attributes'][dev] == 'None':
                        verf.setdefault('devices_attributes', {})
                        verf['devices_attributes'].setdefault(dev, {})
                        verf['devices_attributes'][dev] = {}

                    self.testscript.verifications[name]\
                                ['devices_attributes'][dev]['context'] = context

        self._run_genie_trigger_verification(name=name,
                                             alias=alias,
                                             device=device,
                                             context=context)
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--trigger', dest='trigger', default=None)
    # parser.add_argument('--inventory',
    #                     dest='inventory',
    #                     default='inventory/test.yaml')
    args, unknown = parser.parse_known_args()

    test_path = os.path.dirname(os.path.abspath(__file__))
    # print(args)

    # mapping_datafile is mandatory
    # trigger_uids limit which test to execute

    if args.trigger:
        trigger = args.trigger
    else:
        trigger = RANDOM_TRIGGER

    gRun(mapping_datafile=os.path.join(test_path, 'mapping_datafile.yaml'),
         pts_datafile='pts_datafile.yaml',
         pts_features=['ospf', 'bgp'],
         trigger_uids=Or(trigger))
Ejemplo n.º 10
0
    def genie_run_trigger_alias_context(self, name, device, alias, context):
        '''Call any trigger defined in the trigger datafile on device
        using a specific alias with a context (cli, xml, yang, ...)
        '''

        # Set the variables to find the trigger
        device_handle = self._search_device(device)

        self.testscript.trigger_uids = Or(name)
        self.testscript.trigger_groups = None
        self.testscript.triggers = deepcopy(self.trigger_datafile)
        self.testscript.verifications = None

        # Modify the parameters to include context
        self._add_abstraction_datafiles(datafile=self.testscript.triggers,
                                        name=name,
                                        context=context,
                                        device=device_handle)

        self._run_genie_trigger_verification(name=name,
                                             alias=alias,
                                             device=device,
                                             context=context)
Ejemplo n.º 11
0
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('ats.aetest').setLevel('INFO')
    logging.getLogger('libs').setLevel('DEBUG')
    logging.getLogger('ats.aetest').setLevel('INFO')
    logging.getLogger('libs').setLevel('DEBUG')

    #
    # run a test script and provide some script argumentss
    # this will overwrite the default values set in your script.
    # also showing passing topology information arguments into script
    #
    run(testscript=os.path.join(script_path, 'base_example.py'),
        runtime=runtime,
        parameter_A='jobfile value A',
        labels=labels,
        routers=routers,
        links=links,
        tgns=tgns)

    #
    # run with a specific router
    #
    run(testscript=os.path.join(script_path, 'base_example.py'),
        runtime=runtime,
        parameter_A='jobfile value A',
        labels=labels2,
        routers=routers2,
        links=links,
        tgns=tgns)

    #
    # run the variant script with parsed custom_args and loglevel
    #
    run(testscript=os.path.join(script_path, 'variant_example.py'),
        runtime=runtime,
        loglevel=loglevel,
        **vars(custom_args))

    #**************************************
    #* Run by ID
    #*
    #*  use 'uids' feature to specify which test section uids should run.
    #*  'uids' accepts a callable argument. In this example, instead of writing
    #*  a callable function, we'll leverage datastructure.logic classes.
    #*

    #
    # eg, only run testcases with 'Testcase' in the name,
    # but not LoopingTestcase
    #
    run(testscript=os.path.join(script_path, 'base_example.py'),
        runtime=runtime,
        uids=And('.*Testcase.*', Not('ExampleTestcase')))

    #**************************************
    #* Run by Groups
    #*
    #*  use 'groups' feature to specify which testcase groups should run.
    #*  'groups' accepts a callable argument. In this example, we'll also be
    #*  using datastructure.logic classes.
    #*

    #
    # eg, only run testcases in group_A and group_C
    #
    run(testscript=os.path.join(script_path, 'variant_example.py'),
        runtime=runtime,
        groups=Or('group_A', 'group_C'))