17 Commits

Author SHA1 Message Date
Mike Bayer
43af1cf083 Remove most server_default comparison logic
Added a new test case that covers comparison of a MySQL server default
defined as text("0") in the model as well as in the database.   The
MySQL default comaprison logic in oslo.db was not accommodating of the
model side here being a text() construct.   As modern Alembic
versions supports most of the use cases tested here,
remove all server defaut comparison logic except for the boolean
comparison workaround.

Alembic minimum is bumped to 0.9.6; the issue repaired between
0.8.10 and 0.9.6 is http://alembic.zzzcomputing.com/en/latest/
changelog.html#change-5459a7552a17d8b658f0f710bedf6da0

Depends-on: I1a8244edae47b04b7b1fed54e577d6534945bcd8
Closes-bug: #1776527
Change-Id: I48a103e28d86128ea84466da4d9d6faab1dd9a9d
2018-06-15 13:31:38 +10:00
Mike Bayer
3b260a3bca Conditionally adjust for quoting in comparing MySQL defaults
MariaDB 10.2 appears to not return server defaults with quotes
around integer values which breaks the assumption that we have
to de-quote server default values.  Make the dequoting
a regexp that will pass when the quotes are not present.

Change-Id: Ie5aeffcc3c550673a7fdd82769a315821cebb272
Closes-bug: #1750414
2018-02-22 15:54:58 -05:00
Dong Ma
0a035933c8 turn on warning-is-error in doc build
Change-Id: I0b64c644f40a2da3242274194d1a5d2858813c25
2017-07-03 11:28:14 +00:00
chenlx
443b3e3262 Remove log translations
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Closes-Bug: #1674577

Change-Id: I7553ae7c222f61b6796b72ac4a2b744d3e08fee6
2017-03-30 08:42:42 +08:00
Mehdi Abaakouk
e8e2421f8b migration: don't assume the mixin use provision
In 2ad571c8d7a7e1d8d18f7c5e97c564509fd34816 we have changed the backend
used to cleanup the ModelsMigrationsSync by the one from
oslo_db.sqlalchemy.provision.

But in ModelsMigrationsSync, nothing uses the provisioning system. The
engine can be created outside oslo.db. And oslo.db must must not assume
it have been created by the oslo_db.sqlalchemy.provision module.

For example, 2ad571c8d7a7e1d8d18f7c5e97c564509fd34816 have broken the
Gnocchi models migration test that creates the engine itself.

This change builds a new backend to cleanup all database objects.

Change-Id: Ie8c454528ce3aa816c04fbb4beb69f4b5ec57e9c
Closes-bug: #1647280
2016-12-05 11:46:17 +01:00
Mike Bayer
2ad571c8d7 Enhanced fixtures for enginefacade-based provisioning
The original idea of enginefacade was that applications
would call upon the global _TransactionContextManager
given in oslo_db.sqlalchemy.enginefacade.  However, as it
turns out, virtually no Openstack projects seem to be
using that technique, and instead, everyone is creating
their own ad-hoc _TransactionContextManager objects
and usually establishing it as a module-level global.
Nova has two of them.

Additionally, projects add configuration to these
enginefacades (which IS part of the original idea), and
this configuration in some cases is necessary to be present
for tests that run as well, a key example being the
sqlite_fks flag.   The original DbFixture integration
provided no way of reusing this configuration.

Finally, projects very much tend to use custom fixtures
in order to define their database communication.
Test classes themselves don't really make use of
oslo_db's DbTestCase anymore.

This patch introduces a modernized fixture system
which, in conjunction with the recent provisioning
patch, addresses these use cases.   Applications will typically
create their own subclasses of these fixtures up front
to suit the various testing cases they have, including
SQLite fixed, SQLite ad-hoc, and opportunistic.

In order to accommodate the fixture-based flow
along with the use of testresources for opportunistic
database provisioning, a mixin class OpportunisticDbTestMixin
is still needed when a test needs to use "opportunistic"
testing in order to provide the .resources attribute.
The calculation of .resources is moved into the fixture
system, but because this attribute is consulted before
setUp(), the "opportunistic" fixture must be created
early and stored.

Closes-Bug: #1548960

Change-Id: I0163e637ffef6d45d2573ebe29b5438911d01fce
2016-11-04 17:50:01 +02:00
Julien Danjou
e0db469371 exception: make message mandatory in DbMigrationError and deprecates it
An exception message with None as an error message is not really useful. Since
DbMigrationError is also wrongly written with a lower case b whereas everything
else has a major B, let's create a new correct class and use it.

debtcollector is used to deprecate the old one, and inheritance makes sure the
current code works.

Change-Id: Id9a477aff38afd5b664b75a549ad561f4c24b6f0
2016-06-27 17:29:55 +02:00
Ann Kamyshnikova
f5a8fb34d3 Fix server_default comparison for BigInteger
It is needed to add manual check for server_default parameter for
BigInteger as it is already done for Integer.

