Allow setting DB for unittests via env & add psql support
RALLY_UNITTEST_DB_URL may be used to change test database. Sample usage: export RALLY_UNITTEST_DB_URL="mysql://user:secret@localhost/rally" tox -epy27 Fix postgress related bugs in unit tests. * All enums should have name * Fix invalid unit tests Closes-bug: #1413155 Partial-bug: #1405884 Co-Authored-By: Sergey Skripnick <sskripnick@mirantis.com> Co-Authored-By: Boris Pavlovic <boris@pavlovic.me> Change-Id: Ic741cb79eadf952c3dea99182c1e7d52992c9904
This commit is contained in:
parent
8170d14b60
commit
5533dea487
@ -18,6 +18,7 @@ pbr>=0.6,!=0.7,<1.0
|
||||
pecan>=0.8.0
|
||||
PrettyTable>=0.7,<0.8
|
||||
PyYAML>=3.1.0
|
||||
psycopg2
|
||||
python-designateclient>=1.0.0
|
||||
python-glanceclient>=0.15.0
|
||||
python-keystoneclient>=0.11.1
|
||||
|
@ -31,6 +31,11 @@ To run py26, py27 or pep8 only::
|
||||
|
||||
#NOTE: <name> is one of py26, py27 or pep8
|
||||
|
||||
To run py26, py27 against mysql or psql
|
||||
|
||||
$ export RALLY_UNITTEST_DB_URL="mysql://user:secret@localhost/rally"
|
||||
$ tox -epy27
|
||||
|
||||
To get test coverage::
|
||||
|
||||
$ tox -e cover
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
import mock
|
||||
from oslo.config import fixture
|
||||
from oslotest import base
|
||||
@ -24,8 +26,9 @@ class DatabaseFixture(fixture.Config):
|
||||
"""Create clean DB before starting test."""
|
||||
def setUp(self):
|
||||
super(DatabaseFixture, self).setUp()
|
||||
db_url = os.environ.get("RALLY_UNITTEST_DB_URL", "sqlite://")
|
||||
db.db_cleanup()
|
||||
self.conf.set_default('connection', "sqlite://", group='database')
|
||||
self.conf.set_default("connection", db_url, group="database")
|
||||
db.db_drop()
|
||||
db.db_create()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user