From c296fcb0e0fdbbdcfb6a2bed8cf54804d9913eb9 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Mon, 12 Jun 2017 13:13:41 +0200 Subject: [PATCH] [WIP] Add openvswitch_db integration tests (#23803) * WIP Add openvswitch_db integration tests * Add ovs.yaml playbook entrypoint for OVS * Add test case pattern filtering * Clear out aliases for now Running tests on posix group just fails, containers do not have ovs --- test/integration/ovs.yaml | 12 +++++++++ .../targets/openvswitch_db/aliases | 0 .../targets/openvswitch_db/defaults/main.yaml | 3 +++ .../targets/openvswitch_db/meta/main.yaml | 2 ++ .../targets/openvswitch_db/tasks/main.yml | 16 ++++++++++++ .../targets/openvswitch_db/tests/basic.yaml | 25 +++++++++++++++++++ .../targets/prepare_ovs_tests/tasks/main.yml | 15 +++++++++++ 7 files changed, 73 insertions(+) create mode 100644 test/integration/ovs.yaml create mode 100644 test/integration/targets/openvswitch_db/aliases create mode 100644 test/integration/targets/openvswitch_db/defaults/main.yaml create mode 100644 test/integration/targets/openvswitch_db/meta/main.yaml create mode 100644 test/integration/targets/openvswitch_db/tasks/main.yml create mode 100644 test/integration/targets/openvswitch_db/tests/basic.yaml create mode 100644 test/integration/targets/prepare_ovs_tests/tasks/main.yml diff --git a/test/integration/ovs.yaml b/test/integration/ovs.yaml new file mode 100644 index 00000000000..f3f812673ab --- /dev/null +++ b/test/integration/ovs.yaml @@ -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']" } diff --git a/test/integration/targets/openvswitch_db/aliases b/test/integration/targets/openvswitch_db/aliases new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/integration/targets/openvswitch_db/defaults/main.yaml b/test/integration/targets/openvswitch_db/defaults/main.yaml new file mode 100644 index 00000000000..9ef5ba51651 --- /dev/null +++ b/test/integration/targets/openvswitch_db/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/openvswitch_db/meta/main.yaml b/test/integration/targets/openvswitch_db/meta/main.yaml new file mode 100644 index 00000000000..20d55f506f8 --- /dev/null +++ b/test/integration/targets/openvswitch_db/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_ovs_tests diff --git a/test/integration/targets/openvswitch_db/tasks/main.yml b/test/integration/targets/openvswitch_db/tasks/main.yml new file mode 100644 index 00000000000..306d99c801f --- /dev/null +++ b/test/integration/targets/openvswitch_db/tasks/main.yml @@ -0,0 +1,16 @@ +--- + +- name: collect all test cases + find: + paths: "{{ role_path }}/tests" + patterns: "{{ testcase }}.yaml" + 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 diff --git a/test/integration/targets/openvswitch_db/tests/basic.yaml b/test/integration/targets/openvswitch_db/tests/basic.yaml new file mode 100644 index 00000000000..1f2a3345509 --- /dev/null +++ b/test/integration/targets/openvswitch_db/tests/basic.yaml @@ -0,0 +1,25 @@ +--- + +- command: ovs-vsctl add-br br-test + +- openvswitch_db: + table: Bridge + record: br-test + col: other_config + key: disable-in-band + value: true + +- openvswitch_db: + table: Bridge + record: br-test + col: other_config + key: disable-in-band + value: false + +- openvswitch_db: + table: Bridge + record: br-test + col: other_config + key: disable-in-band + value: false + state: absent diff --git a/test/integration/targets/prepare_ovs_tests/tasks/main.yml b/test/integration/targets/prepare_ovs_tests/tasks/main.yml new file mode 100644 index 00000000000..92d86b85c48 --- /dev/null +++ b/test/integration/targets/prepare_ovs_tests/tasks/main.yml @@ -0,0 +1,15 @@ +--- + +- name: Install openvswitch-switch package if we are on Ubuntu + apt: + name: openvswitch-switch + state: installed + update_cache: yes + when: ansible_distribution == 'Ubuntu' + +- name: Install openvswitch package if we are on Fedora + yum: + name: openvswitch + state: installed + update_cache: yes + when: ansible_distribution == 'Fedora'