* Regexp improvements
* Added check for libxml in configure'; * Added clixon_util_regexp utility function * Yang state get improvements * Integrated state and config into same tree on retrieval, not separate trees * Added cli functions `cli_show_config_state()` and `cli_show_auto_state()` for showing combined config and state info. * Added integrated state in the main example: `interface/oper-state`. * Added performance tests for getting state, see [test/test_perf_state.sh].
This commit is contained in:
parent
c17784cfe9
commit
bc54f2d04c
26 changed files with 895 additions and 185 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
# Scaling/ performance tests
|
||||
# CLI/Netconf/Restconf
|
||||
# Lists (and leaf-lists)
|
||||
# Add, get and delete entries
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
|
@ -8,7 +11,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
|||
: ${format:=xml}
|
||||
|
||||
# Number of list/leaf-list entries in file
|
||||
: ${perfnr:=10000}
|
||||
: ${perfnr:=5000}
|
||||
|
||||
# Number of requests made get/put
|
||||
: ${perfreq:=100}
|
||||
|
|
@ -20,7 +23,6 @@ fyang=$dir/scaling.yang
|
|||
fconfig=$dir/large.xml
|
||||
fconfig2=$dir/large2.xml
|
||||
|
||||
|
||||
cat <<EOF > $fyang
|
||||
module scaling{
|
||||
yang-version 1.1;
|
||||
|
|
@ -48,7 +50,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MODULE_MAIN>scaling</CLICON_YANG_MODULE_MAIN>
|
||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/example/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
|
|
@ -65,89 +67,27 @@ cat <<EOF > $cfg
|
|||
</clixon-config>
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg -y $fyang
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
fi
|
||||
|
||||
# First generate large XML file
|
||||
# Use it latter to generate startup-db in xml, tree formats
|
||||
tmpx=$dir/tmp.xml
|
||||
new "generate large startup config ($tmpx) with $perfnr entries"
|
||||
echo -n "<config><x xmlns=\"urn:example:clixon\">" > $tmpx
|
||||
for (( i=0; i<$perfnr; i++ )); do
|
||||
echo -n "<y><a>$i</a><b>$i</b></y>" >> $tmpx
|
||||
done
|
||||
echo "</x></config>" >> $tmpx
|
||||
|
||||
if false; then
|
||||
# Then generate large JSON file (cant translate namespace - long story)
|
||||
tmpj=$dir/tmp.json
|
||||
new "generate large startup config ($tmpj) with $perfnr entries"
|
||||
echo -n '{"config": {"scaling:x":{"y":[' > $tmpj
|
||||
for (( i=0; i<$perfnr; i++ )); do
|
||||
if [ $i -ne 0 ]; then
|
||||
echo -n ",{\"a\":$i,\"b\":$i}" >> $tmpj
|
||||
else
|
||||
echo -n "{\"a\":$i,\"b\":$i}" >> $tmpj
|
||||
fi
|
||||
|
||||
done
|
||||
echo "]}}}" >> $tmpj
|
||||
fi
|
||||
|
||||
# Loop over mode and format
|
||||
for mode in startup running; do
|
||||
file=$dir/${mode}_db
|
||||
for format in tree xml; do # json - something w namespaces
|
||||
sudo rm -f $file
|
||||
sudo touch $file
|
||||
sudo chmod 666 $file
|
||||
case $format in
|
||||
xml)
|
||||
echo "cp $tmpx $file"
|
||||
cp $tmpx $file
|
||||
;;
|
||||
json)
|
||||
cp $tmpj $file
|
||||
;;
|
||||
tree)
|
||||
echo "clixon_util_datastore -d ${mode} -f tree -y $fyang -b $dir -x $tmpx put create"
|
||||
|
||||
clixon_util_datastore -d ${mode} -f tree -y $fyang -b $dir -x $tmpx put create
|
||||
;;
|
||||
esac
|
||||
new "Startup format: $format mode:$mode"
|
||||
# echo "time sudo $clixon_backend -F1 -D $DBG -s $mode -f $cfg -y $fyang -o CLICON_XMLDB_FORMAT=$format"
|
||||
# Cannot use start_backend here due to expected error case
|
||||
{ time -p sudo $clixon_backend -F1 -D $DBG -s $mode -f $cfg -y $fyang -o CLICON_XMLDB_FORMAT=$format 2> /dev/null; } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
done
|
||||
done
|
||||
|
||||
new "test params: -f $cfg -y $fyang"
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg -y $fyang
|
||||
sudo clixon_backend -zf $cfg
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
|
||||
new "start backend -s init -f $cfg -y $fyang"
|
||||
start_backend -s init -f $cfg -y $fyang
|
||||
new "start backend -s init -f $cfg -- -s"
|
||||
start_backend -s init -f $cfg -- -s
|
||||
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
|
||||
start_restconf -f $cfg
|
||||
|
||||
new "waiting"
|
||||
sleep $RCWAIT
|
||||
wait_backend
|
||||
wait_restconf
|
||||
|
||||
new "generate 'large' config with $perfnr list entries"
|
||||
echo -n "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\">" > $fconfig
|
||||
|
|
@ -158,63 +98,106 @@ echo "</x></config></edit-config></rpc>]]>]]>" >> $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" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
# 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" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
# 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 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
# 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 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
# 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 "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
|
||||
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
|
||||
# Note same entries in the range alreay there, db has same size
|
||||
|
||||
# NETCONF get
|
||||
new "netconf get $perfreq small config"
|
||||
time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
echo "<rpc><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/x/y[a=$rnd][b=$rnd]\" /></get-config></rpc>]]>]]>"
|
||||
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
|
||||
done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
# NETCONF add
|
||||
new "netconf add $perfreq small config"
|
||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
|
||||
done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
# RESTCONF get
|
||||
new "restconf get $perfreq small config"
|
||||
time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
{ 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
|
||||
done } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
# RESTCONF put
|
||||
# Reference:
|
||||
# i686 format=xml perfnr=10000/100 time: 38/29s 20190425 WITH/OUT startup copying
|
||||
# i686 format=tree perfnr=10000/100 time: 72/64s 20190425 WITH/OUT startup copying
|
||||
new "restconf add $perfreq small config"
|
||||
time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
{ 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
|
||||
done } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
# CLI get
|
||||
new "cli get $perfreq small config"
|
||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
$clixon_cli -1 -f $cfg show conf xml x y $rnd > /dev/null
|
||||
done } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
# CLI add
|
||||
new "cli add $perfreq small config"
|
||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
$clixon_cli -1 -f $cfg set x y $rnd b $rnd
|
||||
done } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
# Instead of many small entries, get one large in netconf and restconf
|
||||
# cli?
|
||||
new "netconf get large config"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b></y><y><a>2</a><b>2</b></y><y><a>3</a><b>3</b></y>'
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b></y><y><a>2</a><b>2</b></y><y><a>3</a><b>3</b></y>'
|
||||
|
||||
new "restconf get large config"
|
||||
expecteof "/usr/bin/time -f %e curl -sG http://localhost/restconf/data" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^{"data": {"scaling:x": {"y": \[{"a": 0,"b": 0},{ "a": 1,"b": 1},{ "a": 2,"b": 2},{ "a": 3,"b": 3},'
|
||||
/usr/bin/time -f %e curl -sG http://localhost/restconf/data > /dev/null
|
||||
|
||||
new "cli get large config"
|
||||
/usr/bin/time -f %e $clixon_cli -1f $cfg show config xml> /dev/null
|
||||
|
||||
# Delete entries (last since entries are removed from db)
|
||||
# netconf
|
||||
new "cli delete $perfreq small config"
|
||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
$clixon_cli -1 -f $cfg delete x y $rnd
|
||||
done } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
new "netconf discard-changes"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "netconf delete $perfreq small config"
|
||||
{ time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y operation=\"delete\"><a>$rnd</a></y></x></config></edit-config></rpc>]]>]]>"
|
||||
done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
new "netconf discard-changes"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "restconf delete $perfreq small config"
|
||||
time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
{ 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
|
||||
|
||||
done > /dev/null; } 2>&1 | awk '/real/ {print $2}'
|
||||
exit
|
||||
# Now do leaf-lists istead of leafs
|
||||
|
||||
new "generate large leaf-list config"
|
||||
|
|
@ -225,25 +208,25 @@ done
|
|||
echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig2
|
||||
|
||||
new "netconf replace large list-leaf config"
|
||||
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig2" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig2" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "netconf commit large leaf-list config"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "netconf add $perfreq small leaf-list config"
|
||||
time -p for (( i=0; i<$perfreq; i++ )); do
|
||||
rnd=$(( ( RANDOM % $perfnr ) ))
|
||||
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><c>$rnd</c></x></config></edit-config></rpc>]]>]]>"
|
||||
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
|
||||
done | $clixon_netconf -qf $cfg > /dev/null
|
||||
|
||||
new "netconf add small leaf-list config"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><c>x</c></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><c>x</c></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "netconf commit small leaf-list config"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "netconf get large leaf-list config"
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><c>0</c><c>1</c>'
|
||||
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><c>0</c><c>1</c>'
|
||||
|
||||
new "Kill restconf daemon"
|
||||
stop_restconf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue