- Fixed plugin-module initialized twice in restconf-fcgi

- Test script: wait for restconf to stop
This commit is contained in:
Olof hagsand 2021-04-19 13:35:21 +02:00
parent b88722fa25
commit 91a583253e
5 changed files with 29 additions and 6 deletions

View file

@ -431,9 +431,6 @@ main(int argc,
if (dbg) if (dbg)
clicon_option_dump(h, dbg); clicon_option_dump(h, dbg);
/* Initialize plugin module by creating a handle holding plugin and callback lists */
if (clixon_plugin_module_init(h) < 0)
goto done;
/* Call start function in all plugins before we go interactive */ /* Call start function in all plugins before we go interactive */
if (clixon_plugin_start_all(h) < 0) if (clixon_plugin_start_all(h) < 0)
goto done; goto done;

View file

@ -646,9 +646,9 @@ clixon_plugin_auth_all(clicon_handle h,
clixon_auth_type_t auth_type, clixon_auth_type_t auth_type,
char **authp) char **authp)
{ {
int retval = -1; int retval = -1;
clixon_plugin_t *cp = NULL; clixon_plugin_t *cp = NULL;
int ret = 0; int ret = 0;
clicon_debug(1, "%s", __FUNCTION__); clicon_debug(1, "%s", __FUNCTION__);
if (authp == NULL){ if (authp == NULL){
@ -1115,6 +1115,10 @@ clixon_plugin_module_init(clicon_handle h)
int retval = -1; int retval = -1;
struct plugin_module_struct *ph; struct plugin_module_struct *ph;
if (plugin_module_struct_get(h) != NULL){
clicon_err(OE_PLUGIN, EFAULT, "Already initialized");
goto done;
}
if ((ph = malloc(sizeof(*ph))) == NULL){ if ((ph = malloc(sizeof(*ph))) == NULL){
clicon_err(OE_UNIX, errno, "malloc"); clicon_err(OE_UNIX, errno, "malloc");
goto done; goto done;

View file

@ -386,6 +386,25 @@ function wait_restconf(){
fi fi
} }
# Wait for restconf to stop
# @note assumes port=80 if RCPROTO=http and port=443 if RCPROTO=https
# @see wait_restconf
function wait_restconf_stopped(){
hdr=$(curl $CURLOPTS $* $RCPROTO://localhost/restconf 2> /dev/null)
let i=0;
while [[ $hdr = *"200 OK"* ]]; do
if [ $i -ge $DEMLOOP ]; then
err1 "restconf timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
hdr=$(curl $CURLOPTS $* $RCPROTO://localhost/restconf 2> /dev/null)
let i++;
done
if [ $valgrindtest -eq 3 ]; then
sleep 2 # some problems with valgrind
fi
}
# End of test, final tests before normal exit of test # End of test, final tests before normal exit of test
function endtest() function endtest()
{ {

View file

@ -245,7 +245,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS $DEFAULTNS>
new "minmax: validate should fail empty list" new "minmax: validate should fail empty list"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>operation-failed</error-tag><error-app-tag>too-few-elements</error-app-tag><error-severity>error</error-severity><error-path>/c/a1</error-path></rpc-error></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>operation-failed</error-tag><error-app-tag>too-few-elements</error-app-tag><error-severity>error</error-severity><error-path>/c/a1</error-path></rpc-error></rpc-reply>]]>]]>$"
if [ $BE -ne 0]; then if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)

View file

@ -223,6 +223,9 @@ new "4. stop restconf RPC"
rpcoperation stop rpcoperation stop
if [ $? -ne 0 ]; then exit -1; fi if [ $? -ne 0 ]; then exit -1; fi
new "Wait for restrconf to stop"
wait_restconf_stopped
new "5. Get rpc status stopped" new "5. Get rpc status stopped"
rpcstatus false stopped rpcstatus false stopped
if [ $pid -ne 0 ]; then err "Pid" "$pid"; fi if [ $pid -ne 0 ]; then err "Pid" "$pid"; fi