diff options
author | rahushen <rahul.shenoy.86@gmail.com> | 2017-10-25 17:41:23 +0200 |
---|---|---|
committer | Nathaniel Case <this.is@nathanielca.se> | 2017-10-25 17:41:23 +0200 |
commit | ab84718a016daa65eca1d4f918b7e3d1bd43944f (patch) | |
tree | 6f0ffd5cb52f4ff38d0d36ec802c174646f38dcf /test/integration | |
parent | Add DO SSH key facts module to changelog (diff) | |
download | ansible-ab84718a016daa65eca1d4f918b7e3d1bd43944f.tar.xz ansible-ab84718a016daa65eca1d4f918b7e3d1bd43944f.zip |
NXOS: Integration tests to Ansible (part 3) (#29030)
* Add nxos_file_copy IT
* Restructure nxos_igmp tests
* add nxos_igmp_interface IT
* add nxos_igmp_snooping IT
* add nxos_ntp_auth IT
* Add nxos_ntp_options IT
* update nxos.yaml with new tests
* update nxos_ntp_options test
* update nxos_ntp_auth IT
Diffstat (limited to 'test/integration')
37 files changed, 903 insertions, 20 deletions
diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index c79969eea3..cff1ad08ee 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -313,6 +313,60 @@ - block: - include_role: + name: nxos_file_copy + when: "limit_to in ['*', 'nxos_file_copy']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_file_copy' ]" + test_failed: true + + - block: + - include_role: + name: nxos_igmp_interface + when: "limit_to in ['*', 'nxos_igmp_interface']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_igmp_interface' ]" + test_failed: true + + - block: + - include_role: + name: nxos_igmp + when: "limit_to in ['*', 'nxos_igmp']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_igmp' ]" + test_failed: true + + - block: + - include_role: + name: nxos_igmp_snooping + when: "limit_to in ['*', 'nxos_igmp_snooping']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_igmp_snooping' ]" + test_failed: true + + - block: + - include_role: + name: nxos_ntp_auth + when: "limit_to in ['*', 'nxos_ntp_auth']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_ntp_auth' ]" + test_failed: true + + - block: + - include_role: + name: nxos_ntp_options + when: "limit_to in ['*', 'nxos_ntp_options']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_ntp_options' ]" + test_failed: true + + - block: + - include_role: name: nxos_logging when: "limit_to in ['*', 'nxos_logging']" rescue: diff --git a/test/integration/targets/nxos_file_copy/defaults/main.yaml b/test/integration/targets/nxos_file_copy/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_file_copy/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_file_copy/meta/main.yml b/test/integration/targets/nxos_file_copy/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_file_copy/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_file_copy/tasks/cli.yaml b/test/integration/targets/nxos_file_copy/tasks/cli.yaml new file mode 100644 index 0000000000..0ab3f8f908 --- /dev/null +++ b/test/integration/targets/nxos_file_copy/tasks/cli.yaml @@ -0,0 +1,25 @@ +--- +- name: collect common cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: cli_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ cli_cases.files }}" + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }} connection={{ cli }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_file_copy/tasks/main.yaml b/test/integration/targets/nxos_file_copy/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_file_copy/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_file_copy/tasks/nxapi.yaml b/test/integration/targets/nxos_file_copy/tasks/nxapi.yaml new file mode 100644 index 0000000000..e071f293a2 --- /dev/null +++ b/test/integration/targets/nxos_file_copy/tasks/nxapi.yaml @@ -0,0 +1,38 @@ +--- +- name: collect common nxapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: nxapi_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ nxapi_cases.files }}" + +- 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 }} connection={{ nxapi }}" + 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_file_copy/tests/cli/sanity.yaml b/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml new file mode 100644 index 0000000000..b621782796 --- /dev/null +++ b/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml @@ -0,0 +1,84 @@ +--- +- debug: msg="START TRANSPORT:CLI nxos_file_copy sanity test" + +- name: "Setup - Remove existing file" + nxos_command: &remove_file + commands: + - terminal dont-ask + - delete nxos.yaml + provider: "{{ cli }}" + ignore_errors: yes + +- name: "Setup - Turn on feature scp-server" + nxos_feature: + feature: scp-server + state: enabled + provider: "{{ cli }}" + +- block: + - name: "Copy nxos.yaml to bootflash" + nxos_file_copy: ©_file_same_name + local_file: "./nxos.yaml" + file_system: "bootflash:" + provider: "{{ cli }}" + username: "{{ nxos_cli_user | default('admin') }}" + password: "{{ nxos_cli_pass | default('admin') }}" + host: "{{ inventory_hostname }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence - Copy nxos.yaml to bootflash" + nxos_file_copy: *copy_file_same_name + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Setup - Remove existing file" + nxos_command: *remove_file + register: result + + - name: "Copy ios.yaml to bootflash as another name" + nxos_file_copy: ©_file_different_name + local_file: "./ios.yaml" + remote_file: "nxos.yaml" + file_system: "bootflash:" + provider: "{{ cli }}" + username: "{{ nxos_cli_user | default('admin') }}" + password: "{{ nxos_cli_pass | default('admin') }}" + host: "{{ inventory_hostname }}" + register: result + + - assert: *true + + - name: "Check Idempotence - Copy ios.yaml to bootflash as another name" + nxos_file_copy: *copy_file_different_name + register: result + + - assert: *false + + - name: "Setup - Remove existing file" + nxos_command: *remove_file + register: result + + rescue: + + - debug: msg="TRANSPORT:CLI nxos_file_copy failure detected" + + always: + + - name: "Remove file" + nxos_command: *remove_file + ignore_errors: yes + + - name: "Turn off feature scp-server" + nxos_feature: + feature: scp-server + state: disabled + provider: "{{ cli }}" + + - debug: msg="END TRANSPORT:CLI nxos_file_copy sanity test" diff --git a/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..e9f2c8796e --- /dev/null +++ b/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml @@ -0,0 +1,88 @@ +--- +- debug: msg="START TRANSPORT:NXAPI nxos_file_copy sanity test" + +- name: "Setup - Remove existing file" + nxos_command: &remove_file + commands: + - command: terminal dont-ask + output: text + - command: delete nxos.yaml + output: text + provider: "{{ nxapi }}" + ignore_errors: yes + +- name: "Setup - Turn on feature scp-server" + nxos_feature: + feature: scp-server + state: enabled + provider: "{{ nxapi }}" + +- block: + - name: "Copy nxos.yaml to bootflash" + nxos_file_copy: ©_file_same_name + local_file: "./nxos.yaml" + file_system: "bootflash:" + provider: "{{ nxapi }}" + username: "{{ nxos_nxapi_user | default('admin') }}" + password: "{{ nxos_nxapi_pass | default('admin') }}" + host: "{{ inventory_hostname }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence - Copy nxos.yaml to bootflash" + nxos_file_copy: *copy_file_same_name + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Setup - Remove existing file" + nxos_command: *remove_file + register: result + ignore_errors: yes + + - name: "Copy ios.yaml to bootflash as another name" + nxos_file_copy: ©_file_different_name + local_file: "./ios.yaml" + remote_file: "nxos.yaml" + file_system: "bootflash:" + provider: "{{ nxapi }}" + username: "{{ nxos_nxapi_user | default('admin') }}" + password: "{{ nxos_nxapi_pass | default('admin') }}" + host: "{{ inventory_hostname }}" + register: result + + - assert: *true + + - name: "Check Idempotence - Copy ios.yaml to bootflash as another name" + nxos_file_copy: *copy_file_different_name + register: result + + - assert: *false + + - name: "Setup - Remove existing file" + nxos_command: *remove_file + register: result + ignore_errors: yes + + rescue: + + - debug: msg="TRANSPORT:NXAPI nxos_file_copy failure detected" + + always: + + - name: "Remove file" + nxos_command: *remove_file + ignore_errors: yes + + - name: "Turn off feature scp-server" + nxos_feature: + feature: scp-server + state: disabled + provider: "{{ nxapi }}" + + - debug: msg="END TRANSPORT:NXAPI nxos_file_copy sanity test" diff --git a/test/integration/targets/nxos_igmp/tasks/cli.yaml b/test/integration/targets/nxos_igmp/tasks/cli.yaml index d675462dd0..0ab3f8f908 100644 --- a/test/integration/targets/nxos_igmp/tasks/cli.yaml +++ b/test/integration/targets/nxos_igmp/tasks/cli.yaml @@ -1,15 +1,25 @@ --- -- name: collect all cli test cases +- name: collect common cli test cases find: - paths: "{{ role_path }}/tests/cli" + paths: "{{ role_path }}/tests/common" patterns: "{{ testcase }}.yaml" register: test_cases +- name: collect cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: cli_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ cli_cases.files }}" + - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - name: run test case - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} connection={{ cli }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_igmp/tasks/main.yaml b/test/integration/targets/nxos_igmp/tasks/main.yaml index fea9337c14..4b0f8c64d9 100644 --- a/test/integration/targets/nxos_igmp/tasks/main.yaml +++ b/test/integration/targets/nxos_igmp/tasks/main.yaml @@ -1,7 +1,3 @@ --- -# 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'] } +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_igmp/tasks/nxapi.yaml b/test/integration/targets/nxos_igmp/tasks/nxapi.yaml index 148d8d6486..378db2f016 100644 --- a/test/integration/targets/nxos_igmp/tasks/nxapi.yaml +++ b/test/integration/targets/nxos_igmp/tasks/nxapi.yaml @@ -1,15 +1,25 @@ --- -- name: collect all nxapi test cases +- name: collect common nxapi test cases find: - paths: "{{ role_path }}/tests/nxapi" + paths: "{{ role_path }}/tests/common" patterns: "{{ testcase }}.yaml" register: test_cases +- name: collect nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: nxapi_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ nxapi_cases.files }}" + - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - name: run test case - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} connection={{ nxapi }}" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_igmp/tests/cli/sanity.yaml b/test/integration/targets/nxos_igmp/tests/cli/sanity.yaml deleted file mode 100644 index 6417e21c08..0000000000 --- a/test/integration/targets/nxos_igmp/tests/cli/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ cli }}" - -- import_tasks: targets/nxos_igmp/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_igmp/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_igmp/tests/nxapi/sanity.yaml deleted file mode 100644 index 39aa2810b2..0000000000 --- a/test/integration/targets/nxos_igmp/tests/nxapi/sanity.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- set_fact: connection="{{ nxapi }}" - -- import_tasks: targets/nxos_igmp/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_igmp_interface/defaults/main.yaml b/test/integration/targets/nxos_igmp_interface/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_igmp_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_igmp_interface/meta/main.yml b/test/integration/targets/nxos_igmp_interface/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_igmp_interface/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_igmp_interface/tasks/cli.yaml b/test/integration/targets/nxos_igmp_interface/tasks/cli.yaml new file mode 100644 index 0000000000..0ab3f8f908 --- /dev/null +++ b/test/integration/targets/nxos_igmp_interface/tasks/cli.yaml @@ -0,0 +1,25 @@ +--- +- name: collect common cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: cli_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ cli_cases.files }}" + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }} connection={{ cli }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_igmp_interface/tasks/main.yaml b/test/integration/targets/nxos_igmp_interface/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_igmp_interface/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml b/test/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml new file mode 100644 index 0000000000..e071f293a2 --- /dev/null +++ b/test/integration/targets/nxos_igmp_interface/tasks/nxapi.yaml @@ -0,0 +1,38 @@ +--- +- name: collect common nxapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: nxapi_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ nxapi_cases.files }}" + +- 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 }} connection={{ nxapi }}" + 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_igmp_interface/tests/common/sanity.yaml b/test/integration/targets/nxos_igmp_interface/tests/common/sanity.yaml new file mode 100644 index 0000000000..6290687e9a --- /dev/null +++ b/test/integration/targets/nxos_igmp_interface/tests/common/sanity.yaml @@ -0,0 +1,90 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_igmp_interface sanity test" + +# Select interface for test +- set_fact: intname="{{ nxos_int1 }}" + +- name: "Enable feature PIM" + nxos_feature: + feature: pim + state: enabled + provider: "{{ connection }}" + ignore_errors: yes + +- block: + + - name: put interface in L3 and enable PIM + nxos_config: + commands: + - no switchport + - ip pim sparse-mode + parents: + - "interface {{ intname }}" + match: none + provider: "{{ connection }}" + + - name: Configure igmp interface with non-default values + nxos_igmp_interface: &non-default + interface: "{{ intname }}" + version: 3 + startup_query_interval: 60 + startup_query_count: 5 + robustness: 6 + querier_timeout: 2000 + query_mrt: 12 + query_interval: 200 + last_member_qrt: 2 + last_member_query_count: 4 + report_llg: true + immediate_leave: true + restart: false + state: present + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence - Configure igmp interface with non-default values" + nxos_igmp_interface: *non-default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: Configure igmp interface with default value + nxos_igmp_interface: &default + interface: "{{ intname }}" + state: default + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "Check Idempotence - Configure igmp interface with default value" + nxos_igmp_interface: *default + register: result + + - assert: *false + + always: + - name: Configure igmp interface with default value + nxos_igmp_interface: *default + register: result + + - name: Put interface in default mode + nxos_config: + commands: + - "default interface {{ intname }}" + provider: "{{ connection }}" + match: none + + - name: "Disable feature PIM" + nxos_feature: + feature: pim + state: disabled + provider: "{{ connection }}" + + - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_igmp_interface sanity test" diff --git a/test/integration/targets/nxos_igmp_snooping/defaults/main.yaml b/test/integration/targets/nxos_igmp_snooping/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_igmp_snooping/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_igmp_snooping/meta/main.yml b/test/integration/targets/nxos_igmp_snooping/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_igmp_snooping/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_igmp_snooping/tasks/cli.yaml b/test/integration/targets/nxos_igmp_snooping/tasks/cli.yaml new file mode 100644 index 0000000000..0ab3f8f908 --- /dev/null +++ b/test/integration/targets/nxos_igmp_snooping/tasks/cli.yaml @@ -0,0 +1,25 @@ +--- +- name: collect common cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: cli_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ cli_cases.files }}" + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }} connection={{ cli }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_igmp_snooping/tasks/main.yaml b/test/integration/targets/nxos_igmp_snooping/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_igmp_snooping/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml b/test/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml new file mode 100644 index 0000000000..e071f293a2 --- /dev/null +++ b/test/integration/targets/nxos_igmp_snooping/tasks/nxapi.yaml @@ -0,0 +1,38 @@ +--- +- name: collect common nxapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: nxapi_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ nxapi_cases.files }}" + +- 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 }} connection={{ nxapi }}" + 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_igmp_snooping/tests/common/sanity.yaml b/test/integration/targets/nxos_igmp_snooping/tests/common/sanity.yaml new file mode 100644 index 0000000000..e6691d320b --- /dev/null +++ b/test/integration/targets/nxos_igmp_snooping/tests/common/sanity.yaml @@ -0,0 +1,48 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_igmp_snooping sanity test" + +- block: + + - name: Configure igmp snooping with non-default values + nxos_igmp_snooping: &non-default + snooping: true + group_timeout: never + link_local_grp_supp: true + report_supp: true + v3_report_supp: true + state: present + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence - Configure igmp snooping with non-default values" + nxos_igmp_snooping: *non-default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: Configure igmp snooping with default values + nxos_igmp_snooping: &default + state: default + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "Check Idempotence - Configure igmp snooping with default values" + nxos_igmp_snooping: *default + register: result + + - assert: *false + + always: + - name: Configure igmp snooping with default values + nxos_igmp_snooping: *default + register: result + + - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_igmp_snooping sanity test" diff --git a/test/integration/targets/nxos_ntp_auth/defaults/main.yaml b/test/integration/targets/nxos_ntp_auth/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_ntp_auth/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_ntp_auth/meta/main.yml b/test/integration/targets/nxos_ntp_auth/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_ntp_auth/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_ntp_auth/tasks/cli.yaml b/test/integration/targets/nxos_ntp_auth/tasks/cli.yaml new file mode 100644 index 0000000000..0ab3f8f908 --- /dev/null +++ b/test/integration/targets/nxos_ntp_auth/tasks/cli.yaml @@ -0,0 +1,25 @@ +--- +- name: collect common cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: cli_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ cli_cases.files }}" + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }} connection={{ cli }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_ntp_auth/tasks/main.yaml b/test/integration/targets/nxos_ntp_auth/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_ntp_auth/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml b/test/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml new file mode 100644 index 0000000000..e071f293a2 --- /dev/null +++ b/test/integration/targets/nxos_ntp_auth/tasks/nxapi.yaml @@ -0,0 +1,38 @@ +--- +- name: collect common nxapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: nxapi_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ nxapi_cases.files }}" + +- 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 }} connection={{ nxapi }}" + 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_ntp_auth/tests/common/sanity.yaml b/test/integration/targets/nxos_ntp_auth/tests/common/sanity.yaml new file mode 100644 index 0000000000..cf7877c9a9 --- /dev/null +++ b/test/integration/targets/nxos_ntp_auth/tests/common/sanity.yaml @@ -0,0 +1,87 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_ntp_auth sanity test" + +- name: Configure text ntp authentication + nxos_ntp_auth: &setup + key_id: 32 + md5string: hello + state: absent + provider: "{{ connection }}" + ignore_errors: yes + +- block: + + - name: Configure text ntp authentication + nxos_ntp_auth: &configure_text + key_id: 32 + md5string: hello + auth_type: text + trusted_key: true + authentication: on + state: present + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence - Configure text ntp authentication" + nxos_ntp_auth: *configure_text + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: Remove text ntp authentication + nxos_ntp_auth: &remove_text + key_id: 32 + md5string: hello + auth_type: text + trusted_key: true + authentication: on + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Configure encrypt ntp authentication + nxos_ntp_auth: &configure_encrypt + key_id: 32 + md5string: hello + auth_type: encrypt + trusted_key: true + authentication: on + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "Check Idempotence - Configure encrypt ntp authentication" + nxos_ntp_auth: *configure_encrypt + register: result + + - assert: *false + + - name: Remove encrypt ntp authentication + nxos_ntp_auth: &remove_encrypt + key_id: 32 + md5string: hello + auth_type: encrypt + trusted_key: true + authentication: on + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + always: + - name: Cleanup ntp auth config + nxos_ntp_auth: *setup + ignore_errors: yes + + - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_ntp_auth sanity test" diff --git a/test/integration/targets/nxos_ntp_options/defaults/main.yaml b/test/integration/targets/nxos_ntp_options/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_ntp_options/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_ntp_options/meta/main.yml b/test/integration/targets/nxos_ntp_options/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_ntp_options/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_ntp_options/tasks/cli.yaml b/test/integration/targets/nxos_ntp_options/tasks/cli.yaml new file mode 100644 index 0000000000..0ab3f8f908 --- /dev/null +++ b/test/integration/targets/nxos_ntp_options/tasks/cli.yaml @@ -0,0 +1,25 @@ +--- +- name: collect common cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: cli_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ cli_cases.files }}" + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }} connection={{ cli }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_ntp_options/tasks/main.yaml b/test/integration/targets/nxos_ntp_options/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_ntp_options/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_ntp_options/tasks/nxapi.yaml b/test/integration/targets/nxos_ntp_options/tasks/nxapi.yaml new file mode 100644 index 0000000000..e071f293a2 --- /dev/null +++ b/test/integration/targets/nxos_ntp_options/tasks/nxapi.yaml @@ -0,0 +1,38 @@ +--- +- name: collect common nxapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: collect nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: nxapi_cases + +- set_fact: + test_cases: + files: "{{ test_cases.files }} + {{ nxapi_cases.files }}" + +- 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 }} connection={{ nxapi }}" + 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_ntp_options/tests/common/sanity.yaml b/test/integration/targets/nxos_ntp_options/tests/common/sanity.yaml new file mode 100644 index 0000000000..000096c309 --- /dev/null +++ b/test/integration/targets/nxos_ntp_options/tests/common/sanity.yaml @@ -0,0 +1,74 @@ +--- +- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_ntp_options sanity test" + +- name: "Apply default ntp config" + nxos_ntp_options: &default + state: absent + provider: "{{ connection }}" + ignore_errors: yes + +- block: + + - name: Configure ntp with master and default stratum + nxos_ntp_options: &configure_master_default_stratum + master: true + logging: true + state: present + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence - Configure ntp with master and default stratum" + nxos_ntp_options: *configure_master_default_stratum + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: Remove ntp with master and default stratum + nxos_ntp_options: &remove_master_default_stratum + logging: true + master: true + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: Configure ntp with master and non-default stratum + nxos_ntp_options: &configure_master_non_default_stratum + master: true + logging: true + stratum: 10 + state: present + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "Check Idempotence - Configure ntp with master and non-default stratum" + nxos_ntp_options: *configure_master_non_default_stratum + register: result + + - assert: *false + + - name: Remove ntp with master and non-default stratum + nxos_ntp_options: &remove_master_non_default_stratum + logging: true + master: true + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + always: + - name: Cleanup ntp config + nxos_ntp_options: *default + register: result + + - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_ntp_options sanity test" |