#!/usr/bin/env bash # List pagination tests loosely based on draft-wwlh-netconf-list-pagination-00 # The example-social yang file is used # This tests contains a large state list: audit-logs from the example # Only CLI is used # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi echo "...skipped: Must run interactvely" if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example cfg=$dir/conf.xml fexample=$dir/example-social.yang fstate=$dir/mystate.xml # Common example-module spec (fexample must be set) . ./example_social.sh # Validate internal state xml : ${validatexml:=false} # Number of audit-log entries #: ${perfnr:=20000} : ${perfnr:=200} cat < $cfg $cfg ietf-netconf:startup clixon-restconf:allow-auth-none /usr/local/share/clixon $IETFRFC $dir /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend $dir/restconf.pidfile $dir json true $APPNAME /usr/local/lib/$APPNAME/cli /usr/local/lib/$APPNAME/clispec $validatexml EOF # See draft-wwlh-netconf-list-pagination-00 A.2 (only stats and audit-log) # XXX members not currently used, only audit-logs as generated below cat< $fstate alice 2020-07-08T12:38:32Z admin 2021-04-01T02:51:11Z bob 2020-08-14T03:30:00Z standard 2020-08-14T03:34:30Z eric 2020-09-17T19:38:32Z pro 2020-09-17T18:02:04Z lin 2020-07-09T12:38:32Z standard 2021-04-01T02:51:11Z joe 2020-10-08T12:38:32Z pro 2021-04-01T02:51:11Z EOF # Append generated state data to $fstate file new "generate state with $perfnr list entries" echo "" >> $fstate for (( i=0; i<$perfnr; i++ )); do echo " " >> $fstate mon=$(( ( RANDOM % 10 ) )) day=$(( ( RANDOM % 10 ) )) hour=$(( ( RANDOM % 10 ) )) echo " 2020-0$mon-0$dayT0$hour:48:11Z" >> $fstate echo " bob" >> $fstate ip1=$(( ( RANDOM % 255 ) )) ip2=$(( ( RANDOM % 255 ) )) echo " 192.168.$ip1.$ip2" >> $fstate echo " POST" >> $fstate echo " true" >> $fstate echo " " >> $fstate done echo -n "" >> $fstate # No CR new "test params: -f $cfg -s init -- -sS $fstate" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi sudo pkill -f clixon_backend # to be sure new "start backend -s init -f $cfg -- -sS $fstate" start_backend -s init -f $cfg -- -sS $fstate fi new "wait backend" wait_backend # XXX How to run without using a terminal? new "cli show" $clixon_cli -1 -f $cfg -l o show pagination xpath /es:audit-logs/es:audit-log cli if [ $BE -ne 0 ]; then 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 fi unset validatexml unset perfnr rm -rf $dir new "endtest" endtest