#!/bin/bash # Scaling test number=5000 req=100 if [ $# = 0 ]; then number=1000 elif [ $# = 1 ]; then number=$1 elif [ $# = 2 ]; then number=$1 req=$2 else echo "Usage: $0 [ []]" exit 1 fi APPNAME=example # include err() and new() functions and creates $dir . ./lib.sh cfg=$dir/scaling-conf.xml fyang=$dir/scaling.yang fconfig=$dir/config cat < $fyang module ietf-ip{ container x { list y { key "a"; leaf a { type string; } leaf b { type string; } } leaf-list c { type string; } } } EOF cat < $cfg $cfg $fyang ietf-ip /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile false /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so EOF # kill old backend (if any) new "kill old backend" sudo clixon_backend -zf $cfg -y $fyang if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg -y $fyang" # start new backend sudo clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D sleep 1 new "generate 'large' config with $number list entries" echo -n "" > $fconfig for (( i=0; i<$number; i++ )); do echo -n "$i$i" >> $fconfig done echo "]]>]]>" >> $fconfig # Just for manual dbg echo "$clixon_netconf -qf $cfg -y $fyang" new "netconf write large config" expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$" #echo ']]>]]>' | $clixon_netconf -qf $cfg -y $fyang new "netconf write large config again" expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$" #echo ']]>]]>' | $clixon_netconf -qf $cfg -y $fyang rm $fconfig new "netconf commit large config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^]]>]]>$" new "netconf commit large config again" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^]]>]]>$" new "netconf add small (1 entry) config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "xy]]>]]>" "^]]>]]>$" new "netconf get $req small config" time -p for (( i=0; i<$req; i++ )); do rnd=$(( ( RANDOM % $number ) )) echo "]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null new "netconf get $req restconf small config" time -p for (( i=0; i<$req; i++ )); do rnd=$(( ( RANDOM % $number ) )) #XXX curl -sX PUT -d {"y":{"a":"$rnd","b":"$rnd"}} http://localhost/restconf/data/x/y=$rnd,$rnd done new "netconf add $req small config" time -p for (( i=0; i<$req; i++ )); do rnd=$(( ( RANDOM % $number ) )) echo "$rnd$rnd]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null new "netconf add $req restconf small config" time -p for (( i=0; i<$req; i++ )); do rnd=$(( ( RANDOM % $number ) )) curl -sG http://localhost/restconf/data/x/y=$rnd,$rnd > /dev/null done new "netconf get large config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^0011" new "generate large leaf-list config" echo -n "replace" > $fconfig for (( i=0; i<$number; i++ )); do echo -n "$i" >> $fconfig done echo "]]>]]>" >> $fconfig new "netconf replace large list-leaf config" expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$" rm $fconfig new "netconf commit large leaf-list config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^]]>]]>$" new "netconf add $req small leaf-list config" time -p for (( i=0; i<$req; i++ )); do rnd=$(( ( RANDOM % $number ) )) echo "$rnd]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null new "netconf add small leaf-list config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "x]]>]]>" "^]]>]]>$" new "netconf commit small leaf-list config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^]]>]]>$" new "netconf get large leaf-list config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" "]]>]]>" "^01" new "Kill backend" # Check if still alive pid=`pgrep clixon_backend` if [ -z "$pid" ]; then err "backend already dead" fi # kill backend sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err "kill backend" fi rm -rf $dir