jsnapy icon indicating copy to clipboard operation
jsnapy copied to clipboard

Two-Way List Diffing w/ Key

Open ghost opened this issue 9 years ago • 3 comments

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

ghost avatar Nov 16 '16 07:11 ghost

@titusfoo The module approach would definitely give you more control as you can build contexts within your code.

ydnath avatar Nov 16 '16 07:11 ydnath

@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?

ghost avatar Nov 17 '16 08:11 ghost

@titusfoo We will evaluate this and check if a generic two-way diff can be implemented. Thank you.

ydnath avatar Nov 17 '16 08:11 ydnath