Choose a specific MongoDb version in Travis
Maxime Thoonsen1 min read
I just had a little problem with my tests on Travis due to a wrong MongoDb version. Travis uses the 2.4.12 version of MongoDb and I needed the 2.6.6 version. The official documentation of travis doesn’t provide a way to change the MongoDb version. Fortunately just before that I needed to specify the version of Elasticsearch and the documentation provided me an easy way to do so:
before_install:
- wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.4.deb && sudo dpkg -i --force-confnew elasticsearch-1.2.4.deb
I just needed to install manually Elasticsearch. So why not doing the same thing for MongoDb with the help of the MongoDb documentation:
before_script:
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
- echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
- sudo apt-get update
- sudo apt-get install -y mongodb-org=2.6.6 mongodb-org-server=2.6.6 mongodb-org-shell=2.6.6 mongodb-org-mongos=2.6.6 mongodb-org-tools=2.6.6
- sleep 15 #mongo may not be responded directly. See http://docs.travis-ci.com/user/database-setup/#MongoDB
- mongo --version
This quick hack permits our tests to run correctly.