#!/bin/bash # Scaling/ performance tests # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi # Number of list/leaf-list entries in file : ${perfnr:=2000} # Number of requests made get/put : ${perfreq:=100} APPNAME=example cfg=$dir/scaling-conf.xml fyang=$dir/scaling.yang fconfig=$dir/large.xml fconfig2=$dir/large2.xml cat < $fyang module scaling{ yang-version 1.1; namespace "urn:example:clixon"; prefix ip; container x { list y { key "a"; leaf a { type int32; } leaf b { type int32; } } leaf-list c { type string; } } } EOF cat < $cfg $cfg $dir /usr/local/share/clixon scaling /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/example/$APPNAME.pidfile false $dir false 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_backend -s init -f $cfg -y $fyang fi new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" start_restconf -f $cfg -y $fyang new "waiting" sleep $RCWAIT new "generate 'large' config with $perfnr list entries" echo -n "" > $fconfig for (( i=0; i<$perfnr; i++ )); do echo -n "$i$i" >> $fconfig done echo "]]>]]>" >> $fconfig # Now take large config file and write it via netconf to candidate new "netconf write large config" expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$" # Here, there are $perfnr entries in candidate new "netconf write large config again" expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$" # Now commit it from candidate to running new "netconf commit large config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" # Now commit it again from candidate (validation takes time when # comparing to existing) new "netconf commit large config again" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" # Having a large db, get and put single entries many times # Note same entries in the range alreayd there, db has same size new "netconf add $perfreq small config" time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) echo "$rnd$rnd]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null new "netconf get $perfreq small config" time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) echo "]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null new "restconf get $perfreq small config" time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) curl -sG http://localhost/restconf/data/scaling:x/y=$rnd > /dev/null done new "restconf add $perfreq small config" time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) curl -s -X PUT http://localhost/restconf/data/scaling:x/y=$rnd -d '{"scaling:y":{"a":"'$rnd'","b":"'$rnd'"}}' done # Instead of many small entries, get one large in netconf and restconf new "netconf get large config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^00112233' new "restconf get large config" expecteof "/usr/bin/time -f %e curl -sG http://localhost/restconf/data" 0 "]]>]]>" '^{"data": {"scaling:x": {"y": \[{"a": 0,"b": 0},{ "a": 1,"b": 1},{ "a": 2,"b": 2},{ "a": 3,"b": 3},' new "restconf delete $perfreq small config" time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) curl -s -X DELETE http://localhost/restconf/data/scaling:x/y=$rnd done # Now do leaf-lists istead of leafs new "generate large leaf-list config" echo -n "replace" > $fconfig2 for (( i=0; i<$perfnr; i++ )); do echo -n "$i" >> $fconfig2 done echo "]]>]]>" >> $fconfig2 new "netconf replace large list-leaf config" expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig2" "^]]>]]>$" new "netconf commit large leaf-list config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "netconf add $perfreq small leaf-list config" time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) echo "$rnd]]>]]>" done | $clixon_netconf -qf $cfg -y $fyang > /dev/null new "netconf add small leaf-list config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$" new "netconf commit small leaf-list config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "netconf get large leaf-list config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^01' new "Kill restconf daemon" stop_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 stop_backend -f $cfg rm -rf $dir