Require mongodb >= 2.2 or fail misserably
The patch adds a minimum requirement for mongodb. This will provide a useful error message to users when the installed mongodb version doesn't match the minimum required one. Change-Id: Iff8bb1645e7276529230da58c408552bebd8647a
This commit is contained in:
parent
36e63c9a45
commit
67949a7870
@ -151,6 +151,21 @@ class MongodbDriverTest(MongodbSetupMixin, testing.TestBase):
|
||||
self.assertThat(db.name, matchers.StartsWith(
|
||||
driver.mongodb_conf.database))
|
||||
|
||||
def test_version_match(self):
|
||||
cache = oslo_cache.get_cache()
|
||||
|
||||
with mock.patch('pymongo.MongoClient.server_info') as info:
|
||||
info.return_value = {'version': '2.1'}
|
||||
self.assertRaises(RuntimeError, mongodb.DataDriver,
|
||||
self.conf, cache)
|
||||
|
||||
info.return_value = {'version': '2.11'}
|
||||
|
||||
try:
|
||||
mongodb.DataDriver(self.conf, cache)
|
||||
except RuntimeError:
|
||||
self.fail('version match failed')
|
||||
|
||||
|
||||
@testing.requires_mongodb
|
||||
class MongodbQueueTests(MongodbSetupMixin, base.QueueControllerTest):
|
||||
|
@ -21,6 +21,7 @@ import pymongo
|
||||
import pymongo.errors
|
||||
|
||||
from zaqar.common import decorators
|
||||
from zaqar.i18n import _
|
||||
from zaqar.openstack.common import log as logging
|
||||
from zaqar.queues import storage
|
||||
from zaqar.queues.storage.mongodb import controllers
|
||||
@ -81,6 +82,11 @@ class DataDriver(storage.DataDriverBase):
|
||||
group=options.MONGODB_GROUP)
|
||||
self.mongodb_conf = self.conf[options.MONGODB_GROUP]
|
||||
|
||||
server_version = self.connection.server_info()['version']
|
||||
if tuple(map(int, server_version.split('.'))) < (2, 2):
|
||||
raise RuntimeError(_('The mongodb driver requires mongodb>=2.2, '
|
||||
'%s found') % server_version)
|
||||
|
||||
def is_alive(self):
|
||||
try:
|
||||
# NOTE(zyuan): Requires admin access to mongodb
|
||||
|
Loading…
Reference in New Issue
Block a user