Exemple #1
0
    def test_vsperf_setup(self, mock_ssh, mock_subprocess):
        p = vsperf.Vsperf(self.args, self.ctx)
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
        mock_subprocess.call().execute.return_value = None

        p.setup()
        self.assertIsNotNone(p.client)
        self.assertTrue(p.setup_done)
Exemple #2
0
    def test_teardown_tg_port_not_set(self):
        del self.scenario_cfg['options']['trafficgen_port1']
        del self.scenario_cfg['options']['trafficgen_port2']
        scenario = vsperf.Vsperf(self.scenario_cfg, self.context_cfg)
        scenario.teardown()

        self.mock_subprocess_call.assert_called_once_with(
            'setup_yardstick.sh teardown', shell=True)
        self.assertFalse(scenario.setup_done)
Exemple #3
0
    def test_run_sla_fail_metric_not_defined_in_sla(self):
        del self.scenario_cfg['sla']['throughput_rx_fps']
        scenario = vsperf.Vsperf(self.scenario_cfg, self.context_cfg)
        scenario.setup()

        with self.assertRaises(y_exc.SLAValidationError) as raised:
            scenario.run({})
        self.assertTrue(
            'throughput_rx_fps is not defined in SLA' in str(raised.exception))
Exemple #4
0
    def test_setup_tg_port_not_set(self):
        del self.scenario_cfg['options']['trafficgen_port1']
        del self.scenario_cfg['options']['trafficgen_port2']
        scenario = vsperf.Vsperf(self.scenario_cfg, self.context_cfg)
        scenario.setup()

        self.mock_subprocess_call.assert_called_once_with(
            'setup_yardstick.sh setup', shell=True)
        self.assertIsNone(scenario.tg_port1)
        self.assertIsNone(scenario.tg_port2)
        self.assertIsNotNone(scenario.client)
        self.assertTrue(scenario.setup_done)
Exemple #5
0
    def test_teardown_no_setup_script(self):
        del self.scenario_cfg['options']['setup_script']
        scenario = vsperf.Vsperf(self.scenario_cfg, self.context_cfg)
        scenario.teardown()

        self.mock_subprocess_call.assert_has_calls(
            (mock.call('sudo bash -c "ovs-vsctl del-port br-ex eth1"',
                       shell=True),
             mock.call('sudo bash -c "ovs-vsctl del-port br-ex eth3"',
                       shell=True)))
        self.assertEqual(2, self.mock_subprocess_call.call_count)
        self.assertFalse(scenario.setup_done)
Exemple #6
0
    def test_run_sla_fail_metric_not_defined_in_sla(self):
        del self.scenario_cfg['sla']['throughput_rx_fps']
        scenario = vsperf.Vsperf(self.scenario_cfg, self.context_cfg)
        scenario.setup()

        self.mock_SSH.from_node().execute.return_value = (
            0, 'throughput_rx_fps\r\n14797660.000\r\n', '')

        with self.assertRaises(y_exc.SLAValidationError) as raised:
            scenario.run({})
        self.assertTrue(
            'throughput_rx_fps is not defined in SLA' in str(raised.exception))
Exemple #7
0
    def test_vsperf_run_falied_vsperf_execution(self, mock_ssh,
                                                mock_subprocess):
        p = vsperf.Vsperf(self.args, self.ctx)

        # setup() specific mocks
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
        mock_subprocess.call().execute.return_value = None

        # run() specific mocks
        mock_ssh.SSH.from_node().execute.return_value = (1, '', '')

        result = {}
        self.assertRaises(RuntimeError, p.run, result)
Exemple #8
0
    def test_vsperf_teardown(self, mock_open, mock_ssh, mock_subprocess):
        p = vsperf.Vsperf(self.args, self.ctx)

        # setup() specific mocks
        mock_ssh.SSH().execute.return_value = (0, '', '')
        mock_subprocess.call().execute.return_value = None

        p.setup()
        self.assertIsNotNone(p.client)
        self.assertEqual(p.setup_done, True)

        p.teardown()
        self.assertEqual(p.setup_done, False)
Exemple #9
0
    def test_vsperf_run_ok(self, mock_ssh, mock_subprocess):
        p = vsperf.Vsperf(self.args, self.ctx)

        # setup() specific mocks
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
        mock_subprocess.call().execute.return_value = None

        # run() specific mocks
        mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
        mock_ssh.SSH.from_node().execute.return_value = (
            0, 'throughput_rx_fps\r\n14797660.000\r\n', '')

        result = {}
        p.run(result)

        self.assertEqual(result['throughput_rx_fps'], '14797660.000')
Exemple #10
0
    def setUp(self):
        self.context_cfg = {
            "host": {
                "ip": "10.229.47.137",
                "user": "******",
                "password": "******",
            },
        }
        self.scenario_cfg = {
            'options': {
                'testname': 'p2p_rfc2544_continuous',
                'traffic_type': 'continuous',
                'frame_size': '64',
                'bidirectional': 'True',
                'iload': 100,
                'trafficgen_port1': 'eth1',
                'trafficgen_port2': 'eth3',
                'external_bridge': 'br-ex',
                'conf_file': 'vsperf-yardstick.conf',
                'setup_script': 'setup_yardstick.sh',
                'test_params': 'TRAFFICGEN_DURATION=30;',
            },
            'sla': {
                'metrics': 'throughput_rx_fps',
                'throughput_rx_fps': 500000,
                'action': 'monitor',
            }
        }

        self._mock_SSH = mock.patch.object(ssh, 'SSH')
        self.mock_SSH = self._mock_SSH.start()
        self.mock_SSH.from_node().execute.return_value = (
            0, 'throughput_rx_fps\r\n14797660.000\r\n', '')

        self._mock_subprocess_call = mock.patch.object(subprocess, 'call')
        self.mock_subprocess_call = self._mock_subprocess_call.start()
        self.mock_subprocess_call.return_value = None

        self.addCleanup(self._stop_mock)

        self.scenario = vsperf.Vsperf(self.scenario_cfg, self.context_cfg)