Commit Graph

23 Commits (314496a5815f9e946f1ec87e6e6610c44bfc07bd)

Author SHA1 Message Date
Roman Podoliaka 314496a581 Prevent races in opportunistic db test cases
Opportunistic db test cases create schemas on demand, so that each
test case which inherits the base test case class, will get its own
db schema (i. e. races between tests are not possible).

In order to do schema provisioning we have to connect to RDBMS server
first. So far we've been connecting to the openstack_citest database,
which is guaranteed to exist on CI nodes. It turns out, there are a
few test cases in Nova (maybe in other projects as well), that drop
and recreate the openstack_citest database. If they happen to do that
when the opportunistic db fixture is in the middle of provisioning a
schema, those tests will fail (as there is an an open session to the
database and thus it can't be dropped).

This can be solved easily by changing the way we provision new
schemas in opportunistic db test cases as actually, we don't have to
connect to the openstack_citest database at all:

 - for MySQL we can use an empty db name to connect to MySQL server,
   but not to a particular database
 - PostgreSQL requires us to specify the database name. We can use
   the service postgres database here (PostgreSQL shell utils such
   as createdb, createuser, etc use it for the very same reason)

Closes-Bug: #1328997

Change-Id: I0dc0becc5cb40d3dab3289c865a96113522a0b9a
2014-06-13 15:04:45 +03:00
Jenkins 6f0e998514 Merge "Handle slave database connection in EngineFacade" 2014-06-11 01:05:33 +00:00
Jenkins df21744065 Merge "Remove common context usage from db model_query()" 2014-06-10 19:52:58 +00:00
Roman Podoliaka 1d2df1a2a3 Handle slave database connection in EngineFacade
Make it possible to use an additional (aka, 'slave') database
connection. This might be useful for offloading of read operations
to reduce the load on the RDBMS. Currently, this is only used in
Nova, but can be ported to other projects easily.

Change-Id: I4296347bb9ee0743738fe1126d1cef8e43b9f96e
2014-06-10 17:25:06 +03:00
Jenkins f9167b0e1e Merge "Make get_session() pass kwargs to a sessionmaker" 2014-06-10 14:09:21 +00:00
Jenkins cd801bc47e Merge "Allow for skipping thread_yielding" 2014-06-10 09:52:28 +00:00
Jenkins 0ecd6a63a8 Merge "Fix usage of oslo.config" 2014-06-05 22:01:58 +00:00
Jenkins ad10af347c Merge "replace string format arguments with function parameters" 2014-06-05 22:00:23 +00:00
Victor Sergeyev 4f58e79436 Remove common context usage from db model_query()
Currently, function model_query() from oslo.db.sqlalchemy.utils uses
is_use_context() function in order to determine whether a normal or an
admin user request is being processed. But usage of RequestContext is
not unified across OpenStack projects, so there is no way for oslo.db to
guarantee it processes project_id/deleted filters correctly here.

To remove this ambiguity, project_id/deleted filters should be passed
explicitly instead. At the same time, developers of OpenStack projects
are encouraged to provide wrappers for oslo.db model_query() function,
so that they could determine the values for project_id/deleted filters
depending on how they use RequestContext in their project.

Closes-bug: #1288846
Change-Id: Iec5cbbc44cf9626f0464ab684dff1ba37e006151
2014-06-04 17:53:17 +03:00
Jenkins 06224bcd73 Merge "Do not always adjust sqlalchemy.engine logging" 2014-06-04 11:21:45 +00:00
Christian Berendt d09fff6640 replace string format arguments with function parameters
There are files containing string format arguments inside
logging messages. Using logging function parameters should
be preferred.

Change-Id: I089a4c51c0fe98906d74bcdbd5394e74631d0dba
Partial-Bug: #1321274
2014-06-04 08:20:44 +00:00
Roman Podoliaka 28df4edde0 Make get_session() pass kwargs to a sessionmaker
get_session() method is used to construct a new SQLAlchemy session
instance. Currently, it takes two keyword arguments which are used
to configure the Session instance to be created. Actually, there are
more arguments which can be passed to a sessiomaker instance. oslo.db
should not stay in the way of a developer who wants to use specific
features of SQLAlchemy session: it should handle oslo.db specific
arguments and pass keyword arguments as is when calling the

Change-Id: I1f577a30586eafe1295bcbd15a6a881e9f7f65ab
2014-06-03 12:12:14 +03:00
Jenkins 82bbac9d64 Merge "Add index modifying methods" 2014-06-02 18:31:09 +00:00
Joshua Harlow b07e1de6f6 Allow for skipping thread_yielding
When greenthreads aren't being used this call is not
so useful and since oslo.db is a library it can't be
guaranteed that those using it will be also using
eventlet (or similar library).

Change-Id: Ib06d3761fa3f6d4d089357b396ea8c84d41ee835
2014-05-30 14:52:34 -07:00
Julia Varlamova 58474e8158 Add index modifying methods
Add to openstack/common/db/sqlalchemy/
methods for modifying indexes:
- add_index
- drop_index
- change_index_columns
- index_exists
- column_exists

Add tests for these methods to TestUtils class
in tests/unit/db/sqlalchemy/

Change-Id: Ib7b2a1a8169fff803a925326703e71c014230a68
2014-05-30 18:15:03 +04:00
Ilya Pekelny c260bea9cf Log a cause of db backend connection failure
If opportunistic test case, i.e. fixture, can't connect to a test
database, it is happening silently, without any logs. Most of times we
need to know a cause of failure.

Change-Id: Ia9f93a2ed38d11ec22d7aaafc90e194b153c5393
Closes-Bug: #1306017
2014-05-30 13:00:09 +03:00
Joshua Harlow 47bdbf095d Do not always adjust sqlalchemy.engine logging
Instead of messing with another libraries logger by default
only adjust the levels of that logger if the connection debug
is greater than or equal to zero. This allows those who have
configuration files or other ways to adjust logging to not be
affected by this codes level manipulation (which is likely
a side-effect users would not expect).

Change-Id: I8c52f595e5077627c6999deadfd748034ab02fff
2014-05-29 14:29:33 -07:00
Roman Podoliaka fad6e5c230 Fix usage of oslo.config
- make it possible to create a DBAPI instance given a config instance

- remove usage of global cfg.CONF instance (it's up to a user to pass
  a ConfigOpts instance to oslo.db)

- ensure end applications don't need to import/register/use config
  options directly - instead they pass a config instance to oslo.db
  helpers (EngineFacade.from_config() and DBAPI.from_config() class

At the same time, usage of oslo.config remains completely optional as
we provide an API to pass those parameters programatically.

Change-Id: I1a00db7a4200ebdc96f17256ecbad430477e868f
2014-05-27 15:58:22 +03:00
Jenkins 95dc70a355 Merge "Fix typos: Remove extra ")" in message" 2014-05-20 16:08:53 +00:00
Matt Riedemann 5671755549 Remove patch_migrate()
This is essentially a revert of oslo-incubator commit 3f503faac since
sqlalchemy-migrate 0.9.1 now has that code via commit 93efb62fd.

Change-Id: I5d7d3eaec236140cd47fe419ed6905115354501d
2014-05-05 20:02:27 -07:00
Andreas Jaeger 5c04a25926 Fix typos: Remove extra ")" in message
There's no opening "(", so remove the extra closing ")" from
the message. Also, spell SQLite properly.

Change-Id: Ib1c50fecdb84ef5069b4eaaeee0b1ab500e446b5
2014-04-30 17:01:03 +02:00
Victor Sergeyev 276f7570d7 Make the tests passing
- add missed requirements
- add required modules from openstack.common
- added entry points to setup.cfg
- fixed tests location
- fixed incorrect common modules imports
2014-04-18 12:51:26 +03:00
Victor Sergeyev e4cfa6d39d Fix the script result 2014-04-18 11:33:16 +03:00