Browse Source

pymongo 3.0 breaks ci gate

we pass safe parameter to pymongo.MongoClient but this field is
removed in 3.0. the default value is safe=True as of pymongo>=2.4[1].
this patch also cleans up residual ensure_index usage in tests which
were leftover from when ttl was not native to mongodb[2]

[1] http://emptysqua.re/blog/pymongos-new-default-safe-writes/
[2] I3d91fb08eb51ba6cfd5256abbeca43ed98321412

Closes-Bug: #1441393
Change-Id: I46f6ba28a4986c1f35b726c411d0804f3bb0cbda
tags/2015.1.0rc1
ZhiQiang Fan Lianhao Lu 5 years ago
parent
commit
b69d3a0f1f
2 changed files with 6 additions and 8 deletions
  1. +1
    -2
      ceilometer/storage/mongo/utils.py
  2. +5
    -6
      ceilometer/tests/storage/test_impl_mongodb.py

+ 1
- 2
ceilometer/storage/mongo/utils.py View File

@@ -257,8 +257,7 @@ class ConnectionPool(object):
url,
replicaSet=cfg.CONF.database.mongodb_replica_set))
else:
client = MongoProxy(
pymongo.MongoClient(url, safe=True))
client = MongoProxy(pymongo.MongoClient(url))
return client
except pymongo.errors.ConnectionFailure as e:
LOG.warn(_('Unable to connect to the database server: '


+ 5
- 6
ceilometer/tests/storage/test_impl_mongodb.py View File

@@ -91,15 +91,15 @@ class IndexTest(tests_db.TestBase,
# create a fake index and check it is deleted
coll = getattr(conn.db, coll_name)
index_name = '%s_ttl' % coll_name
coll.ensure_index('foo', name=index_name)
self.CONF.set_override(ttl_opt, -1, group='database')
conn.upgrade()
self.assertTrue(coll.ensure_index('foo', name=index_name))
coll.drop_index(index_name)
self.assertNotIn(index_name, coll.index_information())

self.CONF.set_override(ttl_opt, 456789, group='database')
conn.upgrade()
self.assertFalse(coll.ensure_index('foo', name=index_name))
self.assertEqual(456789,
coll.index_information()
[index_name]['expireAfterSeconds'])

def test_meter_ttl_index_absent(self):
self._test_ttl_index_absent(self.conn, 'meter',
@@ -114,14 +114,13 @@ class IndexTest(tests_db.TestBase,
self.CONF.set_override(ttl_opt, 456789, group='database')
conn.upgrade()
index_name = '%s_ttl' % coll_name
self.assertFalse(coll.ensure_index('foo', name=index_name))
self.assertEqual(456789,
coll.index_information()
[index_name]['expireAfterSeconds'])

self.CONF.set_override(ttl_opt, -1, group='database')
conn.upgrade()
self.assertTrue(coll.ensure_index('foo', name=index_name))
self.assertNotIn(index_name, coll.index_information())

def test_meter_ttl_index_present(self):
self._test_ttl_index_present(self.conn, 'meter',


Loading…
Cancel
Save