Merge "Properly create and delete Aggregates"

This commit is contained in:
Jenkins 2012-09-20 03:57:20 +00:00 committed by Gerrit Code Review
commit be99338950
2 changed files with 34 additions and 0 deletions

View File

@ -610,6 +610,17 @@ class AggregateDBApiTestCase(test.TestCase):
expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
self.assertDictMatch(expected_metadata, _get_fake_aggr_metadata())
def test_aggregate_create_delete_create_with_metadata(self):
"""Ensure aggregate metadata is deleted bug 1052479."""
ctxt = context.get_admin_context()
result = _create_aggregate(context=ctxt)
expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
self.assertDictMatch(expected_metadata, _get_fake_aggr_metadata())
db.aggregate_delete(ctxt, result['id'])
result = _create_aggregate(metadata=None)
expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
self.assertEqual(expected_metadata, {})
def test_aggregate_create_low_privi_context(self):
"""Ensure right context is applied when creating aggregate."""
self.assertRaises(exception.AdminRequired,

View File

@ -480,3 +480,26 @@ class TestMigrations(test.TestCase):
migration_api.downgrade(engine, TestMigrations.REPOSITORY, 111)
agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first()
self.assertEqual(host, agg.host)
def test_migration_133(self):
for key, engine in self.engines.items():
migration_api.version_control(engine, TestMigrations.REPOSITORY,
migration.INIT_VERSION)
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 132)
# Set up a single volume, values don't matter
metadata = sqlalchemy.schema.MetaData()
metadata.bind = engine
aggregates = sqlalchemy.Table('aggregates', metadata,
autoload=True)
name = 'name'
aggregates.insert().values(id=1, availability_zone='nova',
aggregate_name=1, name=name).execute()
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 133)
aggregates.insert().values(id=2, availability_zone='nova',
aggregate_name=2, name=name).execute()
migration_api.downgrade(engine, TestMigrations.REPOSITORY, 132)
agg = sqlalchemy.select([aggregates.c.name]).execute().first()
self.assertEqual(name, agg.name)