def test_migration_146(self): name = 'name' az = 'custom_az' def _145_check(): agg = aggregates.select(aggregates.c.id == 1).execute().first() self.assertEqual(name, agg.name) self.assertEqual(az, agg.availability_zone) for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 145) metadata = sqlalchemy.schema.MetaData() metadata.bind = engine aggregates = sqlalchemy.Table('aggregates', metadata, autoload=True) aggregates.insert().values(id=1, availability_zone=az, aggregate_name=1, name=name).execute() _145_check() migration_api.upgrade(engine, TestMigrations.REPOSITORY, 146) aggregate_metadata = sqlalchemy.Table('aggregate_metadata', metadata, autoload=True) metadata = aggregate_metadata.select(aggregate_metadata.c. aggregate_id == 1).execute().first() self.assertEqual(az, metadata['value']) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 145) _145_check()
def _migrate_down(self, engine, version): migration_api.downgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY))
def _migrate_down(self, engine, version): migration_api.downgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY))
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)
def test_migration_147(self): az = 'test_zone' host1 = 'compute-host1' host2 = 'compute-host2' def _146_check(): service = services.select(services.c.id == 1).execute().first() self.assertEqual(az, service.availability_zone) self.assertEqual(host1, service.host) service = services.select(services.c.id == 2).execute().first() self.assertNotEqual(az, service.availability_zone) service = services.select(services.c.id == 3).execute().first() self.assertEqual(az, service.availability_zone) self.assertEqual(host2, service.host) for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 146) metadata = sqlalchemy.schema.MetaData() metadata.bind = engine #populate service table services = sqlalchemy.Table('services', metadata, autoload=True) services.insert().values(id=1, host=host1, binary='nova-compute', topic='compute', report_count=0, availability_zone=az).execute() services.insert().values(id=2, host='sched-host', binary='nova-scheduler', topic='scheduler', report_count=0, availability_zone='ignore_me').execute() services.insert().values(id=3, host=host2, binary='nova-compute', topic='compute', report_count=0, availability_zone=az).execute() _146_check() migration_api.upgrade(engine, TestMigrations.REPOSITORY, 147) # check aggregate metadata aggregate_metadata = sqlalchemy.Table('aggregate_metadata', metadata, autoload=True) aggregate_hosts = sqlalchemy.Table('aggregate_hosts', metadata, autoload=True) metadata = aggregate_metadata.select(aggregate_metadata.c. aggregate_id == 1).execute().first() self.assertEqual(az, metadata['value']) self.assertEqual(aggregate_hosts.select( aggregate_hosts.c.aggregate_id == 1).execute(). first().host, host1) blank = [h for h in aggregate_hosts.select( aggregate_hosts.c.aggregate_id == 2).execute()] self.assertEqual(blank, []) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 146) _146_check()
def test_migration_98(self): """Test that migration 98 runs This test exists to prove bug 1047633 has been fixed """ for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 97) # Set up a single volume, values don't matter metadata = sqlalchemy.schema.MetaData() metadata.bind = engine volumes = sqlalchemy.Table('volumes', metadata, autoload=True) vol_id = '9db3c2e5-8cac-4e94-9e6c-b5f750736727' volumes.insert().values(id=vol_id).execute() migration_api.upgrade(engine, TestMigrations.REPOSITORY, 98) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 97)
def test_migration_98(self): """Test that migration 98 runs This test exists to prove bug 1047633 has been fixed """ for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 97) # Set up a single volume, values don't matter metadata = sqlalchemy.schema.MetaData() metadata.bind = engine volumes = sqlalchemy.Table('volumes', metadata, autoload=True) vol_id = '9db3c2e5-8cac-4e94-9e6c-b5f750736727' volumes.insert().values(id=vol_id).execute() migration_api.upgrade(engine, TestMigrations.REPOSITORY, 98) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 97)
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)
def test_migration_111(self): for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 110) metadata = sqlalchemy.schema.MetaData() metadata.bind = engine aggregate_hosts = sqlalchemy.Table('aggregate_hosts', metadata, autoload=True) host = 'host' aggregate_hosts.insert().values(id=1, aggregate_id=1, host=host).execute() migration_api.upgrade(engine, TestMigrations.REPOSITORY, 111) agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first() self.assertEqual(host, agg.host) aggregate_hosts.insert().values(id=2, aggregate_id=2, host=host).execute() migration_api.downgrade(engine, TestMigrations.REPOSITORY, 111) agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first() self.assertEqual(host, agg.host)
def test_migration_111(self): for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 110) metadata = sqlalchemy.schema.MetaData() metadata.bind = engine aggregate_hosts = sqlalchemy.Table('aggregate_hosts', metadata, autoload=True) host = 'host' aggregate_hosts.insert().values(id=1, aggregate_id=1, host=host).execute() migration_api.upgrade(engine, TestMigrations.REPOSITORY, 111) agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first() self.assertEqual(host, agg.host) aggregate_hosts.insert().values(id=2, aggregate_id=2, host=host).execute() migration_api.downgrade(engine, TestMigrations.REPOSITORY, 111) agg = sqlalchemy.select([aggregate_hosts.c.host]).execute().first() self.assertEqual(host, agg.host)
def _walk_versions(self, engine=None, snake_walk=False): # Determine latest version script from the repo, then # upgrade from 1 through to the latest, with no data # in the databases. This just checks that the schema itself # upgrades successfully. # Place the database under version control migration_api.version_control(engine, TestMigrations.REPOSITORY) self.assertEqual(0, migration_api.db_version(engine, TestMigrations.REPOSITORY)) LOG.debug('latest version is %s' % TestMigrations.REPOSITORY.latest) for version in xrange(1, TestMigrations.REPOSITORY.latest + 1): # upgrade -> downgrade -> upgrade migration_api.upgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) if snake_walk: migration_api.downgrade(engine, TestMigrations.REPOSITORY, version - 1) self.assertEqual(version - 1, migration_api.db_version(engine, TestMigrations.REPOSITORY)) migration_api.upgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) # Now walk it back down to 0 from the latest, testing # the downgrade paths. for version in reversed( xrange(0, TestMigrations.REPOSITORY.latest)): # downgrade -> upgrade -> downgrade migration_api.downgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) if snake_walk: migration_api.upgrade(engine, TestMigrations.REPOSITORY, version + 1) self.assertEqual(version + 1, migration_api.db_version(engine, TestMigrations.REPOSITORY)) migration_api.downgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual(version, migration_api.db_version(engine, TestMigrations.REPOSITORY))
def _walk_versions(self, engine=None, snake_walk=False): # Determine latest version script from the repo, then # upgrade from 1 through to the latest, with no data # in the databases. This just checks that the schema itself # upgrades successfully. # Place the database under version control migration_api.version_control(engine, TestMigrations.REPOSITORY) self.assertEqual( 0, migration_api.db_version(engine, TestMigrations.REPOSITORY)) LOG.debug('latest version is %s' % TestMigrations.REPOSITORY.latest) for version in xrange(1, TestMigrations.REPOSITORY.latest + 1): # upgrade -> downgrade -> upgrade migration_api.upgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual( version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) if snake_walk: migration_api.downgrade(engine, TestMigrations.REPOSITORY, version - 1) self.assertEqual( version - 1, migration_api.db_version(engine, TestMigrations.REPOSITORY)) migration_api.upgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual( version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) # Now walk it back down to 0 from the latest, testing # the downgrade paths. for version in reversed(xrange(0, TestMigrations.REPOSITORY.latest)): # downgrade -> upgrade -> downgrade migration_api.downgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual( version, migration_api.db_version(engine, TestMigrations.REPOSITORY)) if snake_walk: migration_api.upgrade(engine, TestMigrations.REPOSITORY, version + 1) self.assertEqual( version + 1, migration_api.db_version(engine, TestMigrations.REPOSITORY)) migration_api.downgrade(engine, TestMigrations.REPOSITORY, version) self.assertEqual( version, migration_api.db_version(engine, TestMigrations.REPOSITORY))
def test_migration_91(self): """Test that migration 91 works correctly. This test prevents regression of bugs 1052244 and 1052220. """ for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 90) vol1_id = '10' vol1_uuid = '9db3c2e5-8cac-4e94-9e6c-b5f750736727' vol2_id = '11' vol2_uuid = 'fb17fb5a-ca3d-4bba-8903-fc776ea81d78' snap_id = '7' snap_uuid = 'a87e5108-8a2b-4c89-be96-0e8760db2c6a' inst_id = '0ec45d38-aefd-4c42-a209-361e848240b7' metadata = sqlalchemy.schema.MetaData() metadata.bind = engine instances = sqlalchemy.Table('instances', metadata, autoload=True) volumes = sqlalchemy.Table('volumes', metadata, autoload=True) sm_flavors = sqlalchemy.Table( 'sm_flavors', metadata, autoload=True) sm_backend_config = sqlalchemy.Table( 'sm_backend_config', metadata, autoload=True) sm_volume = sqlalchemy.Table( 'sm_volume', metadata, autoload=True) volume_mappings = sqlalchemy.Table( 'volume_id_mappings', metadata, autoload=True) iscsi_targets = sqlalchemy.Table( 'iscsi_targets', metadata, autoload=True) volume_metadata = sqlalchemy.Table( 'volume_metadata', metadata, autoload=True) snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True) snapshot_mappings = sqlalchemy.Table( 'snapshot_id_mappings', metadata, autoload=True) block_device_mapping = sqlalchemy.Table( 'block_device_mapping', metadata, autoload=True) volumes.insert().values(id=vol1_id).execute() volume_mappings.insert() \ .values(id=vol1_id, uuid=vol1_uuid).execute() snapshots.insert().values(id=snap_id, volume_id=vol1_id).execute() snapshot_mappings.insert() \ .values(id=snap_id, uuid=snap_uuid).execute() volumes.insert().values(id=vol2_id, snapshot_id=snap_id).execute() volume_mappings.insert() \ .values(id=vol2_id, uuid=vol2_uuid).execute() sm_flavors.insert().values(id=7).execute() sm_backend_config.insert().values(id=7, flavor_id=7).execute() sm_volume.insert().values(id=vol1_id, backend_id=7).execute() volume_metadata.insert().values(id=7, volume_id=vol1_id).execute() iscsi_targets.insert().values(id=7, volume_id=vol1_id).execute() instances.insert().values(id=7, uuid=inst_id).execute() block_device_mapping.insert()\ .values(id=7, volume_id=vol1_id, instance_uuid=inst_id) \ .execute() vols = volumes.select().execute().fetchall() self.assertEqual(set([vol.id for vol in vols]), set([vol1_id, vol2_id])) self.assertEqual(snap_id, vols[1].snapshot_id) query = volume_metadata.select(volume_metadata.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = iscsi_targets.select(iscsi_targets.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = block_device_mapping.select(block_device_mapping.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall() self.assertEqual(set([snap.id for snap in snaps]), set([snap_id])) sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall() self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]), set([vol1_id])) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 91) vols = volumes.select().execute().fetchall() self.assertEqual(set([vol.id for vol in vols]), set([vol1_uuid, vol2_uuid])) self.assertEqual(snap_uuid, vols[1].snapshot_id) query = volume_metadata.select(volume_metadata.c.id == 7) self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id) query = iscsi_targets.select(iscsi_targets.c.id == 7) self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id) query = block_device_mapping.select(block_device_mapping.c.id == 7) self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id) snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall() self.assertEqual(set([snap.id for snap in snaps]), set([snap_uuid])) sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall() self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]), set([vol1_uuid])) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 90) vols = volumes.select().execute().fetchall() self.assertEqual(set([vol.id for vol in vols]), set([vol1_id, vol2_id])) self.assertEqual(snap_id, vols[1].snapshot_id) query = volume_metadata.select(volume_metadata.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = iscsi_targets.select(iscsi_targets.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = block_device_mapping.select(block_device_mapping.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall() self.assertEqual(set([snap.id for snap in snaps]), set([snap_id])) sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall() self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]), set([vol1_id]))
def test_migration_152(self): host1 = 'compute-host1' host2 = 'compute-host2' def _151_check(services, volumes): service = services.select(services.c.id == 1).execute().first() self.assertEqual(False, service.deleted) service = services.select(services.c.id == 2).execute().first() self.assertEqual(True, service.deleted) volume = volumes.select(volumes.c.id == "first").execute().first() self.assertEqual(False, volume.deleted) volume = volumes.select(volumes.c.id == "second").execute().first() self.assertEqual(True, volume.deleted) for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 151) metadata = sqlalchemy.schema.MetaData() metadata.bind = engine # NOTE(boris-42): It is enough to test one table with type of `id` # column Integer and one with type String. services = sqlalchemy.Table('services', metadata, autoload=True) volumes = sqlalchemy.Table('volumes', metadata, autoload=True) engine.execute( services.insert(), [ {'id': 1, 'host': host1, 'binary': 'nova-compute', 'report_count': 0, 'topic': 'compute', 'deleted': False}, {'id': 2, 'host': host1, 'binary': 'nova-compute', 'report_count': 0, 'topic': 'compute', 'deleted': True} ] ) engine.execute( volumes.insert(), [ {'id': 'first', 'host': host1, 'deleted': False}, {'id': 'second', 'host': host2, 'deleted': True} ] ) _151_check(services, volumes) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 152) # NOTE(boris-42): One more time get from DB info about tables. metadata2 = sqlalchemy.schema.MetaData() metadata2.bind = engine services = sqlalchemy.Table('services', metadata2, autoload=True) service = services.select(services.c.id == 1).execute().first() self.assertEqual(0, service.deleted) service = services.select(services.c.id == 2).execute().first() self.assertEqual(service.id, service.deleted) volumes = sqlalchemy.Table('volumes', metadata2, autoload=True) volume = volumes.select(volumes.c.id == "first").execute().first() self.assertEqual("", volume.deleted) volume = volumes.select(volumes.c.id == "second").execute().first() self.assertEqual(volume.id, volume.deleted) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 151) # NOTE(boris-42): One more time get from DB info about tables. metadata = sqlalchemy.schema.MetaData() metadata.bind = engine services = sqlalchemy.Table('services', metadata, autoload=True) volumes = sqlalchemy.Table('volumes', metadata, autoload=True) _151_check(services, volumes)
def test_migration_91(self): """Test that migration 91 works correctly. This test prevents regression of bugs 1052244 and 1052220. """ for key, engine in self.engines.items(): migration_api.version_control(engine, TestMigrations.REPOSITORY, migration.INIT_VERSION) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 90) vol1_id = '10' vol1_uuid = '9db3c2e5-8cac-4e94-9e6c-b5f750736727' vol2_id = '11' vol2_uuid = 'fb17fb5a-ca3d-4bba-8903-fc776ea81d78' snap_id = '7' snap_uuid = 'a87e5108-8a2b-4c89-be96-0e8760db2c6a' inst_id = '0ec45d38-aefd-4c42-a209-361e848240b7' metadata = sqlalchemy.schema.MetaData() metadata.bind = engine instances = sqlalchemy.Table('instances', metadata, autoload=True) volumes = sqlalchemy.Table('volumes', metadata, autoload=True) sm_flavors = sqlalchemy.Table('sm_flavors', metadata, autoload=True) sm_backend_config = sqlalchemy.Table('sm_backend_config', metadata, autoload=True) sm_volume = sqlalchemy.Table('sm_volume', metadata, autoload=True) volume_mappings = sqlalchemy.Table('volume_id_mappings', metadata, autoload=True) iscsi_targets = sqlalchemy.Table('iscsi_targets', metadata, autoload=True) volume_metadata = sqlalchemy.Table('volume_metadata', metadata, autoload=True) snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True) snapshot_mappings = sqlalchemy.Table('snapshot_id_mappings', metadata, autoload=True) block_device_mapping = sqlalchemy.Table('block_device_mapping', metadata, autoload=True) volumes.insert().values(id=vol1_id).execute() volume_mappings.insert() \ .values(id=vol1_id, uuid=vol1_uuid).execute() snapshots.insert().values(id=snap_id, volume_id=vol1_id).execute() snapshot_mappings.insert() \ .values(id=snap_id, uuid=snap_uuid).execute() volumes.insert().values(id=vol2_id, snapshot_id=snap_id).execute() volume_mappings.insert() \ .values(id=vol2_id, uuid=vol2_uuid).execute() sm_flavors.insert().values(id=7).execute() sm_backend_config.insert().values(id=7, flavor_id=7).execute() sm_volume.insert().values(id=vol1_id, backend_id=7).execute() volume_metadata.insert().values(id=7, volume_id=vol1_id).execute() iscsi_targets.insert().values(id=7, volume_id=vol1_id).execute() instances.insert().values(id=7, uuid=inst_id).execute() block_device_mapping.insert()\ .values(id=7, volume_id=vol1_id, instance_uuid=inst_id) \ .execute() vols = volumes.select().execute().fetchall() self.assertEqual(set([vol.id for vol in vols]), set([vol1_id, vol2_id])) self.assertEqual(snap_id, vols[1].snapshot_id) query = volume_metadata.select(volume_metadata.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = iscsi_targets.select(iscsi_targets.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = block_device_mapping.select(block_device_mapping.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall() self.assertEqual(set([snap.id for snap in snaps]), set([snap_id])) sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall() self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]), set([vol1_id])) migration_api.upgrade(engine, TestMigrations.REPOSITORY, 91) vols = volumes.select().execute().fetchall() self.assertEqual(set([vol.id for vol in vols]), set([vol1_uuid, vol2_uuid])) self.assertEqual(snap_uuid, vols[1].snapshot_id) query = volume_metadata.select(volume_metadata.c.id == 7) self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id) query = iscsi_targets.select(iscsi_targets.c.id == 7) self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id) query = block_device_mapping.select(block_device_mapping.c.id == 7) self.assertEqual(vol1_uuid, query.execute().fetchone().volume_id) snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall() self.assertEqual(set([snap.id for snap in snaps]), set([snap_uuid])) sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall() self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]), set([vol1_uuid])) migration_api.downgrade(engine, TestMigrations.REPOSITORY, 90) vols = volumes.select().execute().fetchall() self.assertEqual(set([vol.id for vol in vols]), set([vol1_id, vol2_id])) self.assertEqual(snap_id, vols[1].snapshot_id) query = volume_metadata.select(volume_metadata.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = iscsi_targets.select(iscsi_targets.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) query = block_device_mapping.select(block_device_mapping.c.id == 7) self.assertEqual(vol1_id, query.execute().fetchone().volume_id) snaps = sqlalchemy.select([snapshots.c.id]).execute().fetchall() self.assertEqual(set([snap.id for snap in snaps]), set([snap_id])) sm_vols = sqlalchemy.select([sm_volume.c.id]).execute().fetchall() self.assertEqual(set([sm_vol.id for sm_vol in sm_vols]), set([vol1_id]))