Skip to content

Commit

Permalink
Enhancing the logging framework for the check operator (#378)
Browse files Browse the repository at this point in the history
* Enhancing the logging framework for the check operator

* Enhancing the logging framework for the check operator
  • Loading branch information
rahkumar651991 authored Oct 20, 2020
1 parent f25ee17 commit e6a3238
Show file tree
Hide file tree
Showing 9 changed files with 667 additions and 440 deletions.
1 change: 0 additions & 1 deletion lib/jnpr/jsnapy/jsnapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,5 @@ def main():
"ERROR!! %s \nComplete Message: %s" % (type(ex).__name__, str(ex)),
extra=js.log_detail)


if __name__ == '__main__':
main()
678 changes: 239 additions & 439 deletions lib/jnpr/jsnapy/operator.py

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions samples/config_check_op.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
hosts:
- device: host
# - device: 10.221.140.168
username: regress
passwd: MaRtInI
# port: 22
tests:
# - test_is_equal.yml
# - issue_377.yml
# - issue_377_customer.yml
- test_delta_op.py
# - test_no_diff_op.py
# - test_list_not_less_op.py
# - test_list_not_more_op.py
32 changes: 32 additions & 0 deletions samples/configs/host_post_show_summary.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<summary>
<count style="state">
<active>70663</active>
<key>z</key>
<style>4</style>
<total>69772</total>
</count>
<count style="type">
<id>a</id>
<session>24260</session>
</count>
<count style="type">
<id>2</id>
<session>24512</session>
</count>
<count style="value">
<id>first</id>
<session>24</session>
</count>
<count style="value">
<id>second</id>
<session>512</session>
</count>
<system>
<status>2</status>
<count>125</count>
</system>
<system>
<status>1</status>
<count>25</count>
</system>
</summary>
29 changes: 29 additions & 0 deletions samples/configs/host_pre_show_summary.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<summary>
<count style="state">
<active>70663</active>
<key>z</key>
<total>69775</total>
<style>45</style>
<status>34</status>
</count>
<count style="type">
<id>a</id>
<session>24261</session>
</count>
<count style="type">
<id>2</id>
<session>24543</session>
</count>
<count style="value">
<id>first</id>
<session>24</session>
</count>
<count style="value">
<id>second</id>
<session>512</session>
</count>
<system>
<status>2</status>
<count>125</count>
</system>
</summary>
103 changes: 103 additions & 0 deletions samples/test_delta_op.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
tests_include:
- test_1_element_no_id_pass_1_value
- test_1_element_with_id_same_node_name_pass_1_value
- test_1_element_with_id_diff_node_name_pass_1_value
- test_1_element_with_2_id_diff_node_name_pass_1_value
- test_1_element_with_id_diff_node_name_fail_1_value
- test_1_element_with_id_diff_node_name_fail_1_no_xpath
- test_1_element_with_id_diff_node_name_diff_id_fail_2_value
- test_1_element_with_id_diff_node_name_diff_id_pass_1_fail_1_value
- test_2_element_with_id_diff_node_name_pass_2_value

test_1_element_no_id_pass_1_value:
- command: show summary
- item:
xpath: //summary/count[@style='state']
id: .
tests:
- delta: active, 10%
# - delta: , 10%
err: ' Failed!!change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["active"]}} and post <{{id_0}}> : {{post["active"]}}'

test_1_element_with_id_same_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active
tests:
- delta: active, 10%
# - delta: , 10%
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["active"]}} and post <{{id_0}}> : {{post["active"]}}'

test_1_element_with_id_diff_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active
tests:
- delta: total, 10%
err: ' Failed!! change from {{pre["total"]}} to {{post["total"]}}'
info: 'Details is 1st <{{id_0}}> : {{pre["total"]}} and 2nd <{{id_0}}> : {{post["total"]}}'

test_1_element_with_2_id_diff_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active, key
tests:
- delta: total, 10%
err: ' Failed!! change from {{pre["total"]}} to {{post["total"]}}'
info: 'Details is 1st <{{id_0}}>,<{{id_1}}> : {{pre["total"]}} and 2nd <{{id_0}}>,<{{id_1}}> : {{post["total"]}}'

test_1_element_with_id_diff_node_name_fail_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: key
tests:
- delta: style, 10%
err: 'Failed!! change from {{pre["style"]}} to {{post["style"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["style"]}} and pre <{{id_0}}> : {{post["style"]}}'

test_1_element_with_id_diff_node_name_fail_1_no_xpath:
- command: show summary
- iterate:
xpath: //summary/counting
id: key
tests:
- delta: style, 10%
err: 'Failed!! change from {{pre["style"]}} to {{post["style"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["style"]}} and pre <{{id_0}}> : {{post["style"]}}'

test_1_element_with_id_diff_node_name_diff_id_fail_2_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: style
tests:
- delta: total ,10%
err: 'Failed!! change from pre <{{id_0}}> : {{pre["total"]}} to post <{{id_0}}> : {{post["total"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["total"]}} and post <{{id_0}}> : {{post["total"]}}'

test_1_element_with_id_diff_node_name_diff_id_pass_1_fail_1_value:
- command: show summary
- iterate:
xpath: //summary/system
id: status
tests:
- delta: count ,10%
err: 'Failed!! change from pre <{{id_0}}> : {{pre["count"]}} to post <{{id_0}}> : {{post["count"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["count"]}} and post <{{id_0}}> : {{post["count"]}}'

