jsnapy
jsnapy copied to clipboard
Two-Way List Diffing w/ Key
ref #167
I've been trying to figure out this for show bgp neighbors pre/post list diffing
Two-Way List Diffing Required
- Unique key between lists: /bgp-information/bgp-peer/peer-id:text()
- Post[] shall have all the peers as seen in Pre[] in Established state
- Post[] shall not have any new peers compared to Pre[]
Difficulty arises from two-way diffing dynamic lists I see no way of doing..
@vnitinv @ydnath
My guess so far is something like this having to use template and XPath to cross-match[]:
test_command_bgp:
- command: show bgp neighbor
{% for BpeerID in how-to-get-BpeerIDs? %}
- iterate:
xpath: '/bgp-information/bgp-peer/[peer-id:text()={{BpeerID}]'
tests:
- exists # element in which test is performed
err: "Test Failed!! peer-address got changed, it is now <{{post['peer-address']}}>"
info: "Test succeeded!! peer-address is equal to <{{post['peer-address']}}>"
The above would need to have another list context from B-perspective so all the added peers could be found
Is this something I need to write a module for? I am new sorry :)
Cheers
@titusfoo The module approach would definitely give you more control as you can build contexts within your code.
@ydnath Two-Way list diff is pretty common use-case for many audit scenarios e.g. pre/post migrations to make sure all the same pre peers came up on post. Can we flag this as enhancement if nothing on base functionality yet?
@titusfoo We will evaluate this and check if a generic two-way diff can be implemented. Thank you.