#!/usr/bin/env bash # Restconf RFC8040 Appendix A and B "jukebox" example # For collection / scaling activity # 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 fjukebox=$dir/example-jukebox.yang cat < $cfg $cfg ietf-netconf:startup /usr/local/share/clixon $IETFRFC $dir false /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend $dir/restconf.pidfile $dir true EOF cat < $dir/startup_db Foo Fighters Crime and Punishment 1995 One by One 2002 The Color and the Shape 1997 There is Nothing Left to Loose 1999 White and Black 1998 EOF # Common Jukebox spec (fjukebox must be set) . ./jukebox.sh new "test params: -f $cfg -- -s" # XXX: -sS state file 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 "waiting" wait_backend if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre new "start restconf daemon" start_restconf -f $cfg new "waiting" wait_restconf fi new "C.1. 'count' Parameter RESTCONF" expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang.collection+xml" $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Foo%20Fighters/album/?count=2)" 0 "HTTP/1.1 200 OK" "application/yang.collection+xml" 'Crime and Punishment1995One by One2002' new "C.1. 'count' Parameter NETCONF" expecteof "$clixon_netconf -qf $cfg" 0 "runningexample-jukebox/example-jukebox:jukebox/library/artist=Foo Fighters/album2]]>]]>" '^Crime and Punishment1995One by One2002]]>]]>$' if [ $RC -ne 0 ]; then new "Kill restconf daemon" stop_restconf fi if [ $BE -eq 0 ]; then exit # BE fi 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 rm -rf $dir