Ejemplo n.º 1
0
 def test_vnf_execute(self, ssh):
     test_base.mock_ssh(ssh)
     vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
     vpe_approx_vnf.q_in = mock.MagicMock()
     vpe_approx_vnf.q_out = mock.MagicMock()
     vpe_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
     self.assertEqual(vpe_approx_vnf.vnf_execute("quit", 0), '')
Ejemplo n.º 2
0
    def test__build_pipeline_kwargs(self, ssh, mock_get_ctx, *args):
        mock_ssh(ssh)

        nfvi_context = mock.Mock()
        nfvi_context.attrs = {'nfvi_type': "baremetal"}
        mock_get_ctx.return_value = nfvi_context

        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
        udp_replay_approx_vnf.setup_helper.bound_pci = [
            '0000:00:0.1', '0000:00:0.3'
        ]
        udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
        udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(
            return_value="tool_path")
        udp_replay_approx_vnf.scenario_helper = ScenarioHelper(name='vnf__1')
        udp_replay_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG

        udp_replay_approx_vnf._build_pipeline_kwargs()

        self.assertEqual(
            udp_replay_approx_vnf.pipeline_kwargs, {
                'config': '(0,0,1),(1,0,2)',
                'cpu_mask_hex': '0x7',
                'hw_csum': '',
                'port_mask_hex': '0x3',
                'tool_path': 'tool_path',
                'whitelist': '0000:00:0.1 -w 0000:00:0.3'
            })
Ejemplo n.º 3
0
    def test_run_vpe(self, ssh):
        test_base.mock_ssh(ssh)

        vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
        vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
        vpe_approx_vnf.vnf_cfg = {
            'lb_config': 'SW',
            'lb_count': 1,
            'worker_config': '1C/1T',
            'worker_threads': 1,
        }
        vpe_approx_vnf.scenario_helper.scenario_cfg = {
            'options': {
                NAME: {
                    'traffic_type': '4',
                    'topology': 'nsb_test_case.yaml',
                    'vnf_config': 'vpe_config',
                }
            }
        }
        vpe_approx_vnf.topology = "nsb_test_case.yaml"
        vpe_approx_vnf.nfvi_type = "baremetal"
        vpe_approx_vnf._provide_config_file = mock.Mock()
        vpe_approx_vnf._build_config = mock.MagicMock()

        self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
        self.assertIsInstance(vpe_approx_vnf.ssh_helper, mock.Mock)
        self.assertIsNone(vpe_approx_vnf._run())
Ejemplo n.º 4
0
    def test_collect_kpi(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD_0
        get_stats_ret_val = \
            "stats\r\r\n\r\nUDP_Replay stats:\r\n--------------\r\n" \
            "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\
            "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \
            "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>"
        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
        udp_replay_approx_vnf.scenario_helper.scenario_cfg = {
            'nodes': {
                udp_replay_approx_vnf.name: "mock"
            }
        }
        udp_replay_approx_vnf.q_in = mock.MagicMock()
        udp_replay_approx_vnf.q_out = mock.MagicMock()
        udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
        udp_replay_approx_vnf.get_stats = mock.Mock(
            return_value=get_stats_ret_val)
        result = {
            'physical_node': 'mock_node',
            'collect_stats': {},
            'packets_dropped': 0,
            'packets_fwd': 14748451,
            'packets_in': 14748472
        }
        self.assertEqual(result, udp_replay_approx_vnf.collect_kpi())
Ejemplo n.º 5
0
    def test_collect_kpi(self, ssh, *args):
        mock_ssh(ssh)
        prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
        prox_traffic_gen.scenario_helper.scenario_cfg = {
            'nodes': {prox_traffic_gen.name: "mock"}
        }
        prox_traffic_gen._vnf_wrapper.resource_helper.resource = mock.MagicMock(
            **{"self.check_if_system_agent_running.return_value": [False]})

        vnfd_helper = mock.MagicMock()
        vnfd_helper.ports_iter.return_value = [('xe0', 0), ('xe1', 1)]
        prox_traffic_gen.resource_helper.vnfd_helper = vnfd_helper

        prox_traffic_gen._vnf_wrapper.resource_helper.client = mock.MagicMock()
        prox_traffic_gen._vnf_wrapper.resource_helper.client.multi_port_stats.return_value = \
            [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5]]
        prox_traffic_gen._vnf_wrapper.resource_helper.client.multi_port_stats_diff.return_value = \
            [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]
        prox_traffic_gen._vnf_wrapper.resource_helper.client.\
            multi_port_stats_tuple.return_value = \
                {"xe0": {"in_packets": 1, "out_packets": 2}}

        prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="")
        expected = {
            'collect_stats': {'live_stats': {'xe0': {'in_packets': 1, 'out_packets': 2}}},
            'physical_node': 'mock_node'
        }
        result = prox_traffic_gen.collect_kpi()
        self.assertDictEqual(result, expected)
