#!/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 EOF # Append generated state data to $fstate file # Generation of random timestamps (not used) # and succesive bob$i member-ids 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$i" >> $fstate echo " 192.168.1.32" >> $fstate echo " POST" >> $fstate echo " true" >> $fstate echo " " >> $fstate done echo -n "" >> $fstate # No CR new "test params: -f $cfg -s init -- -siS $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 -- -siS $fstate" start_backend -s init -f $cfg -- -siS $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