Ejemplo n.º 1
0
    def test_netperf_node_successful_setup(self, mock_ssh):

        p = netperf_node.NetperfNode({}, self.ctx)
        mock_ssh.SSH().execute.return_value = (0, '', '')

        p.setup()
        self.assertIsNotNone(p.server)
        self.assertIsNotNone(p.client)
        self.assertEqual(p.setup_done, True)
Ejemplo n.º 2
0
    def test_netperf_node_unsuccessful_script_error(self, mock_ssh):

        options = {}
        args = {'options': options}
        result = {}

        p = netperf_node.NetperfNode(args, self.ctx)
        mock_ssh.SSH().execute.return_value = (0, '', '')
        p.host = mock_ssh.SSH()

        mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
        self.assertRaises(RuntimeError, p.run, result)
Ejemplo n.º 3
0
    def test_netperf_node_unsuccessful_sla(self, mock_ssh):

        options = {}
        args = {'options': options, 'sla': {'mean_latency': 5}}
        result = {}

        p = netperf_node.NetperfNode(args, self.ctx)
        mock_ssh.SSH().execute.return_value = (0, '', '')
        p.host = mock_ssh.SSH()

        sample_output = self._read_sample_output()
        mock_ssh.SSH().execute.return_value = (0, sample_output, '')
        self.assertRaises(AssertionError, p.run, result)
Ejemplo n.º 4
0
    def test_netperf_node_successful_sla(self, mock_ssh):

        options = {}
        args = {'options': options, 'sla': {'mean_latency': 100}}
        result = {}

        p = netperf_node.NetperfNode(args, self.ctx)
        mock_ssh.SSH().execute.return_value = (0, '', '')
        p.host = mock_ssh.SSH()

        sample_output = self._read_sample_output()
        mock_ssh.SSH().execute.return_value = (0, sample_output, '')
        expected_result = jsonutils.loads(sample_output)
        p.run(result)
        self.assertEqual(result, expected_result)