Ejemplo n.º 6
0
    def test__vnf_up_post(self, ssh, *args):
        mock_ssh(ssh)
        prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
        prox_approx_vnf.resource_helper = resource_helper = mock.Mock()

        prox_approx_vnf._vnf_up_post()
        resource_helper.up_post.assert_called_once()
Ejemplo n.º 7
0
 def test_collect_kpi(self, ssh, *args):
     mock_ssh(ssh)
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     vfw_approx_vnf = FWApproxVnf(name, vnfd)
     vfw_approx_vnf.scenario_helper.scenario_cfg = {
         'nodes': {
             vfw_approx_vnf.name: "mock"
         }
     }
     vfw_approx_vnf.q_in = mock.MagicMock()
     vfw_approx_vnf.q_out = mock.MagicMock()
     vfw_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
     vfw_approx_vnf.resource = mock.Mock(autospec=ResourceProfile)
     vfw_approx_vnf.resource_helper = mock.MagicMock(
         **{'collect_kpi.return_value': {
             "core": {}
         }})
     vfw_approx_vnf.vnf_execute = mock.Mock(return_value=self.STATS)
     result = {
         'physical_node': 'mock_node',
         'packets_dropped': 0,
         'packets_fwd': 6007180,
         'packets_in': 6007180,
         'collect_stats': {
             'core': {}
         },
     }
     self.assertEqual(result, vfw_approx_vnf.collect_kpi())
Ejemplo n.º 8
0
    def test_collect_kpi_sa_running(self, ssh, *args):
        test_base.mock_ssh(ssh)

        resource = mock.Mock(autospec=ResourceProfile)
        resource.check_if_system_agent_running.return_value = 0, '1234'
        resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}

        vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
        vpe_approx_vnf.scenario_helper.scenario_cfg = {
            'nodes': {
                vpe_approx_vnf.name: "mock"
            }
        }
        vpe_approx_vnf.q_in = mock.MagicMock()
        vpe_approx_vnf.q_out = mock.MagicMock()
        vpe_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        vpe_approx_vnf.resource_helper.resource = resource

        expected = {
            'physical_node': 'mock_node',
            'pkt_in_down_stream': 0,
            'pkt_in_up_stream': 0,
            'pkt_drop_down_stream': 0,
            'pkt_drop_up_stream': 0,
            'collect_stats': {
                'core': {
                    'foo': 234
                }
            },
        }
        self.assertEqual(vpe_approx_vnf.collect_kpi(), expected)
Ejemplo n.º 9
0
    def test_collect_kpi(self, ssh, *args):
        mock_ssh(ssh)

        resource_helper = mock.MagicMock()
        resource_helper.execute.return_value = [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5],
                                                [2, 1, 2, 3, 4, 5], [3, 1, 2, 3, 4, 5]]
        resource_helper.collect_collectd_kpi.return_value = {'core': {'result': 234}}

        prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id')
        prox_approx_vnf.scenario_helper.scenario_cfg = {
            'nodes': {prox_approx_vnf.name: "mock"}
        }
        prox_approx_vnf.resource_helper = resource_helper

        expected = {
            'physical_node': 'mock_node',
            'packets_in': 4,
            'packets_dropped': 4,
            'packets_fwd': 8,
            'collect_stats': {'core': {'result': 234}},
        }
        result = prox_approx_vnf.collect_kpi()
        self.assertEqual(result['packets_in'], expected['packets_in'])
        self.assertEqual(result['packets_dropped'], expected['packets_dropped'])
        self.assertEqual(result['packets_fwd'], expected['packets_fwd'])
        self.assertNotEqual(result['packets_fwd'], 0)
        self.assertNotEqual(result['packets_fwd'], 0)
