jsnapy check error - 'NoneType' object has no attribute 'strip'
manokarthickgit opened this issue · 2 comments
Description of Issue/Question
Customer is trying to compare the BFD session info for pre/post state and is failing for multihop BFD session where we don't have argument for interfaces.
For multihop BFD there will be no underlying interface.
XML syntax looks good when viewed on the CLI.
But the pre/post xml collected via jsnapy doesn't look good and it fails the test.
Snaphot xml:
~/jsnapy/snapshots/10.49.241.79_pre_show_bfd_session.xml
<bfd-session-information style="brief">
<bfd-session>
<session-neighbor>10.255.254.13</session-neighbor>
<session-state>Up</session-state>
<session-interface>ge-0/0/1.0</session-interface>
<session-detection-time>0.300</session-detection-time>
<session-transmission-interval>0.100</session-transmission-interval>
<session-adaptive-multiplier>3</session-adaptive-multiplier>
</bfd-session>
<bfd-session>
<session-neighbor>10.255.255.1</session-neighbor>
<session-state>Up</session-state>
<session-interface/>
<session-detection-time>0.300</session-detection-time>
<session-transmission-interval>0.100</session-transmission-interval>
<session-adaptive-multiplier>3</session-adaptive-multiplier>
</bfd-session>
<sessions>2</sessions>
<clients>2</clients>
<cumulative-transmission-rate>20.0</cumulative-transmission-rate>
<cumulative-reception-rate>20.0</cumulative-reception-rate>
</bfd-session-information>
cli xml:
root@R1_re> show bfd session
Detect Transmit
Address State Interface Time Interval Multiplier
10.255.254.13 Up ge-0/0/1.0 0.300 0.100 3
10.255.255.1 Up 0.300 0.100 3
root@R1_re> show bfd session |display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1R3/junos">
<bfd-session-information xmlns="http://xml.juniper.net/junos/16.1R3/junos-bfd" junos:style="brief">
<bfd-session>
<session-neighbor>10.255.254.13</session-neighbor>
<session-state>Up</session-state>
<session-interface>ge-0/0/1.0</session-interface>
<session-detection-time>0.300</session-detection-time>
<session-transmission-interval>0.100</session-transmission-interval>
<session-adaptive-multiplier>3</session-adaptive-multiplier>
</bfd-session>
<bfd-session>
<session-neighbor>10.255.255.1</session-neighbor>
<session-state>Up</session-state>
<session-interface></session-interface>
<session-detection-time>0.300</session-detection-time>
<session-transmission-interval>0.100</session-transmission-interval>
<session-adaptive-multiplier>3</session-adaptive-multiplier>
</bfd-session>
<sessions>2</sessions>
<clients>2</clients>
<cumulative-transmission-rate>20.0</cumulative-transmission-rate>
<cumulative-reception-rate>20.0</cumulative-reception-rate>
</bfd-session-information>
<cli>
<banner></banner>
</cli>
</rpc-reply>
Setup
Config:
-------
config_snap.yml
hosts:
- device: 10.49.241.79
username : root
passwd : Embe1mpls
tests:
- test_bfd.yml
test_bfd.yml
show_bfd_session:
- command: show bfd session
- iterate:
xpath: //bfd-session-information/bfd-session
id: ./session-neighbor
tests:
- no-diff: ./session-state
err: "Different states"
info: "Same states"
- iterate:
xpath: //bfd-session-information
id: ./bfd-session/session-neighbor
tests:
- no-diff: ./bfd-session/session-interface
err: "Different interface"
info: "Same interface"
ignore-null: True
- item:
xpath: //bfd-session-information
id: "clients"
tests:
- no-diff: ./clients
err: "Different number of clients"
info: "Number of clients is the same"
- item:
xpath: //bfd-session-information
id: "sessions"
tests:
- no-diff: ./sessions
err: "Different number of sessions"
info: "Number of sessions is the same"
Steps to Reproduce Issue
jsnapy --check pre post -f config_snap.yml
**************************** Device: 10.49.241.79 ****************************
Tests Included: show_bfd_session
************************* Command: show bfd session *************************
PASS | All "./session-state" is same in pre and post snapshot [ 2 matched ]
ERROR!! AttributeError
Complete Message: 'NoneType' object has no attribute 'strip'
PASS | All "./clients" is same in pre and post snapshot [ 1 matched ]
PASS | All "./sessions" is same in pre and post snapshot [ 1 matched ]
------------------------------- Final Result!! -------------------------------
show_bfd_session : Passed
Total No of tests passed: 3
Total No of tests failed: 1
Versions Report
jsnapy --version
JSNAPy version: 1.3.2
The issue was fixed along with commit-id 9ad8375.
The sample set used for testing is as below.
cat ~/jsnapy/snapshots/router_pre_show_bfd_session.xml
< bfd-session-information style="brief">
< bfd-session>
< session-neighbor>xx.yyy.vv.zz
< session-state>Up
< ession-interface>ge-0/0/1.0
< session-detection-time>0.300
< session-transmission-interval>0.100
< session-adaptive-multiplier>3
< /bfd-session>
< bfd-session>
< session-neighbor>xx.yy.vv.zz
< session-state>Up
< session-interface/>
< session-detection-time>0.300
< session-transmission-interval>0.100
< session-adaptive-multiplier>3
< /bfd-session>
< sessions>2
< clients>2
< cumulative-transmission-rate>20.0
< cumulative-reception-rate>20.0
< /bfd-session-information>
cat ~/jsnapy/snapshots/router_post_show_bfd_session.xml
< bfd-session-information style="brief">
< bfd-session>
< session-neighbor>xx.yyy.vv.zz
< session-state>Up
< session-interface>ge-0/0/1.0
< session-detection-time>0.300
< session-transmission-interval>0.100
< session-adaptive-multiplier>3
< /bfd-session>
< bfd-session>
< session-neighbor>xx.yy.vv.zz
< session-state>Up
< session-interface/>
< session-detection-time>0.300
< session-transmission-interval>0.100
< session-adaptive-multiplier>3
< /bfd-session>
< sessions>2
< clients>2
< cumulative-transmission-rate>20.0
< cumulative-reception-rate>20.0
< /bfd-session-information>
test_bfd.yml
show_bfd_session:
-
command: show bfd session
-
iterate:
xpath: //bfd-session-information/bfd-session
id: ./session-neighbor
tests:
- no-diff: ./session-state
err: "Different states"
info: "Same states" -
iterate:
xpath: //bfd-session-information
id: ./bfd-session/session-neighbor
tests:
- no-diff: ./bfd-session/session-interface
err: "Different interface"
info: "Same interface"
ignore-null: True -
item:
xpath: //bfd-session-information
id: "clients"
tests:
- no-diff: ./clients
err: "Different number of clients"
info: "Number of clients is the same" -
item:
xpath: //bfd-session-information
id: "sessions"
tests:
- no-diff: ./sessions
err: "Different number of sessions"
info: "Number of sessions is the same"
jsnapy --check pre post -f test.yml
jsnapy.cfg file location used : /etc/jsnapy
Configuration file location used : /etc/jsnapy
*************************** Device: xx.yy.vv.zz ***************************
Tests Included: show_bfd_session
************************* Command: show bfd session *************************
----------------------Performing no-diff Test Operation----------------------
Same states
Same states
PASS | All "./session-state" is same in pre and post snapshot [ 2 matched ]
----------------------Performing no-diff Test Operation----------------------
Same interface
Same interface
PASS | All "./session-interface" is same in pre and post snapshot [ 2 matched ]
----------------------Performing no-diff Test Operation----------------------
Number of clients is the same
PASS | All "./clients" is same in pre and post snapshot [ 1 matched ]
----------------------Performing no-diff Test Operation----------------------
Number of sessions is the same
PASS | All "./sessions" is same in pre and post snapshot [ 1 matched ]
------------------------------- Final Result!! -------------------------------
show_bfd_session : Passed
Total No of tests passed: 4
Total No of tests failed: 0
Overall Tests passed!!!