Example #1
0
    def run_initialize(self):
        """ Prepare test execution environment
        """
        # mount hugepages if needed
        self._mount_hugepages()

        self._logger.debug("Controllers:")
        loader = Loader()
        self._traffic_ctl = component_factory.create_traffic(
            self._traffic['traffic_type'], loader.get_trafficgen_class())

        self._vnf_ctl = component_factory.create_vnf(self.deployment,
                                                     loader.get_vnf_class(),
                                                     len(self._step_vnf_list))

        self._vnf_list = self._vnf_ctl.get_vnfs()

        self._pod_ctl = component_factory.create_pod(self.deployment,
                                                     loader.get_pod_class())

        self._pod_list = self._pod_ctl.get_pods()

        # verify enough hugepages are free to run the testcase
        if not self._check_for_enough_hugepages():
            raise RuntimeError('Not enough hugepages free to run test.')

        # perform guest related handling
        tmp_vm_count = self._vnf_ctl.get_vnfs_number() + len(
            self._step_vnf_list)
        if tmp_vm_count:
            # copy sources of l2 forwarding tools into VM shared dir if needed
            self._copy_fwd_tools_for_all_guests(tmp_vm_count)

            # in case of multi VM in parallel, set the number of streams to the number of VMs
            if self.deployment.startswith('pvpv'):
                # for each VM NIC pair we need an unique stream
                streams = 0
                for vm_nic in S.getValue('GUEST_NICS_NR')[:tmp_vm_count]:
                    streams += int(vm_nic / 2) if vm_nic > 1 else 1
                self._logger.debug(
                    "VMs with parallel connection were detected. "
                    "Thus Number of streams was set to %s", streams)
                # update streams if needed; In case of additional VNFs deployed by TestSteps
                # user can define a proper stream count manually
                if 'multistream' not in self._traffic or self._traffic[
                        'multistream'] < streams:
                    self._traffic.update({'multistream': streams})

            # OVS Vanilla requires guest VM MAC address and IPs to work
            if 'linux_bridge' in S.getValue('GUEST_LOOPBACK'):
                self._traffic['l2'].update({
                    'srcmac':
                    S.getValue('VANILLA_TGEN_PORT1_MAC'),
                    'dstmac':
                    S.getValue('VANILLA_TGEN_PORT2_MAC')
                })
                self._traffic['l3'].update({
                    'srcip':
                    S.getValue('VANILLA_TGEN_PORT1_IP'),
                    'dstip':
                    S.getValue('VANILLA_TGEN_PORT2_IP')
                })

        if self._vswitch_none:
            self._vswitch_ctl = component_factory.create_pktfwd(
                self.deployment, loader.get_pktfwd_class())
        else:
            self._vswitch_ctl = component_factory.create_vswitch(
                self.deployment, loader.get_vswitch_class(), self._traffic,
                self._tunnel_operation)

        self._collector = component_factory.create_collector(
            loader.get_collector_class(), self._results_dir, self.name)
        self._loadgen = component_factory.create_loadgen(
            loader.get_loadgen_class(), self._load_cfg)

        self._output_file = os.path.join(
            self._results_dir,
            "result_{}_{}_{}.csv".format(str(S.getValue('_TEST_INDEX')),
                                         self.name, self.deployment))

        self._step_status = {'status': True, 'details': ''}

        # Perform LLC-allocations
        if S.getValue('LLC_ALLOCATION'):
            self._rmd.setup_llc_allocation()

        self._logger.debug("Setup:")
