summaryrefslogtreecommitdiff
path: root/oslo_db/tests
Commit message (Collapse)AuthorAgeFilesLines
* Make DBAPI class work with mocks correctly1.5.0Roman Podoliaka2015-02-251-0/+8
| | | | | | | | | | | | | | | | | | | Currently, DBAPI __getattr__() implementation will *always* implicitly wrap all mocked methods of a target class/module using wrap_db_retry(), as retry_on_* attributes will always exist and be true for mock instances. Not only this leads to a situation, when we would retry methods, we were not going to retry, but this also fails with AttributeError on functools.wraps() call, breaking valid unit tests in projects. DBAPI is changed in a way, so that it does dict look ups instead of fetching instance attributes to ensure mocked methods are handled correctly and aren't wrapped when they shouldn't be wrapped. Related issue: http://stackoverflow.com/questions/22204660/python-mock-wrapsf-problems Change-Id: I36550ffa88056c53a431d64e61e84fbb44bbf68d
* Merge "Organize provisioning to use testresources"Jenkins2015-02-125-19/+118
|\
| * Organize provisioning to use testresourcesMike Bayer2015-02-045-19/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Fix PatchStacktraceTest for pypy"Jenkins2015-02-051-1/+3
|\ \
| * | Fix PatchStacktraceTest for pypyOleksii Chuprykov2015-01-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | test_trace test cannot pass with mocked do_execute on pypy environment. Allow test to call do_execute with correct sql query. Change-Id: I165fc4de9f4a7f10cb45e92301652224e63f113b
* | | Merge "Refactor database migration manager to use given engine"Jenkins2015-02-042-15/+54
|\ \ \ | |_|/ |/| |
| * | Refactor database migration manager to use given engineVictor Sergeyev2015-01-272-15/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removing global engine object introduces some changes to migration api. Basically we need to move engine creation to outer scope. In order to address these issues we need to refactor alembic api. Co-Authored-By: Dmitry Shulyak <dshulyak@mirantis.com> Adopted from Ia2f9586c4e9c31339dd7dcd9f45a58e8a8409921 Change-Id: Ic7dcf1d2f38388bd1e5a517ce60190bff499686a
* | | Merge "Implement backend-specific drop_all_objects for provisioning."Jenkins2015-02-031-0/+81
|\ \ \
| * | | Implement backend-specific drop_all_objects for provisioning.Mike Bayer2015-01-291-0/+81
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Add retry decorator allowing to retry DB operations on requestEugene Nikanorov2015-01-302-0/+42
|/ / | | | | | | | | | | | | | | | | Improve retrying decorator such that wrapped code could request retry attempt in the arbitrary conditions by raising RetryRequest exception. Wrapped code should provide inner exception that is raised when amount of retries are exceeded. Change-Id: I596fea8dc798a11fcdfdd69208af3313f41d755b
* | Merge "Retry query if db deadlock error is received"Jenkins2015-01-271-24/+128
|\ \
| * | Retry query if db deadlock error is receivedrossella2015-01-141-24/+128
| |/ | | | | | | | | | | | | | | | | Add a decorator retry_on_deadlock(). All db.api functions marked with this decorator will be retried if a DBDeadlock exception is received. Change-Id: I3488bfec67ec1c563292f1b61a7a9697f118809c Closes-bug: 1348588
* | Merge "Fix 0 version handling in migration_cli manager"Jenkins2015-01-261-0/+5
|\ \
| * | Fix 0 version handling in migration_cli managerBoris Bobrov2015-01-261-0/+5
| |/ | | | | | | | | Change-Id: Ieabcf541bd5f2e6706159efe9d6ac54c7376004c Closes-Bug: 1413277
* | Update Oslo imports to remove namespace packageDoug Hellmann2015-01-214-6/+6
|/ | | | | Change-Id: I4ec9b2a310471e4e07867073e9577731ac34027d Blueprint: drop-namespace-packages
* Merge "Ensure DBConnectionError is raised on failed revalidate"Jenkins2015-01-131-1/+95
|\
| * Ensure DBConnectionError is raised on failed revalidateMike Bayer2015-01-121-1/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The second call to connection.scalar() inside of _connect_ping_listener() is not subject to the exc_filters system under SQLAlchemy 0.9 and earlier, in the case that the attempt to revalidate within fails. This causes the exception to be propagated outwards as the original OperationalError (assuming that's what the DBAPI raised, as is typical), rather than it being wrapped again in DBConnectionError. SQLAlchemy 1.0 has altered this behavior such that the handle_error() listener is invoked correctly for revalidiation attempts (it was being invoked before, but without the correct state), as well as for initial connect attempts, as part of https://bitbucket.org/zzzeek/sqlalchemy/issue/3266/. For 0.9 and earlier, we here backport this system into oslo/db/sqlalchemy/compat.py, including that we redefine the connection pool's handler to re-throw the original dbapi.Error instance directly, then move the handling of this error in terms of SQLAlchemy wrapping and events into the Engine and Connection. The approach here works back to SQLAlchemy 0.8, and is conditional based on whether or not SQLAlchemy 1.0 is detected. Change-Id: I455e957b043318a8500909c66cadde53228b52d6
* | Restore the check_foreign_keys() method.1.4.1Mike Bayer2015-01-121-0/+187
|/ | | | | | | | | | | | 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
* Merge "Make sure sort_key_attr is QueryableAttribute when query"Jenkins2015-01-122-42/+74
|\
| * Make sure sort_key_attr is QueryableAttribute when queryEli Qiao2015-01-092-42/+74
| | | | | | | | | | | | | | | | | | | | When doing query.order_by, sort_key_attr is get from model class, we need to make sure sort_key_attr is really a QueryableAttribute type instance before we do the query or it will cause errors. This will prevent if there IS a function which name is same as sort_key. Closes-Bug: 1405069 Change-Id: I8a3eb08ab3469ec08e05bfce754b664943d65c83
* | Ensure mysql_sql_mode is set for MySQLOpportunisticTestsMike Bayer2015-01-082-2/+18
|/ | | | | | | | | | | | | | | | The default setting for oslo.db is TRADITIONAL for mysql_sql_mode; this is set up in oslo_db/options.py as well as in EngineFacade; however, the provisioning system currently does not use these options or EngineFacade, and the default for mysql_sql_mode in the base session.create_engine() is None. For a MySQL/MariaDB database where this is not established in my.cnf, tests will run without TRADITIONAL SQL mode and some tests will fail, including some Nova migration tests that rely upon this. This patch resolves that as well as the warning we see in tests regarding the empty SQL mode. Change-Id: I3acdc0fb30327f56a76ee299cc6bade7c5a7e312
* Merge "Ensure PostgreSQL connection errors are wrapped"Jenkins2015-01-061-0/+15
|\
| * Ensure PostgreSQL connection errors are wrappedRoman Podoliaka2015-01-051-0/+15
| | | | | | | | | | | | | | | | Currently PostgreSQL connection errors are not wrapped with our custom DBConnectionError and engine.connect() will raise OperationalError instead. Change-Id: Iefdb9a99ca0cbe982bf12cb7e1ac47996fc5a025
* | Merge "Fix PatchStacktraceTest test"Jenkins2015-01-052-29/+45
|\ \
| * | Fix PatchStacktraceTest testVictor Sergeyev2015-01-052-29/+45
| |/ | | | | | | | | | | | | | | | | | | | | | | After we moved out from the namespaces, tests were moved to oslo_db/tests. The code in oslo_db.sqlalchemy.session filters out lines from modules under oslo_db, so the test filename does not appear in the context for the error message. Use patched traceback module in tests to fix it. Closes-Bug: #1405376 Change-Id: Id6022c065dfe13351fca5e54baa343d6c96b0270
* | Remove check_foreign_keys from ModelsMigrationsSyncAnn Kamyshnikova2014-12-312-2/+2
|/ | | | | | | Alembic 0.7.1 contains checks of foreign keys so method check_foreign_keys is not needed anymore. Change-Id: I77a2bba2de08125b5a601de03c1d2d5c73fa33ee
* Move files out of the namespace packageDoug Hellmann2014-12-2433-0/+8393
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