Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def test_vnf_execute(self, ssh, _):
     mock_ssh(ssh)
     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)
     self.assertEqual(vpe_approx_vnf.vnf_execute("quit", 0), '')
Ejemplo n.º 3
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)