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
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
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
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
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
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
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
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
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
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
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
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
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
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