mongodb: Ignore suffix in server version
Make sure the logic accepts additional suffix string such as 1.2.3-4.5, which is exposed by some distributions of mongodb. Closes-Bug: #1709607 Change-Id: I23c101fddce514ca840d80cef9c035a7ce3c9808 Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -86,7 +86,8 @@ class DataDriver(storage.DataDriverBase):
|
|||||||
|
|
||||||
conn = self.connection
|
conn = self.connection
|
||||||
server_info = conn.server_info()['version']
|
server_info = conn.server_info()['version']
|
||||||
self.server_version = tuple(map(int, server_info.split('.')))
|
version_str = server_info.split('-')[0]
|
||||||
|
self.server_version = tuple(map(int, version_str.split('.')))
|
||||||
|
|
||||||
if self.server_version < (2, 2):
|
if self.server_version < (2, 2):
|
||||||
raise RuntimeError(_('The mongodb driver requires mongodb>=2.2, '
|
raise RuntimeError(_('The mongodb driver requires mongodb>=2.2, '
|
||||||
|
@@ -172,17 +172,37 @@ class MongodbDriverTest(MongodbSetupMixin, testing.TestBase):
|
|||||||
|
|
||||||
with mock.patch('pymongo.MongoClient.server_info') as info:
|
with mock.patch('pymongo.MongoClient.server_info') as info:
|
||||||
info.return_value = {'version': '2.1'}
|
info.return_value = {'version': '2.1'}
|
||||||
|
self.assertRaises(RuntimeError, mongodb.DataDriver,
|
||||||
|
self.conf, cache,
|
||||||
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
info.return_value = {'version': '2.1.0'}
|
||||||
|
self.assertRaises(RuntimeError, mongodb.DataDriver,
|
||||||
|
self.conf, cache,
|
||||||
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
info.return_value = {'version': '2.1.0-1.0'}
|
||||||
self.assertRaises(RuntimeError, mongodb.DataDriver,
|
self.assertRaises(RuntimeError, mongodb.DataDriver,
|
||||||
self.conf, cache,
|
self.conf, cache,
|
||||||
mongodb.ControlDriver(self.conf, cache))
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
|
||||||
info.return_value = {'version': '2.11'}
|
info.return_value = {'version': '2.2'}
|
||||||
|
mongodb.DataDriver(self.conf, cache,
|
||||||
try:
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
info.return_value = {'version': '2.2.0'}
|
||||||
|
mongodb.DataDriver(self.conf, cache,
|
||||||
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
info.return_value = {'version': '2.2.0-1.0'}
|
||||||
|
mongodb.DataDriver(self.conf, cache,
|
||||||
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
|
||||||
|
info.return_value = {'version': '2.10'}
|
||||||
|
mongodb.DataDriver(self.conf, cache,
|
||||||
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
info.return_value = {'version': '2.10.0'}
|
||||||
|
mongodb.DataDriver(self.conf, cache,
|
||||||
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
|
info.return_value = {'version': '2.10.0-1.0'}
|
||||||
mongodb.DataDriver(self.conf, cache,
|
mongodb.DataDriver(self.conf, cache,
|
||||||
mongodb.ControlDriver(self.conf, cache))
|
mongodb.ControlDriver(self.conf, cache))
|
||||||
except RuntimeError:
|
|
||||||
self.fail('version match failed')
|
|
||||||
|
|
||||||
def test_replicaset_or_mongos_needed(self):
|
def test_replicaset_or_mongos_needed(self):
|
||||||
cache = oslo_cache.get_cache(self.conf)
|
cache = oslo_cache.get_cache(self.conf)
|
||||||
|
Reference in New Issue
Block a user