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' })
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()
def test__build_config(self, ssh, mock_context, *args): mock_ssh(ssh) udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) udp_replay_approx_vnf.queue_wrapper = mock.MagicMock() udp_replay_approx_vnf.nfvi_context = mock_context udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'} udp_replay_approx_vnf.setup_helper.bound_pci = [] 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 cmd_line = udp_replay_approx_vnf._build_config() expected = \ "sudo tool_path --log-level=5 -c 0x7 -n 4 -w -- -p 0x3 --config='(0,0,1),(1,0,2)'" self.assertEqual(cmd_line, expected)