Skip to content

Commit dce5251

Browse files
author
rsmekala
committed
Added UT for juniper_junos_config
1 parent 24d8e45 commit dce5251

File tree

6 files changed

+132
-11
lines changed

6 files changed

+132
-11
lines changed

tests/pb.juniper_junos_config.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
- name: Test juniper_junos_config module
3+
hosts: all
4+
connection: local
5+
gather_facts: no
6+
roles:
7+
- Juniper.junos
8+
tasks:
9+
#################
10+
- name: Retrieve the committed configuration
11+
juniper_junos_config:
12+
retrieve: 'committed'
13+
diff: false
14+
check: false
15+
commit: false
16+
register: test1
17+
ignore_errors: True
18+
tags: [ test1 ]
19+
20+
- name: Check TEST 1
21+
assert:
22+
that:
23+
- test1.config
24+
- "'host-name choc-qfx-a;' in test1.config"
25+
#################
26+
- name: Append .foo to the hostname using private config mode.
27+
juniper_junos_config:
28+
config_mode: 'private'
29+
load: 'merge'
30+
lines:
31+
- "set system host-name {{ inventory_hostname }}.foo"
32+
register: test2
33+
ignore_errors: True
34+
tags: [ test2 ]
35+
36+
- name: Check TEST 2
37+
assert:
38+
that:
39+
- test2.diff_lines
40+
- "'+ host-name choc-qfx-a.foo;' in test2.diff_lines"
41+
#################
42+
- name: Rollback to the previous config.
43+
juniper_junos_config:
44+
config_mode: 'private'
45+
rollback: "1"
46+
register: test3
47+
ignore_errors: True
48+
tags: [ test3 ]
49+
50+
- name: Check TEST 3
51+
assert:
52+
that:
53+
- test3.diff_lines
54+
- "'- host-name choc-qfx-a.foo;' in test3.diff_lines"
55+
#################
56+
- name: Creates directory
57+
file:
58+
path: out
59+
state: directory
60+
61+
- name: Configure LLDP
62+
juniper_junos_config:
63+
load: 'merge'
64+
lines:
65+
- "set protocols lldp advertisement-interval 30"
66+
- "set protocols lldp transmit-delay 2"
67+
- "set protocols lldp hold-multiplier 4"
68+
- "set protocols lldp ptopo-configuration-trap-interval 30"
69+
- "set protocols lldp ptopo-configuration-maximum-hold-time 300"
70+
- "set protocols lldp lldp-configuration-notification-interval 30"
71+
- "set protocols lldp interface all disable"
72+
- "set protocols lldp interface ge-1/1/1"
73+
format: 'set'
74+
comment: 'Start LLDP with given options'
75+
dest_dir: './out'
76+
register: test4
77+
ignore_errors: True
78+
tags: [ test4 ]
79+
80+
- name: Rollback to the rescue config.
81+
juniper_junos_config:
82+
rollback: 'rescue'
83+
84+
- name: Check out/choc-qfx-a.diff exists
85+
stat:
86+
path: out/choc-qfx-a.diff
87+
register: stat_result_1
88+
89+
- name: Check TEST 4
90+
assert:
91+
that:
92+
- stat_result_1.stat.exists == True
93+
- test4.diff_lines
94+
- "'+ interface ge-1/1/1;' in test4.diff_lines"
95+
96+
- name: Clean up TEST 4
97+
file:
98+
path: out
99+
state: absent
100+
#################
101+
- name: Retrieve [edit system services] of current committed config.
102+
juniper_junos_config:
103+
retrieve: 'committed'
104+
filter: 'system/services'
105+
diff: true
106+
check: false
107+
commit: false
108+
register: test5
109+
ignore_errors: True
110+
tags: [ test5 ]
111+
112+
- name: Check TEST 5
113+
assert:
114+
that:
115+
- test5.failed == False
116+
- "'system {' in test5.config_lines"
117+
#################
118+
#TODO: Add tests for commit check and commit confirmed workflows

tests/pb.juniper_junos_facts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Test junos_get_facts module
2+
- name: Test juniper_junos_facts module
33
hosts: all
44
connection: local
55
gather_facts: no

tests/pb.juniper_junos_jsnapy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Test junos_ping module
2+
- name: Test juniper_junos_ping module
33
hosts: all
44
connection: local
55
gather_facts: no

tests/pb.juniper_junos_ping.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Test junos_ping module
2+
- name: Test juniper_junos_ping module
33
hosts: all
44
connection: local
55
gather_facts: no

tests/pb.juniper_junos_pmtud.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Test junos_pmtud module
2+
- name: Test juniper_junos_pmtud module
33
hosts: all
44
connection: local
55
gather_facts: no

tests/pb.juniper_junos_rpc.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Test junos_rpc module
2+
- name: Test juniper_junos_rpc module
33
hosts: all
44
connection: local
55
gather_facts: no
@@ -55,8 +55,6 @@
5555
file:
5656
path: get_config.conf
5757
state: absent
58-
59-
6058
#################
6159

6260
- name: "Get Device Configuration in text"
@@ -101,6 +99,11 @@
10199
- test4.results[1].msg == "The RPC executed successfully."
102100
tags: [ test4 ]
103101

102+
- name: Clean up TEST 4
103+
file:
104+
path: get_config.conf
105+
state: absent
106+
104107
#################
105108

106109
- name: "Execute multiple RPCs with multiple kwargs"
@@ -149,14 +152,14 @@
149152
ignore_errors: True
150153
tags: [ test6 ]
151154

152-
- name: Check out/choc-qfx-a_get-interface-information.xml exists
155+
- name: Check get-interface-information.xml exists
153156
stat:
154-
path: out/choc-qfx-a_get-interface-information.xml
157+
path: "out/{{ inventory_hostname }}_get-interface-information.xml"
155158
register: stat_result_1
156159

157-
- name: Check out/choc-qfx-a_get-software-information.xml exists
160+
- name: Check get-software-information.xml exists
158161
stat:
159-
path: out/choc-qfx-a_get-software-information.xml
162+
path: "out/{{ inventory_hostname }}_get-software-information.xml"
160163
register: stat_result_2
161164

162165
- name: Check TEST 6

0 commit comments

Comments
 (0)