From 1a696c5604b3dadb1eb78879d966c4f1d2c65263 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 3 Nov 2016 22:27:50 +0000 Subject: [PATCH] Forbid contract migration scripts for Ocata This test case will guarantee us that no unsafe contract scripts are landed. Since in Ocata timeframe any contract script is unsafe, we forbid them globally. Later in Pike, we may revisit the approach taken here. Change-Id: I5e72288ead653bdd4b5bc7e8e602a615826334fe Partially-Implements: blueprint online-upgrades --- neutron/tests/functional/db/test_migrations.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index cbb52ab3bf4..04d231f1a47 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -319,6 +319,22 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): def test_has_offline_migrations_all_heads_upgraded(self): self._test_has_offline_migrations('heads', False) + # NOTE(ihrachys): if this test fails for you, it probably means that you + # attempt to add an unsafe contract migration script, that is in + # contradiction to blueprint online-upgrades + # TODO(ihrachys): revisit later in Pike+ where some contract scripts may be + # safe again + def test_forbid_offline_migrations_starting_newton(self): + engine = self.get_engine() + cfg.CONF.set_override('connection', engine.url, group='database') + # the following revisions are Newton heads + for revision in ('5cd92597d11d', '5c85685d616d'): + migration.do_alembic_command( + self.alembic_config, 'upgrade', revision) + self.assertFalse(migration.has_offline_migrations( + self.alembic_config, 'unused'), + msg='Offline contract migration scripts are forbidden for Ocata+') + class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin, _TestModelsMigrations,