我正在尝试确定如何测试junos偶尔使用的节点属性。在这种情况下,我想查找所有20w到1y之间的BGP会话。秒值包含在node属性中,但是我无法弄清楚如何进行测试。
我尝试了使用整个显式xpath的各种方法,一直到下面的代码。
这是我尝试访问的xpath(为简便起见进行编辑):
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/18.2R3/junos">
<bgp-information xmlns="http://xml.juniper.net/junos/18.2R3/junos-routing">
<bgp-peer junos:style="terse" heading="Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...">
<elapsed-time junos:seconds="263788">3d 1:16:28</elapsed-time>
</bgp-peer>
</bgp-information>
</rpc-reply>
test_bgp_summ:
- rpc: get-bgp-summary-information
- iterate:
xpath: /bgp-information/bgp-peer
id: ./peer-address
tests:
- in-range: //@junos:seconds, 12096000, 31449600
err: ""
info: 'Peer session <{{id_0}}> is likely stale'
答案 0 :(得分:0)
您需要在测试中包括经过时间节点:
show_bgp_sum:
- command: show bgp summary
- iterate:
xpath: '//bgp-information/bgp-peer'
id: ./peer-address
tests:
- exists: elapsed-time/@seconds
err: "elpased-time doesn't exist"
info: "Elapsed-time is: <{{post['elapsed-time/@seconds']}}>"
和输出:
"passed": [
{
"actual_node_value": "1309804",
"id": {
"./peer-address": "10.10.12.100"
},
"message": "Elapsed-time is: <1309804>",
"post": {
"elapsed-time/@seconds": "1309804"
},
"pre": {
"elapsed-time/@seconds": "1309802"
}
},