コード例 #1
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)
コード例 #2
0
    def test_collect_kpi(self, ssh, mock_time):
        mock_ssh(ssh)

        prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
        prox_traffic_gen._vnf_wrapper.resource_helper.resource = mock.MagicMock(
            **{"check_if_sa_running.return_value": [False]})
        prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="")
        self.assertEqual({}, prox_traffic_gen.collect_kpi())
コード例 #3
0
    def test_collect_kpi(self, ssh, mock_time):
        mock_ssh(ssh)

        prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
        prox_traffic_gen._vnf_wrapper.resource = mock.Mock(
            autospec=ResourceProfile)
        prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="")
        self.assertEqual({}, prox_traffic_gen.collect_kpi())
コード例 #4
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)
コード例 #5
0
 def test_terminate(self, ssh, mock_socket, mock_time):
     mock_ssh(ssh)
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     prox_traffic_gen = ProxTrafficGen(NAME, vnfd)
     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()
     self.assertEqual(None, prox_traffic_gen.terminate())
コード例 #6
0
ファイル: test_tg_prox.py プロジェクト: warmwm/yardstick-ha
 def test_terminate(self, ssh, *args):
     mock_ssh(ssh)
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     prox_traffic_gen = ProxTrafficGen(NAME, vnfd)
     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())
コード例 #7
0
    def test__traffic_runner(self, ssh, mock_time):
        mock_ssh(ssh)

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

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        sut = ProxTrafficGen(NAME, vnfd)
        sut.prox_config_dict = {}
        sut._get_socket = mock.MagicMock()
        sut.ssh_helper = mock.Mock()
        sut.ssh_helper.run = mock.Mock()
        sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
        sut._connect_client = mock.Mock(autospec=STLClient)
        sut._connect_client.get_stats = mock.Mock(return_value="0")
        sut._traffic_runner(mock_traffic_profile)
コード例 #8
0
ファイル: test_tg_prox.py プロジェクト: PLVision/yardstick
    def test__traffic_runner(self, ssh, *args):
        mock_ssh(ssh)

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

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        sut = ProxTrafficGen(NAME, vnfd, 'task_id')
        sut._get_socket = mock.MagicMock()
        sut.ssh_helper = mock.Mock()
        sut.ssh_helper.run = mock.Mock()
        sut.setup_helper.prox_config_dict = {}
        sut._connect_client = mock.Mock(autospec=mock.Mock())
        sut._connect_client.get_stats = mock.Mock(return_value="0")
        sut._setup_mq_producer = mock.Mock(return_value='mq_producer')
        sut._traffic_runner(mock_traffic_profile, mock.ANY)
コード例 #9
0
 def test_listen_traffic(self, ssh, mock_socket, mock_time):
     mock_ssh(ssh)
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     prox_traffic_gen = ProxTrafficGen(NAME, vnfd)
     self.assertIsNone(prox_traffic_gen.listen_traffic(mock.Mock()))
コード例 #10
0
 def test_scale(self, ssh, mock_time):
     mock_ssh(ssh, exec_result=(1, "", ""))
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     prox_traffic_gen = ProxTrafficGen(NAME, vnfd)
     with self.assertRaises(NotImplementedError):
         prox_traffic_gen.scale('')
コード例 #11
0
    def bad_test_instantiate(self, ssh, mock_find, mock_cpu_sys_cores,
                             mock_time):
        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)
        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, {})
コード例 #12
0
 def test___init__(self, ssh, mock_time):
     mock_ssh(ssh)
     prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
     self.assertIsNone(prox_traffic_gen._tg_process)
     self.assertIsNone(prox_traffic_gen._traffic_process)
コード例 #13
0
    def test_collect_kpi(self, ssh, mock_time):
        mock_ssh(ssh)

        prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
        prox_traffic_gen._queue = mock.MagicMock()
        self.assertEqual({}, prox_traffic_gen.collect_kpi())
コード例 #14
0
ファイル: test_tg_prox.py プロジェクト: PLVision/yardstick
 def test_listen_traffic(self, ssh, *args):
     mock_ssh(ssh)
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     prox_traffic_gen = ProxTrafficGen(NAME, vnfd, 'task_id')
     self.assertIsNone(prox_traffic_gen.listen_traffic(mock.Mock()))
コード例 #15
0
ファイル: test_tg_prox.py プロジェクト: PLVision/yardstick
 def test___init__(self, ssh, *args):
     mock_ssh(ssh)
     prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0, 'task_id')
     self.assertIsNone(prox_traffic_gen._tg_process)
     self.assertIsNone(prox_traffic_gen._traffic_process)
     self.assertIsNone(prox_traffic_gen._mq_producer)