From 80ec3658033b1520cac9071e36b0cda2ac60f166 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 20 Nov 2015 17:35:10 +0100 Subject: [PATCH] neutron-db-manage: expose alembic 'heads' command This command shows current heads in all alembic branches. Even without the command, we *can* get the heads values by looking into *_HEAD files in tree. Still, those files may be missing; and the command is a tiny bit more easy to use. Also, it gives access to more details on head revisions if used with --verbose. Change-Id: I6e7b7b5cd6f704d5d4bb4d845bf5098d4045924a --- neutron/db/migration/cli.py | 2 +- neutron/tests/unit/db/test_migration.py | 34 +++++++++---------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index 99bf7e605..9dc22112c 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -431,7 +431,7 @@ def update_head_file(config): def add_command_parsers(subparsers): - for name in ['current', 'history', 'branches']: + for name in ['current', 'history', 'branches', 'heads']: parser = add_alembic_subparser(subparsers, name) parser.set_defaults(func=do_generic_show) parser.add_argument('--verbose', diff --git a/neutron/tests/unit/db/test_migration.py b/neutron/tests/unit/db/test_migration.py index 578343154..20f25c7ea 100644 --- a/neutron/tests/unit/db/test_migration.py +++ b/neutron/tests/unit/db/test_migration.py @@ -173,38 +173,28 @@ class TestCli(base.BaseTestCase): [{'revision': 'foo', 'sql': True}] ) - def test_branches(self): + def _validate_cmd(self, cmd): self._main_test_helper( - ['prog', 'branches'], - 'branches', + ['prog', cmd], + cmd, [{'verbose': False}]) self._main_test_helper( - ['prog', 'branches', '--verbose'], - 'branches', + ['prog', cmd, '--verbose'], + cmd, [{'verbose': True}]) - def test_current(self): - self._main_test_helper( - ['prog', 'current'], - 'current', - [{'verbose': False}]) + def test_branches(self): + self._validate_cmd('branches') - self._main_test_helper( - ['prog', 'current', '--verbose'], - 'current', - [{'verbose': True}]) + def test_current(self): + self._validate_cmd('current') def test_history(self): - self._main_test_helper( - ['prog', 'history'], - 'history', - [{'verbose': False}]) + self._validate_cmd('history') - self._main_test_helper( - ['prog', 'history', '--verbose'], - 'history', - [{'verbose': True}]) + def test_heads(self): + self._validate_cmd('heads') def test_check_migration(self): with mock.patch.object(cli, 'validate_head_file') as validate: -- 2.45.2