Skip to content

Commit

Permalink
Enable running Travis in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
shailesh33 committed Dec 19, 2016
1 parent 74d1173 commit 9cc6f17
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 11 deletions.
30 changes: 30 additions & 0 deletions test/run_loop.py
@@ -0,0 +1,30 @@
#!/usr/bin/python
import subprocess, time

def run_command(cmd):
"""Execute a shell command and return the output
:param command: the command to be run and all of the arguments
:returns: success_boolean, command_string, stdout, stderr
"""

proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(proc.stdout.readline, b''):
print(">>> " + line.rstrip())
(stdout, stderr) = proc.communicate()
return proc.returncode == 0, proc

def main():
cmd = "bash travis.sh -n"
for i in range(0, 50):
print"Running loop {}".format(i+1)
success, proc = run_command(cmd)
if not success:
for line in iter(proc.stderr.readline, b''):
print("--- " + line.rstrip())
break
else:
print "...........................Success\n"
time.sleep(30)

if __name__ == "__main__":
main()
40 changes: 29 additions & 11 deletions travis.sh
Expand Up @@ -7,8 +7,25 @@ if [ -n "$TRAVIS" ]; then
sudo pip install git+https://github.com/andymccurdy/redis-py.git@2.10.3
fi


# parse options
rebuild=true
while [ "$#" -gt 0 ]; do
arg=$1
case $1 in
-n|--no-rebuild) shift; rebuild=false;;
-*) usage_fatal "unknown option: '$1'";;
*) break;; # reached the list of file names
esac
done


#build Dynomite
CFLAGS="-ggdb3 -O0" autoreconf -fvi && ./configure --enable-debug=log && make
if [[ "${rebuild}" == "true" ]]; then
CFLAGS="-ggdb3 -O0" autoreconf -fvi && ./configure --enable-debug=log && make
else
echo "not rebuilding Dynomite"
fi

# Create the environment

Expand All @@ -34,15 +51,15 @@ function launch_redis() {
}
function launch_dynomite() {
./_binaries/dynomite -d -o ./logs/a_dc1.log \
-c ./conf/a_dc1.yml -M100000 -v6
-c ./conf/a_dc1.yml -v6
./_binaries/dynomite -d -o ./logs/a_dc2_rack1_node1.log \
-c ./conf/a_dc2_rack1_node1.yml -M100000 -v6
-c ./conf/a_dc2_rack1_node1.yml -v6
./_binaries/dynomite -d -o ./logs/a_dc2_rack1_node2.log \
-c ./conf/a_dc2_rack1_node2.yml -M100000 -v6
-c ./conf/a_dc2_rack1_node2.yml -v6
./_binaries/dynomite -d -o ./logs/a_dc2_rack2_node1.log \
-c ./conf/a_dc2_rack2_node1.yml -M100000 -v6
-c ./conf/a_dc2_rack2_node1.yml -v6
./_binaries/dynomite -d -o ./logs/a_dc2_rack2_node2.log \
-c ./conf/a_dc2_rack2_node2.yml -M100000 -v6
-c ./conf/a_dc2_rack2_node2.yml -v6
}

function kill_redis() {
Expand All @@ -68,16 +85,17 @@ DYNOMITE_NODES=`pgrep dynomite | wc -l`
REDIS_NODES=`pgrep redis-server | wc -l`

if [[ $DYNOMITE_NODES -ne 5 ]]; then
echo "Not all dynomite nodes are running"
echo "Not all dynomite nodes are running" >&2
RESULT=1
cleanup_and_exit
fi
if [[ $REDIS_NODES -ne 6 ]]; then
echo "Not all redis nodes are running"
echo "Not all redis nodes are running" >&2
RESULT=1
cleanup_and_exit
fi

echo "Cluster Deployed....."
sleep 10

./func_test.py
Expand All @@ -87,20 +105,20 @@ echo $RESULT
# check a single stats port
curl -s localhost:22222/info | python -mjson.tool > /dev/null
if [[ $? -ne 0 ]]; then
echo "Stats are not working or not valid json"
echo "Stats are not working or not valid json" >&2
RESULT=1
fi

DYNOMITE_NODES=`pgrep dynomite | wc -l`
REDIS_NODES=`pgrep redis-server | wc -l`

if [[ $DYNOMITE_NODES -ne 5 ]]; then
echo "Not all dynomite nodes are running"
echo "Not all dynomite nodes are running" >&2
RESULT=1
cleanup_and_exit
fi
if [[ $REDIS_NODES -ne 6 ]]; then
echo "Not all redis nodes are running"
echo "Not all redis nodes are running" >&2
RESULT=1
cleanup_and_exit
fi
Expand Down

0 comments on commit 9cc6f17

Please sign in to comment.