The put_config() retry loop was catching and printing RpcError
exceptions but never re-raising them after exhausting retries.
This caused tests to silently continue despite configuration
failures, masking validation errors.
Now properly propagates errors after all retries are exhausted,
matching the error handling behavior of the RESTCONF backend.
Fixes#1250
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Libyang is smart, it "fixes" the timezone for you, this was overriden by a
hack in netconf.py and restconf.py, but what you really want is to see
in operational what the current timezone is.
Unclear if the libyang merge operation actually does it's job of merging
all the data properly in the restconf backend.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
When first starting up the YANG models are downloaded. Initially all
were printed on the test console, so this was later changed to become
a sort of progress output. However, that broke tap output, causing a
missing leading '#' for the final "YANG models downloaded." message.
Thist patch drops the output entirely from the netconf transport, it
was never added to the restconf transport.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Being able to check for a TCP based service is generally useful, not
only for NETCONF. Therefore, break it out to a separate function that
allows any port to be queried.
Fixes the following issue when deleting /infix-services:mdns/interfaces,
which works fine over RESTCONF:
Traceback (most recent call last):
File "/home/jocke/src/infix/test/./case/infix_services/mdns_allow_deny/test.py", line 142, in <module>
dut.delete_xpath("/infix-services:mdns/interfaces")
File "/home/jocke/src/infix/test/infamy/netconf.py", line 418, in delete_xpath
oldd = mod.parse_data_dict(old, no_state=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.infix/venv/lib/python3.11/site-packages/libyang/schema.py", line 215, in parse_data_dict
return dict_to_dnode(
^^^^^^^^^^^^^^
File "/root/.infix/venv/lib/python3.11/site-packages/libyang/data.py", line 1277, in dict_to_dnode
result.root().validate(
File "/root/.infix/venv/lib/python3.11/site-packages/libyang/data.py", line 430, in validate
self.validate_all(no_state, validate_present)
File "/root/.infix/venv/lib/python3.11/site-packages/libyang/data.py", line 449, in validate_all
raise self.context.error("validation failed")
libyang.util.LibyangError: validation failed:
Invalid leafref value "e3" - no target instance "/if:interfaces/if:interface/if:name" with the same value.
The patch skips validation of the diff in favor of checking the result
of libyang.xpath_del().
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Replace the existing remove-module-names-pass in the RESTCONF
transport -- which only worked for top-level containers -- with
libyang's standard `.print_dict()` used by the NETCONF transport
implementation.
As a bouns, the implementation of `.get_iface()` is now transport
agnostic.
Instead of copy factoy config to reset between tests,
use the new test-config.cfg.
Change the logic in the factory config since the default values have changed.
Previous xpath may or may not been an xpath, we still called it xpath.
Remove the obscure function get_xpath() and instead transform to a
URI in restconf.py
This fix issue #490
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Abstract functions and common functions are located in transport.py
Some quirks has been required due to how rousette works,
these functions has been added to the abstract class
Can be removed when rousette behaves as expected.
This is the only way to delete with restconf so it it must also be
implemented in netconf. This replace the put_diff_dict function.
Also: how the xpath looks is different in restconf/netconf therefore
each protocl has a get_xpath() function as well.
- Fix most of what pylint complains about
- Simplify constructs and add missing whitespace
- Simplify output of YANG model downloader
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This patch handles a corner case we for some reason have not run into
yet. With the new container operational data it was triggered almost
immediately, so let's add some basic guards around it and return None
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The netconf-client Python lib currently does not support the <get-data>
RPC. This commit adds a local extension to the Device class which can
be upstreamed at a later time.
Also some added comments and disabling of pylint warnings.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
As an example, when running meta/play, a call to a device's `_debug()`
method will enable logging of all transmitted and received NETCONF
messages, which is very useful during debugging.
As with config, the call can be described with a regular python
dictionary. As an example, to reboot the device:
target.call_dict("ietf-system", { "system-restart": {} })
Instead of relying on startup-config == factory-config we can now set
running-config to factory-config using the factory-default rpc when
we prepare for a new test.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This should copy factory running, instead of using the factory-reset RPC
but for now we use startup since 'factory' is not yet supported as a
copy-from target.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
File "/home/runner/work/infix/infix/test/infamy/netconf.py", line 116, in put_config
except self.ncc.RpcError:
^^^^^^^^^^^^^^^^^
AttributeError: 'Manager' object has no attribute 'RpcError'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
While running tests in GitHub action, the following[1] often happens.
From the timestamp it seems unlikely to be casused by timeout, which
from what I can tell is 120 sec in the library and 30 sec on our socket.
This never happens when running locally, so I've added a simple
try-catch to retry the operation, because some[2] jobs actually pass.
2023-06-18 09:18:17 # Traceback (most recent call last):
2023-06-18 09:18:17 # File "/home/runner/work/infix/infix/test/case/infix_interfaces/dual_bridge.py", line 18, in <module>
2023-06-18 09:18:17 # target.put_config_dict("ietf-interfaces", {
2023-06-18 09:18:17 # File "/home/runner/work/infix/infix/test/infamy/netconf.py", line 117, in put_config_dict
2023-06-18 09:18:17 # return self.put_config(lyd.print_mem("xml", with_siblings=True, pretty=False))
2023-06-18 09:18:17 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-06-18 09:18:17 # File "/home/runner/work/infix/infix/test/infamy/netconf.py", line 112, in put_config
2023-06-18 09:18:17 # self.ncc.edit_config(xml, default_operation='merge')
2023-06-18 09:18:17 # File "/root/.infix-test-venv/lib/python3.11/site-packages/netconf_client/ncclient.py", line 277, in edit_config
2023-06-18 09:18:17 # self._send_rpc(rpc_xml)
2023-06-18 09:18:17 # File "/root/.infix-test-venv/lib/python3.11/site-packages/netconf_client/ncclient.py", line 223, in _send_rpc
2023-06-18 09:18:17 # r = f.result(timeout=timeout)
2023-06-18 09:18:17 # ^^^^^^^^^^^^^^^^^^^^^^^^^
2023-06-18 09:18:17 # File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
2023-06-18 09:18:17 # return self.__get_result()
2023-06-18 09:18:17 # ^^^^^^^^^^^^^^^^^^^
2023-06-18 09:18:17 # File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
2023-06-18 09:18:17 # raise self._exception
2023-06-18 09:18:17 # netconf_client.error.RpcError: EV ORIGIN: "rpc" ID 5 processing timed out.
2023-06-18 09:18:17 #
[1]: https://github.com/kernelkit/infix/actions/runs/5302735753/jobs/9597878647
[2]. https://github.com/kernelkit/infix/actions/runs/5302735946/jobs/9597878838
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Unsure if this is right, but existing nework test does not send loopback
or other interfaces in the networking configuration, so maybe merge?
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>