# Unittest for yardstick.benchmark.contexts.standalone
from __future__ import absolute_import
+
import os
import unittest
+
import mock
from yardstick.benchmark.contexts import standalone
-from yardstick.benchmark.contexts import sriov
-from yardstick.benchmark.contexts import ovsdpdk
+from yardstick.benchmark.contexts.standalone import ovsdpdk, sriov
MOCKS = {
'yardstick.benchmark.contexts': mock.MagicMock(),
- 'yardstick.benchmark.contexts.sriov': mock.MagicMock(),
- 'yardstick.benchmark.contexts.ovsdpdk': mock.MagicMock(),
+ 'yardstick.benchmark.contexts.standalone.sriov': mock.MagicMock(),
+ 'yardstick.benchmark.contexts.standalone.ovsdpdk': mock.MagicMock(),
'yardstick.benchmark.contexts.standalone': mock.MagicMock(),
}
-@mock.patch('yardstick.benchmark.contexts.ovsdpdk.time')
+@mock.patch('yardstick.benchmark.contexts.standalone.ovsdpdk.time')
@mock.patch('yardstick.benchmark.contexts.standalone.time')
-@mock.patch('yardstick.benchmark.contexts.sriov.time')
+@mock.patch('yardstick.benchmark.contexts.standalone.sriov.time')
class StandaloneContextTestCase(unittest.TestCase):
NODES_SAMPLE = "nodes_sample_new.yaml"
NODES_SAMPLE_SRIOV = "nodes_sample_new_sriov.yaml"
result = self.test_context._get_server(attr_name)
self.assertEqual(result, None)
-
-
def test__get_server_duplicate_sriov(self, mock_sriov_time, mock_standlalone_time,
mock_ovsdpdk_time):
attrs = {
ValueError,
self.test_context._get_server,
attr_name)
+
def test__get_server_found_sriov(self, mock_sriov_time, mock_standlalone_time,
mock_ovsdpdk_time):
attrs = {
self.test_context.nfvi_obj.setup_ovs_bridge = mock.Mock()
self.test_context.nfvi_obj.add_oflows = mock.Mock()
- # self.test_context.nfvi_obj.setup_ovs(PORTS)
- # self.test_context.nfvi_obj.start_ovs_serverswitch()
- # self.test_context.nfvi_obj.setup_ovs_bridge()
- # self.test_context.nfvi_obj.add_oflows()
-
result = self.test_context.nfvi_obj.setup_ovs_context(
PORTS,
NIC_DETAILS,
self.assertIsNone(self.test_context.undeploy())
def test_get_nfvi_obj_sriov(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- with mock.patch('yardstick.benchmark.contexts.sriov'):
+ with mock.patch('yardstick.benchmark.contexts.standalone.sriov'):
attrs = {
'name': 'sriov',
'file': self._get_file_abspath(self.NODES_SAMPLE)
self.assertIsNotNone(self.test_context.get_nfvi_obj())
def test_get_nfvi_obj_ovs(self, mock_sriov_time, mock_standlalone_time, mock_ovsdpdk_time):
- with mock.patch('yardstick.benchmark.contexts.ovsdpdk'):
+ with mock.patch('yardstick.benchmark.contexts.standalone.ovsdpdk'):
attrs = {
'name': 'ovs',
'file': self._get_file_abspath(self.NODES_SAMPLE_OVSDPDK)
expected = network1
result = self.test_context._get_network(attr_name)
self.assertDictEqual(result, expected)
+
if __name__ == '__main__':
unittest.main()