Skip to content

Commit

Permalink
Add test case port toggle (#484)
Browse files Browse the repository at this point in the history
* [test cases] add back recover variable validity check

base_sanity and interface were called from other tests that didn't
define recover variable.

When the test succeeds, everything is fine. Otherwise, the test will
complain that recover is not defined.

* [test case] add test case: port toggle

This test tests following scenario:

- disable all ports.
- check to make sure that all ports were down.
- enable all ports.
- check all ports were up after a pause.

* [port toggle] improve test performance
  • Loading branch information
yxieca authored Feb 24, 2018
1 parent a4056cd commit 020c4a8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/base_sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

when:
- ({{ ps_out.stdout_lines | length }} <= 0) or ({{ orch_out.stdout_lines | length }} <= 0)
- recover == "true"
- recover is defined and recover == "true"

- name: Get syslog error information
shell: cat /var/log/syslog |tail -n 5000 |grep -i error
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/test/tasks/interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

when:
- ansible_interface_link_down_ports | length > 0
- recover == "true"
- recover is defined and recover == "true"

- debug: msg="Found link down ports {{ansible_interface_link_down_ports}}"
when: ansible_interface_link_down_ports | length > 0
Expand Down
29 changes: 29 additions & 0 deletions ansible/roles/test/tasks/port_toggle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
- name: build shell command string
debug: msg="PORTS={{minigraph_ports.keys() | join(' ')}}; for port in $PORTS; do config interface shutdown $port; done"

- name: turn off all ports on device
shell: PORTS="{{minigraph_ports.keys() | join(' ')}}"; for port in $PORTS; do config interface shutdown $port; done
become: yes

- name: Get interface facts
interface_facts: up_ports={{minigraph_ports}}

- name: Verify interfaces are all down
assert: { that: "{{ ansible_interface_link_down_ports | length }} == {{ minigraph_ports | length }}" }

- always:
- name: build shell command string
debug: msg="PORTS={{minigraph_ports.keys() | join(' ')}}; for port in $PORTS; do config interface startup $port; done"

- name: turn off all ports on device
shell: PORTS="{{minigraph_ports.keys() | join(' ')}}"; for port in $PORTS; do config interface startup $port; done
become: yes

- name: wait 1 minute for ports to come up
pause: seconds=60

- name: Get interface facts
interface_facts: up_ports={{minigraph_ports}}

- name: Verify interfaces are up correctly
assert: { that: "{{ ansible_interface_link_down_ports | length }} == 0" }
4 changes: 4 additions & 0 deletions ansible/roles/test/vars/testcases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ testcases:
filename: pfc_wd.yml
topologies: [t0, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64]

port_toggle:
filename: port_toggle.yml
topologies: [t0, t0-64, t0-64-32, t0-116, t1, t1-lag, t1-64-lag, ptf32, ptf64]

qos:
filename: qos.yml
topologies: [ptf32, ptf64]
Expand Down

0 comments on commit 020c4a8

Please sign in to comment.