Closes-bug: #1569262

Change-Id: I91b5b3516a6ea0674bc31f3d5a91505fcd927b8b
2016-04-15 17:11:42 +03:00
AKamyshnikova
60af1042b8 Fix comparison of Variant and other type in compare_type
Neutron hit problem with comparison Variant type and BigInteger.
Seems that comparison with Variant is not done properly so add
correction of it in compare_type.

Change-Id: Ic5279fcf11cf9123d007010d094a7f255ba0555e
Related-bug: #1526675
2015-12-19 10:28:55 +03:00
Brant Knudson
14c955cf6d Fix warnings in docstrings
When generating the docs some warnings were generated.

Also, configure doc build so that if there are warnings, the
build will fail.

Change-Id: I7e10499294cf1f06f766cbff392e9de32ea48e5a
2015-09-24 10:56:06 -05:00
Victor Stinner
897498eee2 Fix test_migrations on Python 3
migrate.versioning.api.VerNum() conversion to integer doesn't work in
all cases. Cast explicitly to int in WalkVersionsMixin.walk_versions()
to fix this issue.

Modify unit tests to use VerNum objects instead of using directly
integers. The bug was not seen in tests because tests used int numbers.

Example of error:

    Traceback (most recent call last):
      ...
      File "oslo_db/sqlalchemy/test_migrations.py", line 189, in walk_versions
        versions = range(self.INIT_VERSION + 1, self.REPOSITORY.latest + 1)
    TypeError: 'VerNum' object cannot be interpreted as an integer

This bug impact for example glance.tests.unit.test_migrations of the
Glance project.

Change-Id: I043a66268b957b97f2e8f652c0ee8aec3a00e8dd
2015-07-28 12:50:04 +02:00
Davanum Srinivas
94d583acde Allow projects that use test_models_sync to filter some changes
Adding a filter method so subclasses can choose to implement their
own whitelist/blacklist of differences between their schema and
models.

Closes-Bug: #1468463
Change-Id: I6a5940abd100553da7c7e37efbbcf1d5eac996e5
2015-07-01 14:54:19 +03:00
Mike Bayer
6ccea346d9 Organize provisioning to use testresources
This change introduces the use of the testresources package,
such that the provisioning system uses TestResourceManager
objects in order to create and drop databases, schemas,
and manage transactional testing.  A new series of objects
to support transparent transaction containers within
tests is added as well.

partially implement bp: long-lived-transactionalized-db-fixtures
Partial-Bug: #1339206

Change-Id: I16bfa3af0e1ad6a9231ea38dea7cd76092347f55
2015-02-04 12:49:01 +02:00
Mike Bayer
dcd137a6d5 Implement backend-specific drop_all_objects for provisioning.
This patch implements the drop_all_objects() portion
of the testresources series of changes, so that this
utility is usable right now.  In particular, as SQLAlchemy 1.0
will support reflection of foreign key names in SQLite,
it's necessary that we don't emit a DROP CONSTRAINT
for these against SQLite as SQLite does not support
this command.

The drop_all_objects() is added as a first class element
here and is also added to the _cleanup() method of
the test_migrations base.

Tests are added which exercise the case of mutually-dependent
foreign keys on Postgresql and MySQL as well.

partially implement bp: long-lived-transactionalized-db-fixtures
Partial-Bug: #1339206

Change-Id: I56777834187651f5ba2e43482546c2981524b11c
2015-01-29 14:30:49 -05:00
Mike Bayer
b1fc55c7ce Restore the check_foreign_keys() method.
This method was prematurely removed from oslo.db without
a deprecation phase, when Alembic added support for
foreign key autodetection.   oslo.db continues to use
alembic for this purpose, however the
ModelsMigrationsSync.check_foreign_keys() method is restored
directly for those projects which were calling into it
explicitly.

Change-Id: Id892567bd60d6b4b88765bbfe3cd5c5e75910b25
2015-01-12 17:26:23 -05:00
Ann Kamyshnikova
75b402be3b Remove check_foreign_keys from ModelsMigrationsSync
Alembic 0.7.1 contains checks of foreign keys so method
check_foreign_keys is not needed anymore.

Change-Id: I77a2bba2de08125b5a601de03c1d2d5c73fa33ee
2014-12-31 11:56:59 +03:00
Doug Hellmann
7063585c60 Move files out of the namespace package
Move the public API out of oslo.db to oslo_db. Retain the ability to
import from the old namespace package for backwards compatibility for
this release cycle.

Blueprint: drop-namespace-packages

Change-Id: Ie96b482b9fbcb1d85203ad35bb65c1f43e912a44
2014-12-24 13:28:48 +02:00