* Made a separate Clixon datastore XML/JSON top-level symbol
* Replaces the hardcoded "config" keyword. * Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h * Tests: added endtest to all tests. Removed all premature exits if BE=0
This commit is contained in:
parent
2ab90d847b
commit
b7991d9b39
132 changed files with 939 additions and 628 deletions
|
|
@ -32,6 +32,9 @@ Expected: April
|
|||
|
||||
### Minor features
|
||||
|
||||
* Made a separate Clixon datastore XML/JSON top-level symbol
|
||||
* Replaces the hardcoded "config" keyword.
|
||||
* Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h
|
||||
* Introduced a delay before making process start/stop/restart processes for race conditions when configuring eg restconf
|
||||
* For restconf `CLICON_BACKEND_RESTCONF_PROCESS`, restart restconf if restconf is edited.
|
||||
|
||||
|
|
@ -39,7 +42,6 @@ Expected: April
|
|||
|
||||
* Reverted blocked signal behavior introduced in 5.0.
|
||||
|
||||
|
||||
## 5.0.0
|
||||
27 February 2021
|
||||
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ client_get_config_only(clicon_handle h,
|
|||
if (xret==NULL)
|
||||
cprintf(cbret, "<data/>");
|
||||
else{
|
||||
if (xml_name_set(xret, "data") < 0)
|
||||
if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
|
||||
goto done;
|
||||
|
|
@ -638,10 +638,13 @@ from_client_edit_config(clicon_handle h,
|
|||
}
|
||||
}
|
||||
/* Get config element */
|
||||
if ((xc = xpath_first(xn, nsc, "%s%sconfig", prefix?prefix:"", prefix?":":"")) == NULL){
|
||||
if ((xc = xpath_first(xn, nsc, "%s%s%s",
|
||||
prefix?prefix:"",
|
||||
prefix?":":"",
|
||||
NETCONF_INPUT_CONFIG)) == NULL){
|
||||
cprintf(cbx, "Element not found, or mismatching prefix %s for namespace %s",
|
||||
prefix?prefix:"null", NETCONF_BASE_NAMESPACE);
|
||||
if (netconf_missing_element(cbret, "protocol", "config", cbuf_get(cbx)) < 0)
|
||||
if (netconf_missing_element(cbret, "protocol", NETCONF_INPUT_CONFIG, cbuf_get(cbx)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -1215,7 +1218,7 @@ from_client_get(clicon_handle h,
|
|||
if (xret==NULL)
|
||||
cprintf(cbret, "<data/>");
|
||||
else{
|
||||
if (xml_name_set(xret, "data") < 0)
|
||||
if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
|
||||
goto done;
|
||||
/* Top level is data, so add 1 to depth if significant */
|
||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
|
||||
|
|
|
|||
|
|
@ -420,6 +420,11 @@ startup_commit(clicon_handle h,
|
|||
* XXX note here startup is copied to candidate, which may confuse everything
|
||||
* XXX default values are overwritten
|
||||
*/
|
||||
if (td->td_target)
|
||||
/* target is datastore, but is here transformed to mimic an incoming
|
||||
* edit-config
|
||||
*/
|
||||
xml_name_set(td->td_target, NETCONF_INPUT_CONFIG);
|
||||
if ((ret = xmldb_put(h, "running", OP_REPLACE, td->td_target,
|
||||
clicon_username_get(h), cbret)) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ clixon_plugin_statedata_one(clixon_plugin *cp,
|
|||
cxobj *x = NULL;
|
||||
|
||||
if ((fn = cp->cp_api.ca_statedata) != NULL){
|
||||
if ((x = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((x = xml_new(XML_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (fn(h, nsc, xpath, x) < 0){
|
||||
if (clicon_errno < 0)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ db_merge(clicon_handle h,
|
|||
/* Get data as xml from db1 */
|
||||
if (xmldb_get0(h, (char*)db1, YB_MODULE, NULL, NULL, 0, &xt, NULL) < 0)
|
||||
goto done;
|
||||
xml_name_set(xt, NETCONF_INPUT_CONFIG);
|
||||
/* Merge xml into db2. Without commit */
|
||||
retval = xmldb_put(h, (char*)db2, OP_MERGE, xt, clicon_username_get(h), cbret);
|
||||
done:
|
||||
|
|
@ -168,8 +169,10 @@ load_extraxml(clicon_handle h,
|
|||
{
|
||||
int retval = -1;
|
||||
cxobj *xt = NULL;
|
||||
cxobj *xerr = NULL;
|
||||
FILE *fp = NULL;
|
||||
yang_stmt *yspec = NULL;
|
||||
int ret;
|
||||
|
||||
if (filename == NULL)
|
||||
return 1;
|
||||
|
|
@ -178,11 +181,25 @@ load_extraxml(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
|
||||
/* No yang check yet because it has <config> as top symbol, do it later after that is removed */
|
||||
if (clixon_xml_parse_file(fp, YB_NONE, yspec, NULL, &xt, &xerr) < 0)
|
||||
goto done;
|
||||
/* Replace parent w first child */
|
||||
if (xml_rootchild(xt, 0, &xt) < 0)
|
||||
goto done;
|
||||
/* Ensure edit-config "config" statement */
|
||||
if (xt)
|
||||
xml_name_set(xt, NETCONF_INPUT_CONFIG);
|
||||
/* Now we can yang bind */
|
||||
if ((ret = xml_bind_yang(xt, YB_MODULE, yspec, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (netconf_err2cb(xerr, cbret) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Merge user reset state */
|
||||
retval = xmldb_put(h, (char*)db, OP_MERGE, xt, clicon_username_get(h), cbret);
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ cli_dbxml(clicon_handle h,
|
|||
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvv_i) < 0)
|
||||
goto done;
|
||||
/* Create config top-of-tree */
|
||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
xbot = xtop;
|
||||
if (api_path){
|
||||
|
|
@ -834,8 +834,8 @@ load_config_file(clicon_handle h,
|
|||
goto done;
|
||||
x = NULL;
|
||||
while ((x = xml_child_each(xt, x, -1)) != NULL) {
|
||||
/* Ensure top-level is "config", maybe this is too rough? */
|
||||
xml_name_set(x, "config");
|
||||
/* Read as datastore-top but transformed into an edit-config "config" */
|
||||
xml_name_set(x, NETCONF_INPUT_CONFIG);
|
||||
if (clicon_xml2cbuf(cbxml, x, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -919,7 +919,7 @@ save_config_file(clicon_handle h,
|
|||
/* get-config returns a <data> tree. Save as <config> tree so it can be used
|
||||
* as data-store.
|
||||
*/
|
||||
if (xml_name_set(xt, "config") < 0)
|
||||
if (xml_name_set(xt, DATASTORE_TOP_SYMBOL) < 0)
|
||||
goto done;
|
||||
if ((f = fopen(filename, "w")) == NULL){
|
||||
clicon_err(OE_CFG, errno, "Creating file %s", filename);
|
||||
|
|
@ -1270,11 +1270,11 @@ cli_copy_config(clicon_handle h,
|
|||
}
|
||||
toname = cv_string_get(tocv);
|
||||
/* Create copy xml tree x2 */
|
||||
if ((x2 = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((x2 = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (xml_copy(x1, x2) < 0)
|
||||
goto done;
|
||||
xml_name_set(x2, "config");
|
||||
xml_name_set(x2, NETCONF_INPUT_CONFIG);
|
||||
cprintf(cb, "/%s", keyname);
|
||||
|
||||
if ((x = xpath_first(x2, nsc, "%s", cbuf_get(cb))) == NULL){
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ expand_dbvar(void *h,
|
|||
xcur = xt; /* default top-of-tree */
|
||||
xpathcur = xpath;
|
||||
/* Create config top-of-tree */
|
||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xtop = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
xbot = xtop;
|
||||
/* This is primarily to get "y",
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ usage(clicon_handle h,
|
|||
fprintf(stderr, "usage:%s [options]\n"
|
||||
"where options are\n"
|
||||
"\t-h \t\t Help\n"
|
||||
"\t-D <level>\t Debug level _ overrides any config debug setting\n"
|
||||
"\t-D <level>\t Debug level, overrides any config debug setting\n"
|
||||
"\t-f <file>\t Configuration file (mandatory)\n"
|
||||
"\t-E <dir> \t Extra configuration file directory\n"
|
||||
"\t-l <s|f<file>> \t Log on (s)yslog, (f)ile (syslog is default)\n"
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ api_data_write(clicon_handle h,
|
|||
else
|
||||
op = OP_REPLACE; /* OP_CREATE if it does not exist */
|
||||
/* Create config top-of-tree */
|
||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
/* Translate api_path to xml in the form of xtop/xbot */
|
||||
xbot = xtop;
|
||||
|
|
@ -480,7 +480,7 @@ api_data_write(clicon_handle h,
|
|||
*/
|
||||
dname = xml_name(xdata);
|
||||
if (api_path==NULL) {
|
||||
if (strcmp(dname, "data")!=0){
|
||||
if (strcmp(dname, NETCONF_OUTPUT_DATA)!=0){
|
||||
if (netconf_bad_element_xml(&xerr, "application", dname,
|
||||
"Data element does not match top-level data") < 0)
|
||||
goto done;
|
||||
|
|
@ -497,7 +497,7 @@ api_data_write(clicon_handle h,
|
|||
if (xtop) /* also xbot */
|
||||
xml_free(xtop);
|
||||
xtop = xdata;
|
||||
xml_name_set(xtop, "config");
|
||||
xml_name_set(xtop, NETCONF_INPUT_CONFIG);
|
||||
/* remove default namespace */
|
||||
if ((xa = xml_find_type(xtop, NULL, "xmlns", CX_ATTR)) != NULL){
|
||||
if (xml_rm(xa) < 0)
|
||||
|
|
@ -818,7 +818,7 @@ api_data_delete(clicon_handle h,
|
|||
for (i=0; i<pi; i++)
|
||||
api_path = index(api_path+1, '/');
|
||||
/* Create config top-of-tree */
|
||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
xbot = xtop;
|
||||
if (api_path){
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ api_data_post(clicon_handle h,
|
|||
for (i=0; i<pi; i++)
|
||||
api_path = index(api_path+1, '/');
|
||||
/* Create config top-of-tree */
|
||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
/* Translate api_path to xtop/xbot */
|
||||
xbot = xtop;
|
||||
|
|
@ -524,7 +524,7 @@ api_operations_post_input(clicon_handle h,
|
|||
goto fail;
|
||||
break;
|
||||
} /* switch media_in */
|
||||
xml_name_set(xdata, "data");
|
||||
xml_name_set(xdata, NETCONF_OUTPUT_DATA);
|
||||
/* Here xdata is:
|
||||
* <data><input xmlns="urn:example:clixon">...</input></data>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ api_root_restconf(clicon_handle h,
|
|||
if (api_yang_library_version(h, req, pretty, media_out) < 0)
|
||||
goto done;
|
||||
}
|
||||
else if (strcmp(api_resource, "data") == 0){ /* restconf, skip /api/data */
|
||||
else if (strcmp(api_resource, NETCONF_OUTPUT_DATA) == 0){ /* restconf, skip /api/data */
|
||||
if (api_data(h, req, path, pcvec, 2, qvec, indata,
|
||||
pretty, media_out, IETF_DS_NONE) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -92,3 +92,11 @@
|
|||
* clixon-4.4
|
||||
*/
|
||||
#define STATE_ORDERED_BY_SYSTEM
|
||||
|
||||
/* Top-symbol in clixon datastores
|
||||
* This is traditionally same as NETCONF_INPUT_CONFIG ("config") but can be different
|
||||
* If you change this, you need to change test shell variable in lib.sh: DATASTORE_TOP
|
||||
* Consider making this an option or configure option
|
||||
* see XMLDB_CONFIG_HACK
|
||||
*/
|
||||
#define DATASTORE_TOP_SYMBOL "config"
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *s
|
|||
int upgrade_callback_delete_all(clicon_handle h);
|
||||
int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);
|
||||
|
||||
const clixon_auth_type_t clixon_auth_type_str2int(char *auth_type);
|
||||
const int clixon_auth_type_str2int(char *auth_type);
|
||||
const char *clixon_auth_type_int2str(clixon_auth_type_t auth_type);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,26 @@
|
|||
* operations, <error-info> content, and the <action> element.
|
||||
*/
|
||||
#define YANG_XML_NAMESPACE "urn:ietf:params:xml:ns:yang:1"
|
||||
|
||||
/* Input symbol for netconf edit-config (+validate)
|
||||
* ietf-netconf.yang defines is as input:
|
||||
* choice edit-content {
|
||||
* anyxml config;
|
||||
* See also DATASTORE_TOP_SYMBOL which is the clixon datastore top symbol. By default also config
|
||||
*/
|
||||
#define NETCONF_INPUT_CONFIG "config"
|
||||
|
||||
/* Output symbol for netconf get/get-config
|
||||
* ietf-netconf.yang defines it as output:
|
||||
* output { anyxml data;
|
||||
*/
|
||||
#define NETCONF_OUTPUT_DATA "data"
|
||||
|
||||
/* Name of xml top object created by xml parse functions
|
||||
* This is a "neutral" symbol without any meaning as opposed to the previous symbols ^
|
||||
*/
|
||||
#define XML_TOP_SYMBOL "top"
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
|
|
@ -147,6 +167,7 @@ typedef struct clixon_xml_vec clixon_xvec; /* struct defined in clicon_xml_vec.c
|
|||
#define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
|
||||
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
|
||||
#define XML_FLAG_DEFAULT 0x20 /* Added when a value is set as default @see xml_default */
|
||||
#define XML_FLAG_TOP 0x40 /* Top datastore symbol */
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ clixon_client_get_xdata(int sock,
|
|||
goto done; /* Not fatal */
|
||||
}
|
||||
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
||||
if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ xmldb_copy(clicon_handle h,
|
|||
else if (x2 == NULL){ /* create x2 and copy from x1 */
|
||||
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
xml_flag_set(x2, XML_FLAG_TOP);
|
||||
if (xml_copy(x1, x2) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -224,6 +225,7 @@ xmldb_copy(clicon_handle h,
|
|||
xml_free(x2);
|
||||
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
xml_flag_set(x2, XML_FLAG_TOP);
|
||||
if (xml_copy(x1, x2) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -372,7 +374,7 @@ xmldb_exists(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Clear database cache if any for mem/size optimization only
|
||||
/*! Clear database cache if any for mem/size optimization only, not file itself
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] db Database
|
||||
* @retval -1 Error
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ singleconfigroot(cxobj *xt,
|
|||
x = NULL;
|
||||
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){
|
||||
i++;
|
||||
if (strcmp(xml_name(x), "config")){
|
||||
clicon_err(OE_DB, ENOENT, "Wrong top-element %s expected config",
|
||||
xml_name(x));
|
||||
if (strcmp(xml_name(x), DATASTORE_TOP_SYMBOL)){
|
||||
clicon_err(OE_DB, ENOENT, "Wrong top-element %s expected %s",
|
||||
xml_name(x), DATASTORE_TOP_SYMBOL);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -462,7 +462,7 @@ xmldb_readfile(clicon_handle h,
|
|||
if ((ret = clixon_json_parse_file(fp, yb, yspec, &x0, NULL)) < 0) /* XXX: ret == 0*/
|
||||
goto done;
|
||||
}
|
||||
else if ((ret = clixon_xml_parse_file(fp, yb, yspec, "</config>", &x0, NULL)) < 0)
|
||||
else if ((ret = clixon_xml_parse_file(fp, yb, yspec, NULL /* "</config>" XXX */, &x0, NULL)) < 0)
|
||||
goto done;
|
||||
#ifdef XMLDB_READFILE_FAIL /* The functions calling this function cannot handle a failed parse yet */
|
||||
if (ret == 0)
|
||||
|
|
@ -473,7 +473,7 @@ xmldb_readfile(clicon_handle h,
|
|||
* 1. File is empty <top/> -> rename top-level to "config"
|
||||
*/
|
||||
if (xml_child_nr(x0) == 0){
|
||||
if (xml_name_set(x0, "config") < 0)
|
||||
if (xml_name_set(x0, DATASTORE_TOP_SYMBOL) < 0)
|
||||
goto done;
|
||||
}
|
||||
/* 2. File is not empty <top><config>...</config></top> -> replace root */
|
||||
|
|
@ -482,6 +482,7 @@ xmldb_readfile(clicon_handle h,
|
|||
if (singleconfigroot(x0, &x0) < 0)
|
||||
goto done;
|
||||
}
|
||||
xml_flag_set(x0, XML_FLAG_TOP);
|
||||
if (xml_child_nr(x0) == 0 && de)
|
||||
de->de_empty = 1;
|
||||
|
||||
|
|
@ -695,6 +696,7 @@ xmldb_get_cache(clicon_handle h,
|
|||
/* Make new tree by copying top-of-tree from x0t to x1t */
|
||||
if ((x1t = xml_new(xml_name(x0t), NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
xml_flag_set(x1t, XML_FLAG_TOP);
|
||||
xml_spec_set(x1t, xml_spec(x0t));
|
||||
|
||||
if (xlen < 1000){
|
||||
|
|
@ -996,7 +998,7 @@ xmldb_get0_clear(clicon_handle h,
|
|||
|
||||
/* clear mark and change */
|
||||
xml_apply0(x, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
|
||||
(void*)(0xffff));
|
||||
(void*)(XML_FLAG_MARK|XML_FLAG_ADD|XML_FLAG_CHANGE));
|
||||
ok:
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ check_body_namespace(cxobj *x0,
|
|||
|
||||
/* XXX: need to identify root better than hiereustics and strcmp,... */
|
||||
isroot = xml_parent(x1p)==NULL &&
|
||||
strcmp(xml_name(x1p), "config") == 0 &&
|
||||
strcmp(xml_name(x1p), DATASTORE_TOP_SYMBOL) == 0 &&
|
||||
xml_prefix(x1p)==NULL;
|
||||
if (nodeid_split(x1bstr, &prefix, NULL) < 0)
|
||||
goto done;
|
||||
|
|
@ -935,14 +935,14 @@ xmldb_put(clicon_handle h,
|
|||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
if (x1 && strcmp(xml_name(x1), "config") != 0){
|
||||
clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"config\"",
|
||||
xml_name(x1));
|
||||
if (x1 && strcmp(xml_name(x1), NETCONF_INPUT_CONFIG) != 0){
|
||||
clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"%s\"",
|
||||
xml_name(x1), NETCONF_INPUT_CONFIG);
|
||||
goto done;
|
||||
}
|
||||
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
|
||||
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE)
|
||||
x0 = de->de_xml;
|
||||
x0 = de->de_xml; /* XXX flag is not XML_FLAG_TOP */
|
||||
}
|
||||
/* If there is no xml x0 tree (in cache), then read it from file */
|
||||
if (x0 == NULL){
|
||||
|
|
@ -952,9 +952,10 @@ xmldb_put(clicon_handle h,
|
|||
if (ret == 0)
|
||||
goto fail;
|
||||
}
|
||||
if (strcmp(xml_name(x0), "config")!=0){
|
||||
clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"config\"",
|
||||
xml_name(x0));
|
||||
if (strcmp(xml_name(x0), DATASTORE_TOP_SYMBOL) !=0 ||
|
||||
xml_flag(x0, XML_FLAG_TOP) == 0){
|
||||
clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"%s\"",
|
||||
xml_name(x0), DATASTORE_TOP_SYMBOL);
|
||||
goto done;
|
||||
}
|
||||
/* Here x0 looks like: <config>...</config> */
|
||||
|
|
|
|||
|
|
@ -1232,7 +1232,8 @@ _json_parse(char *str,
|
|||
*/
|
||||
if (yspec && xml_prefix(x) == NULL
|
||||
#ifdef XMLDB_CONFIG_HACK
|
||||
&& strcmp(xml_name(x), "config") != 0
|
||||
// && !xml_flag(x, XML_FLAG_TOP)
|
||||
&& strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) != 0
|
||||
#endif
|
||||
){
|
||||
if ((cberr = cbuf_new()) == NULL){
|
||||
|
|
@ -1261,8 +1262,11 @@ _json_parse(char *str,
|
|||
break;
|
||||
case YB_MODULE:
|
||||
#ifdef XMLDB_CONFIG_HACK
|
||||
if (strcmp(xml_name(x),"config") == 0 ||
|
||||
strcmp(xml_name(x),"data") == 0){
|
||||
if (
|
||||
// xml_flag(x, XML_FLAG_TOP)
|
||||
strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) == 0
|
||||
|| strcmp(xml_name(x), NETCONF_OUTPUT_DATA) == 0
|
||||
){
|
||||
/* xt:<top> nospec
|
||||
* x: <config>
|
||||
* <a> <-- populate from modules
|
||||
|
|
|
|||
|
|
@ -964,7 +964,7 @@ static const map_str2int clixon_auth_type[] = {
|
|||
|
||||
/*! Translate from string to auth-type
|
||||
*/
|
||||
const clixon_auth_type_t
|
||||
const int
|
||||
clixon_auth_type_str2int(char *auth_type)
|
||||
{
|
||||
return clicon_str2int(clixon_auth_type, auth_type);
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ clicon_rpc_get_config(clicon_handle h,
|
|||
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
|
||||
xd = xml_parent(xd); /* point to rpc-reply */
|
||||
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
||||
if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
}
|
||||
else{
|
||||
|
|
@ -831,7 +831,7 @@ clicon_rpc_get(clicon_handle h,
|
|||
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
|
||||
xd = xml_parent(xd); /* point to rpc-reply */
|
||||
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
||||
if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -1905,7 +1905,7 @@ xml_copy_one(cxobj *x0,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT)); /* Maybe more flags */
|
||||
xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT | XML_FLAG_TOP)); /* Maybe more flags */
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -82,9 +82,6 @@
|
|||
#define BUFLEN 1024
|
||||
/* Indentation for xml pretty-print. Consider option? */
|
||||
#define XML_INDENT 3
|
||||
/* Name of xml top object created by xml parse functions */
|
||||
#define XML_TOP_SYMBOL "top"
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
* XML printing functions. Output a parse tree to file, string cligen buf
|
||||
|
|
@ -516,8 +513,11 @@ _xml_parse(const char *str,
|
|||
* x: <a> <-- populate from modules
|
||||
*/
|
||||
#ifdef XMLDB_CONFIG_HACK
|
||||
if (strcmp(xml_name(x),"config") == 0 ||
|
||||
strcmp(xml_name(x),"data") == 0){
|
||||
if (
|
||||
// xml_flag(x, XML_FLAG_TOP)
|
||||
strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) == 0
|
||||
|| strcmp(xml_name(x), NETCONF_OUTPUT_DATA) == 0
|
||||
){
|
||||
/* xt:<top> nospec
|
||||
* x: <config>
|
||||
* <a> <-- populate from modules
|
||||
|
|
|
|||
|
|
@ -1329,7 +1329,7 @@ xml_global_defaults(clicon_handle h,
|
|||
/* First get or compute global xml tree cache */
|
||||
if ((de = clicon_db_elmnt_get(h, key)) == NULL){
|
||||
/* Create it */
|
||||
if ((xcache = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xcache = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (xml_global_defaults_create(xcache, yspec, state) < 0)
|
||||
goto done;
|
||||
|
|
@ -1353,7 +1353,7 @@ xml_global_defaults(clicon_handle h,
|
|||
xml_apply_ancestor(x0, (xml_applyfn_t*)xml_flag_set, (void*)XML_FLAG_CHANGE);
|
||||
}
|
||||
/* Create a new tree and copy over the parts from the cache that matches xpath */
|
||||
if ((xpart = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
||||
if ((xpart = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||
goto done;
|
||||
if (xml_copy_marked(xcache, xpart) < 0) /* config */
|
||||
goto done;
|
||||
|
|
@ -1763,11 +1763,12 @@ assign_namespace_element(cxobj *x0, /* source */
|
|||
char *prefix0 = NULL;;
|
||||
int isroot;
|
||||
|
||||
/* XXX: need to identify root better than hiereustics and strcmp,... */
|
||||
/* XXX: need to identify root better than hiereustics and strcmp,...
|
||||
* see XMLDB_CONFIG_HACK
|
||||
*/
|
||||
isroot = xml_parent(x1p)==NULL &&
|
||||
(strcmp(xml_name(x1p), "config") == 0 || strcmp(xml_name(x1p), "top") == 0)&&
|
||||
xml_flag(x1p, XML_FLAG_TOP) &&
|
||||
xml_prefix(x1p)==NULL;
|
||||
|
||||
/* 1. Find N=namespace(x0) in x0 element */
|
||||
prefix0 = xml_prefix(x0);
|
||||
if (xml2ns(x0, prefix0, &namespace) < 0)
|
||||
|
|
|
|||
|
|
@ -61,3 +61,8 @@ TOP_SRCDIR=@top_srcdir@
|
|||
|
||||
# Clixon version
|
||||
CLIXON_VERSION=@CLIXON_VERSION@
|
||||
|
||||
# Which XML symbol to add to top datastore config level
|
||||
# see also DATASTORE_TOP_SYMBOL
|
||||
DATASTORE_TOP="config"
|
||||
|
||||
|
|
|
|||
|
|
@ -361,6 +361,7 @@ function wait_restconf(){
|
|||
fi
|
||||
}
|
||||
|
||||
# End of test, final tests before normal exit of test
|
||||
function endtest()
|
||||
{
|
||||
if [ $valgrindtest -eq 1 ]; then
|
||||
|
|
@ -657,6 +658,10 @@ function expectmatch(){
|
|||
r=$2
|
||||
expret=$3
|
||||
expect=$4
|
||||
# echo "ret:$ret"
|
||||
# echo "ret:$r"
|
||||
# echo "expret:$expret"
|
||||
# echo "expect:$expect"
|
||||
if [ $r != $expret ]; then
|
||||
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
|
||||
echo -e "\e[0m:"
|
||||
|
|
|
|||
|
|
@ -277,3 +277,6 @@ unset format
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -260,3 +260,7 @@ unset nr
|
|||
unset clixon_util_path
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
||||
|
|
|
|||
|
|
@ -311,3 +311,6 @@ fi
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -246,10 +246,7 @@ testrun "$CONFIG" "$EXPSTATE"
|
|||
|
||||
#-----------------------------
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -258,5 +255,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -135,3 +135,6 @@ fi
|
|||
stop_backend -f $cfg
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -169,3 +169,5 @@ fi
|
|||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -287,10 +287,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -299,8 +296,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -126,10 +126,7 @@ new "cli rpc"
|
|||
# We dont know which message-id the cli app uses
|
||||
expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "<rpc-reply $DEFAULTONLY message-id=" "><x xmlns=\"urn:example:clixon\">ipv4</x><y xmlns=\"urn:example:clixon\">42</y></rpc-reply>"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -138,5 +135,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ show("Show a particular state of the system"){
|
|||
EOF
|
||||
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<table xmlns="urn:example:clixon">
|
||||
<parameter>
|
||||
<name>a</name>
|
||||
<value>42</value>
|
||||
</parameter>
|
||||
</table>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
# Add inline state
|
||||
|
|
|
|||
|
|
@ -291,3 +291,6 @@ fi
|
|||
stop_backend -f $cfg
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -215,3 +215,6 @@ fi
|
|||
stop_backend -f $cfg
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ show("Show a particular state of the system"){
|
|||
EOF
|
||||
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<table xmlns="urn:example:clixon">
|
||||
<parameter>
|
||||
<name>p1</name>
|
||||
|
|
@ -110,7 +110,7 @@ cat <<EOF > $dir/startup_db
|
|||
</index>
|
||||
</parameter>
|
||||
</table>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
|
|
@ -162,3 +162,6 @@ fi
|
|||
stop_backend -f $cfg
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -136,3 +136,6 @@ fi
|
|||
|
||||
unset nr
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -125,10 +125,7 @@ expectpart "$($clixon_cli -1 -f $cfg set ex y a 2 b v2)" 0 ""
|
|||
new "show conf"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><ex xmlns=\"urn:example:clixon\"><x><a>1</a><b>v1</b></x><x><a>1</a><b>v2</b></x><x><a>1</a><b>v3</b></x><x><a>2</a><b>v1</b></x><x><a>2</a><b>v2</b></x><x><a>2</a><b>v3</b></x><y><a>1</a><b>v1</b></y><y><a>2</a><b>v1</b></y><y><a>1</a><b>v2</b></y><y><a>1</a><b>v3</b></y><y><a>2</a><b>v2</b></y></ex></data></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -137,5 +134,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -109,10 +109,7 @@ for c in 2 4; do
|
|||
expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 255 "^$"
|
||||
done
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -121,5 +118,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -79,3 +79,6 @@ if [ $BE -ne 0 ]; then
|
|||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -157,10 +157,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=`pgrep -u root -f clixon_backend`
|
||||
|
|
@ -169,6 +166,7 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# unset conditional parameters
|
||||
unset format
|
||||
|
|
@ -177,3 +175,6 @@ unset format
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -126,3 +126,6 @@ new "Start with 2 extra configfiles + command-line"
|
|||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_MODULE_SET_ID=4 -o CLICON_FEATURE=test4 -l o show options)" 0 'CLICON_MODULE_SET_ID: "4"' 'CLICON_FEATURE: "test1"' 'CLICON_FEATURE: "test2"' 'CLICON_FEATURE: "test3"' 'CLICON_FEATURE: "test4"'
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ EOF
|
|||
|
||||
# Create empty startup
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config/>
|
||||
<${DATASTORE_TOP}/>
|
||||
EOF
|
||||
|
||||
# rm candidate and running
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ module ietf-ip{
|
|||
}
|
||||
EOF
|
||||
|
||||
xml='<config><x xmlns="urn:example:clixon"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x></config>'
|
||||
xml="<x xmlns=\"urn:example:clixon\"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x>"
|
||||
|
||||
xml2="<${DATASTORE_TOP}><x xmlns=\"urn:example:clixon\"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x></${DATASTORE_TOP}>"
|
||||
|
||||
name=text
|
||||
|
||||
|
|
@ -68,13 +70,13 @@ ret=$($clixon_util_datastore $conf put replace "$xml")
|
|||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore get"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
|
||||
|
||||
new "datastore put all remove"
|
||||
expectpart "$($clixon_util_datastore $conf put remove "<config/>")" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
|
||||
|
||||
new "datastore get"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<config/>$"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<${DATASTORE_TOP}/>$"
|
||||
|
||||
new "datastore put all merge"
|
||||
ret=$($clixon_util_datastore $conf put merge "$xml")
|
||||
|
|
@ -83,23 +85,23 @@ expectmatch "$ret" $? "0" ""
|
|||
# expectpart "$($clixon_util_datastore $conf put merge $xml)" 0 ""
|
||||
|
||||
new "datastore get"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
|
||||
|
||||
new "datastore put all delete"
|
||||
expectpart "$($clixon_util_datastore $conf put remove "<config/>")" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
|
||||
|
||||
new "datastore get"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<config/>$"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<${DATASTORE_TOP}/>$"
|
||||
|
||||
new "datastore put all create"
|
||||
ret=$($clixon_util_datastore $conf put create "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore get"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
|
||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
|
||||
|
||||
new "datastore put top create"
|
||||
expectpart "$($clixon_util_datastore $conf put create "<config><x/></config>")" 0 "" # error
|
||||
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"/>')" 0 "" # error
|
||||
|
||||
# Single key operations
|
||||
# leaf
|
||||
|
|
@ -110,43 +112,43 @@ new "datastore init"
|
|||
expectpart "$($clixon_util_datastore $conf init)" 0 ""
|
||||
|
||||
new "datastore create leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put create "<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>")" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||
|
||||
new "datastore create leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||
|
||||
new "datastore delete leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put delete '<config><x><y><a>1</a><b>3</b></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put delete '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b></y></x>')" 0 ""
|
||||
|
||||
new "datastore replace leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||
|
||||
new "datastore remove leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put remove '<config><x><g/></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put remove '<x xmlns="urn:example:clixon"><g/></x>')" 0 ""
|
||||
|
||||
new "datastore remove leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put remove '<config><x><y><a>1</a><b>3</b><c/></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put remove '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c/></y></x>')" 0 ""
|
||||
|
||||
new "datastore delete leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put delete '<config><x><g/></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put delete '<x xmlns="urn:example:clixon"><g/></x>')" 0 ""
|
||||
|
||||
new "datastore merge leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put merge '<config><x><g>nalle</g></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put merge '<x xmlns="urn:example:clixon"><g>nalle</g></x>')" 0 ""
|
||||
|
||||
new "datastore replace leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put replace '<config><x><g>nalle</g></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put replace '<x xmlns="urn:example:clixon"><g>nalle</g></x>')" 0 ""
|
||||
|
||||
new "datastore merge leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put merge '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put merge '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||
|
||||
new "datastore replace leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put replace '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put replace '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||
|
||||
new "datastore create leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><h><j>aaa</j></h></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><h><j>aaa</j></h></x>')" 0 ""
|
||||
|
||||
new "datastore create leaf"
|
||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
||||
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||
|
||||
new "datastore other db init"
|
||||
expectpart "$($clixon_util_datastore -d kalle -b $mydir -y $dir/ietf-ip.yang init)" 0 ""
|
||||
|
|
@ -166,3 +168,6 @@ rm -rf $mydir
|
|||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ EOF
|
|||
)
|
||||
|
||||
function testrun(){
|
||||
new "test params: -f $cfg -- -U"
|
||||
new "test params: -f $cfg -- -U" # -U : upgrade
|
||||
# Bring your own backend
|
||||
if [ $BE -ne 0 ]; then
|
||||
# kill old backend (if any)
|
||||
|
|
@ -116,7 +116,7 @@ function testrun(){
|
|||
# Create startup db of "old" db with incorrect augment namespace tagging
|
||||
# without modstate
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<x xmlns="urn:example:a">
|
||||
<y>
|
||||
<z>
|
||||
|
|
@ -126,10 +126,13 @@ cat <<EOF > $dir/startup_db
|
|||
</x>
|
||||
<remove_me xmlns="urn:example:a"><k>This node is obsolete</k></remove_me>
|
||||
<remove_me xmlns="urn:example:a"><k>this too</k></remove_me>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
new "general-purpose upgrade without modstate"
|
||||
testrun
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
|
|||
|
|
@ -72,3 +72,6 @@ rm -rf $dir
|
|||
|
||||
# unset conditional parameters
|
||||
unset make
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -328,4 +328,5 @@ rm -rf $dir
|
|||
unset nr
|
||||
unset clixon_util_path # for other script reusing it
|
||||
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -99,4 +99,5 @@ expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /ex:table/ex:parameter/ex:n
|
|||
rm -rf $dir
|
||||
unset clixon_util_path # for other script reusing it
|
||||
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -138,3 +138,6 @@ rm -rf $dir
|
|||
# unset conditional parameters
|
||||
unset clixon_util_json
|
||||
unset clixon_util_xml
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -197,3 +197,6 @@ rm -rf $dir
|
|||
# unset conditional parameters
|
||||
unset clixon_util_json
|
||||
unset clixon_util_xml
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -158,9 +158,9 @@ fi
|
|||
# From startup 1, only r1, all else should be filled in
|
||||
SXML='<r1 xmlns="urn:example:clixon">99</r1>'
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
$SXML
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
XML='<r1 xmlns="urn:example:clixon">99</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3>'
|
||||
|
||||
|
|
@ -186,11 +186,11 @@ sudo chmod 666 $dir/running_db
|
|||
new "Check running no defaults: r1 only"
|
||||
# Running should have only non-defaults, ie only r1 that is set to 99
|
||||
|
||||
moreret=$(diff $dir/running_db <(echo "<config>
|
||||
moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
|
||||
$SXML
|
||||
</config>"))
|
||||
</${DATASTORE_TOP}>"))
|
||||
if [ $? -ne 0 ]; then
|
||||
err "<config>$SXML</config>" "$moreret"
|
||||
err "<${DATASTORE_TOP}>$SXML</${DATASTORE_TOP}>" "$moreret"
|
||||
fi
|
||||
|
||||
new "Change default value r2"
|
||||
|
|
@ -201,12 +201,12 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "
|
|||
|
||||
new "Check running no defaults: r1 and r2"
|
||||
# Again, running should have only non-defaults, ie only r1 and r2
|
||||
moreret=$(diff $dir/running_db <(echo "<config>
|
||||
moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
|
||||
$SXML
|
||||
<r2 xmlns=\"urn:example:clixon\">88</r2>
|
||||
</config>"))
|
||||
</${DATASTORE_TOP}>"))
|
||||
if [ $? -ne 0 ]; then
|
||||
err "<config>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></config>" "$moreret"
|
||||
err "<${DATASTORE_TOP}>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></${DATASTORE_TOP}>" "$moreret"
|
||||
fi
|
||||
|
||||
new "Kill backend"
|
||||
|
|
@ -218,9 +218,9 @@ fi
|
|||
|
||||
# From startup 2, only presence p4, s4/np5 should be filled in
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<p4 xmlns="urn:example:clixon"></p4>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
XML='<r1 xmlns="urn:example:clixon">11</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3><p4 xmlns="urn:example:clixon"><s4>44</s4><np45><s5>45</s5></np45></p4>'
|
||||
if [ $BE -ne 0 ]; then
|
||||
|
|
@ -248,9 +248,9 @@ fi
|
|||
|
||||
# Only single x list element
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<xs-config xmlns="urn:example:clixon"><x><name>a</name></x></xs-config>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
XML='<r1 xmlns="urn:example:clixon">11</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3>'
|
||||
if [ $BE -ne 0 ]; then
|
||||
|
|
@ -277,3 +277,6 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -187,10 +187,7 @@ expectpart "$($clixon_cli -1f $cfg -l o set sender a)" 0 "^$"
|
|||
new "cli sender template"
|
||||
expectpart "$($clixon_cli -1f $cfg -l o set sender b template a)" 0 "^$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -199,5 +196,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -264,9 +264,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><validate><source><candi
|
|||
new "netconf discard-changes"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
if [ $BE -ne 0 ]; then
|
||||
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
|
|
@ -276,5 +274,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -175,10 +175,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get content=\"nonconfig
|
|||
new "netconf get / config-only ok"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get content=\"config\"><filter type=\"xpath\" select=\"/\"/></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><sender-config xmlns=\"urn:example:example\"><name>y</name></sender-config></data></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -187,5 +184,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -245,10 +245,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS $DEFAULTNS><edit-config>
|
|||
new "minmax: validate should fail empty list"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<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 -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -257,5 +254,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -191,10 +191,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -203,8 +200,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -231,3 +231,6 @@ rm -rf $dir
|
|||
|
||||
# unset conditional parameters
|
||||
unset clixon_util_socket
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -321,10 +321,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -333,8 +330,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ EOF
|
|||
|
||||
# Set initial NACM rules in startup enabling admin and a single param config
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<table xmlns="urn:example:nacm">
|
||||
<parameters>
|
||||
<parameter>
|
||||
|
|
@ -86,7 +86,7 @@ cat <<EOF > $dir/startup_db
|
|||
$NGROUPS
|
||||
$NADMIN
|
||||
</nacm>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
|
|
@ -171,3 +171,6 @@ fi
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -303,3 +303,6 @@ fi
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -301,3 +301,6 @@ fi
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ EOF
|
|||
|
||||
# Use startup or set values with POST (below)
|
||||
if [ $db = startup ]; then
|
||||
sudo echo "<config>$NACM$XML</config>" > $dir/startup_db
|
||||
sudo echo "<${DATASTORE_TOP}>$NACM$XML</${DATASTORE_TOP}>" > $dir/startup_db
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then # Bring your own backend
|
||||
|
|
|
|||
|
|
@ -216,10 +216,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -228,8 +225,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -259,10 +259,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -271,8 +268,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -261,10 +261,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -273,8 +270,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -227,10 +227,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -239,8 +236,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -304,10 +304,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><client-rpc xmlns=\"urn:
|
|||
new "netconf extra leaf in leaf should fail"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface><name>e0<name>e1</name></name></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces</error-message></rpc-error></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -316,5 +313,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -80,10 +80,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get><filter type='xpath
|
|||
new "get xpath one"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get><filter type='xpath' select=\"/fi:x/fi:y[fi:a='1']\" xmlns:fi='urn:example:filter' /></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -92,5 +89,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -149,3 +149,5 @@ fi
|
|||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -59,8 +59,9 @@ EOF
|
|||
|
||||
new "test params: -f $cfg -s startup"
|
||||
|
||||
echo '<config><ex:x xmlns:ex="urn:example:whitespace">
|
||||
<ex:y> <ex:a>foo</ex:a>\n <ex:b> </ex:b></ex:y> </ex:x></config></edit-config></rpc>]]>]]>$start</config>' > $dir/startup_db
|
||||
# Keep the following as is (whitespace)
|
||||
echo "<${DATASTORE_TOP}><ex:x xmlns:ex=\"urn:example:whitespace\">
|
||||
<ex:y> <ex:a>foo</ex:a>\n <ex:b> </ex:b></ex:y> </ex:x></${DATASTORE_TOP}>" > $dir/startup_db
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
|
|
@ -137,10 +138,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><validate><source><candi
|
|||
new "netconf discard-changes"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -149,5 +147,9 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -161,3 +161,5 @@ fi
|
|||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ EOF
|
|||
rm -f $dbdir/candidate_db
|
||||
# alt
|
||||
cat <<EOF > $dbdir/running_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<y0 xmlns="urn:example:order">d</y0>
|
||||
<y1 xmlns="urn:example:order">d</y1>
|
||||
<y2 xmlns="urn:example:order"><k>d</k><a>bar</a></y2>
|
||||
|
|
@ -148,7 +148,7 @@ cat <<EOF > $dbdir/running_db
|
|||
<y3 xmlns="urn:example:order"><k>c</k><a>bar</a></y3>
|
||||
<y2 xmlns="urn:example:order"><k>b</k><a>bar</a></y2>
|
||||
<y3 xmlns="urn:example:order"><k>b</k><a>bar</a></y3>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
new "test params: -s running -f $cfg -- -s"
|
||||
|
|
@ -391,10 +391,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><ca
|
|||
new "check ordered-by-user: e,a,71,b,42,c,d"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><y2 xmlns=\"urn:example:order\"><k>e</k><a>bar</a></y2><y2 xmlns=\"urn:example:order\"><k>a</k><a>foo</a></y2><y2 xmlns=\"urn:example:order\"><k>71</k><a>fie</a></y2><y2 xmlns=\"urn:example:order\"><k>b</k><a>bar</a></y2><y2 xmlns=\"urn:example:order\"><k>42</k><a>fum</a></y2><y2 xmlns=\"urn:example:order\"><k>c</k><a>foo</a></y2><y2 xmlns=\"urn:example:order\"><k>d</k><a>fie</a></y2></data></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -403,8 +400,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
# unset conditional parameters
|
||||
unset format
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -824,3 +824,6 @@ rm -rf $dir
|
|||
|
||||
# unset conditional parameters
|
||||
unset regex
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -149,10 +149,7 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<r
|
|||
|
||||
# XXX No leafref cli tests
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -161,6 +158,7 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
@ -168,3 +166,6 @@ rm -rf $dir
|
|||
unset format
|
||||
unset perfnr
|
||||
unset perfreq
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -70,11 +70,11 @@ function testrun(){
|
|||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "generate config with $nr list entries"
|
||||
echo -n "<config><x xmlns=\"urn:example:clixon\">" > $dir/startup_db
|
||||
echo -n "<${DATASTORE_TOP}><x xmlns=\"urn:example:clixon\">" > $dir/startup_db
|
||||
for (( i=0; i<$nr; i++ )); do
|
||||
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dir/startup_db
|
||||
done
|
||||
echo "</x></config>" >> $dir/startup_db
|
||||
echo "</x></${DATASTORE_TOP}>" >> $dir/startup_db
|
||||
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg
|
||||
|
|
@ -173,5 +173,7 @@ b:
|
|||
childvec: 8
|
||||
(ns-cache: 115) # only in startup?
|
||||
|
||||
|
||||
fi
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -191,10 +191,7 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]
|
|||
new "netconf get large leaf-list config"
|
||||
expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:clixon\"><c>0</c><c>1</c>" 2>&1 | awk '/real/ {print $2}'
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -203,6 +200,7 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
@ -210,3 +208,6 @@ rm -rf $dir
|
|||
unset format
|
||||
unset perfnr
|
||||
unset perfreq
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -197,10 +197,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -209,6 +206,7 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
@ -219,3 +217,6 @@ unset RESTCONFIG
|
|||
unset format
|
||||
unset perfnr
|
||||
unset perfreq
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -163,3 +163,6 @@ rm -rf $dir
|
|||
|
||||
# unset conditional parameters
|
||||
unset perfnr
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -196,10 +196,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -208,6 +205,7 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
@ -219,3 +217,5 @@ unset perfreq
|
|||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -208,5 +208,5 @@ unset format
|
|||
unset perfnr
|
||||
unset perfreq
|
||||
|
||||
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -30,3 +30,5 @@ rm -rf $dir
|
|||
unset clixon_util_xml
|
||||
unset perfnr
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -134,3 +134,6 @@ new "Start as non-privileged, try to drop (but fail)"
|
|||
testrun $(whoami) $BUSER $BUSER drop_perm 1
|
||||
|
||||
sudo rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -414,3 +414,6 @@ unset RESTCONFIG
|
|||
unset RESTCONFIG1
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -208,10 +208,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -220,8 +217,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ EOF
|
|||
|
||||
# NACM rules and top/ config
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
|
||||
<enable-nacm>true</enable-nacm>
|
||||
<read-default>deny</read-default>
|
||||
|
|
@ -163,7 +163,7 @@ cat <<EOF > $dir/startup_db
|
|||
<anonymous>42</anonymous>
|
||||
<wilma>71</wilma>
|
||||
</top>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
# Restconf auth test with arguments:
|
||||
|
|
@ -316,3 +316,6 @@ unset MSGERR1
|
|||
unset MSGERR2
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -245,10 +245,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -257,8 +254,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -256,10 +256,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -268,8 +265,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -171,10 +171,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -183,8 +180,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ NACM0="<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">
|
|||
"
|
||||
|
||||
cat<<EOF > $startupdb
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
$NACM0
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
# An extra testmodule that includes nacm
|
||||
|
|
@ -158,9 +158,9 @@ fi
|
|||
|
||||
# Restart
|
||||
cat<<EOF > $startupdb
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
$NACM0
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
|
|
@ -270,3 +270,6 @@ fi
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -42,6 +42,17 @@ cat <<EOF > $cfg
|
|||
</clixon-config>
|
||||
EOF
|
||||
|
||||
cat <<EOF > $dir/example.yang
|
||||
module example {
|
||||
namespace "urn:example:clixon";
|
||||
prefix ex;
|
||||
revision 2021-03-05;
|
||||
leaf val{
|
||||
type string;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Subroutine send a process control RPC and tricks to echo process-id returned
|
||||
# Args:
|
||||
# 1: operation
|
||||
|
|
@ -101,11 +112,11 @@ EOF
|
|||
new "ENABLE true"
|
||||
# First basic operation with restconf enable is true
|
||||
cat<<EOF > $startupdb
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<restconf xmlns="http://clicon.org/restconf">
|
||||
<enable>true</enable>
|
||||
</restconf>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
new "kill old restconf"
|
||||
|
|
@ -273,11 +284,11 @@ fi
|
|||
new "ENABLE false"
|
||||
# Second basic operation with restconf enable is false
|
||||
cat<<EOF > $startupdb
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
<restconf xmlns="http://clicon.org/restconf">
|
||||
<enable>false</enable>
|
||||
</restconf>
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
|
||||
new "kill old restconf"
|
||||
|
|
@ -320,7 +331,7 @@ pid=$(testrpc status 1)
|
|||
if [ $? -ne 0 ]; then echo "$pid";exit -1; fi
|
||||
|
||||
# Edit a field, eg debug
|
||||
new "Edit a field via restconf"
|
||||
new "Edit a restconf field via restconf"
|
||||
expectpart "$(curl $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/clixon-restconf:restconf/debug -d '{"clixon-restconf:debug":1}' )" 0 "HTTP/1.1 201 Created"
|
||||
|
||||
new "check status RPC new pid"
|
||||
|
|
@ -331,6 +342,18 @@ if [ $pid -eq $pid1 ]; then
|
|||
err "A different pid" "Same pid: $pid"
|
||||
fi
|
||||
|
||||
new "Edit a non-restconf field via restconf"
|
||||
echo "curl $CURLOPTS -X POST -H \"Content-Type: application/yang-data+json\" $RCPROTO://localhost/restconf/data -d '{\"example:val\":\"xyz\"}'"
|
||||
|
||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data -d '{"example:val":"xyz"}' )" 0 "HTTP/1.1 201 Created"
|
||||
|
||||
new "check status RPC same pid"
|
||||
pid2=$(testrpc status 1)
|
||||
if [ $? -ne 0 ]; then echo "$pid2";exit -1; fi
|
||||
if [ $pid1 -ne $pid2 ]; then
|
||||
err "Same pid $pid1" "$pid2"
|
||||
fi
|
||||
|
||||
new "Disable restconf"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><default-operation>merge</default-operation><target><candidate/></target><config><restconf xmlns=\"http://clicon.org/restconf\"><enable>false</enable></restconf></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
|
|
|
|||
|
|
@ -166,9 +166,9 @@ EOF
|
|||
function testrun()
|
||||
{
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<${DATASTORE_TOP}>
|
||||
$RULES
|
||||
</config>
|
||||
</${DATASTORE_TOP}>
|
||||
EOF
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
|
|
|
|||
|
|
@ -135,3 +135,6 @@ fi
|
|||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -188,10 +188,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -200,8 +197,12 @@ if [ -z "$pid" ]; then
|
|||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -96,4 +96,5 @@ rm -rf $dir
|
|||
unset nr
|
||||
unset clixon_util_path # for other script reusing it
|
||||
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -94,3 +94,6 @@ rm -rf $dir
|
|||
|
||||
# unset conditional parameters
|
||||
unset clixon_util_socket
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ function testrun(){
|
|||
exprun=$5 # expected running_db after startup
|
||||
|
||||
sudo rm -f $dir/*_db
|
||||
echo "<config>$rdb</config>" > $dir/running_db
|
||||
echo "<config>$sdb</config>" > $dir/startup_db
|
||||
echo "<config>$edb</config>" > $dir/extra_db
|
||||
echo "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>" > $dir/running_db
|
||||
echo "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>" > $dir/startup_db
|
||||
echo "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>" > $dir/extra_db
|
||||
|
||||
if [ $BE -ne 0 ]; then # Bring your own backend
|
||||
# kill old backend (if any)
|
||||
|
|
@ -118,9 +118,9 @@ function testfail(){
|
|||
|
||||
sudo rm -f $dir/*_db
|
||||
|
||||
echo "<config>$rdb</config>" > $dir/running_db
|
||||
echo "<config>$sdb</config>" > $dir/startup_db
|
||||
echo "<config>$edb</config>" > $dir/extra_db
|
||||
echo "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>" > $dir/running_db
|
||||
echo "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>" > $dir/startup_db
|
||||
echo "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>" > $dir/extra_db
|
||||
|
||||
# kill old backend (if any)
|
||||
new "kill old backend"
|
||||
|
|
@ -138,20 +138,20 @@ function testfail(){
|
|||
sudo chmod 666 $dir/running_db
|
||||
sudo chmod 666 $dir/startup_db
|
||||
new "Checking running unchanged"
|
||||
ret=$(diff $dir/running_db <(echo "<config>$rdb</config>"))
|
||||
ret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>"))
|
||||
if [ $? -ne 0 ]; then
|
||||
err "<config>$rdb</config>" "$ret"
|
||||
err "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>" "$ret"
|
||||
fi
|
||||
new "Checking startup unchanged"
|
||||
ret=$(diff $dir/startup_db <(echo "<config>$sdb</config>"))
|
||||
ret=$(diff $dir/startup_db <(echo "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>"))
|
||||
if [ $? -ne 0 ]; then
|
||||
err "<config>$sdb</config>" "$ret"
|
||||
err "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>" "$ret"
|
||||
fi
|
||||
|
||||
new "Checking extra unchanged"
|
||||
ret=$(diff $dir/extra_db <(echo "<config>$edb</config>"))
|
||||
ret=$(diff $dir/extra_db <(echo "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>"))
|
||||
if [ $? -ne 0 ]; then
|
||||
err "<config>$edb</config>" "$ret"
|
||||
err "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>" "$ret"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -190,3 +190,6 @@ rm -rf $dir
|
|||
|
||||
# unset conditional parameters
|
||||
unset format
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
|
|
@ -253,10 +253,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
|
|
@ -266,8 +263,12 @@ fi
|
|||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
sudo pkill -u root -f clixon_backend
|
||||
fi
|
||||
|
||||
# Set by restconf_config
|
||||
unset RESTCONFIG
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
new "endtest"
|
||||
endtest
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue