diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index c51974d3652..1085cc73a2e 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 00000000000..5f709c5aac1 --- /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 00000000000..ae741cbdc71 --- /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 00000000000..d675462dd02 --- /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 00000000000..fea9337c14c --- /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 00000000000..ea525379f7f --- /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 00000000000..e490d8e5978 --- /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 00000000000..5a21e730602 --- /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 00000000000..dea9331d126 --- /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 00000000000..5f709c5aac1 --- /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 00000000000..ae741cbdc71 --- /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 00000000000..d675462dd02 --- /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 00000000000..fea9337c14c --- /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 00000000000..ea525379f7f --- /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 00000000000..47b06c4a1d2 --- /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 00000000000..d3f8efbe237 --- /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 00000000000..ec7fd8ebc79 --- /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