summaryrefslogtreecommitdiff
path: root/nova/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests/unit')
-rw-r--r--nova/tests/unit/notifications/objects/test_notification.py8
-rw-r--r--nova/tests/unit/scheduler/test_filter_scheduler.py86
2 files changed, 78 insertions, 16 deletions
diff --git a/nova/tests/unit/notifications/objects/test_notification.py b/nova/tests/unit/notifications/objects/test_notification.py
index a3ffc4e172..221699802f 100644
--- a/nova/tests/unit/notifications/objects/test_notification.py
+++ b/nova/tests/unit/notifications/objects/test_notification.py
@@ -370,9 +370,11 @@ notification_object_data = {
'AuditPeriodPayload': '1.0-2b429dd307b8374636703b843fa3f9cb',
'BandwidthPayload': '1.0-ee2616a7690ab78406842a2b68e34130',
'BlockDevicePayload': '1.0-29751e1b6d41b1454e36768a1e764df8',
+ 'CellMappingPayload': '1.0-cf7faeb3cdd6b0c742ff74c80b88fb11',
'ComputeTaskNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'ComputeTaskPayload': '1.0-e3d34762c14d131c98337b72e8c600e1',
- 'EventType': '1.18-44f33a06fd08fdba0b7dc266116c017b',
+ 'DestinationPayload': '1.0-4ccf26318dd18c4377dada2b1e74ec2e',
+ 'EventType': '1.19-000a76e83b06a9de11d365465a755a5e',
'ExceptionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'ExceptionPayload': '1.1-6c43008bd81885a63bc7f7c629f0793b',
'FlavorNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
@@ -418,7 +420,9 @@ notification_object_data = {
'MetricsNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'MetricsPayload': '1.0-65c69b15b4de5a8c01971cb5bb9ab650',
'NotificationPublisher': '2.2-b6ad48126247e10b46b6b0240e52e614',
- 'RequestSpecPayload': '1.0-ef9936c8da44e442e397b02dec3f6914',
+ 'RequestSpecPayload': '1.1-64d30723a2e381d0cd6a16a877002c64',
+ 'SchedulerRetriesPayload': '1.0-03a07d09575ef52cced5b1b24301d0b4',
+ 'SelectDestinationsNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'ServerGroupNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'ServerGroupPayload': '1.1-4ded2997ea1b07038f7af33ef5c45f7f',
'ServiceStatusNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
diff --git a/nova/tests/unit/scheduler/test_filter_scheduler.py b/nova/tests/unit/scheduler/test_filter_scheduler.py
index 459f710bb0..da01fb1fde 100644
--- a/nova/tests/unit/scheduler/test_filter_scheduler.py
+++ b/nova/tests/unit/scheduler/test_filter_scheduler.py
@@ -83,7 +83,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
instance_group=None, instance_uuid=uuids.instance)
# Reset the RequestSpec changes so they don't interfere with the
@@ -149,7 +152,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
instance_group=group)
@@ -198,7 +204,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
instance_group=None)
@@ -268,7 +277,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
instance_group=None)
@@ -321,7 +333,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
instance_group=None)
@@ -500,7 +515,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
instance_group=ig, instance_uuid=uuids.instance0)
# Reset the RequestSpec changes so they don't interfere with the
@@ -765,9 +783,16 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
- num_instances=1)
+ num_instances=1,
+ image=None,
+ numa_topology=None,
+ pci_requests=None,
+ instance_uuid=uuids.instance_id)
mock_schedule.return_value = [[fake_selection]]
dests = self.driver.select_destinations(self.context, spec_obj,
@@ -793,9 +818,16 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
- num_instances=2)
+ num_instances=2,
+ image=None,
+ numa_topology=None,
+ pci_requests=None,
+ instance_uuid=uuids.instance_id)
mock_schedule.return_value = [[fake_selection]]
dests = self.driver.select_destinations(self.context, spec_obj,
@@ -824,8 +856,12 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
root_gb=512,
ephemeral_gb=0,
swap=0,
- vcpus=1),
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor"),
project_id=uuids.project_id,
+ instance_uuid=uuids.instance_id,
instance_group=None)
host_state = mock.Mock(spec=host_manager.HostState, host="fake_host",
@@ -1020,16 +1056,32 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
self._test_not_enough_alternates(num_hosts=3, max_attempts=5)
self._test_not_enough_alternates(num_hosts=20, max_attempts=5)
+ @mock.patch('nova.compute.utils.notify_about_scheduler_action')
@mock.patch.object(filter_scheduler.FilterScheduler, '_schedule')
- def test_select_destinations_notifications(self, mock_schedule):
+ def test_select_destinations_notifications(self, mock_schedule,
+ mock_notify):
mock_schedule.return_value = ([[mock.Mock()]], [[mock.Mock()]])
with mock.patch.object(self.driver.notifier, 'info') as mock_info:
+ flavor = objects.Flavor(memory_mb=512,
+ root_gb=512,
+ ephemeral_gb=0,
+ swap=0,
+ vcpus=1,
+ disabled=False,
+ is_public=True,
+ name="small_flavor")
expected = {'num_instances': 1,
- 'instance_properties': {'uuid': uuids.instance},
- 'instance_type': {},
+ 'instance_properties': {
+ 'uuid': uuids.instance,
+ 'ephemeral_gb': 0,
+ 'memory_mb': 512,
+ 'vcpus': 1,
+ 'root_gb': 512},
+ 'instance_type': flavor,
'image': {}}
spec_obj = objects.RequestSpec(num_instances=1,
+ flavor=flavor,
instance_uuid=uuids.instance)
self.driver.select_destinations(self.context, spec_obj,
@@ -1042,6 +1094,12 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
dict(request_spec=expected))]
self.assertEqual(expected, mock_info.call_args_list)
+ mock_notify.assert_has_calls([
+ mock.call(context=self.context, request_spec=spec_obj,
+ action='select_destinations', phase='start'),
+ mock.call(context=self.context, request_spec=spec_obj,
+ action='select_destinations', phase='end')])
+
def test_get_all_host_states_provider_summaries_is_none(self):
"""Tests that HostManager.get_host_states_by_uuids is called with
compute_uuids being None when the incoming provider_summaries is None.