Skip to content

Commit

Permalink
Travic CI support
Browse files Browse the repository at this point in the history
  • Loading branch information
tahajahangir committed Jun 4, 2014
1 parent 9f9372d commit 2551637
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python
python:
- "2.7"

script:
- pip install -r requirements-dev.txt
- make mongo-start
- make mongo-config
- python setup.py build
- make test

32 changes: 24 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,47 @@ MONGOD=mongod
MONGO_DATA=`pwd`/data

mongo-start-node1:
${MONGOD} --port=27027 --dbpath=${MONGO_DATA}/db/node1 --replSet=mongotor --logpath=${MONGO_DATA}/log/node1.log --fork --smallfiles
${MONGOD} --port=27027 --dbpath=${MONGO_DATA}/db/node1 --replSet=mongotor --logpath=${MONGO_DATA}/log/node1.log --fork --smallfiles --oplogSize 30 --nojournal

mongo-start-node2:
${MONGOD} --port=27028 --dbpath=${MONGO_DATA}/db/node2 --replSet=mongotor --logpath=${MONGO_DATA}/log/node2.log --fork --smallfiles
${MONGOD} --port=27028 --dbpath=${MONGO_DATA}/db/node2 --replSet=mongotor --logpath=${MONGO_DATA}/log/node2.log --fork --smallfiles --oplogSize 30 --nojournal

mongo-start-arbiter:
${MONGOD} --port=27029 --dbpath=${MONGO_DATA}/db/arbiter --replSet=mongotor --logpath=${MONGO_DATA}/log/arbiter.log --fork --smallfiles
${MONGOD} --port=27029 --dbpath=${MONGO_DATA}/db/arbiter --replSet=mongotor --logpath=${MONGO_DATA}/log/arbiter.log --fork --smallfiles --oplogSize 30 --nojournal

mongo-start: mongo-kill
mongo-restart: mongo-kill mongo-start

mongo-start:
mkdir -p ${MONGO_DATA}/db/node1 ${MONGO_DATA}/db/node2 ${MONGO_DATA}/db/arbiter ${MONGO_DATA}/log

echo "starting mongo instance"
make mongo-start-node1
make mongo-start-node2
make mongo-start-arbiter
sleep 5
echo 'Waiting 10s for `mongod`s to start'
sleep 10

mongo-kill-node1:
ps -eo pid,args | grep 27027 | grep ${MONGO_DATA} | grep -v grep | awk '{print $$1}' | xargs kill 2> /dev/null | true

mongo-kill-node2:
ps -eo pid,args | grep 27028 | grep ${MONGO_DATA} | grep -v grep | awk '{print $$1}' | xargs kill 2> /dev/null | true

mongo-kill-arbiter:
ps -eo pid,args | grep 27029 | grep ${MONGO_DATA} | grep -v grep | awk '{print $$1}' | xargs kill 2> /dev/null | true

mongo-kill:
echo "killing mongo instance"
ps -ef | grep mongo | grep -v grep | grep ${MONGO_DATA} | tr -s ' ' | cut -d ' ' -f 3 | xargs kill 2> /dev/null | true
echo 'Waiting for `mongod`s to stop'
sleep 5
make mongo-kill-node1
make mongo-kill-node2
make mongo-kill-arbiter
echo 'Waiting 1s for `mongod`s to stop'
sleep 1

mongo-config:
mongo localhost:27027 < config-replicaset.js
echo 'Waiting 40s to let replicaset elect a primary'
sleep 40

install_deps:
pip install -r requirements-dev.txt
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

(MONGOdb + TORnado) is an asynchronous toolkit for working with ``mongodb`` inside a ``tornado`` app. Mongotor has a pure implementation of python + tornado and only depends on tornado and bson (provided by pymongo)

[![Build Status](https://travis-ci.org/marcelnicolay/mongotor.svg?branch=master)](https://travis-ci.org/marcelnicolay/mongotor)

## Features

MongoTor is still an alpha project, but already implements the following features:
Expand Down Expand Up @@ -191,4 +193,4 @@ make test

## Issues

Please report any issues via [github issues](https://github.com/marcelnicolay/mongotor/issues)
Please report any issues via [github issues](https://github.com/marcelnicolay/mongotor/issues)
9 changes: 3 additions & 6 deletions tests/test_replicaset.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ def test_configure_nodes(self):

def test_raises_error_when_mode_is_secondary_and_secondary_is_down(self):
"""[ReplicaSetTestCase] - Raise error when mode is secondary and secondary is down"""
os.system('make mongo-kill > /dev/null 2>&1')
os.system('make mongo-start-node1')
os.system('make mongo-start-arbiter')

time.sleep(10)
os.system('make mongo-kill-node2')
time.sleep(1) # stops are fast

try:
db = Database.init(["localhost:27027", "localhost:27028"], dbname='test')
Expand All @@ -56,7 +53,7 @@ def test_raises_error_when_mode_is_secondary_and_secondary_is_down(self):
.throw(DatabaseError)
finally:
os.system('make mongo-start-node2')
time.sleep(10)
time.sleep(5) # wait to become secondary again


class SecondaryPreferredTestCase(testing.AsyncTestCase):
Expand Down

0 comments on commit 2551637

Please sign in to comment.