diff options
| author | Rick Harris <rconradharris@gmail.com> | 2013-02-26 00:47:49 +0000 |
|---|---|---|
| committer | Rick Harris <rconradharris@gmail.com> | 2013-02-26 00:49:59 +0000 |
| commit | e62d0cb93a4ac788f208982d5d24ced4bc7c4c8f (patch) | |
| tree | 4aa6e46d159d14a384dbedcbbeccf415ea0601fe /nova/tests | |
| parent | d9bbcfb76646cb77d9dfc867f057917b3e059a4f (diff) | |
Migration 147: Prevent duplicate aggregate_hosts
If an aggregate_host record is already present, then the `upgrade`
shouldn't attempt to add it again.
Change-Id: Ib7ab10fa7c166ccaa3df6a96eb08c7ebcd0af38c
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_migrations.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index 55963a81b..60efcf34f 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -588,8 +588,24 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn): services = get_table(engine, 'services') engine.execute(services.insert(), data) + self._pre_upgrade_147_no_duplicate_aggregate_hosts(engine) return data + def _pre_upgrade_147_no_duplicate_aggregate_hosts(self, engine): + engine.execute(get_table(engine, 'aggregate_metadata').insert(), [ + {'aggregate_id': 1, + 'key': 'availability_zone', + 'value': 'custom_az'}]) + + engine.execute(get_table(engine, 'aggregate_hosts').insert(), [ + {'aggregate_id': 1, + 'host': 'compute-host3'}]) + + engine.execute(get_table(engine, 'services').insert(), [ + {'id': 99, 'host': 'compute-host3', + 'binary': 'nova-compute', 'topic': 'compute', + 'report_count': 0, 'availability_zone': 'custom_az'}]) + def _check_147(self, engine, data): aggregate_md = get_table(engine, 'aggregate_metadata') aggregate_hosts = get_table(engine, 'aggregate_hosts') @@ -612,6 +628,15 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn): ).execute().first() self.assertEqual(host, None) + self._check_147_no_duplicate_aggregate_hosts(engine, data) + + def _check_147_no_duplicate_aggregate_hosts(self, engine, data): + aggregate_hosts = get_table(engine, 'aggregate_hosts') + agg1_hosts = [h['host'] for h in aggregate_hosts.select( + aggregate_hosts.c.aggregate_id == 1 + ).execute().fetchall()] + self.assertEqual(['compute-host3'], agg1_hosts) + # migration 149, changes IPAddr storage format def _pre_upgrade_149(self, engine): provider_fw_rules = get_table(engine, 'provider_fw_rules') |
