예제 #1
0
 def test_vpe_rxq(self):
     vnfd_helper = VnfdHelper(self.VNFD_0)
     config_create = ConfigCreate(vnfd_helper, 2)
     config = configparser.ConfigParser()
     config_create.downlink_ports = ['xe0']
     config_create.vpe_rxq(config)
     self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
예제 #2
0
    def test_create_vpe_config(self):
        uplink_ports = [
            {
                'index': 0,
                'dpdk_port_num': 1,
                'peer_intf': {
                    'dpdk_port_num': 2,
                    'index': 3,
                },
            },
        ]

        downlink_ports = [
            {
                'index': 2,
                'dpdk_port_num': 3,
                'peer_intf': {
                    'dpdk_port_num': 0,
                    'index': 1,
                },
            },
        ]

        vnfd_helper = VnfdHelper(self.VNFD_0)
        config_create = ConfigCreate(vnfd_helper, 23)
        config_create.downlink_ports = ['xe1']
        config_create.uplink_ports = ['xe1']
        curr_path = os.path.dirname(os.path.abspath(__file__))
        vpe_cfg = "samples/vnf_samples/nsut/vpe/vpe_config"
        vnf_cfg = os.path.join(curr_path, "../../../../..", vpe_cfg)
        config_create.create_vpe_config(vnf_cfg)
        os.system("git checkout -- %s" % vnf_cfg)
예제 #3
0
    def test_get_sink_swq(self):
        vnfd_helper = VnfdHelper(self.VNFD_0)
        config_create = ConfigCreate(vnfd_helper, 2)
        config = configparser.ConfigParser()
        config.add_section('PIPELINE0')
        config.set('PIPELINE0', 'key1', 'value1')
        config.set('PIPELINE0', 'key2', 'value2 SINK')
        config.set('PIPELINE0', 'key3', 'TM value3')
        config.set('PIPELINE0', 'key4', 'value4')
        config.set('PIPELINE0', 'key5', 'the SINK value5')

        self.assertEqual(
            config_create.get_sink_swq(config, 'PIPELINE0', 'key1', 5),
            'SWQ-1')
        self.assertEqual(
            config_create.get_sink_swq(config, 'PIPELINE0', 'key2', 5),
            'SWQ-1 SINK0')
        self.assertEqual(
            config_create.get_sink_swq(config, 'PIPELINE0', 'key3', 5),
            'SWQ-1 TM5')
        config_create.sw_q += 1
        self.assertEqual(
            config_create.get_sink_swq(config, 'PIPELINE0', 'key4', 5), 'SWQ0')
        self.assertEqual(
            config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5),
            'SWQ0 SINK1')
예제 #4
0
 def test_set_priv_que_handler(self):
     topology_file = mock.Mock()
     config_tpl = mock.Mock()
     tmp_file = mock.Mock()
     vnfd_mock = VnfdHelper(self.VNFD_0)
     opnfv_vnf = samplevnf_helper.MultiPortConfig(
         topology_file, config_tpl, tmp_file, vnfd_mock)
     opnfv_vnf.socket = 0
     opnfv_vnf.start_core = 0
     opnfv_vnf.port_pair_list = [("xe0", "xe1")]
     opnfv_vnf.port_pairs = [("xe0", "xe1")]
     opnfv_vnf.txrx_pipeline = ''
     opnfv_vnf.rules = ''
     opnfv_vnf.write_parser = mock.MagicMock()
     opnfv_vnf.read_parser = mock.MagicMock()
     opnfv_vnf.read_parser.sections = mock.Mock(return_value=['MASTER'])
     opnfv_vnf.read_parser.has_option = mock.Mock(return_value=[])
     opnfv_vnf.write_parser.set = mock.Mock()
     opnfv_vnf.write_parser.add_section = mock.Mock()
     opnfv_vnf.read_parser.items = mock.MagicMock()
     opnfv_vnf.pipeline_counter = 0
     opnfv_vnf.worker_config = '1t'
     opnfv_vnf.start_core = 0
     opnfv_vnf.lb_count = 1
     result = opnfv_vnf.set_priv_que_handler()
     self.assertIsNone(result)
