~vishvananda/nova/has_role_cache

« back to all changes in this revision

Viewing changes to nova/tests/test_cloud.py

  • Committer: Tarmac
  • Author(s): Vishvananda Ishaya
  • Date: 2011-02-23 19:46:13 UTC
  • mfrom: (706.4.6 fix-describe-groups)
  • Revision ID: tarmac-20110223194613-uwpmk33wfvr970rc
Fixes and optimizes filtering for describe_security_groups.  Also adds a unit test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
        db.instance_destroy(self.context, inst['id'])
137
137
        db.floating_ip_destroy(self.context, address)
138
138
 
 
139
    def test_describe_security_groups(self):
 
140
        """Makes sure describe_security_groups works and filters results."""
 
141
        sec = db.security_group_create(self.context,
 
142
                                       {'project_id': self.context.project_id,
 
143
                                        'name': 'test'})
 
144
        result = self.cloud.describe_security_groups(self.context)
 
145
        # NOTE(vish): should have the default group as well
 
146
        self.assertEqual(len(result['securityGroupInfo']), 2)
 
147
        result = self.cloud.describe_security_groups(self.context,
 
148
                      group_name=[sec['name']])
 
149
        self.assertEqual(len(result['securityGroupInfo']), 1)
 
150
        self.assertEqual(
 
151
                result['securityGroupInfo'][0]['groupName'],
 
152
                sec['name'])
 
153
        db.security_group_destroy(self.context, sec['id'])
 
154
 
139
155
    def test_describe_volumes(self):
140
156
        """Makes sure describe_volumes works and filters results."""
141
157
        vol1 = db.volume_create(self.context, {})
294
310
                LOG.debug(_("Terminating instance %s"), instance_id)
295
311
                rv = self.compute.terminate_instance(instance_id)
296
312
 
297
 
    def test_describe_instances(self):
298
 
        """Makes sure describe_instances works."""
299
 
        instance1 = db.instance_create(self.context, {'host': 'host2'})
300
 
        comp1 = db.service_create(self.context, {'host': 'host2',
301
 
                                                 'availability_zone': 'zone1',
302
 
                                                 'topic': "compute"})
303
 
        result = self.cloud.describe_instances(self.context)
304
 
        self.assertEqual(result['reservationSet'][0]
305
 
                         ['instancesSet'][0]
306
 
                         ['placement']['availabilityZone'], 'zone1')
307
 
        db.instance_destroy(self.context, instance1['id'])
308
 
        db.service_destroy(self.context, comp1['id'])
309
 
 
310
313
    @staticmethod
311
314
    def _fake_set_image_description(ctxt, image_id, description):
312
315
        from nova.objectstore import handler