Remove fake_libvirt_utils users in functional testing.
This is the final step before we can remove the fake utils entirely. Change-Id: I8e5a122cc547222249973cf595d90c2d8d5658d4
This commit is contained in:
parent
383a4cf371
commit
b96d1221db
|
@ -23,7 +23,6 @@ from nova.tests import fixtures as nova_fixtures
|
||||||
from nova.tests.functional import fixtures as func_fixtures
|
from nova.tests.functional import fixtures as func_fixtures
|
||||||
from nova.tests.functional import test_servers as base
|
from nova.tests.functional import test_servers as base
|
||||||
from nova.tests.unit.virt.libvirt import fake_imagebackend
|
from nova.tests.unit.virt.libvirt import fake_imagebackend
|
||||||
from nova.tests.unit.virt.libvirt import fake_libvirt_utils
|
|
||||||
from nova.tests.unit.virt.libvirt import fakelibvirt
|
from nova.tests.unit.virt.libvirt import fakelibvirt
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,9 +33,6 @@ class ServersTestBase(base.ServersTestBase):
|
||||||
|
|
||||||
# Replace libvirt with fakelibvirt
|
# Replace libvirt with fakelibvirt
|
||||||
self.useFixture(fake_imagebackend.ImageBackendFixture())
|
self.useFixture(fake_imagebackend.ImageBackendFixture())
|
||||||
self.useFixture(fixtures.MonkeyPatch(
|
|
||||||
'nova.virt.libvirt.driver.libvirt_utils',
|
|
||||||
fake_libvirt_utils))
|
|
||||||
self.useFixture(fixtures.MonkeyPatch(
|
self.useFixture(fixtures.MonkeyPatch(
|
||||||
'nova.virt.libvirt.driver.libvirt',
|
'nova.virt.libvirt.driver.libvirt',
|
||||||
fakelibvirt))
|
fakelibvirt))
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import io
|
||||||
import six
|
import six
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
@ -56,6 +57,14 @@ class NUMAServersTestBase(base.ServersTestBase):
|
||||||
return self.start_service('scheduler')
|
return self.start_service('scheduler')
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
new=mock.Mock(return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84}))
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
new=mock.Mock(return_value=True))
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
new=mock.Mock(side_effect=[io.BytesIO(b''), io.BytesIO(b'')]))
|
||||||
class NUMAServersTest(NUMAServersTestBase):
|
class NUMAServersTest(NUMAServersTestBase):
|
||||||
|
|
||||||
def _run_build_test(self, flavor_id, end_status='ACTIVE'):
|
def _run_build_test(self, flavor_id, end_status='ACTIVE'):
|
||||||
|
@ -179,7 +188,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
|
|
||||||
return self._wait_for_state_change(found_server, 'BUILD')
|
return self._wait_for_state_change(found_server, 'BUILD')
|
||||||
|
|
||||||
def test_create_server_with_single_physnet(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_create_server_with_single_physnet(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
extra_spec = {'hw:numa_nodes': '1'}
|
extra_spec = {'hw:numa_nodes': '1'}
|
||||||
flavor_id = self._create_flavor(extra_spec=extra_spec)
|
flavor_id = self._create_flavor(extra_spec=extra_spec)
|
||||||
networks = [
|
networks = [
|
||||||
|
@ -192,7 +210,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
self.assertTrue(self.mock_filter.called)
|
self.assertTrue(self.mock_filter.called)
|
||||||
self.assertEqual('ACTIVE', status)
|
self.assertEqual('ACTIVE', status)
|
||||||
|
|
||||||
def test_create_server_with_multiple_physnets(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_create_server_with_multiple_physnets(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
"""Test multiple networks split across host NUMA nodes.
|
"""Test multiple networks split across host NUMA nodes.
|
||||||
|
|
||||||
This should pass because the networks requested are split across
|
This should pass because the networks requested are split across
|
||||||
|
@ -212,7 +239,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
self.assertTrue(self.mock_filter.called)
|
self.assertTrue(self.mock_filter.called)
|
||||||
self.assertEqual('ACTIVE', status)
|
self.assertEqual('ACTIVE', status)
|
||||||
|
|
||||||
def test_create_server_with_multiple_physnets_fail(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_create_server_with_multiple_physnets_fail(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
"""Test multiple networks split across host NUMA nodes.
|
"""Test multiple networks split across host NUMA nodes.
|
||||||
|
|
||||||
This should fail because we've requested a single-node instance but the
|
This should fail because we've requested a single-node instance but the
|
||||||
|
@ -231,7 +267,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
self.assertTrue(self.mock_filter.called)
|
self.assertTrue(self.mock_filter.called)
|
||||||
self.assertEqual('ERROR', status)
|
self.assertEqual('ERROR', status)
|
||||||
|
|
||||||
def test_create_server_with_physnet_and_tunneled_net(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_create_server_with_physnet_and_tunneled_net(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
"""Test combination of physnet and tunneled network.
|
"""Test combination of physnet and tunneled network.
|
||||||
|
|
||||||
This should pass because we've requested a single-node instance and the
|
This should pass because we've requested a single-node instance and the
|
||||||
|
@ -250,7 +295,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
self.assertTrue(self.mock_filter.called)
|
self.assertTrue(self.mock_filter.called)
|
||||||
self.assertEqual('ACTIVE', status)
|
self.assertEqual('ACTIVE', status)
|
||||||
|
|
||||||
def test_rebuild_server_with_network_affinity(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_rebuild_server_with_network_affinity(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
extra_spec = {'hw:numa_nodes': '1'}
|
extra_spec = {'hw:numa_nodes': '1'}
|
||||||
flavor_id = self._create_flavor(extra_spec=extra_spec)
|
flavor_id = self._create_flavor(extra_spec=extra_spec)
|
||||||
networks = [
|
networks = [
|
||||||
|
@ -299,7 +353,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
self.assertEqual(500, ex.response.status_code)
|
self.assertEqual(500, ex.response.status_code)
|
||||||
self.assertIn('NoValidHost', six.text_type(ex))
|
self.assertIn('NoValidHost', six.text_type(ex))
|
||||||
|
|
||||||
def test_cold_migrate_with_physnet(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_cold_migrate_with_physnet(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
host_info = fakelibvirt.NUMAHostInfo(cpu_nodes=2, cpu_sockets=1,
|
host_info = fakelibvirt.NUMAHostInfo(cpu_nodes=2, cpu_sockets=1,
|
||||||
cpu_cores=2, cpu_threads=2,
|
cpu_cores=2, cpu_threads=2,
|
||||||
kB_mem=15740000)
|
kB_mem=15740000)
|
||||||
|
@ -363,7 +426,16 @@ class NUMAServersWithNetworksTest(NUMAServersTestBase):
|
||||||
self.assertIsNotNone(network_metadata)
|
self.assertIsNotNone(network_metadata)
|
||||||
self.assertEqual(set(['foo']), network_metadata.physnets)
|
self.assertEqual(set(['foo']), network_metadata.physnets)
|
||||||
|
|
||||||
def test_cold_migrate_with_physnet_fails(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_cold_migrate_with_physnet_fails(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
host_infos = [
|
host_infos = [
|
||||||
# host 1 has room on both nodes
|
# host 1 has room on both nodes
|
||||||
fakelibvirt.NUMAHostInfo(cpu_nodes=2, cpu_sockets=1,
|
fakelibvirt.NUMAHostInfo(cpu_nodes=2, cpu_sockets=1,
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import io
|
||||||
|
|
||||||
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
@ -43,11 +46,21 @@ class _PCIServersTestBase(base.ServersTestBase):
|
||||||
host_manager = self.scheduler.manager.driver.host_manager
|
host_manager = self.scheduler.manager.driver.host_manager
|
||||||
pci_filter_class = host_manager.filter_cls_map['PciPassthroughFilter']
|
pci_filter_class = host_manager.filter_cls_map['PciPassthroughFilter']
|
||||||
host_pass_mock = mock.Mock(wraps=pci_filter_class().host_passes)
|
host_pass_mock = mock.Mock(wraps=pci_filter_class().host_passes)
|
||||||
_p = mock.patch('nova.scheduler.filters.pci_passthrough_filter'
|
self.mock_filter = self.useFixture(fixtures.MockPatch(
|
||||||
'.PciPassthroughFilter.host_passes',
|
'nova.scheduler.filters.pci_passthrough_filter'
|
||||||
side_effect=host_pass_mock)
|
'.PciPassthroughFilter.host_passes',
|
||||||
self.mock_filter = _p.start()
|
side_effect=host_pass_mock)).mock
|
||||||
self.addCleanup(_p.stop)
|
self.useFixture(fixtures.MockPatch(
|
||||||
|
'nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84}))
|
||||||
|
self.useFixture(fixtures.MockPatch(
|
||||||
|
'nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True))
|
||||||
|
self.useFixture(fixtures.MockPatch(
|
||||||
|
'nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')]))
|
||||||
|
|
||||||
def _setup_scheduler_service(self):
|
def _setup_scheduler_service(self):
|
||||||
# Enable the 'NUMATopologyFilter', 'PciPassthroughFilter'
|
# Enable the 'NUMATopologyFilter', 'PciPassthroughFilter'
|
||||||
|
|
|
@ -10,9 +10,11 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import io
|
||||||
|
import mock
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import mock
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
@ -40,7 +42,17 @@ class VGPUReshapeTests(base.ServersTestBase):
|
||||||
self.assertEqual(expected_status, server['status'])
|
self.assertEqual(expected_status, server['status'])
|
||||||
return server
|
return server
|
||||||
|
|
||||||
def test_create_servers_with_vgpu(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b''),
|
||||||
|
io.BytesIO(b'')])
|
||||||
|
def test_create_servers_with_vgpu(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
"""Verify that vgpu reshape works with libvirt driver
|
"""Verify that vgpu reshape works with libvirt driver
|
||||||
|
|
||||||
1) create two servers with an old tree where the VGPU resource is on
|
1) create two servers with an old tree where the VGPU resource is on
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import io
|
||||||
|
import mock
|
||||||
|
|
||||||
from nova.tests.functional.api import client
|
from nova.tests.functional.api import client
|
||||||
from nova.tests.functional.libvirt import base
|
from nova.tests.functional.libvirt import base
|
||||||
from nova.tests.unit.virt.libvirt import fakelibvirt
|
from nova.tests.unit.virt.libvirt import fakelibvirt
|
||||||
|
@ -43,7 +46,16 @@ class RealTimeServersTest(base.ServersTestBase):
|
||||||
client.OpenStackApiException,
|
client.OpenStackApiException,
|
||||||
self.api.post_server, {'server': server})
|
self.api.post_server, {'server': server})
|
||||||
|
|
||||||
def test_success(self):
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_success(
|
||||||
|
self, mock_file_open, mock_valid_hostname, mock_get_fs_info):
|
||||||
host_info = fakelibvirt.NUMAHostInfo(cpu_nodes=2, cpu_sockets=1,
|
host_info = fakelibvirt.NUMAHostInfo(cpu_nodes=2, cpu_sockets=1,
|
||||||
cpu_cores=2, cpu_threads=2,
|
cpu_cores=2, cpu_threads=2,
|
||||||
kB_mem=15740000)
|
kB_mem=15740000)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
|
import io
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import nova
|
import nova
|
||||||
|
@ -23,7 +24,6 @@ from nova.tests import fixtures as nova_fixtures
|
||||||
from nova.tests.functional import fixtures as func_fixtures
|
from nova.tests.functional import fixtures as func_fixtures
|
||||||
from nova.tests.unit import cast_as_call
|
from nova.tests.unit import cast_as_call
|
||||||
from nova.tests.unit import policy_fixture
|
from nova.tests.unit import policy_fixture
|
||||||
from nova.tests.unit.virt.libvirt import fake_libvirt_utils
|
|
||||||
from nova.tests.unit.virt.libvirt import fakelibvirt
|
from nova.tests.unit.virt.libvirt import fakelibvirt
|
||||||
from nova.virt.libvirt import guest as libvirt_guest
|
from nova.virt.libvirt import guest as libvirt_guest
|
||||||
|
|
||||||
|
@ -39,9 +39,6 @@ class TestSerialConsoleLiveMigrate(test.TestCase):
|
||||||
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
|
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
|
||||||
api_version='v2.1'))
|
api_version='v2.1'))
|
||||||
# Replace libvirt with fakelibvirt
|
# Replace libvirt with fakelibvirt
|
||||||
self.useFixture(fixtures.MonkeyPatch(
|
|
||||||
'nova.virt.libvirt.driver.libvirt_utils',
|
|
||||||
fake_libvirt_utils))
|
|
||||||
self.useFixture(fixtures.MonkeyPatch(
|
self.useFixture(fixtures.MonkeyPatch(
|
||||||
'nova.virt.libvirt.driver.libvirt',
|
'nova.virt.libvirt.driver.libvirt',
|
||||||
fakelibvirt))
|
fakelibvirt))
|
||||||
|
@ -85,7 +82,18 @@ class TestSerialConsoleLiveMigrate(test.TestCase):
|
||||||
@mock.patch('nova.conductor.tasks.live_migrate.LiveMigrationTask.'
|
@mock.patch('nova.conductor.tasks.live_migrate.LiveMigrationTask.'
|
||||||
'_check_destination_is_not_source', return_value=False)
|
'_check_destination_is_not_source', return_value=False)
|
||||||
@mock.patch('nova.virt.libvirt.LibvirtDriver._create_image')
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._create_image')
|
||||||
def test_serial_console_live_migrate(self, mock_create_image,
|
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
|
||||||
|
return_value={'total': 128,
|
||||||
|
'used': 44,
|
||||||
|
'free': 84})
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.is_valid_hostname',
|
||||||
|
return_value=True)
|
||||||
|
@mock.patch('nova.virt.libvirt.driver.libvirt_utils.file_open',
|
||||||
|
side_effect=[io.BytesIO(b''), io.BytesIO(b'')])
|
||||||
|
def test_serial_console_live_migrate(self, mock_file_open,
|
||||||
|
mock_valid_hostname,
|
||||||
|
mock_get_fs_info,
|
||||||
|
mock_create_image,
|
||||||
mock_conductor_source_check,
|
mock_conductor_source_check,
|
||||||
mock_path_get_size,
|
mock_path_get_size,
|
||||||
mock_get_disk_size,
|
mock_get_disk_size,
|
||||||
|
|
Loading…
Reference in New Issue