diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/dellemc/os9/tests/integration | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/os9/tests/integration')
20 files changed, 477 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/__init__.py b/ansible_collections/dellemc/os9/tests/integration/targets/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/__init__.py diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/defaults/main.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/defaults/main.yaml new file mode 100644 index 000000000..55a93fc23 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*"
\ No newline at end of file diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tasks/cli.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tasks/cli.yaml new file mode 100644 index 000000000..7152815d7 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tasks/cli.yaml @@ -0,0 +1,14 @@ +--- +- 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: "{{ item }}" + with_items: "{{ test_items }}"
\ No newline at end of file diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tasks/main.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tasks/main.yaml new file mode 100644 index 000000000..d4898c29b --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] }
\ No newline at end of file diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/bad_operator b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/bad_operator new file mode 100644 index 000000000..42a164c85 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/bad_operator @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/bad_operator.yaml" + +- name: test bad operator + os9_command: + commands: + - show version + - show interfaces TenGigabitEthernet 0/0 + wait_for: + - "result[0] contains 'Description : blah'" + provider: "{{ cli }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END cli/bad_operator.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/contains b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/contains new file mode 100644 index 000000000..2f56a11f9 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/contains @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/contains.yaml" + +- name: test contains operator + os9_command: + commands: + - show version + - show interface TenGigabitEthernet 0/0 + wait_for: + - "result[0] contains 2.0" + - "result[1] contains TenGigabitEthernet " + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + +- debug: msg="END cli/contains.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/invalid b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/invalid new file mode 100644 index 000000000..cffc24f81 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/invalid @@ -0,0 +1,28 @@ +--- +- debug: msg="START cli/invalid.yaml" + +- name: run invalid command + os9_command: + commands: ['show foo'] + provider: "{{ cli }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed" + +- name: run commands that include invalid command + os9_command: + commands: + - show version + - show foo + provider: "{{ cli }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed" + +- debug: msg="END cli/invalid.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/output b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/output new file mode 100644 index 000000000..1fd537880 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/output @@ -0,0 +1,29 @@ +--- +- debug: msg="START cli/output.yaml" + +- name: get output for single command + os9_command: + commands: ['show version'] + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + +- name: get output for multiple commands + os9_command: + commands: + - show version + - show interfaces + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout | length == 2" + +- debug: msg="END cli/output.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/show_commands.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/show_commands.yaml new file mode 100644 index 000000000..80d19518e --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/show_commands.yaml @@ -0,0 +1,74 @@ +--- +- debug: msg="START cli/show_commands.yaml" + +- name: test bad operator + os9_command: + commands: + - show version + - show interfaces TenGigabitEthernet 0/0 + wait_for: + - "result[0] contains 'Description : blah'" + provider: "{{ cli }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- name: get output for single command + os9_command: + commands: ['show version'] + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + +- name: get output for multiple commands + os9_command: + commands: + - show version + - show interfaces + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout | length == 2" + +- name: show run command with grep Option + os9_command: + commands: + - show run | grep username + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.stdout | length == 1" + +- name: Execute multiple show commands continously + os9_command: + commands: + - show system + - show file-systems + - show startup-config + - show tech-support + - show logging + - show system brief | grep Management + provider: "{{ cli }}" + retries: 8 + interval: 5 + register: result + +- assert: + that: + - "result.stdout | length == 6" + +- debug: msg="END cli/show_commands.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/timeout b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/timeout new file mode 100644 index 000000000..60dbb761f --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_command/os9_command/tests/cli/timeout @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/timeout.yaml" + +- name: test bad condition + os9_command: + commands: + - show version + wait_for: + - "result[0] contains bad_value_string" + provider: "{{ cli }}" + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- debug: msg="END cli/timeout.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/defaults/main.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/defaults/main.yaml new file mode 100644 index 000000000..5f709c5aa --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tasks/cli.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tasks/cli.yaml new file mode 100644 index 000000000..346bdf2d1 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tasks/cli.yaml @@ -0,0 +1,13 @@ +--- +- 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: "{{ item }}" + with_items: "{{ test_items }}" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tasks/main.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tasks/main.yaml new file mode 100644 index 000000000..415c99d8b --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/configcommands.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/configcommands.yaml new file mode 100644 index 000000000..d737a4909 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/configcommands.yaml @@ -0,0 +1,134 @@ +--- +- debug: msg="START cli/config command execution" + +- name: COnfigure managemnet protocol telnet + os9_config: + lines: ['hostname {{ inventory_hostname }}', 'ip telnet server enable'] + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: Create new username and set password + os9_config: + lines: ['username test password test123'] + provider: "{{ cli }}" + register: result + +- name: Update the new user test privilige using replace line Option + os9_config: + lines: + - username test password test123 privilege 15 + provider: "{{ cli }}" + replace: line + save: no + register: result + +- name: Validate the newly created username using show run command use the keyword wait_for + os9_command: + commands: + - show running-config | grep username + - show running-config | grep username | grep test + wait_for: + - "result[0] contains test" + provider: "{{ cli }}" + +- name: Configure SNMP v2 credentials on device and enable traps + os9_config: + lines: + - snmp-server community ansibleread ro + - snmp-server community ansiblewrite rw + - snmp-server enable traps + - snmp-server host 10.16.148.142 traps version 2c public udp-port 162 + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: Validate is newly created snmp v2 is available in running config + os9_command: + commands: + - show running-config | grep snmp-server + wait_for: + - "result[0] contains ansibleread" + - "result[0] contains ansiblewrite" + provider: "{{ cli }}" + register: result + +- name: Configure Clock timezone + os9_config: + lines: "clock timezone UTC 0 0" + provider: "{{ cli }}" + register: result + +- name: Configure Logging to NMS Server + os9_config: + lines: + - logging 10.16.148.142 + #before: + # - no logging 10.16.148.142 + #ignore: yes + provider: "{{ cli }}" + register: result + +- name: Configure Default Gateway + os9_config: + lines: + - management route 0.0.0.0/0 10.16.148.254 + provider: "{{ cli }}" + register: result + + #- assert: + # that: + # - "result.changed == true" + #- "'management route 0.0.0.0/0 10.16.148.254' in result.updates" + +- name: Enable spanning tree protocol using parent , before and after keywords in config module + os9_config: + lines: + - no disable + - hello-time 1 + - max-age 6 + - forward-delay 4 + - bridge-priority 0 + parents: ['protocol spanning-tree rstp'] + before: ['no protocol spanning-tree rstp'] + after: ['exit'] + provider: "{{ cli }}" + register: result + +- name: save the running config into startup config using save keyword in os9 config module + os9_config: + save: yes + provider: "{{ cli }}" + register: result + +- name: Validate the newly added commands are available in startup-config + os9_command: + commands: + - show startup-config + provider: "{{ cli }}" + register: result + +- name: COnfigure new vlan using src file given as input and backup the configuration + os9_config: + src: vlan_config.txt + provider: "{{ cli }}" + update: merge + backup: yes + register: result + + +- name: Validate the check Option for update in Dell os9 config using the config file provided with config option + os9_config: + src: vlan_config.txt + provider: "{{ cli }}" + update: check + config: Aggregation1_config.2016-09-06@15:26:02 + register: result + +- debug: msg="END cli/configcommands" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/toplevel.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/toplevel.yaml new file mode 100644 index 000000000..65df0afa1 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/toplevel.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/toplevel.yaml" + +- name: setup + os9_config: + lines: ['hostname {{ inventory_hostname }}'] + provider: "{{ cli }}" + match: none + +- name: configure top level command + os9_config: + lines: ['hostname foo'] + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + os9_config: + lines: ['hostname foo'] + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os9_config: + lines: ['hostname {{ inventory_hostname }}'] + provider: "{{ cli }}" + match: none + +- debug: msg="END cli/toplevel.yaml" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/vlan_config.txt b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/vlan_config.txt new file mode 100644 index 000000000..894052832 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_config/os9_config/tests/cli/vlan_config.txt @@ -0,0 +1,9 @@ +interface Vlan 1000 + description "vlan added from ansible" + name Testansible-1000 + ip unreachables + ip helper-address 100.1.1.1 + ip udp-helper udp-port 1000 + no shutdown +~ + diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/defaults/main.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/defaults/main.yaml new file mode 100644 index 000000000..5f709c5aa --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tasks/cli.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tasks/cli.yaml new file mode 100644 index 000000000..346bdf2d1 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tasks/cli.yaml @@ -0,0 +1,13 @@ +--- +- 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: "{{ item }}" + with_items: "{{ test_items }}" diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tasks/main.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tasks/main.yaml new file mode 100644 index 000000000..415c99d8b --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tests/cli/testcases_facts.yaml b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tests/cli/testcases_facts.yaml new file mode 100644 index 000000000..9315f3445 --- /dev/null +++ b/ansible_collections/dellemc/os9/tests/integration/targets/os9_facts/os9_facts/tests/cli/testcases_facts.yaml @@ -0,0 +1,55 @@ +--- +- debug: msg="START cli/testcases_facts.yaml" + +- name: Get all the interfaces facts + os9_facts: + gather_subset: + - interfaces + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.ansible_facts is defined" + - "result.ansible_facts.ansible_net_all_ipv4_addresses is defined" + - "result.ansible_facts.ansible_net_interfaces is defined" + - "result.ansible_facts.ansible_net_neighbors is defined" + +- name: Get all the facts Excpet Interfaces using ! Operator and validate + os9_facts: + gather_subset: + - "!interfaces" + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.ansible_facts is defined" + - "result.ansible_facts.ansible_net_all_ipv4_addresses is not defined" + - "result.ansible_facts.ansible_net_interfaces is not defined" + - "result.ansible_facts.ansible_net_neighbors is not defined" + - "result.ansible_facts.ansible_net_config is defined" + - "result.ansible_facts.ansible_net_filesystems is defined" + +- name: Test with multiple subsets provided + os9_facts: + gather_subset: + - config + - hardware + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + - "result.ansible_facts is defined" + - "result.ansible_facts.ansible_net_filesystems is defined" + - "result.ansible_facts.ansible_net_memtotal_mb is defined" + - "result.ansible_facts.ansible_net_memfree_mb is defined" + - "result.ansible_facts.ansible_net_config is defined" + + + +- debug: msg="START cli/testcases_facts.yaml" |