예제 #5
0
 def test_dpdk_port_to_link_id(self):
     vnfd_helper = VnfdHelper(self.VNFD_0)
     config_create = ConfigCreate(vnfd_helper, 2)
     self.assertEqual(config_create.dpdk_port_to_link_id_map, {
         'xe0': 0,
         'xe1': 1
     })
예제 #6
0
 def test_generate_lb_to_port_pair_mapping(self):
     topology_file = mock.Mock()
     config_tpl = mock.Mock()
     tmp_file = mock.Mock()
     vnfd_mock = VnfdHelper(self.VNFD_0)
     opnfv_vnf = samplevnf_helper.MultiPortConfig(
         topology_file, config_tpl, tmp_file, vnfd_mock)
     opnfv_vnf.socket = 0
     opnfv_vnf.start_core = 0
     opnfv_vnf.txrx_pipeline = ''
     opnfv_vnf.rules = ''
     opnfv_vnf.write_parser = mock.MagicMock()
     opnfv_vnf.read_parser = mock.MagicMock()
     opnfv_vnf.read_parser.sections = mock.Mock(return_value=['MASTER'])
     opnfv_vnf.read_parser.has_option = mock.Mock(return_value=[])
     opnfv_vnf.write_parser.set = mock.Mock()
     opnfv_vnf.write_parser.add_section = mock.Mock()
     opnfv_vnf.read_parser.items = mock.MagicMock()
     opnfv_vnf.pipeline_counter = 0
     opnfv_vnf.worker_config = '1t'
     opnfv_vnf.start_core = 0
     opnfv_vnf.lb_count = 1
     opnfv_vnf._port_pairs = samplevnf_helper.PortPairs(vnfd_mock.interfaces)
     opnfv_vnf.port_pair_list = opnfv_vnf._port_pairs.port_pair_list
     result = opnfv_vnf.generate_lb_to_port_pair_mapping()
     self.assertIsNone(result)
     result = opnfv_vnf.set_priv_to_pub_mapping()
     self.assertEqual('(0,1)', result)
예제 #7
0
    def setUp(self):
        vnfd_helper = VnfdHelper(
            TestVcmtsVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0])
        ssh_helper = mock.Mock()
        scenario_helper = mock.Mock()
        scenario_helper.options = self.OPTIONS

        self.setup_helper = vcmts_vnf.VcmtsdSetupEnvHelper(
            vnfd_helper, ssh_helper, scenario_helper)
예제 #8
0
 def test_vpe_initialize(self):
     vnfd_helper = VnfdHelper(self.VNFD_0)
     config_create = ConfigCreate(vnfd_helper, 2)
     config = configparser.ConfigParser()
     config_create.vpe_initialize(config)
     self.assertEqual(config.get('EAL', 'log_level'), '0')
     self.assertEqual(config.get('PIPELINE0', 'type'), 'MASTER')
     self.assertEqual(config.get('PIPELINE0', 'core'), 's2C0')
     self.assertEqual(config.get('MEMPOOL0', 'pool_size'), '256K')
     self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
예제 #9
0
 def test_create_vpe_config(self):
     vnfd_helper = VnfdHelper(self.VNFD_0)
     config_create = ConfigCreate(vnfd_helper, 23)
     config_create.downlink_ports = ['xe1']
     config_create.uplink_ports = ['xe1']
     curr_path = os.path.dirname(os.path.abspath(__file__))
     vpe_cfg = "samples/vnf_samples/nsut/vpe/vpe_config"
     vnf_cfg = os.path.join(curr_path, "../../../../..", vpe_cfg)
     config_create.create_vpe_config(vnf_cfg)
     os.system("git checkout -- %s" % vnf_cfg)
예제 #10
0
    def test_run_vcmtsd(self):
        us_constructed = self._build_us_parameters()

        vnfd_helper = VnfdHelper(
            TestVcmtsVNF.VNFD['vnfd:vnfd-catalog']['vnfd'][0])
        ssh_helper = mock.MagicMock()
        scenario_helper = mock.Mock()
        scenario_helper.options = self.OPTIONS

        setup_helper = vcmts_vnf.VcmtsdSetupEnvHelper(vnfd_helper, ssh_helper,
                                                      scenario_helper)

        setup_helper.run_vcmtsd('us', self.POD_CFG)
        ssh_helper.send_command.assert_called_with(us_constructed)
