add some scripts

v4
vinllen 5 years ago
parent b4e3583a54
commit 6efda175d0
  1. 54
      test/deploy_cluster.sh
  2. 2
      test/deploy_standalone.sh
  3. 43
      test/test_normal.sh
  4. 10
      tools/build-cluster.expect
  5. 1317
      tools/redis.conf

@ -0,0 +1,54 @@
#!/bin/bash
set -o errexit
# start an standalone redis with given port
if [ $# != 3 ] ; then
echo "USAGE: $0 [beginning port] [start/stop] [number of node]"
exit 1
elif [ $2 != "start" -a $2 != "stop" ]; then
echo "parameter illegal"
exit 2
fi
port=$1
path="cluster-$port"
curPath=$(cd "$(dirname "$0")"; pwd)
subPath="$curPath/$path"
if [ $2 == "start" ]; then
# start
mkdir -p $subPath
cd $subPath
cnt=0
for ((i=$port;i<$port+100&&cnt<$3;i++));
do
inUse=$(lsof -i:$i | wc -l)
if [ $inUse -gt 1 ]; then
echo "port[$i] in using"
continue
fi
cnt=$cnt+1
echo "build node with port[$i]"
nodePath="$i"
mkdir -p $nodePath
cd $nodePath
../../../tools/redis-server --port $i --pidfile $i.pid --cluster-enabled yes --cluster-node-timeout 5000 1>$i.log 2>&1 &
nodeList=$nodeList" 127.0.0.1:$i"
cd ..
sleep 1
done
#../../tools/redis-trib.rb create --replicas 1 $nodeList
expect -f ../../tools/build-cluster.expect ../../tools/redis-trib.rb $nodeList
else
# stop
cd $curPath
for i in $subPath/*
do
echo "try kill $i"
nodePath=$(basename $i)
kill -9 $(cat $subPath/$nodePath/$nodePath.pid)
done
rm -rf $subPath
fi

@ -1,5 +1,7 @@
#!/bin/bash
set -o errexit
# start an standalone redis with given port
if [ $# != 2 ] ; then
echo "USAGE: $0 [port] [start/stop]"

@ -0,0 +1,43 @@
#!/bin/bash
set -o errexit
curPath=$(cd "$(dirname "$0")"; pwd)
function write {
ret=$()
}
function testIncr {
src=$1 # source redis address
dst=$2 # target redis address
fatherPath=$3
sonPath=$4
# 1. write redis-shake.conf
echo "source.address = $1" > redis-shake.conf
echo "source.type = standalone" >> redis-shake.conf
echo "target.address= $2" >> redis-shake.conf
echo "target.type = standalone" >> redis-shake.conf
echo "log.file = $fatherPath/$sonPath/redis-shake.log"
# 2. start redis-shake
../../bin/redis-shake -conf=redis-shake.conf -type=sync &
# 3. write & test
}
function TestNormal {
src=$1 # source redis address
dst=$2 # target redis address
# mkdir a path
cd $curPath
sub="incr"
mkdir -p $sub && cd $sub
# test incr
testIncr $1 $2 $curPath $sub
# test full
}

@ -0,0 +1,10 @@
#!/usr/bin/expect -f
set rb [lindex $argv 0]
set list [lrange $argv 1 end]
spawn $rb create --replicas 1 {*}$list
#expect "(type 'yes' to accept):"
expect "to accept\):"
send "yes\r"
#expect "[OK] All 16384 slots covered."
#send "\r"
expect eof

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save