diff --git a/ceilometer/storage/impl_db2.py b/ceilometer/storage/impl_db2.py index 07563742d..80f78e6ba 100644 --- a/ceilometer/storage/impl_db2.py +++ b/ceilometer/storage/impl_db2.py @@ -22,6 +22,7 @@ """ import copy +import urlparse import weakref import bson.code @@ -142,9 +143,15 @@ class ConnectionPool(object): if client: return client LOG.info('connecting to DB2 on %s', url) - client = pymongo.MongoClient( - url, - safe=True) + url_parsed = urlparse.urlparse(url) + if url_parsed.path.startswith('/ceilometer_for_tox_testing_'): + #note(sileht): this is a workaround for running tests without reach + #the maximum allowed connection of mongod in gate + #this only work with pymongo >= 2.6, this is not in the + #requirements file because is not needed for normal use of mongo + client = pymongo.MongoClient(url, safe=True, max_pool_size=None) + else: + client = pymongo.MongoClient(url, safe=True) self._pool[url] = weakref.ref(client) return client diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index aa17006e0..53da7f2cb 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -23,6 +23,7 @@ import calendar import copy import operator +import urlparse import weakref import bson.code @@ -149,9 +150,15 @@ class ConnectionPool(object): if client: return client LOG.info('connecting to MongoDB on %s', url) - client = pymongo.MongoClient( - url, - safe=True) + url_parsed = urlparse.urlparse(url) + if url_parsed.path.startswith('/ceilometer_for_tox_testing_'): + #note(sileht): this is a workaround for running tests without reach + #the maximum allowed connection of mongod in gate + #this only work with pymongo >= 2.6, this is not in the + #requirements file because is not needed for normal use of mongo + client = pymongo.MongoClient(url, safe=True, max_pool_size=None) + else: + client = pymongo.MongoClient(url, safe=True) self._pool[url] = weakref.ref(client) return client diff --git a/run-tests.sh b/run-tests.sh index 11c4568a6..f353cc63b 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -26,7 +26,7 @@ MONGO_DATA=`mktemp -d /tmp/CEILO-MONGODB-XXXXX` trap "clean_exit" EXIT mkfifo ${MONGO_DATA}/out export PATH=${PATH:+$PATH:}/sbin:/usr/sbin -mongod --maxConns 256 --nojournal --noprealloc --smallfiles --quiet --noauth --port 29000 --dbpath "${MONGO_DATA}" --bind_ip localhost &>${MONGO_DATA}/out & +mongod --maxConns 32 --nojournal --noprealloc --smallfiles --quiet --noauth --port 29000 --dbpath "${MONGO_DATA}" --bind_ip localhost &>${MONGO_DATA}/out & MONGO_PID=$! # Wait for Mongo to start listening to connections while read line @@ -36,5 +36,5 @@ done < ${MONGO_DATA}/out # Read the fifo for ever otherwise mongod would block # + that gives us the log on screen cat ${MONGO_DATA}/out > /dev/null & -export CEILOMETER_TEST_MONGODB_URL="mongodb://localhost:29000/ceilometer" +export CEILOMETER_TEST_MONGODB_URL="mongodb://localhost:29000/ceilometer_for_tox_testing" python setup.py testr --slowest --testr-args="$*" $COVERAGE_ARG