Ejemplo n.º 10
0
    def test_run_router(self, ssh):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        router_vnf = RouterVNF(name, vnfd)
        router_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
        router_vnf._run()
        router_vnf.ssh_helper.drop_connection.assert_called_once()
Ejemplo n.º 11
0
    def test_terminate(self, ssh, _):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        router_vnf = RouterVNF(name, vnfd)
        router_vnf._vnf_process = mock.MagicMock()
        router_vnf._vnf_process.terminate = mock.Mock()
        self.assertIsNone(router_vnf.terminate())
Ejemplo n.º 12
0
    def test_terminate(self, ssh):
        test_base.mock_ssh(ssh)

        vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
        vpe_approx_vnf._vnf_process = mock.MagicMock()
        vpe_approx_vnf._resource_collect_stop = mock.Mock()
        vpe_approx_vnf.resource_helper = mock.MagicMock()

        self.assertIsNone(vpe_approx_vnf.terminate())
Ejemplo n.º 13
0
 def test_wait_for_instantiate_panic(self, ssh, *args):
     mock_ssh(ssh, exec_result=(1, "", ""))
     prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id')
     prox_approx_vnf._vnf_process = mock.MagicMock(**{"is_alive.return_value": True})
     prox_approx_vnf._run_prox = mock.Mock(return_value=0)
     prox_approx_vnf.WAIT_TIME = 0
     prox_approx_vnf.q_out.put("PANIC")
     with self.assertRaises(RuntimeError):
         prox_approx_vnf.wait_for_instantiate()
