Fix sending actions
DatastoreAccess::execute functions always expect input with the prefix
deleted. This does make the test somewhat prettier, because you don't
need to repeat the prefix all the time, however, this adds complexity to
the `execute` functions, because you have to consider that. Also what
really happens inside NetconfAccess/SysrepoAccess is that it just gets
concatenated again.
The actual bug is this: when using ProxyDatastore datastore to send
RPC/action, getItems is called to get the input. This algorithm was
supposed to strip the prefixes. But there was an error in this stripping
algorithm, because stripping an "action" path is more difficult than RPC
because it can be nested.
The solution: get rid of the compacted paths in input to simplify the
algorithms.
Also, there is another bug, where the output XPaths don't get the action
prefix trimmed because the input action path is fully prefixed, but the
output XPaths aren't. More info in comment.
Change-Id: I28acaffadb55d89e508d75d58d365a3523f295bb
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index cf92a45..000f3c7 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -961,8 +961,8 @@
{
rpc = "/example-schema:launch-nukes";
input = {
- {"description", "dummy"s},
- {"payload/kilotons", uint64_t{333'666}},
+ {joinPaths(rpc, "description"), "dummy"s},
+ {joinPaths(rpc, "payload/kilotons"), uint64_t{333'666}},
};
proxyDatastore.initiate(rpc);
proxyDatastore.setLeaf("/example-schema:launch-nukes/example-schema:payload/example-schema:kilotons", uint64_t{333'666});
@@ -973,8 +973,8 @@
{
rpc = "/example-schema:launch-nukes";
input = {
- {"description", "dummy"s},
- {"payload/kilotons", uint64_t{4}},
+ {joinPaths(rpc, "description"), "dummy"s},
+ {joinPaths(rpc, "payload/kilotons"), uint64_t{4}},
};
proxyDatastore.initiate(rpc);
proxyDatastore.setLeaf("/example-schema:launch-nukes/example-schema:payload/example-schema:kilotons", uint64_t{4});
@@ -989,8 +989,8 @@
{
rpc = "/example-schema:launch-nukes";
input = {
- {"payload/kilotons", uint64_t{6}},
- {"cities/targets[city='Prague']/city", "Prague"s},
+ {joinPaths(rpc, "payload/kilotons"), uint64_t{6}},
+ {joinPaths(rpc, "cities/targets[city='Prague']/city"), "Prague"s},
};
proxyDatastore.initiate(rpc);
proxyDatastore.setLeaf("/example-schema:launch-nukes/example-schema:payload/example-schema:kilotons", uint64_t{6});
@@ -1013,7 +1013,7 @@
rpc = "/example-schema:fire";
input = {
- {"whom", "Colton"s}
+ {joinPaths(rpc, "whom"), "Colton"s}
};
proxyDatastore.initiate(rpc);
proxyDatastore.setLeaf("/example-schema:fire/example-schema:whom", "Colton"s);
@@ -1038,6 +1038,10 @@
SECTION("action")
{
+ auto createTemporaryDatastore = [](const std::shared_ptr<DatastoreAccess>& datastore) {
+ return std::make_shared<YangAccess>(std::static_pointer_cast<YangSchema>(datastore->schema()));
+ };
+ ProxyDatastore proxyDatastore(datastore, createTemporaryDatastore);
std::string path;
DatastoreAccess::Tree input, output;
@@ -1048,10 +1052,17 @@
datastore->commitChanges();
SECTION("shutdown")
{
- path = "/example-schema:ports[name='A']/shutdown";
+ path = "/example-schema:ports[name='A']/example-schema:shutdown";
+ input = {
+ {"/example-schema:ports[name='A']/shutdown/force", true}
+ };
+ proxyDatastore.initiate(path);
+ proxyDatastore.setLeaf("/example-schema:ports[name='A']/example-schema:shutdown/example-schema:force", true);
+
}
catching<OnExec>([&] { REQUIRE(datastore->execute(path, input) == output); });
+ catching<OnExec>([&] { REQUIRE(proxyDatastore.execute() == output); });
}
waitForCompletionAndBitMore(seq1);