~cbehrens/nova/rpc-kombu

« back to all changes in this revision

Viewing changes to nova/tests/test_service.py

  • Committer: Mark Washenberger
  • Date: 2011-03-15 18:19:47 UTC
  • mfrom: (806 nova)
  • mto: This revision was merged to the branch mainline in revision 814.
  • Revision ID: mark.washenberger@rackspace.com-20110315181947-no5rfi12g7fa75sm
mergeĀ lp:nova

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from nova import test
31
31
from nova import service
32
32
from nova import manager
 
33
from nova.compute import manager as compute_manager
33
34
 
34
35
FLAGS = flags.FLAGS
35
36
flags.DEFINE_string("fake_manager", "nova.tests.test_service.FakeManager",
251
252
        serv.report_state()
252
253
 
253
254
        self.assert_(not serv.model_disconnected)
 
255
 
 
256
    def test_compute_can_update_available_resource(self):
 
257
        """Confirm compute updates their record of compute-service table."""
 
258
        host = 'foo'
 
259
        binary = 'nova-compute'
 
260
        topic = 'compute'
 
261
 
 
262
        # Any mocks are not working without UnsetStubs() here.
 
263
        self.mox.UnsetStubs()
 
264
        ctxt = context.get_admin_context()
 
265
        service_ref = db.service_create(ctxt, {'host': host,
 
266
                                               'binary': binary,
 
267
                                               'topic': topic})
 
268
        serv = service.Service(host,
 
269
                               binary,
 
270
                               topic,
 
271
                               'nova.compute.manager.ComputeManager')
 
272
 
 
273
        # This testcase want to test calling update_available_resource.
 
274
        # No need to call periodic call, then below variable must be set 0.
 
275
        serv.report_interval = 0
 
276
        serv.periodic_interval = 0
 
277
 
 
278
        # Creating mocks
 
279
        self.mox.StubOutWithMock(service.rpc.Connection, 'instance')
 
280
        service.rpc.Connection.instance(new=mox.IgnoreArg())
 
281
        service.rpc.Connection.instance(new=mox.IgnoreArg())
 
282
        self.mox.StubOutWithMock(serv.manager.driver,
 
283
                                 'update_available_resource')
 
284
        serv.manager.driver.update_available_resource(mox.IgnoreArg(), host)
 
285
 
 
286
        # Just doing start()-stop(), not confirm new db record is created,
 
287
        # because update_available_resource() works only in
 
288
        # libvirt environment. This testcase confirms
 
289
        # update_available_resource() is called. Otherwise, mox complains.
 
290
        self.mox.ReplayAll()
 
291
        serv.start()
 
292
        serv.stop()
 
293
 
 
294
        db.service_destroy(ctxt, service_ref['id'])