system: Implement interface statistics in IETFInterfaces
The YANG model ietf-interfaces [1] models interface statistics. This
commit implements some of the interface statistics that are available
via libnl.
Also require newer sysrepo. This version fixes deadlock between push and
pull ops data manipulation from multiple threads [2].
[1] https://tools.ietf.org/html/rfc8343
[2] https://github.com/sysrepo/sysrepo/issues/2375
Bug: https://github.com/sysrepo/sysrepo/issues/2375
Change-Id: I6daa798af25181cb49cb199631f853520c0e91ce
diff --git a/tests/sysrepo_system-ietfinterfaces.cpp b/tests/sysrepo_system-ietfinterfaces.cpp
index 1497f49..766396f 100644
--- a/tests/sysrepo_system-ietfinterfaces.cpp
+++ b/tests/sysrepo_system-ietfinterfaces.cpp
@@ -16,13 +16,23 @@
{
TEST_SYSREPO_INIT_LOGS;
TEST_SYSREPO_INIT;
+
TEST_SYSREPO_INIT_CLIENT;
auto network = std::make_shared<velia::system::IETFInterfaces>(srSess);
// We didn't came up with some way of mocking netlink. At least check that there is the loopback
// interface with expected values. It is *probably* safe to assume that there is at least the lo device.
- REQUIRE(dataFromSysrepo(client, "/ietf-interfaces:interfaces/interface[name='lo']", SR_DS_OPERATIONAL) == std::map<std::string, std::string> {
+ auto lo = dataFromSysrepo(client, "/ietf-interfaces:interfaces/interface[name='lo']", SR_DS_OPERATIONAL);
+
+ // ensure statistics keys exist and remove them ; we can't really predict the content
+ for (const auto& key : {"/statistics", "/statistics/in-discards", "/statistics/in-errors", "/statistics/in-octets", "/statistics/out-discards", "/statistics/out-errors", "/statistics/out-octets"}) {
+ auto it = lo.find(key);
+ REQUIRE(it != lo.end());
+ lo.erase(it);
+ }
+
+ REQUIRE(lo == std::map<std::string, std::string> {
{"/name", "lo"},
{"/type", "iana-if-type:softwareLoopback"},
{"/phys-address", "00:00:00:00:00:00"},
@@ -37,6 +47,5 @@
{"/ietf-ip:ipv6/address[ip='::1']/prefix-length", "128"},
{"/ietf-ip:ipv6/ietf-ipv6-unicast-routing:ipv6-router-advertisements", ""},
{"/ietf-ip:ipv6/ietf-ipv6-unicast-routing:ipv6-router-advertisements/prefix-list", ""},
- {"/statistics", ""},
});
}