Exemple #1
0
    def test_collect_kpi_sa_not_running(self, ssh, *args):
        mock_ssh(ssh)

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

        vpe_approx_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': {}},
        }
        self.assertEqual(vpe_approx_vnf.collect_kpi(), expected)
Exemple #2
0
    def test_collect_kpi_sa_running(self, ssh, _):
        mock_ssh(ssh)

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

        vpe_approx_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)
        vpe_approx_vnf.resource_helper.resource = resource

        expected = {
            '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)
 def test_collect_kpi(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, "", ""))
         ssh.from_node.return_value = ssh_mock
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         vpe_approx_vnf = VpeApproxVnf(vnfd)
         vpe_approx_vnf.resource = mock.Mock(autospec=ResourceProfile)
         vpe_approx_vnf.resource.check_if_sa_running = \
             mock.Mock(return_value=[0, 1])
         vpe_approx_vnf.resource.amqp_collect_nfvi_kpi= \
             mock.Mock(return_value={})
         result = {
             'pkt_in_down_stream': 0,
             'pkt_in_up_stream': 0,
             'collect_stats': {
                 'core': {}
             },
             'pkt_drop_down_stream': 0,
             'pkt_drop_up_stream': 0
         }
         self.assertEqual(result, vpe_approx_vnf.collect_kpi())