Tests: added expect script for pagination stdio
This commit is contained in:
parent
927d6f2d9c
commit
e0f5472161
8 changed files with 99 additions and 18 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -13,6 +13,8 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: install expect
|
||||
run: sudo apt install -y expect
|
||||
# 1) checkout and compile natively
|
||||
- name: install cligen
|
||||
run: (git clone https://github.com/clicon/cligen.git && cd cligen && ./configure && make && sudo make install)
|
||||
|
|
|
|||
|
|
@ -188,6 +188,14 @@ typedef int (plgextension_t)(clicon_handle h, yang_stmt *yext, yang_stmt *ys);
|
|||
typedef int (plgauth_t)(clicon_handle h, void *req, clixon_auth_type_t auth_type, char **authp);
|
||||
|
||||
/*! Reset system status
|
||||
*
|
||||
* Add xml or set state in backend system.
|
||||
* plugin_reset in each backend plugin after all plugins have been initialized.
|
||||
* This gives the application a chance to reset system state back to a base state.
|
||||
* This is generally done when a system boots up to make sure the initial system state
|
||||
* is well defined.
|
||||
* This involves creating default configuration files for various daemons, set interface
|
||||
* flags etc.
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] db Database name (eg "running")
|
||||
* @retval -1 Fatal error
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ automatically run as part of the all.sh, sum.sh tests etc. The scripts
|
|||
need to follow some rules to work properly, please look at one or two
|
||||
to get the idea.
|
||||
|
||||
Most scripts are bash scripts using standard awk/sed etc. There is
|
||||
also (at least one) expect script.
|
||||
|
||||
Note that some IETF yangs need to be available, by default these are in `/usr/local//share/yang/standard`. You can change this location with configure option `--with-yang-standard-dir=DIR`
|
||||
|
||||
See also the [site.sh](#site-sh) for example for skipping tests or setting some site-specific variables.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ cat <<EOF > $fexample
|
|||
}
|
||||
|
||||
leaf email-address {
|
||||
type inet:email-address;
|
||||
type string;
|
||||
mandatory true;
|
||||
description
|
||||
"The member's email address.";
|
||||
|
|
@ -119,6 +119,7 @@ cat <<EOF > $fexample
|
|||
leaf-list following {
|
||||
type leafref {
|
||||
path "/members/member/member-id";
|
||||
require-instance false;
|
||||
}
|
||||
description
|
||||
"Other members this members is following.";
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@
|
|||
# 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
|
||||
|
||||
if [ -z "$(type expect 2> /dev/null)" ]; then
|
||||
echo "...skipped: Expect not installed"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
fexample=$dir/example-social.yang
|
||||
|
||||
|
|
@ -29,6 +31,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
<CLICON_FEATURE>clixon-restconf:allow-auth-none</CLICON_FEATURE> <!-- Use auth-type=none -->
|
||||
<CLICON_YANG_DIR>${YANG_STANDARD_DIR}/ietf/RFC</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>
|
||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
|
|
@ -147,9 +150,11 @@ fi
|
|||
new "wait backend"
|
||||
wait_backend
|
||||
|
||||
# XXX How to run without using a terminal?
|
||||
new "cli show"
|
||||
$clixon_cli -f $cfg -l o -1 show pagination xpath /es:members/es:member[es:member-id=\'bob\']/es:favorites/es:uint64-numbers cli
|
||||
xpath="/es:members/es:member[es:member-id=\'bob\']/es:favorites/es:uint64-numbers"
|
||||
new "cli show pagination config using expect"
|
||||
expect ./test_pagination_expect.exp "$cfg" "$xpath" "uint64-numbers 18" "uint64-numbers 19"
|
||||
|
||||
#$clixon_cli -f $cfg -l o -1 show pagination xpath /es:members/es:member[es:member-id=\'bob\']/es:favorites/es:uint64-numbers cli
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
|
|
@ -164,6 +169,7 @@ fi
|
|||
|
||||
unset validatexml
|
||||
unset perfnr
|
||||
unset xpath
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
62
test/test_pagination_expect.exp
Executable file
62
test/test_pagination_expect.exp
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env expect -f
|
||||
# Tests of paginated state scrolling using expect. Simply that --More-- is shown and
|
||||
# that first two pages scroll OK. More tests could be done.
|
||||
# Arguments:
|
||||
# 0: clixon configuration file
|
||||
# 1: xpath
|
||||
# 2: line1 should appear on first page
|
||||
# 3: line2 should appear on second page (and not on first)
|
||||
|
||||
set timeout 1
|
||||
#log_user 0
|
||||
|
||||
set stty_init "rows 20 cols 128"
|
||||
|
||||
send_user "\nTest State paginate cli scrolling\n"
|
||||
|
||||
set cfg [lindex $argv 0]
|
||||
set xpath [lindex $argv 1]
|
||||
set line1 [lindex $argv 2]
|
||||
set line2 [lindex $argv 3]
|
||||
|
||||
spawn clixon_cli -f $cfg
|
||||
|
||||
send "show pagination xpath $xpath cli\n"
|
||||
|
||||
expect {
|
||||
timeout { send_user "\n$line1 not received.\n"; exit 1}
|
||||
"$line1" { send_user "\n$line1 OK.\n";}
|
||||
}
|
||||
|
||||
expect {
|
||||
timeout { send_user "\nmember-id $line2.\n";}
|
||||
"member-id $line2" { send_user "\n$line2 not expected.\n"; exit 1}
|
||||
}
|
||||
|
||||
expect {
|
||||
timeout { send_user "\nMore 1 not received.\n"; exit 1}
|
||||
-ex "--More--" {send_user "\nMore 1 OK.\n"}
|
||||
}
|
||||
|
||||
send " "
|
||||
|
||||
expect {
|
||||
timeout { send_user "\n$line2 not received.\n"; exit 1}
|
||||
"$line2" { send_user "\n$line2 OK.\n"}
|
||||
}
|
||||
|
||||
expect {
|
||||
timeout { send_user "\nMore 2 not received.\n"; exit 1}
|
||||
-ex "--More--" { send_user "\nMore 2 OK.\n"}
|
||||
}
|
||||
|
||||
send "q"
|
||||
|
||||
expect {
|
||||
-ex "--More--" { send_user "\nMore not expected.\n"; exit 1}
|
||||
}
|
||||
|
||||
send "\d"
|
||||
close
|
||||
|
||||
send_user "\nTest OK\n"
|
||||
|
|
@ -158,18 +158,17 @@ testrun_stop
|
|||
|
||||
#----------------------------
|
||||
|
||||
echo "...skipped: Must run interactively"
|
||||
if false; then
|
||||
# Only if expect installed
|
||||
if [ -n "$(type expect 2> /dev/null)" ]; then
|
||||
|
||||
testrun_start "/es:audit-logs/es:audit-log"
|
||||
|
||||
# XXX How to run without using a terminal? Maybe use expect/unbuffer
|
||||
new "cli show"
|
||||
$clixon_cli -1 -f $cfg -l o show pagination xpath $xpath cli
|
||||
#expectpart "$(echo -n | unbuffer -p $clixon_cli -1 -f $cfg -l o show pagination xpath $xpath cli)" 0 foo
|
||||
newtest "CLI scroll test using expect"
|
||||
expect ./test_pagination_expect.exp "$cfg" "$xpath" bob3 bob4
|
||||
|
||||
testrun_stop
|
||||
|
||||
fi # interactive
|
||||
fi # expect
|
||||
|
||||
unset validatexml
|
||||
unset perfnr
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ You can also run a single vagrant test as follows:
|
|||
|
||||
The current vagrant boxes are verified continuously:
|
||||
* ubuntu/bionic64
|
||||
* generic/centos8
|
||||
* generic/freebsd12
|
||||
# * generic/centos8
|
||||
* generic/freebsd13
|
||||
|
||||
For other vagrant boxes, see [search vagrant boxes](https://vagrantcloud.com/search)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue