~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/scheduler/test_rpcapi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012, Red Hat, Inc.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
"""
 
18
Unit Tests for nova.scheduler.rpcapi
 
19
"""
 
20
 
 
21
from nova import context
 
22
from nova import flags
 
23
from nova import rpc
 
24
from nova.scheduler import rpcapi as scheduler_rpcapi
 
25
from nova import test
 
26
 
 
27
 
 
28
FLAGS = flags.FLAGS
 
29
 
 
30
 
 
31
class SchedulerRpcAPITestCase(test.TestCase):
 
32
 
 
33
    def setUp(self):
 
34
        super(SchedulerRpcAPITestCase, self).setUp()
 
35
 
 
36
    def tearDown(self):
 
37
        super(SchedulerRpcAPITestCase, self).tearDown()
 
38
 
 
39
    def _test_scheduler_api(self, method, rpc_method, **kwargs):
 
40
        ctxt = context.RequestContext('fake_user', 'fake_project')
 
41
        rpcapi = scheduler_rpcapi.SchedulerAPI()
 
42
        expected_retval = 'foo' if method == 'call' else None
 
43
        expected_msg = rpcapi.make_msg(method, **kwargs)
 
44
        expected_msg['version'] = rpcapi.RPC_API_VERSION
 
45
        if rpc_method == 'cast' and method == 'run_instance':
 
46
            kwargs['call'] = False
 
47
 
 
48
        self.fake_args = None
 
49
        self.fake_kwargs = None
 
50
 
 
51
        def _fake_rpc_method(*args, **kwargs):
 
52
            self.fake_args = args
 
53
            self.fake_kwargs = kwargs
 
54
            if expected_retval:
 
55
                return expected_retval
 
56
 
 
57
        self.stubs.Set(rpc, rpc_method, _fake_rpc_method)
 
58
 
 
59
        retval = getattr(rpcapi, method)(ctxt, **kwargs)
 
60
 
 
61
        self.assertEqual(retval, expected_retval)
 
62
        expected_args = [ctxt, FLAGS.scheduler_topic, expected_msg]
 
63
        for arg, expected_arg in zip(self.fake_args, expected_args):
 
64
            self.assertEqual(arg, expected_arg)
 
65
 
 
66
    def test_run_instance_call(self):
 
67
        self._test_scheduler_api('run_instance', rpc_method='call',
 
68
                topic='fake_topic', request_spec='fake_request_spec',
 
69
                admin_password='pw', injected_files='fake_injected_files',
 
70
                requested_networks='fake_requested_networks',
 
71
                is_first_time=True, filter_properties='fake_filter_properties')
 
72
 
 
73
    def test_run_instance_cast(self):
 
74
        self._test_scheduler_api('run_instance', rpc_method='cast',
 
75
                topic='fake_topic', request_spec='fake_request_spec',
 
76
                admin_password='pw', injected_files='fake_injected_files',
 
77
                requested_networks='fake_requested_networks',
 
78
                is_first_time=True, filter_properties='fake_filter_properties')
 
79
 
 
80
    def test_prep_resize(self):
 
81
        self._test_scheduler_api('prep_resize', rpc_method='cast',
 
82
                topic='fake_topic', instance_uuid='fake_uuid',
 
83
                instance_type_id='fake_type_id', image='fake_image',
 
84
                update_db='fake_update_db', request_spec='fake_request_spec',
 
85
                filter_properties='fake_props')
 
86
 
 
87
    def test_show_host_resources(self):
 
88
        self._test_scheduler_api('show_host_resources', rpc_method='call',
 
89
                host='fake_host')
 
90
 
 
91
    def test_live_migration(self):
 
92
        self._test_scheduler_api('live_migration', rpc_method='call',
 
93
                block_migration='fake_block_migration',
 
94
                disk_over_commit='fake_disk_over_commit',
 
95
                instance_id='fake_id', dest='fake_dest', topic='fake_topic')
 
96
 
 
97
    def test_update_service_capabilities(self):
 
98
        self._test_scheduler_api('update_service_capabilities',
 
99
                rpc_method='fanout_cast', service_name='fake_name',
 
100
                host='fake_host', capabilities='fake_capabilities')
 
101
 
 
102
    def test_get_host_list(self):
 
103
        self._test_scheduler_api('get_host_list', rpc_method='call')