예제 #11
0
 def test_get_default_flows(self):
     """Check if default ACL SampleVNF CLI commands are
     generated correctly"""
     ssh_helper = mock.Mock()
     vnfd_helper = VnfdHelper({
         'vdu': [{
             'external-interface': [{
                 'virtual-interface': {
                     'local_ip': '152.16.100.19',
                     'netmask': '255.255.255.0',
                     'dpdk_port_num': 0,
                     'dst_ip': '152.16.100.20',
                     'vld_id': 'uplink_0',
                     'ifname': 'xe0',
                 },
                 'vnfd-connection-point-ref': 'xe0',
                 'name': 'xe0'
             }, {
                 'virtual-interface': {
                     'local_ip': '152.16.40.19',
                     'netmask': '255.255.255.0',
                     'dpdk_port_num': 1,
                     'dst_ip': '152.16.40.20',
                     'vld_id': 'downlink_0',
                     'ifname': 'xe1',
                 },
                 'vnfd-connection-point-ref': 'xe1',
                 'name': 'xe1'
             }]
         }]
     })
     setup_helper = AclApproxSetupEnvSetupEnvHelper(vnfd_helper, ssh_helper,
                                                    None)
     self.check_acl_commands(
         setup_helper.get_flows_config(),
         [
             # format: (<cli pattern>, <number of expected matches>)
             ("^p action add [0-9]+ accept$", 2),
             ("^p action add [0-9]+ count$", 2),
             ("^p action add [0-9]+ fwd 1$", 1),
             ("^p action add [0-9]+ fwd 0$", 1),
             ("^p acl add 1 152.16.100.0 24 152.16.40.0 24 0 65535 0 65535 0 0 [0-9]+$",
              1),
             ("^p acl add 1 152.16.40.0 24 152.16.100.0 24 0 65535 0 65535 0 0 [0-9]+$",
              1),
             ("^p acl applyruleset$", 1)
         ])
예제 #12
0
 def test_generate_script(self):
     topology_file = mock.Mock()
     config_tpl = mock.Mock()
     tmp_file = mock.Mock()
     vnfd_mock = VnfdHelper(self.VNFD_0)
     opnfv_vnf = samplevnf_helper.MultiPortConfig(
         topology_file, config_tpl, tmp_file, vnfd_mock)
     opnfv_vnf.get_config_tpl_data = mock.MagicMock()
     opnfv_vnf.socket = 0
     opnfv_vnf.start_core = 0
     opnfv_vnf.update_write_parser = mock.MagicMock()
     opnfv_vnf.generate_script_data = \
         mock.Mock(return_value={'link_config': 0, 'arp_config': '',
                                 'arp_config6': '', 'actions': '',
                                 'arp_route_tbl': '', 'arp_route_tbl6': '',
                                 'rules': ''})
     opnfv_vnf.port_pair_list = [("xe0", "xe1")]
     self.assertIsNotNone(opnfv_vnf.generate_script(self.VNFD))
     opnfv_vnf.lb_config = 'HW'
     self.assertIsNotNone(opnfv_vnf.generate_script(self.VNFD))
예제 #13
0
 def test_generate_vpe_script(self):
     vnfd_helper = VnfdHelper(self.VNFD_0)
     vpe_config_vnf = ConfigCreate(vnfd_helper, 2)
     intf = [
         {
             "name": 'xe1',
             "virtual-interface": {
                 "dst_ip": "1.1.1.1",
                 "dst_mac": "00:00:00:00:00:00:02",
             },
         },
         {
             "name": 'xe2',
             "virtual-interface": {
                 "dst_ip": "1.1.1.1",
                 "dst_mac": "00:00:00:00:00:00:02",
             },
         },
     ]
     vpe_config_vnf.downlink_ports = ['xe1']
     vpe_config_vnf.uplink_ports = ['xe2']
     result = vpe_config_vnf.generate_vpe_script(intf)
     self.assertIsInstance(result, str)
     self.assertNotEqual(result, '')
