#!/usr/bin/env bash # List pagination tests according to draft-ietf-netconf-list-pagination-04 # sort-by and where in Appendix A.3.5 # Only NETCONF, see more extensive testng in _draft test # 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 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} cat < $cfg $cfg ietf-netconf:startup ${YANG_INSTALLDIR} $IETFRFC $dir /usr/local/var/run/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/run/$APPNAME.pidfile $dir json true $APPNAME /usr/local/lib/$APPNAME/cli /usr/local/lib/$APPNAME/clispec $validatexml EOF # See draft-netconf-list-pagination-04.txt A.2 (except stats and audit-log) cat <<'EOF' > $dir/startup_db {"config": { "example-social:members": { "member": [ { "member-id": "bob", "email-address": "bob@example.com", "password": "$0$1543", "avatar": "BASE64VALUE=", "tagline": "Here and now, like never before.", "posts": { "post": [ { "timestamp": "2020-08-14T03:32:25Z", "body": "Just got in." }, { "timestamp": "2020-08-14T03:33:55Z", "body": "What's new?" }, { "timestamp": "2020-08-14T03:34:30Z", "body": "I'm bored..." } ] }, "favorites": { "decimal64-numbers": ["3.14159", "2.71828"] } }, { "member-id": "eric", "email-address": "eric@example.com", "password": "$0$1543", "avatar": "BASE64VALUE=", "tagline": "Go to bed with dreams; wake up with a purpose.", "following": ["alice"], "posts": { "post": [ { "timestamp": "2020-09-17T18:02:04Z", "title": "Son, brother, husband, father", "body": "What's your story?" } ] }, "favorites": { "bits": ["two", "one", "zero"] } }, { "member-id": "alice", "email-address": "alice@example.com", "password": "$0$1543", "avatar": "BASE64VALUE=", "tagline": "Every day is a new day", "privacy-settings": { "hide-network": false, "post-visibility": "public" }, "following": ["bob", "eric", "lin"], "posts": { "post": [ { "timestamp": "2020-07-08T13:12:45Z", "title": "My first post", "body": "Hiya all!" }, { "timestamp": "2020-07-09T01:32:23Z", "title": "Sleepy...", "body": "Catch y'all tomorrow." } ] }, "favorites": { "uint8-numbers": [17, 13, 11, 7, 5, 3], "int8-numbers": [-5, -3, -1, 1, 3, 5] } }, { "member-id": "lin", "email-address": "lin@example.com", "password": "$0$1543", "privacy-settings": { "hide-network": true, "post-visibility": "followers-only" }, "following": ["joe", "eric", "alice"] }, { "member-id": "joe", "email-address": "joe@example.com", "password": "$0$1543", "avatar": "BASE64VALUE=", "tagline": "Greatness is measured by courage and heart.", "privacy-settings": { "post-visibility": "unlisted" }, "following": ["bob"], "posts": { "post": [ { "timestamp": "2020-10-17T18:02:04Z", "body": "What's your status?" } ] } } ] } } } EOF # See draft-netconf-list-pagination-04.txt A.2 (only stats and audit-log) cat< $fstate bob 2020-08-14T03:30:00Z standard 2020-08-14T03:34:30Z eric 2020-09-17T19:38:32Z pro 2020-09-17T18:02:04Z alice 2020-07-08T12:38:32Z admin 2021-04-01T02:51:11Z 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 new "test params: -f $cfg -s startup -- -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 startup -f $cfg -- -sS $fstate" start_backend -s startup -f $cfg -- -sS $fstate fi new "wait backend" wait_backend new "A.3.4.1. direction=forwards" # 17, 13, 11, 7, 5, 3] # Confusing: forwards means dont change order expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "forwards" "alice171311753" new "A.3.4.2. direction=backwards" # 3, 5, 7, 11, 13, 17] expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "backwards" "alice357111317" new "A.3.5.1.1. sort-by type is a leaf-list" # 3,5,7,11,13,17 expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "." "alice357111317" new "A.3.5.1.2. sort-by type is a list and sort-by node is a direct descendent" # alice, bob, eric, joe, lin expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "member-id" "alice.*bob.*eric.*joe.*lin" new "A.3.5.1.3. sort-by type is a list and sort-by node is an indirect descendent" # alice, lin, bob, eric, joe expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "stats/joined" "alice.*lin.*bob.*eric.*joe" new "A.3.6.2. where, match on descendent string containing a substring" # bob, eric, alice, lin, joe # Confusing: all match expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" ".[contains (email-address,'@example.com')]" "bob.*eric.*alice.*lin.*joe" new "A.3.6.3. where, match on decendent timestamp starting with a substring" # bob, eric, alice, joe, # starts-with NYI, replaced with contains # posts//post[starts-with(timestamp,'2020')] expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "posts/post[contains(timestamp,'2020')]" "bob.*eric.*alice.*joe" new "A.3.9.1. All six parameters at once" # eric, bob expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "//post[contains(timestamp,'2020')]member-idbackwards22" "eric.*bob" 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 rm -rf $dir new "endtest" endtest