diff options
author | Victor Sergeyev <vsergeyev@mirantis.com> | 2014-07-23 13:15:23 +0300 |
---|---|---|
committer | Victor Sergeyev <vsergeyev@mirantis.com> | 2014-07-23 20:08:41 +0300 |
commit | 82de9e34d0cf7343aae77c78b0b645ac1765ac35 (patch) | |
tree | 0c3b2233927bf2e8788d1d1ddea753204a7f9d7a | |
parent | 12023ad1a116be4b1b15272b2d43dce3833403a7 (diff) | |
download | ironic-82de9e34d0cf7343aae77c78b0b645ac1765ac35.tar.gz |
Catch oslo.db error instead of sqlalchemy error
The latest oslo.db code wraps all sqlalchemy exceptions and re-raise
them as oslo.db exceptions. But there is a single case in Ironic when
we suppose to get sqlalchemy exception, so this will break unittest,
when the new version of oslo.db will come.
Added check for the new oslo.db exception, left the old check for the
compatibility.
Closes-Bug: #1214341
Change-Id: Iae5599948d29778ac416edf31d3b1b2f7a8a54a9
-rw-r--r-- | ironic/tests/db/sqlalchemy/test_migrations.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ironic/tests/db/sqlalchemy/test_migrations.py b/ironic/tests/db/sqlalchemy/test_migrations.py index 8a643f3fc..3dde3a8ac 100644 --- a/ironic/tests/db/sqlalchemy/test_migrations.py +++ b/ironic/tests/db/sqlalchemy/test_migrations.py @@ -42,6 +42,7 @@ import contextlib from alembic import script import mock +from oslo.db import exception from oslo.db.sqlalchemy import test_base from oslo.db.sqlalchemy import utils as db_utils import sqlalchemy @@ -307,8 +308,12 @@ class MigrationCheckersMixin(object): 'instance_uuid': instance_uuid} nodes.insert().values(data).execute() data['uuid'] = utils.generate_uuid() - self.assertRaises(sqlalchemy.exc.IntegrityError, - nodes.insert().execute, data) + # TODO(viktors): Remove check on sqlalchemy.exc.IntegrityError, when + # Ironic will use oslo.db 0.4.0 or higher. + # See bug #1214341 for details. + self.assertRaises( + (sqlalchemy.exc.IntegrityError, exception.DBDuplicateEntry), + nodes.insert().execute, data) class TestMigrationsMySQL(MigrationCheckersMixin, |