#!/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 config list: members/member/favorites/uint8-numbers # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example if [ -z "$(type expect 2> /dev/null)" ]; then echo "...skipped: Expect not installed" rm -rf $dir if [ "$s" = $0 ]; then exit 0; else return 0; fi fi # Skip test if valgrind if [ $valgrindtest -ne 0 ]; then echo "...skipped for valgrind " rm -rf $dir return 0 # skip fi cfg=$dir/conf.xml fexample=$dir/example-social.yang # Common example-module spec (fexample must be set) . ./example_social.sh # Validate internal state xml : ${validatexml:=false} # Number of audit-log entries # Note mem.sh sets it : ${perfnr:=20000} cat < $cfg $cfg ietf-netconf:startup clixon-restconf:allow-auth-none ${YANG_STANDARD_DIR}/ietf/RFC ${YANG_INSTALLDIR} $dir /usr/local/var/run/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/run/$APPNAME.pidfile $dir xml true $APPNAME /usr/local/lib/$APPNAME/cli cli /usr/local/lib/$APPNAME/clispec $validatexml EOF # Based on draft-wwlh-netconf-list-pagination-00 A.2 but bob has a generated uint8-numbers list # start file cat <<'EOF' > $dir/startup_db alice alice@example.com $0$1543 BASE64VALUE= Every day is a new day false public bob eric lin 2020-07-08T13:12:45Z My first post Hiya all! 2020-07-09T01:32:23Z Sleepy... Catch y'all tomorrow. 17 13 11 7 5 3 -5 -3 -1 1 3 5 bob bob@example.com $0$1543 BASE64VALUE= Here and now, like never before. public 2020-08-14T03:32:25Z Just got in. 2020-08-14T03:33:55Z What's new? 2020-08-14T03:34:30Z I'm bored... EOF new "generate config with $perfnr leaf-list entries" for (( i=0; i<$perfnr; i++ )); do echo " $i" >> $dir/startup_db done # end file cat <<'EOF' >> $dir/startup_db -9 2 EOF new "test params: -f $cfg -s startup" 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 startup -f $cfg" start_backend -s startup -f $cfg fi new "wait backend" wait_backend xpath="/es:members/es:member[es:member-id=\'bob\']/es:favorites/es:uint64-numbers" new "cli show pagination config using expect" sudo="sudo -g ${CLICON_GROUP}" ## cheat clixon_cli_="${clixon_cli##$sudo }" clixon_cli="$clixon_cli_" $sudo --preserve-env=clixon_cli expect ./test_pagination_expect.exp "$cfg" "$xpath" "uint64-numbers 18" "uint64-numbers 19" if [ $? -ne 0 ]; then err1 "Failed: CLI show paginate config scroll using expect" fi 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 rm -rf $dir new "endtest" endtest