aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
diff options
context:
space:
mode:
authorStepan Andrushko <stepanx.andrushko@intel.com>2018-06-27 21:43:18 +0300
committerStepan Andrushko <stepanx.andrushko@intel.com>2018-08-23 12:24:22 +0300
commit39bcfa45da62a3126ad2a2290aaaa0670e8c5cb0 (patch)
treeeac9695b5bf4a93503e7755274c266de41d6625c /yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
parentc6175b5bc59706c3a423fe2781f99e32930bb570 (diff)
Provide access to VM in Standalone context
Add possibility to access VM with SampleVNF image, which is spawned on baremetal server using password or key pairs (provided or generated). Changes provided for OVS-DPDK and SRIOV cases. JIRA: YARDSTICK-1260 Change-Id: I89cf17dc83f02abe23d206b24b9d0ec1298d3231 Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
Diffstat (limited to 'yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py')
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
index 74c31569c..ae8e95f9a 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
@@ -113,8 +113,8 @@ class SriovContextTestCase(unittest.TestCase):
self.sriov.vm_deploy = True
self.sriov.connection = mock_ssh
- self.sriov.vm_names = ['vm_0', 'vm_1']
- self.sriov.drivers = ['vm_0', 'vm_1']
+ self.sriov.vm_names = ['vm-0', 'vm-1']
+ self.sriov.drivers = ['vm-0', 'vm-1']
self.assertIsNone(self.sriov.undeploy())
def _get_file_abspath(self, filename):
@@ -254,7 +254,7 @@ class SriovContextTestCase(unittest.TestCase):
ssh.return_value = ssh_mock
self.sriov.vm_deploy = True
self.sriov.connection = ssh_mock
- self.sriov.vm_names = ['vm_0', 'vm_1']
+ self.sriov.vm_names = ['vm-0', 'vm-1']
self.sriov.drivers = []
self.sriov.networks = self.NETWORKS
self.sriov.helper.get_mac_address = mock.Mock(return_value="")
@@ -267,7 +267,7 @@ class SriovContextTestCase(unittest.TestCase):
def test__enable_interfaces(self, mock_add_sriov, mock_ssh):
self.sriov.vm_deploy = True
self.sriov.connection = mock_ssh
- self.sriov.vm_names = ['vm_0', 'vm_1']
+ self.sriov.vm_names = ['vm-0', 'vm-1']
self.sriov.drivers = []
self.sriov.networks = self.NETWORKS
self.assertEqual(
@@ -276,12 +276,13 @@ class SriovContextTestCase(unittest.TestCase):
mock_add_sriov.assert_called_once_with(
'0000:00:0a.0', 0, self.NETWORKS['private_0']['mac'], 'test')
+ @mock.patch.object(model.StandaloneContextHelper, 'check_update_key')
@mock.patch.object(model.Libvirt, 'build_vm_xml')
@mock.patch.object(model.Libvirt, 'check_if_vm_exists_and_delete')
@mock.patch.object(model.Libvirt, 'write_file')
@mock.patch.object(model.Libvirt, 'virsh_create_vm')
- def test_setup_sriov_context(self, mock_create_vm, mock_write_file,
- mock_check, mock_build_vm_xml):
+ def test_setup_sriov_context(self, mock_create_vm, mock_write_file, mock_check,
+ mock_build_vm_xml, mock_check_update_key):
self.sriov.servers = {
'vnf_0': {
'network_ports': {
@@ -297,24 +298,29 @@ class SriovContextTestCase(unittest.TestCase):
self.sriov.vm_flavor = 'flavor'
self.sriov.networks = 'networks'
self.sriov.configure_nics_for_sriov = mock.Mock()
+ self.sriov._name_task_id = 'fake_name'
cfg = '/tmp/vm_sriov_0.xml'
- vm_name = 'vm_0'
+ vm_name = 'vm-0'
xml_out = mock.Mock()
mock_build_vm_xml.return_value = (xml_out, '00:00:00:00:00:01')
+ mock_check_update_key.return_value = 'node_2'
+ cdrom_img = '/var/lib/libvirt/images/cdrom-0.img'
with mock.patch.object(self.sriov, 'vnf_node') as mock_vnf_node, \
mock.patch.object(self.sriov, '_enable_interfaces') as \
mock_enable_interfaces:
mock_enable_interfaces.return_value = 'out_xml'
mock_vnf_node.generate_vnf_instance = mock.Mock(
- return_value='node')
+ return_value='node_1')
nodes_out = self.sriov.setup_sriov_context()
- self.assertEqual(['node'], nodes_out)
+ mock_check_update_key.assert_called_once_with(connection, 'node_1', vm_name,
+ self.sriov._name_task_id, cdrom_img)
+ self.assertEqual(['node_2'], nodes_out)
mock_vnf_node.generate_vnf_instance.assert_called_once_with(
'flavor', 'networks', '1.2.3.4', 'vnf_0',
self.sriov.servers['vnf_0'], '00:00:00:00:00:01')
mock_build_vm_xml.assert_called_once_with(
- connection, 'flavor', vm_name, 0)
+ connection, 'flavor', vm_name, 0, cdrom_img)
mock_create_vm.assert_called_once_with(connection, cfg)
mock_check.assert_called_once_with(vm_name, connection)
mock_write_file.assert_called_once_with(cfg, 'out_xml')
@@ -332,7 +338,7 @@ class SriovContextTestCase(unittest.TestCase):
ssh.return_value = ssh_mock
self.sriov.vm_deploy = True
self.sriov.connection = ssh_mock
- self.sriov.vm_names = ['vm_0', 'vm_1']
+ self.sriov.vm_names = ['vm-0', 'vm-1']
self.sriov.drivers = []
self.sriov.servers = {
'vnf_0': {