From 4d5c428b796e5efd0bdd72ab8da60fb687ecc9ea Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 1 Dec 2020 22:34:24 +0100 Subject: [PATCH] * Test fixes * cligen hist file size test * clixon-example.yang update --- test/test_cli_history.sh | 32 +++++++++++++++++++++----------- test/test_restconf.sh | 6 +++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/test/test_cli_history.sh b/test/test_cli_history.sh index 2be7e4c3..8b6d17e1 100755 --- a/test/test_cli_history.sh +++ b/test/test_cli_history.sh @@ -10,6 +10,7 @@ APPNAME=example cfg=$dir/conf_yang.xml histfile=$dir/histfile +histsize=10 # Use yang in example @@ -24,7 +25,7 @@ cat < $cfg /usr/local/lib/$APPNAME/cli $APPNAME $histfile - 10 + $histsize /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME @@ -77,7 +78,7 @@ if [ $nr -ne 1 ]; then fi new "cli add entry and create newhist file" -expecteof "$clixon_cli -f $cfg -o CLICON_CLI_HIST_FILE=$dir/newhist" 0 "example 43" "data" +expecteof "$clixon_cli -f $cfg -o CLICON_CLI_HIST_FILE=$dir/newhist" 0 "example 43" "data" 2> /dev/null new "Check newhist exists" if [ ! -f $dir/newhist ]; then @@ -111,18 +112,27 @@ if [ $nr -ne 2 ]; then err "2" "$nr" fi -if [ $BE -eq 0 ]; then - exit # BE +# Add lots of entries (so it wraps) +for (( i=0; i<$histsize; i++ )); do + echo "example $i" | $clixon_cli -f $cfg > /dev/null 2>&1 +done + +new "Check $histfile is $histsize long (wraps)" +nr=$(cat $histfile | wc -l) +if [ $nr -ne $histsize ]; then + err "$histsize" "$nr" fi -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +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 -# kill backend -stop_backend -f $cfg unset nr rm -rf $dir diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 4612da0c..ba62d649 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -23,7 +23,7 @@ APPNAME=example cfg=$dir/conf.xml # clixon-example and clixon-restconf is used, copy here -cp /usr/local/share/clixon/clixon-example@2020-03-11.yang $dir/ +cp /usr/local/share/clixon/clixon-example@2020-12-01.yang $dir/ cp /usr/local/share/clixon/clixon-restconf@2020-10-30.yang $dir/ cat < $cfg @@ -148,7 +148,7 @@ testrun() # Should be alphabetically ordered new "restconf get restconf/operations. RFC8040 3.3.2 (json)" - expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/operations)" 0 'HTTP/1.1 200 OK' '{"operations":{"clixon-example:client-rpc":\[null\],"clixon-example:empty":\[null\],"clixon-example:optional":\[null\],"clixon-example:example":\[null\]' '"clixon-lib:debug":\[null\],"clixon-lib:ping":\[null\],"clixon-lib:stats":\[null\],"clixon-lib:restart-plugin":\[null\],"ietf-netconf:get-config":\[null\],"ietf-netconf:edit-config":\[null\],"ietf-netconf:copy-config":\[null\],"ietf-netconf:delete-config":\[null\],"ietf-netconf:lock":\[null\],"ietf-netconf:unlock":\[null\],"ietf-netconf:get":\[null\],"ietf-netconf:close-session":\[null\],"ietf-netconf:kill-session":\[null\],"ietf-netconf:commit":\[null\],"ietf-netconf:discard-changes":\[null\],"ietf-netconf:validate":\[null\]' + expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/operations)" 0 'HTTP/1.1 200 OK' '{"operations":{' '"clixon-example:client-rpc":\[null\],"clixon-example:empty":\[null\],"clixon-example:optional":\[null\],"clixon-example:example":\[null\]' '"clixon-lib:debug":\[null\],"clixon-lib:ping":\[null\],"clixon-lib:stats":\[null\],"clixon-lib:restart-plugin":\[null\]' '"ietf-netconf:get-config":\[null\],"ietf-netconf:edit-config":\[null\],"ietf-netconf:copy-config":\[null\],"ietf-netconf:delete-config":\[null\],"ietf-netconf:lock":\[null\],"ietf-netconf:unlock":\[null\],"ietf-netconf:get":\[null\],"ietf-netconf:close-session":\[null\],"ietf-netconf:kill-session":\[null\],"ietf-netconf:commit":\[null\],"ietf-netconf:discard-changes":\[null\],"ietf-netconf:validate":\[null\]' new "restconf get restconf/operations. RFC8040 3.3.2 (xml)" ret=$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $proto://$addr/restconf/operations) @@ -173,7 +173,7 @@ testrun() expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:modules-state/module=ietf-interfaces,2018-02-20)" 0 'HTTP/1.1 200 OK' '{"ietf-yang-library:module":\[{"name":"ietf-interfaces","revision":"2018-02-20","namespace":"urn:ietf:params:xml:ns:yang:ietf-interfaces","conformance-type":"implement"}\]}' new "restconf schema resource, mod-state top-level" - expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:modules-state)" 0 'HTTP/1.1 200 OK' '{"ietf-yang-library:modules-state":{"module-set-id":"0","module":\[{"name":"clixon-example","revision":"2020-03-11","namespace":"urn:example:clixon","conformance-type":"implement"},{"name":"clixon-lib","revision":"2020-04-23","' + expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:modules-state)" 0 'HTTP/1.1 200 OK' '{"ietf-yang-library:modules-state":{"module-set-id":"0","module":\[{"name":"clixon-example","revision":"2020-12-01","namespace":"urn:example:clixon","conformance-type":"implement"},{"name":"clixon-lib","revision":"2020-04-23","' new "restconf options. RFC 8040 4.1" expectpart "$(curl $CURLOPTS -X OPTIONS $proto://$addr/restconf/data)" 0 "HTTP/1.1 200 OK" "Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE"