#!/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 # Scaling 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 scaling{ yang-version 1.1; namespace "urn:example:clixon"; prefix ip; container x { list y { key "a"; leaf a { type string; } leaf b { type string; } } leaf-list c { type string; } } } EOF cat < $cfg $cfg $dir /usr/local/share/clixon $IETFRFC scaling /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile false /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so EOF new "test params: -f $cfg" -y $fyang if [ $BE -ne 0 ]; then 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 -D $DBG if [ $? -ne 0 ]; then err fi fi new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" sudo su -c "$clixon_restconf -f $cfg -y $fyang -D $DBG" -s /bin/sh www-data & sleep $RCWAIT 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" 0 "]]>]]>" "^]]>]]>$" new "netconf commit large config again" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "netconf add small (1 entry) config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 '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" 0 "]]>]]>" '^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" 0 "]]>]]>" "^]]>]]>$" 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" 0 'x]]>]]>' "^]]>]]>$" new "netconf commit small leaf-list config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "netconf get large leaf-list config" expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^01' new "Kill restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE fi new "Kill backend" # Check if premature kill pid=`pgrep -u root -f clixon_backend` if [ -z "$pid" ]; then err "backend already dead" fi # kill backend sudo clixon_backend -z -f $cfg if [ $? -ne 0 ]; then err "kill backend" fi rm -rf $dir