Example #2
0
    def run(self):
        """Run the test

        All setup and teardown through controllers is included.
        """
        self._logger.debug(self.name)

        # copy sources of l2 forwarding tools into VM shared dir if needed
        self._copy_fwd_tools_for_guest()

        self._logger.debug("Controllers:")
        loader = Loader()
        traffic_ctl = component_factory.create_traffic(
            self._traffic['traffic_type'], loader.get_trafficgen_class())
        vnf_ctl = component_factory.create_vnf(self.deployment,
                                               loader.get_vnf_class())
        vswitch_ctl = component_factory.create_vswitch(
            self.deployment, loader.get_vswitch_class(), self._traffic)
        collector = component_factory.create_collector(
            loader.get_collector_class(), self._results_dir, self.name)
        loadgen = component_factory.create_loadgen(self._loadgen,
                                                   self._load_cfg)

        self._logger.debug("Setup:")
        with vswitch_ctl, loadgen:
            with vnf_ctl, collector:
                vswitch = vswitch_ctl.get_vswitch()
                # TODO BOM 15-08-07 the frame mod code assumes that the
                # physical ports are ports 1 & 2. The actual numbers
                # need to be retrived from the vSwitch and the metadata value
                # updated accordingly.
                bridge = S.getValue('VSWITCH_BRIDGE_NAME')
                if self._frame_mod == "vlan":
                    # 0x8100 => VLAN ethertype
                    self._logger.debug(" ****   VLAN   ***** ")
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '2',
                        'actions': ['push_vlan:0x8100', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '1',
                        'actions': ['push_vlan:0x8100', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                elif self._frame_mod == "mpls":
                    # 0x8847 => MPLS unicast ethertype
                    self._logger.debug(" ****   MPLS  ***** ")
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '2',
                        'actions': ['push_mpls:0x8847', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '1',
                        'actions': ['push_mpls:0x8847', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                elif self._frame_mod == "mac":
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '2',
                        'actions':
                        ['mod_dl_src:22:22:22:22:22:22', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '1',
                        'actions':
                        ['mod_dl_src:11:11:11:11:11:11', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                elif self._frame_mod == "dscp":
                    # DSCP 184d == 0x4E<<2 => 'Expedited Forwarding'
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '2',
                        'dl_type': '0x0800',
                        'actions': ['mod_nw_tos:184', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '1',
                        'dl_type': '0x0800',
                        'actions': ['mod_nw_tos:184', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                elif self._frame_mod == "ttl":
                    # 251 and 241 are the highest prime numbers < 255
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '2',
                        'dl_type': '0x0800',
                        'actions': ['mod_nw_ttl:251', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table': '2',
                        'priority': '1000',
                        'metadata': '1',
                        'dl_type': '0x0800',
                        'actions': ['mod_nw_ttl:241', 'goto_table:3']
                    }
                    vswitch.add_flow(bridge, flow)
                elif self._frame_mod == "ip_addr":
                    flow = {
                        'table':
                        '2',
                        'priority':
                        '1000',
                        'metadata':
                        '2',
                        'dl_type':
                        '0x0800',
                        'actions': [
                            'mod_nw_src:10.10.10.10', 'mod_nw_dst:20.20.20.20',
                            'goto_table:3'
                        ]
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table':
                        '2',
                        'priority':
                        '1000',
                        'metadata':
                        '1',
                        'dl_type':
                        '0x0800',
                        'actions': [
                            'mod_nw_src:20.20.20.20', 'mod_nw_dst:10.10.10.10',
                            'goto_table:3'
                        ]
                    }
                    vswitch.add_flow(bridge, flow)
                elif self._frame_mod == "ip_port":
                    # TODO BOM 15-08-27 The traffic generated is assumed
                    # to be UDP (nw_proto 17d) which is the default case but
                    # we will need to pick up the actual traffic params in use.
                    flow = {
                        'table':
                        '2',
                        'priority':
                        '1000',
                        'metadata':
                        '2',
                        'dl_type':
                        '0x0800',
                        'nw_proto':
                        '17',
                        'actions': [
                            'mod_tp_src:44444', 'mod_tp_dst:44444',
                            'goto_table:3'
                        ]
                    }
                    vswitch.add_flow(bridge, flow)
                    flow = {
                        'table':
                        '2',
                        'priority':
                        '1000',
                        'metadata':
                        '1',
                        'dl_type':
                        '0x0800',
                        'nw_proto':
                        '17',
                        'actions': [
                            'mod_tp_src:44444', 'mod_tp_dst:44444',
                            'goto_table:3'
                        ]
                    }
                    vswitch.add_flow(bridge, flow)
                else:
                    pass

                with traffic_ctl:
                    traffic_ctl.send_traffic(self._traffic)

                # dump vswitch flows before they are affected by VNF termination
                vswitch_ctl.dump_vswitch_flows()

        self._logger.debug("Traffic Results:")
        traffic_ctl.print_results()

        self._logger.debug("Collector Results:")
        collector.print_results()

        output_file = os.path.join(
            self._results_dir,
            "result_" + self.name + "_" + self.deployment + ".csv")

        tc_results = self._append_results(traffic_ctl.get_results())
        TestCase._write_result_to_file(tc_results, output_file)

        report.generate(output_file, tc_results, collector.get_results())