Esempio n. 1
0
    def test___init___with_custom_rfc_helper(self):
        class MyRfcHelper(tg_rfc2544_ixia.IxiaRfc2544Helper):
            pass

        ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(
            mock.Mock(), MyRfcHelper)
        self.assertIsInstance(ixia_resource_helper.rfc_helper, MyRfcHelper)
 def test_stop_collect_with_client(self):
     mock_client = mock.Mock()
     ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock())
     ixia_resource_helper.client = mock_client
     ixia_resource_helper._ix_scenario = mock.Mock()
     ixia_resource_helper.stop_collect()
     self.assertEqual(1, ixia_resource_helper._terminated.value)
     ixia_resource_helper._ix_scenario.stop_protocols.assert_called_once()
 def test__init_ix_scenario_not_supported_cfg_type(self):
     mock_scenario_helper = mock.Mock()
     mock_scenario_helper.scenario_cfg = {
         'ixia_config': 'FakeScenario',
         'options': 'scenario_options'
     }
     mock_setup_helper = mock.Mock(scenario_helper=mock_scenario_helper)
     ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(
         mock_setup_helper)
     ixia_resource_helper._ixia_scenarios = {'TestScenario': mock.Mock()}
     with self.assertRaises(RuntimeError):
         ixia_resource_helper._init_ix_scenario()
Esempio n. 4
0
    def test_run_traffic(self):
        mock_tprofile = mock.Mock()
        mock_tprofile.get_drop_percentage.return_value = True, 'fake_samples'
        ixia_rhelper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock())
        ixia_rhelper.rfc_helper = mock.Mock()
        ixia_rhelper.vnfd_helper = mock.Mock()
        ixia_rhelper.vnfd_helper.port_pairs.all_ports = []
        with mock.patch.object(ixia_rhelper, 'generate_samples'), \
                mock.patch.object(ixia_rhelper, '_build_ports'), \
                mock.patch.object(ixia_rhelper, '_initialize_client'):
            ixia_rhelper.run_traffic(mock_tprofile)

        self.assertEqual('fake_samples', ixia_rhelper._queue.get())
 def test__init_ix_scenario(self):
     mock_scenario = mock.Mock()
     mock_scenario_helper = mock.Mock()
     mock_scenario_helper.scenario_cfg = {
         'ixia_config': 'TestScenario',
         'options': 'scenario_options'
     }
     mock_setup_helper = mock.Mock(scenario_helper=mock_scenario_helper)
     ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(
         mock_setup_helper)
     ixia_resource_helper._ixia_scenarios = {'TestScenario': mock_scenario}
     ixia_resource_helper.client = 'client'
     ixia_resource_helper.context_cfg = 'context'
     ixia_resource_helper._init_ix_scenario()
     mock_scenario.assert_called_once_with('client', 'context',
                                           'scenario_options')
    def test_run_traffic(self):
        mock_tprofile = mock.Mock()
        mock_tprofile.config.duration = 10
        mock_tprofile.get_drop_percentage.return_value = True, 'fake_samples'
        ixia_rhelper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock())
        ixia_rhelper.rfc_helper = mock.Mock()
        ixia_rhelper.vnfd_helper = mock.Mock()
        ixia_rhelper._ix_scenario = mock.Mock()
        ixia_rhelper.vnfd_helper.port_pairs.all_ports = []
        with mock.patch.object(ixia_rhelper, 'generate_samples'), \
                mock.patch.object(ixia_rhelper, '_build_ports'), \
                mock.patch.object(ixia_rhelper, '_initialize_client'), \
                mock.patch.object(utils, 'wait_until_true'):
            ixia_rhelper.run_traffic(mock_tprofile)

        self.assertEqual('fake_samples', ixia_rhelper._queue.get())
        mock_tprofile.update_traffic_profile.assert_called_once()
Esempio n. 7
0
 def test_stop_collect_with_client(self):
     mock_client = mock.Mock()
     ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock())
     ixia_resource_helper.client = mock_client
     ixia_resource_helper.stop_collect()
     self.assertEqual(1, ixia_resource_helper._terminated.value)
 def test_setup(self, mock__init_ix_scenario):
     ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock())
     ixia_resource_helper.setup()
     mock__init_ix_scenario.assert_called_once()