Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openvswitch_db tests #26330

Merged
merged 1 commit into from
Jul 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/integration/network-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
- { include: iosxr.yaml }
- { include: nxos.yaml }
- { include: junos.yaml }
- { include: vyos.yaml }
- { include: ops.yaml }
- { include: ovs.yaml }
- { include: dellos10.yaml }
- { include: dellos9.yaml }
- { include: dellos6.yaml }
12 changes: 12 additions & 0 deletions test/integration/ovs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- hosts: ovs
gather_facts: no
remote_user: ubuntu
become: yes

vars:
limit_to: "*"
debug: false

roles:
- { role: openvswitch_db, when: "limit_to in ['*', 'openvswitch_db']" }
Empty file.
3 changes: 3 additions & 0 deletions test/integration/targets/openvswitch_db/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []
2 changes: 2 additions & 0 deletions test/integration/targets/openvswitch_db/meta/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- prepare_ovs_tests
17 changes: 17 additions & 0 deletions test/integration/targets/openvswitch_db/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

- name: collect all test cases
find:
paths: "{{ role_path }}/tests"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases

- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

- name: run test case
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
83 changes: 83 additions & 0 deletions test/integration/targets/openvswitch_db/tests/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---

- command: ovs-vsctl add-br br-test

- name: Create bridge
openvswitch_db:
table: Bridge
record: br-test
col: other_config
key: disable-in-band
value: true
register: result

- assert:
that:
- "result.changed == true"

- name: Create bridge again (idempotent)
openvswitch_db:
table: Bridge
record: br-test
col: other_config
key: disable-in-band
value: true
register: result

- assert:
that:
- "result.changed == false"

- name: Change column value
openvswitch_db:
table: Bridge
record: br-test
col: other_config
key: disable-in-band
value: false
register: result

- assert:
that:
- "result.changed == true"

- name: Change column value again (idempotent)
openvswitch_db:
table: Bridge
record: br-test
col: other_config
key: disable-in-band
value: false
register: result

- assert:
that:
- "result.changed == false"

- name: Remove bridge
openvswitch_db:
table: Bridge
record: br-test
col: other_config
key: disable-in-band
value: false
state: absent
register: result

- assert:
that:
- "result.changed == true"

- name: Remove bridge again (idempotent)
openvswitch_db:
table: Bridge
record: br-test
col: other_config
key: disable-in-band
value: false
state: absent
register: result

- assert:
that:
- "result.changed == false"