From b574be6616c2e273fdaf2d17b3cae26ccab0f0a6 Mon Sep 17 00:00:00 2001 From: saichint Date: Thu, 31 Aug 2017 11:17:29 -0700 Subject: [PATCH] add it cases for vrf_af and vpc_interface (#28889) --- test/integration/nxos.yaml | 18 ++++ .../nxos_vpc_interface/defaults/main.yaml | 2 + .../targets/nxos_vpc_interface/meta/main.yml | 2 + .../targets/nxos_vpc_interface/tasks/cli.yaml | 15 +++ .../nxos_vpc_interface/tasks/main.yaml | 7 ++ .../nxos_vpc_interface/tasks/nxapi.yaml | 28 +++++ .../nxos_vpc_interface/tests/cli/sanity.yaml | 4 + .../tests/common/sanity.yaml | 102 ++++++++++++++++++ .../tests/nxapi/sanity.yaml | 4 + .../targets/nxos_vrf_af/defaults/main.yaml | 2 + .../targets/nxos_vrf_af/meta/main.yml | 2 + .../targets/nxos_vrf_af/tasks/cli.yaml | 15 +++ .../targets/nxos_vrf_af/tasks/main.yaml | 7 ++ .../targets/nxos_vrf_af/tasks/nxapi.yaml | 28 +++++ .../targets/nxos_vrf_af/tests/cli/sanity.yaml | 4 + .../nxos_vrf_af/tests/common/sanity.yaml | 80 ++++++++++++++ .../nxos_vrf_af/tests/nxapi/sanity.yaml | 4 + 17 files changed, 324 insertions(+) create mode 100644 test/integration/targets/nxos_vpc_interface/defaults/main.yaml create mode 100644 test/integration/targets/nxos_vpc_interface/meta/main.yml create mode 100644 test/integration/targets/nxos_vpc_interface/tasks/cli.yaml create mode 100644 test/integration/targets/nxos_vpc_interface/tasks/main.yaml create mode 100644 test/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml create mode 100644 test/integration/targets/nxos_vpc_interface/tests/cli/sanity.yaml create mode 100644 test/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml create mode 100644 test/integration/targets/nxos_vpc_interface/tests/nxapi/sanity.yaml create mode 100644 test/integration/targets/nxos_vrf_af/defaults/main.yaml create mode 100644 test/integration/targets/nxos_vrf_af/meta/main.yml create mode 100644 test/integration/targets/nxos_vrf_af/tasks/cli.yaml create mode 100644 test/integration/targets/nxos_vrf_af/tasks/main.yaml create mode 100644 test/integration/targets/nxos_vrf_af/tasks/nxapi.yaml create mode 100644 test/integration/targets/nxos_vrf_af/tests/cli/sanity.yaml create mode 100644 test/integration/targets/nxos_vrf_af/tests/common/sanity.yaml create mode 100644 test/integration/targets/nxos_vrf_af/tests/nxapi/sanity.yaml diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index c51974d365..1085cc73a2 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -177,6 +177,24 @@ failed_modules: "{{ failed_modules }} + [ 'nxos_vpc' ]" test_failed: true + - block: + - include_role: + name: nxos_vpc_interface + when: "limit_to in ['*', 'nxos_vpc_interface']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_vpc_interface' ]" + test_failed: true + + - block: + - include_role: + name: nxos_vrf_af + when: "limit_to in ['*', 'nxos_vrf_af']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_vrf_af' ]" + test_failed: true + - block: - include_role: name: nxos_vtp_domain diff --git a/test/integration/targets/nxos_vpc_interface/defaults/main.yaml b/test/integration/targets/nxos_vpc_interface/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vpc_interface/meta/main.yml b/test/integration/targets/nxos_vpc_interface/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vpc_interface/tasks/cli.yaml b/test/integration/targets/nxos_vpc_interface/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + 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/nxos_vpc_interface/tasks/main.yaml b/test/integration/targets/nxos_vpc_interface/tasks/main.yaml new file mode 100644 index 0000000000..fea9337c14 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/tasks/main.yaml @@ -0,0 +1,7 @@ +--- +# Use block to ensure that both cli and nxapi tests +# will run even if there are failures or errors. +- block: + - { include: cli.yaml, tags: ['cli'] } + always: + - { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml b/test/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml new file mode 100644 index 0000000000..ea525379f7 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/tasks/nxapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_vpc_interface/tests/cli/sanity.yaml b/test/integration/targets/nxos_vpc_interface/tests/cli/sanity.yaml new file mode 100644 index 0000000000..e490d8e597 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/tests/cli/sanity.yaml @@ -0,0 +1,4 @@ +--- +- set_fact: connection="{{ cli }}" + +- import_tasks: targets/nxos_vpc_interface/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml b/test/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml new file mode 100644 index 0000000000..5a21e73060 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/tests/common/sanity.yaml @@ -0,0 +1,102 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vpc_interface sanity test" + +- block: + - name: enable feature vpc + nxos_feature: + feature: vpc + state: enabled + provider: "{{ connection }}" + + - name: create port-channel + nxos_config: + commands: + - interface port-channel10 + - switchport + match: none + provider: "{{ connection }}" + + - name: configure vpc + nxos_vpc: + state: present + domain: 100 + role_priority: 32667 + system_priority: 2000 + pkl_dest: 192.168.100.4 + pkl_src: 10.1.100.20 + peer_gw: true + auto_recovery: false + provider: "{{ connection }}" + + - name: Configure vpc port channel + nxos_vpc_interface: &conf + portchannel: 10 + vpc: 100 + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Conf Idempotence" + nxos_vpc_interface: *conf + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: remove vpc port channel + nxos_vpc_interface: &remove + portchannel: 10 + vpc: 100 + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "Remove Idempotence" + nxos_vpc_interface: *remove + register: result + + - assert: *false + + always: + - name: remove vpc + nxos_vpc: + state: absent + domain: 100 + role_priority: 32667 + system_priority: 2000 + pkl_dest: 192.168.100.4 + pkl_src: 10.1.100.20 + peer_gw: true + auto_recovery: false + provider: "{{ connection }}" + ignore_errors: yes + + - name: remove vpc port channel + nxos_vpc_interface: + portchannel: 10 + vpc: 100 + state: absent + provider: "{{ connection }}" + ignore_errors: yes + + - name: remove port channel + nxos_config: + commands: + - no interface port-channel10 + match: none + provider: "{{ connection }}" + ignore_errors: yes + + - name: disable feature vpc + nxos_feature: + feature: vpc + state: disabled + provider: "{{ connection }}" + +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vpc_interface sanity test" diff --git a/test/integration/targets/nxos_vpc_interface/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vpc_interface/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..dea9331d12 --- /dev/null +++ b/test/integration/targets/nxos_vpc_interface/tests/nxapi/sanity.yaml @@ -0,0 +1,4 @@ +--- +- set_fact: connection="{{ nxapi }}" + +- import_tasks: targets/nxos_vpc_interface/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_vrf_af/defaults/main.yaml b/test/integration/targets/nxos_vrf_af/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vrf_af/meta/main.yml b/test/integration/targets/nxos_vrf_af/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vrf_af/tasks/cli.yaml b/test/integration/targets/nxos_vrf_af/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + 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/nxos_vrf_af/tasks/main.yaml b/test/integration/targets/nxos_vrf_af/tasks/main.yaml new file mode 100644 index 0000000000..fea9337c14 --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/tasks/main.yaml @@ -0,0 +1,7 @@ +--- +# Use block to ensure that both cli and nxapi tests +# will run even if there are failures or errors. +- block: + - { include: cli.yaml, tags: ['cli'] } + always: + - { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vrf_af/tasks/nxapi.yaml b/test/integration/targets/nxos_vrf_af/tasks/nxapi.yaml new file mode 100644 index 0000000000..ea525379f7 --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/tasks/nxapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_vrf_af/tests/cli/sanity.yaml b/test/integration/targets/nxos_vrf_af/tests/cli/sanity.yaml new file mode 100644 index 0000000000..47b06c4a1d --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/tests/cli/sanity.yaml @@ -0,0 +1,4 @@ +--- +- set_fact: connection="{{ cli }}" + +- import_tasks: targets/nxos_vrf_af/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_vrf_af/tests/common/sanity.yaml b/test/integration/targets/nxos_vrf_af/tests/common/sanity.yaml new file mode 100644 index 0000000000..d3f8efbe23 --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/tests/common/sanity.yaml @@ -0,0 +1,80 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vrf_af sanity test" + +- name: Configure feature bgp + nxos_feature: + feature: bgp + state: enabled + provider: "{{ connection }}" + +- name: Configure feature nv overlay + nxos_config: + commands: "feature nv overlay" + provider: "{{ connection }}" + +- name: Configure nv overlay evpn + nxos_config: + commands: "nv overlay evpn" + provider: "{{ connection }}" + +- block: + - name: Configure vrf af + nxos_vrf_af: &configure + vrf: ansible + afi: ipv4 + route_target_both_auto_evpn: true + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Conf Idempotence" + nxos_vrf_af: *configure + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: Remove vrf af + nxos_vrf_af: &remove + vrf: ansible + afi: ipv4 + route_target_both_auto_evpn: true + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - pause: + seconds: 30 + + - name: "Remove Idempotence" + nxos_vrf_af: *remove + register: result + + - assert: *false + + always: + - name: Remove feature bgp + nxos_feature: + feature: bgp + state: disabled + provider: "{{ connection }}" + + - name: Remove feature nv overlay + nxos_config: + commands: "no feature nv overlay" + provider: "{{ connection }}" + ignore_errors: yes + + - name: Remove nv overlay evpn + nxos_config: + commands: "no nv overlay evpn" + provider: "{{ connection }}" + ignore_errors: yes + +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vrf_af sanity test" diff --git a/test/integration/targets/nxos_vrf_af/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vrf_af/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..ec7fd8ebc7 --- /dev/null +++ b/test/integration/targets/nxos_vrf_af/tests/nxapi/sanity.yaml @@ -0,0 +1,4 @@ +--- +- set_fact: connection="{{ nxapi }}" + +- import_tasks: targets/nxos_vrf_af/tests/common/sanity.yaml