test_2_element_with_id_diff_node_name_pass_2_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='type']
id: id
tests:
- delta: session, 10%
err: ' Failed!! Total session change from {{pre["session"]}} to {{post["session"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["session"]}} and post <{{id_0}}> : {{post["session"]}}'

79 changes: 79 additions & 0 deletions samples/test_list_not_less_op.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
tests_include:
- test_1_element_no_id_pass_1_value
- test_1_element_with_id_same_node_name_pass_1_value
- test_1_element_with_id_diff_node_name_pass_1_value
- test_1_element_with_2_id_diff_node_name_pass_1_value
- test_1_element_with_id_diff_node_name_fail_1_value
- test_2_element_with_id_diff_node_name_pass_2_value

test_1_element_no_id_pass_1_value:
- command: show summary
- item:
xpath: //summary/count[@style='state']
id: .
tests:
- list-not-less: active
err: ' Failed!!change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["active"]}} and post <{{id_0}}> : {{post["active"]}}'

test_1_element_with_id_same_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active
tests:
- list-not-less: active
# - list-not-less:
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["active"]}} and post <{{id_0}}> : {{post["active"]}}'

test_1_element_with_id_diff_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: key
tests:
- list-not-less: active
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is 1st <{{id_0}}> : {{pre["active"]}} and 2nd <{{id_0}}> : {{post["active"]}}'

test_1_element_with_2_id_diff_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active, key
tests:
- list-not-less: active
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is 1st <{{id_0}}>,<{{id_1}}> : {{pre["active"]}} and 2nd <{{id_0}}>,<{{id_1}}> : {{post["active"]}}'

test_1_element_with_id_diff_node_name_fail_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active
tests:
- list-not-less: style
err: 'Failed!! change from {{pre["style"]}} to {{post["style"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["style"]}} and pre <{{id_0}}> : {{post["style"]}}'

test_1_element_with_id_diff_node_name_diff_id_missing_fail_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: style
tests:
- list-not-less: total
err: 'Failed!! change from pre <{{id_0}}> : {{pre["total"]}} to post <{{id_0}}> : {{post["total"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["total"]}} and post <{{id_0}}> : {{post["total"]}}'

test_2_element_with_id_diff_node_name_pass_2_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='value']
id: id
tests:
- list-not-less: session
err: ' Failed!! Total session change from {{pre["session"]}} to {{post["session"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["session"]}} and post <{{id_0}}> : {{post["session"]}}'

80 changes: 80 additions & 0 deletions samples/test_list_not_more_op.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
tests_include:
- test_1_element_no_id_pass_1_value
- test_1_element_with_id_same_node_name_pass_1_value
- test_1_element_with_id_diff_node_name_pass_1_value
- test_1_element_with_2_id_diff_node_name_pass_1_value
- test_1_element_with_id_diff_node_name_fail_1_value
- test_1_element_with_id_diff_node_name_diff_id_pass_1_fail_1_value
- test_2_element_with_id_diff_node_name_pass_2_value

test_1_element_no_id_pass_1_value:
- command: show summary
- item:
xpath: //summary/count[@style='state']
id: .
tests:
- list-not-more: active
err: ' Failed!!change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["active"]}} and post <{{id_0}}> : {{post["active"]}}'

test_1_element_with_id_same_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active
tests:
- list-not-more: active
# - list-not-more:
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["active"]}} and post <{{id_0}}> : {{post["active"]}}'

test_1_element_with_id_diff_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: key
tests:
- list-not-more: active
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is 1st <{{id_0}}> : {{pre["active"]}} and 2nd <{{id_0}}> : {{post["active"]}}'

test_1_element_with_2_id_diff_node_name_pass_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active, key
tests:
- list-not-more: active
err: ' Failed!! change from {{pre["active"]}} to {{post["active"]}}'
info: 'Details is 1st <{{id_0}}>,<{{id_1}}> : {{pre["active"]}} and 2nd <{{id_0}}>,<{{id_1}}> : {{post["active"]}}'

test_1_element_with_id_diff_node_name_fail_1_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='state']
id: active
tests:
- list-not-more: style
err: 'Failed!! change from {{pre["style"]}} to {{post["style"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["style"]}} and pre <{{id_0}}> : {{post["style"]}}'

test_1_element_with_id_diff_node_name_diff_id_pass_1_fail_1_value:
- command: show summary
- iterate:
xpath: //summary/system
id: status
tests:
- list-not-more: count
err: 'Failed!! change from pre <{{id_0}}> : {{pre["count"]}} to post <{{id_0}}> : {{post["count"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["count"]}} and post <{{id_0}}> : {{post["count"]}}'

test_2_element_with_id_diff_node_name_pass_2_value:
- command: show summary
- iterate:
xpath: //summary/count[@style='value']
id: id
tests:
- list-not-more: session
err: ' Failed!! Total session change from {{pre["session"]}} to {{post["session"]}}'
info: 'Details is pre <{{id_0}}> : {{pre["session"]}} and post <{{id_0}}> : {{post["session"]}}'

Loading

0 comments on commit e6a3238

Please sign in to comment.