diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-04-30 19:04:09 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-04-30 19:04:09 +0000 |
| commit | 85f1f074b24c1f7eb7ab93f7d7bdb9cdffaeed35 (patch) | |
| tree | dc200914b384d7382567c30d65d8f4939a4144cf /nova/tests | |
| parent | d04a023ec6d716a03ab98b842abb572437728a59 (diff) | |
| parent | 2cf1f39d9ea7a9436708c5458d42d4dd75717e16 (diff) | |
Merge "Add the availability_zone to the volume.usage notifications"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 2 | ||||
| -rw-r--r-- | nova/tests/conductor/test_conductor.py | 16 | ||||
| -rw-r--r-- | nova/tests/test_db_api.py | 14 | ||||
| -rw-r--r-- | nova/tests/test_migrations.py | 16 |
4 files changed, 38 insertions, 10 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index d4612a62e..277e804ac 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -454,6 +454,7 @@ class ComputeVolumeTestCase(BaseTestCase): 'instance_uuid': 'fake_instance_uuid', 'project_id': 'fake_project_id', 'user_id': 'fake_user_id', + 'availability_zone': 'fake-az', 'tot_reads': 11, 'curr_reads': 22, 'tot_read_bytes': 33, @@ -483,6 +484,7 @@ class ComputeVolumeTestCase(BaseTestCase): self.assertEquals(payload['read_bytes'], 77) self.assertEquals(payload['writes'], 121) self.assertEquals(payload['write_bytes'], 165) + self.assertEquals(payload['availability_zone'], 'fake-az') def test_detach_volume_usage(self): # Test that detach volume update the volume usage cache table correctly diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 9731a76d7..b3088855a 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -82,6 +82,7 @@ class _BaseTestCase(object): inst['ephemeral_gb'] = 0 inst['architecture'] = 'x86_64' inst['os_type'] = 'Linux' + inst['availability_zone'] = 'fake-az' inst.update(params) return db.instance_create(self.context, inst) @@ -374,17 +375,18 @@ class _BaseTestCase(object): def test_vol_usage_update(self): self.mox.StubOutWithMock(db, 'vol_usage_update') + inst = self._create_fake_instance({ + 'project_id': 'fake-project_id', + 'user_id': 'fake-user_id', + }) db.vol_usage_update(self.context, 'fake-vol', 'rd-req', 'rd-bytes', - 'wr-req', 'wr-bytes', 'fake-id', - 'fake-project_id', 'fake-user_id', 'fake-refr', - 'fake-bool') + 'wr-req', 'wr-bytes', inst['uuid'], + 'fake-project_id', 'fake-user_id', 'fake-az', + 'fake-refr', 'fake-bool') self.mox.ReplayAll() self.conductor.vol_usage_update(self.context, 'fake-vol', 'rd-req', 'rd-bytes', 'wr-req', 'wr-bytes', - {'uuid': 'fake-id', - 'project_id': 'fake-project_id', - 'user_id': 'fake-user_id'}, - 'fake-refr', 'fake-bool') + inst, 'fake-refr', 'fake-bool') def test_compute_node_create(self): self.mox.StubOutWithMock(db, 'compute_node_create') diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index efdba9b78..6dc3287bf 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -2705,17 +2705,20 @@ class VolumeUsageDBApiTestCase(test.TestCase): wr_req=30, wr_bytes=40, instance_id='fake-instance-uuid1', project_id='fake-project-uuid1', - user_id='fake-user-uuid1') + user_id='fake-user-uuid1', + availability_zone='fake-az') vol_usage = db.vol_usage_update(ctxt, 2, rd_req=100, rd_bytes=200, wr_req=300, wr_bytes=400, instance_id='fake-instance-uuid2', project_id='fake-project-uuid2', - user_id='fake-user-uuid2') + user_id='fake-user-uuid2', + availability_zone='fake-az') vol_usage = db.vol_usage_update(ctxt, 1, rd_req=1000, rd_bytes=2000, wr_req=3000, wr_bytes=4000, instance_id='fake-instance-uuid1', project_id='fake-project-uuid1', user_id='fake-user-uuid1', + availability_zone='fake-az', last_refreshed=refreshed_time) vol_usages = db.vol_get_usage_by_time(ctxt, start_time) @@ -2733,6 +2736,7 @@ class VolumeUsageDBApiTestCase(test.TestCase): 'project_id': 'fake-project-uuid', 'user_id': 'fake-user-uuid', 'instance_uuid': 'fake-instance-uuid', + 'availability_zone': 'fake-az', 'tot_reads': 600, 'tot_read_bytes': 800, 'tot_writes': 1000, @@ -2746,23 +2750,27 @@ class VolumeUsageDBApiTestCase(test.TestCase): wr_req=300, wr_bytes=400, instance_id='fake-instance-uuid', project_id='fake-project-uuid', - user_id='fake-user-uuid') + user_id='fake-user-uuid', + availability_zone='fake-az') vol_usage = db.vol_usage_update(ctxt, 1, rd_req=200, rd_bytes=300, wr_req=400, wr_bytes=500, instance_id='fake-instance-uuid', project_id='fake-project-uuid', user_id='fake-user-uuid', + availability_zone='fake-az', update_totals=True) vol_usage = db.vol_usage_update(ctxt, 1, rd_req=300, rd_bytes=400, wr_req=500, wr_bytes=600, instance_id='fake-instance-uuid', project_id='fake-project-uuid', + availability_zone='fake-az', user_id='fake-user-uuid') vol_usage = db.vol_usage_update(ctxt, 1, rd_req=400, rd_bytes=500, wr_req=600, wr_bytes=700, instance_id='fake-instance-uuid', project_id='fake-project-uuid', user_id='fake-user-uuid', + availability_zone='fake-az', update_totals=True) vol_usages = db.vol_get_usage_by_time(ctxt, start_time) diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index f62e627ce..8c2f04f21 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -1269,6 +1269,22 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn): self.assertFalse('user_id' in rows[0]) self.assertEqual(rows[0]['instance_id'], None) + def _check_176(self, engine, data): + volume_usage_cache = get_table(engine, 'volume_usage_cache') + # Get the record + rows = volume_usage_cache.select().execute().fetchall() + self.assertEqual(len(rows), 1) + + self.assertEqual(rows[0]['availability_zone'], None) + + def _post_downgrade_176(self, engine): + volume_usage_cache = get_table(engine, 'volume_usage_cache') + # Get the record + rows = volume_usage_cache.select().execute().fetchall() + self.assertEqual(len(rows), 1) + + self.assertFalse('availability_zone' in rows[0]) + class TestBaremetalMigrations(BaseMigrationTestCase, CommonTestsMixIn): """Test sqlalchemy-migrate migrations.""" |