예제 #14
0
 def test___init__(self):
     vnfd_helper = VnfdHelper(self.VNFD_0)
     config_create = ConfigCreate(vnfd_helper, 2)
     self.assertEqual(config_create.uplink_ports, ['xe0'])
     self.assertEqual(config_create.downlink_ports, ['xe1'])
     self.assertEqual(config_create.socket, 2)
예제 #15
0
 def test_generate_config_data(self):
     topology_file = mock.Mock()
     config_tpl = mock.Mock()
     tmp_file = mock.Mock()
     vnfd_mock = VnfdHelper(self.VNFD_0)
     opnfv_vnf = samplevnf_helper.MultiPortConfig(
         topology_file, config_tpl, tmp_file, vnfd_mock)
     opnfv_vnf.socket = 0
     opnfv_vnf.start_core = 0
     opnfv_vnf.port_pair_list = [("xe0", "xe1")]
     opnfv_vnf.port_pairs = [("xe0", "xe1")]
     opnfv_vnf.txrx_pipeline = ''
     opnfv_vnf.rules = ''
     opnfv_vnf.write_parser = mock.MagicMock()
     opnfv_vnf.read_parser = mock.MagicMock()
     opnfv_vnf.read_parser.sections = mock.Mock(return_value=['MASTER'])
     opnfv_vnf.read_parser.has_option = mock.Mock(return_value=[])
     opnfv_vnf.write_parser.set = mock.Mock()
     opnfv_vnf.write_parser.add_section = mock.Mock()
     opnfv_vnf.read_parser.items = mock.MagicMock()
     opnfv_vnf.pipeline_counter = 0
     opnfv_vnf.worker_config = '1t'
     opnfv_vnf.start_core = 0
     opnfv_vnf.lb_count = 1
     opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     opnfv_vnf.interfaces = opnfv_vnf.vnfd['vdu'][0]['external-interface']
     opnfv_vnf.lb_to_port_pair_mapping = [0, 1]
     opnfv_vnf.lb_index = 1
     opnfv_vnf.ports_len = 1
     opnfv_vnf.pktq_out = ['1', '2']
     opnfv_vnf.prv_que_handler = 0
     opnfv_vnf.init_write_parser_template = mock.Mock()
     opnfv_vnf.arpicmp_tpl = mock.MagicMock()
     opnfv_vnf.txrx_tpl = mock.MagicMock()
     opnfv_vnf.loadb_tpl = mock.MagicMock()
     opnfv_vnf.vnf_tpl = {'public_ip_port_range': '98164810 (1,65535)',
                          'vnf_set': "(2,4,5)"}
     opnfv_vnf.generate_vnf_data = mock.Mock(return_value={})
     opnfv_vnf.update_write_parser = mock.Mock()
     result = opnfv_vnf.generate_config_data()
     self.assertIsNone(result)
     opnfv_vnf.generate_final_txrx_data = mock.Mock()
     opnfv_vnf.update_write_parser = mock.Mock()
     result = opnfv_vnf.generate_config_data()
     self.assertIsNone(result)
     opnfv_vnf.lb_to_port_pair_mapping = [0, 1]
     opnfv_vnf.lb_index = 1
     opnfv_vnf.ports_len = 1
     opnfv_vnf.pktq_out = ['1', '2']
     opnfv_vnf.prv_que_handler = 0
     opnfv_vnf.init_write_parser_template = mock.Mock()
     opnfv_vnf.arpicmp_tpl = mock.MagicMock()
     opnfv_vnf.txrx_tpl = mock.MagicMock()
     opnfv_vnf.loadb_tpl = mock.MagicMock()
     opnfv_vnf.vnf_type = 'CGNAPT'
     opnfv_vnf.update_timer = mock.Mock()
     opnfv_vnf.port_pair_list = [("xe0", "xe1"), ("xe0", "xe2")]
     opnfv_vnf.lb_to_port_pair_mapping = [0, 1]
     opnfv_vnf.generate_arpicmp_data = mock.Mock()
     result = opnfv_vnf.generate_config_data()
     self.assertIsNone(result)