Ejemplo n.º 14
0
    def test_instantiate(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        router_vnf = RouterVNF(name, vnfd)
        router_vnf.WAIT_TIME = 0
        router_vnf.INTERFACE_WAIT = 0
        self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
        self.assertIsNone(router_vnf.instantiate(self.scenario_cfg,
                                                 self.context_cfg))
Ejemplo n.º 15
0
    def test_vnf_execute_command(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        vfw_approx_vnf = FWApproxVnf(name, vnfd)
        vfw_approx_vnf.q_in = mock.MagicMock()
        vfw_approx_vnf.q_out = mock.MagicMock()
        vfw_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        cmd = "quit"
        self.assertEqual(vfw_approx_vnf.vnf_execute(cmd), "")
Ejemplo n.º 16
0
    def test_get_stats(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        vfw_approx_vnf = FWApproxVnf(name, vnfd)
        vfw_approx_vnf.q_in = mock.MagicMock()
        vfw_approx_vnf.q_out = mock.MagicMock()
        vfw_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        vfw_approx_vnf.vnf_execute = mock.Mock(return_value=self.STATS)
        self.assertEqual(self.STATS, vfw_approx_vnf.get_stats())
Ejemplo n.º 17
0
    def test_vnf_execute_command(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd, 'task_id')
        acl_approx_vnf.q_in = mock.MagicMock()
        acl_approx_vnf.q_out = mock.MagicMock()
        acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        cmd = "quit"
        self.assertEqual("", acl_approx_vnf.vnf_execute(cmd))
Ejemplo n.º 18
0
    def test_terminate(self, ssh, *args):
        mock_ssh(ssh)
        prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
        prox_approx_vnf._vnf_process = mock.MagicMock()
        prox_approx_vnf._vnf_process.terminate = mock.Mock()
        prox_approx_vnf.ssh_helper = mock.MagicMock()
        prox_approx_vnf.setup_helper = mock.Mock()
        prox_approx_vnf.resource_helper = mock.MagicMock()

        self.assertIsNone(prox_approx_vnf.terminate())
Ejemplo n.º 19
0
    def test_get_stats(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
        acl_approx_vnf.q_in = mock.MagicMock()
        acl_approx_vnf.q_out = mock.MagicMock()
        acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        result = "ACL TOTAL: pkts_processed: 100, pkts_drop: 0, spkts_received: 100"
        acl_approx_vnf.vnf_execute = mock.Mock(return_value=result)
        self.assertEqual(result, acl_approx_vnf.get_stats())
Ejemplo n.º 20
0
    def test_run_udp_replay(self, ssh, *args):
        mock_ssh(ssh)

        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
        udp_replay_approx_vnf._build_config = mock.MagicMock()
        udp_replay_approx_vnf.queue_wrapper = mock.MagicMock()
        udp_replay_approx_vnf.scenario_helper = mock.MagicMock()

        udp_replay_approx_vnf._run()

        udp_replay_approx_vnf.ssh_helper.run.assert_called_once()
Ejemplo n.º 21
0
    def test_terminate(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
        acl_approx_vnf._vnf_process = mock.MagicMock()
        acl_approx_vnf._vnf_process.terminate = mock.Mock()
        acl_approx_vnf.used_drivers = {"01:01.0": "i40e", "01:01.1": "i40e"}
        acl_approx_vnf.vnf_execute = mock.MagicMock()
        acl_approx_vnf.dpdk_devbind = "dpdk-devbind.py"
        acl_approx_vnf._resource_collect_stop = mock.Mock()
        self.assertIsNone(acl_approx_vnf.terminate())
Ejemplo n.º 22
0
    def bad_test_instantiate(self, ssh, mock_cpu_sys_cores, *args):
        mock_ssh(ssh)

        mock_cpu_sys_cores.get_core_socket.return_value = {'0': '01234'}

        mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
        mock_traffic_profile.get_traffic_definition.return_value = "64"
        mock_traffic_profile.params = self.TRAFFIC_PROFILE

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        prox_traffic_gen = ProxTrafficGen(NAME, vnfd, 'task_id')
        ssh_helper = mock.MagicMock(**{
            "execute.return_value": (0, "", ""),
            "bin_path": ""
        })
        prox_traffic_gen.ssh_helper = ssh_helper
        prox_traffic_gen.setup_helper.dpdk_bind_helper.ssh_helper = ssh_helper
        prox_traffic_gen.setup_helper._setup_resources = mock.MagicMock()
        prox_traffic_gen.setup_hugepages = mock.MagicMock()
        prox_traffic_gen.generate_prox_config_file = mock.MagicMock()
        prox_traffic_gen.upload_prox_config = mock.MagicMock()
        prox_traffic_gen.setup_helper._find_used_drivers = mock.MagicMock()
        prox_traffic_gen.setup_helper.used_drivers = {}
        prox_traffic_gen.setup_helper.bound_pci = []
        prox_traffic_gen._start_server = mock.Mock(return_value=0)
        prox_traffic_gen._tg_process = mock.MagicMock()
        prox_traffic_gen._tg_process.start = mock.Mock()
        prox_traffic_gen._tg_process.exitcode = 0
        prox_traffic_gen._tg_process._is_alive = mock.Mock(return_value=1)
        prox_traffic_gen.ssh_helper = mock.MagicMock()
        prox_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
        scenario_cfg = {
            'task_path': '',
            'options': {
                'tg__1': {
                    'prox_args': {
                        '-e': '',
                        '-t': ''
                    },
                    'prox_config': 'configs/l3-gen-2.cfg',
                    'prox_path': '/root/dppd-PROX-v035/build/prox'
                },
                'vnf__1': {
                    'prox_args': {
                        '-t': ''
                    },
                    'prox_config': 'configs/l3-swap-2.cfg',
                    'prox_path': '/root/dppd-PROX-v035/build/prox'
                }
            }
        }
        prox_traffic_gen.instantiate(scenario_cfg, {})
Ejemplo n.º 23
0
    def test_instantiate(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        vfw_approx_vnf = FWApproxVnf(name, vnfd)
        vfw_approx_vnf.ssh_helper = ssh
        vfw_approx_vnf.deploy_helper = mock.MagicMock()
        vfw_approx_vnf.resource_helper = mock.MagicMock()
        vfw_approx_vnf._build_config = mock.MagicMock()
        self.scenario_cfg['vnf_options'] = {'acl': {'cfg': "", 'rules': ""}}
        self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
        self.assertIsNone(
            vfw_approx_vnf.instantiate(self.scenario_cfg, self.context_cfg))
Ejemplo n.º 24
0
 def test_collect_kpi(self, ssh, *args):
     mock_ssh(ssh)
     prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
     prox_traffic_gen.scenario_helper.scenario_cfg = {
         'nodes': {
             prox_traffic_gen.name: "mock"
         }
     }
     prox_traffic_gen._vnf_wrapper.resource_helper.resource = mock.MagicMock(
         **{"self.check_if_system_agent_running.return_value": [False]})
     prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="")
     expected = {'collect_stats': {}, 'physical_node': 'mock_node'}
     self.assertEqual(prox_traffic_gen.collect_kpi(), expected)
Ejemplo n.º 25
0
    def test_get_stats(self, ssh, *args):
        mock_ssh(ssh)

        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
        udp_replay_approx_vnf.q_in = mock.MagicMock()
        udp_replay_approx_vnf.q_out = mock.MagicMock()
        udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        mock_result = \
            "CG-NAPT(.*\n)*Received 100, Missed 0, Dropped 0,Translated 100,ingress"

        udp_replay_approx_vnf.vnf_execute = mock.Mock(return_value=mock_result)

        self.assertEqual(mock_result, udp_replay_approx_vnf.get_stats())
Ejemplo n.º 26
0
    def test_instantiate(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
        acl_approx_vnf.deploy_helper = mock.MagicMock()
        acl_approx_vnf.resource_helper = mock.MagicMock()
        acl_approx_vnf._build_config = mock.MagicMock()
        self.scenario_cfg['vnf_options'] = {'acl': {'cfg': "", 'rules': ""}}
        acl_approx_vnf.q_out.put("pipeline>")
        acl_approx_vnf.WAIT_TIME = 0
        self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
        self.assertIsNone(
            acl_approx_vnf.instantiate(self.scenario_cfg, self.context_cfg))
Ejemplo n.º 27
0
 def test_terminate(self, ssh, *args):
     mock_ssh(ssh)
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     prox_traffic_gen = ProxTrafficGen(NAME, vnfd, 'task_id')
     prox_traffic_gen._terminated = mock.MagicMock()
     prox_traffic_gen._traffic_process = mock.MagicMock()
     prox_traffic_gen._traffic_process.terminate = mock.Mock()
     prox_traffic_gen.ssh_helper = mock.MagicMock()
     prox_traffic_gen.setup_helper = mock.MagicMock()
     prox_traffic_gen.resource_helper = mock.MagicMock()
     prox_traffic_gen._vnf_wrapper.setup_helper = mock.MagicMock()
     prox_traffic_gen._vnf_wrapper._vnf_process = mock.MagicMock()
     prox_traffic_gen._vnf_wrapper.resource_helper = mock.MagicMock()
     self.assertIsNone(prox_traffic_gen.terminate())
Ejemplo n.º 28
0
    def test_vnf_execute_oserror(self, ssh, *args):
        mock_ssh(ssh)
        prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
        prox_approx_vnf.resource_helper = resource_helper = mock.Mock()

        resource_helper.execute.side_effect = OSError(errno.EPIPE, "")
        prox_approx_vnf.vnf_execute("", _ignore_errors=True)

        resource_helper.execute.side_effect = OSError(errno.ESHUTDOWN, "")
        prox_approx_vnf.vnf_execute("", _ignore_errors=True)

        resource_helper.execute.side_effect = OSError(errno.EADDRINUSE, "")
        with self.assertRaises(OSError):
            prox_approx_vnf.vnf_execute("", _ignore_errors=True)
Ejemplo n.º 29
0
    def test__bind_device_kernel_with_failure(self, ssh):
        mock_ssh(ssh)

        execute_result_data = [
            (1, 'bad stdout messages', 'error messages'),
            (0, '', ''),
            (0, 'if_name_1', ''),
            (0, 'if_name_2', ''),
        ]
        ssh.from_node.return_value.execute.side_effect = iter(execute_result_data)
        ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
        ext_ifs = ping_traffic_gen.vnfd_helper.interfaces
        self.assertNotEqual(ext_ifs[0]['virtual-interface']['local_iface_name'], 'if_name_1')
        self.assertNotEqual(ext_ifs[1]['virtual-interface']['local_iface_name'], 'if_name_2')
Ejemplo n.º 30
0
    def test_run_prox(self, ssh, *_):
        mock_ssh(ssh)

        prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
        prox_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG
        prox_approx_vnf.ssh_helper.join_bin_path.return_value = '/tool_path12/tool_file34'
        prox_approx_vnf.setup_helper.remote_path = 'configs/file56.cfg'

        expected = "sudo bash -c 'cd /tool_path12; " \
                   "/tool_path12/tool_file34 -o cli -t  -f /tmp/l3-swap-2.cfg '"

        prox_approx_vnf._run()
        result = prox_approx_vnf.ssh_helper.run.call_args[0][0]
        self.assertEqual(result, expected)