diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:03:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:03:42 +0000 |
commit | 66cec45960ce1d9c794e9399de15c138acb18aed (patch) | |
tree | 59cd19d69e9d56b7989b080da7c20ef1a3fe2a5a /ansible_collections/dellemc/os10/tests/integration | |
parent | Initial commit. (diff) | |
download | ansible-66cec45960ce1d9c794e9399de15c138acb18aed.tar.xz ansible-66cec45960ce1d9c794e9399de15c138acb18aed.zip |
Adding upstream version 7.3.0+dfsg.upstream/7.3.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/os10/tests/integration')
339 files changed, 7873 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/os10/tests/integration/target-prefixes.network b/ansible_collections/dellemc/os10/tests/integration/target-prefixes.network new file mode 100644 index 00000000..69b59b3f --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +os10 diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/01_aaa_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/01_aaa_configure.j2 new file mode 100644 index 00000000..aa8ad40a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/01_aaa_configure.j2 @@ -0,0 +1,15 @@ +os10_aaa: + tacacs_server: + host: + - ip: 10.10.10.10 + key: 0 + value: "aaaa" + auth_port: 3 + state: present + aaa_authentication: + login: + - console: true + type: group radius group tacacs+ local + state: present + re_authenticate: false + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/02_aaa_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/02_aaa_update.j2 new file mode 100644 index 00000000..89728ab9 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/02_aaa_update.j2 @@ -0,0 +1,24 @@ +os10_aaa: + radius_server: + retransmit: 6 + timeout: 9 + host: + - ip: 10.10.10.10 + key: 0 + value: "abc" + auth_port: 3 + state: present + tacacs_server: + host: + - ip: 10.10.10.10 + key: 0 + value: "aaaa" + auth_port: 3 + state: present + aaa_authentication: + login: + - console: true + type: group radius group tacacs+ local + state: present + re_authenticate: false + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/03_aaa_empty_string.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/03_aaa_empty_string.j2 new file mode 100644 index 00000000..1950e499 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/03_aaa_empty_string.j2 @@ -0,0 +1,24 @@ +os10_aaa: + radius_server: + retransmit: + timeout: + host: + - ip: 10.10.10.10 + key: + value: "abc" + auth_port: + state: present + tacacs_server: + host: + - ip: 10.10.10.10 + key: 0 + value: "aaaa" + auth_port: 3 + state: present + aaa_authentication: + login: + - console: true + type: group radius group tacacs+ local + state: "absent" + re_authenticate: false + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/04_aaa_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/04_aaa_absent.j2 new file mode 100644 index 00000000..b7a86a2d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/04_aaa_absent.j2 @@ -0,0 +1,23 @@ +os10_aaa: + radius_server: + retransmit: 6 + timeout: 9 + host: + - ip: 10.10.10.10 + key: 0 + value: "abc" + auth_port: 3 + state: absent + tacacs_server: + host: + - ip: 10.10.10.10 + key: 0 + value: "aaaa" + auth_port: 3 + state: absent + aaa_authentication: + login: + - console: true + type: group radius group tacacs+ local + state: "absent" + re_authenticate: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/05_aaa_stateless.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/05_aaa_stateless.j2 new file mode 100644 index 00000000..8beb9cc1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/05_aaa_stateless.j2 @@ -0,0 +1,20 @@ +os10_aaa: + radius_server: + retransmit: 6 + timeout: 9 + host: + - ip: 10.10.10.10 + key: 0 + value: "abc" + auth_port: 3 + tacacs_server: + host: + - ip: 10.10.10.10 + key: 0 + value: "aaaa" + auth_port: 3 + aaa_authentication: + login: + - console: true + type: group radius group tacacs+ local + re_authenticate: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/teardown.j2 new file mode 100644 index 00000000..d9fa0fe4 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/templates/aaa_basic/steps/teardown.j2 @@ -0,0 +1,23 @@ +os10_aaa: + radius_server: + retransmit: + timeout: + host: + - ip: 10.10.10.10 + key: 0 + value: "abc" + auth_port: 3 + state: absent + tacacs_server: + host: + - ip: 10.10.10.10 + key: 0 + value: "aaaa" + auth_port: 3 + state: absent + aaa_authentication: + login: + - console: true + type: group radius group tacacs+ local + state: "absent" + re_authenticate: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tests/aaa_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tests/aaa_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/tests/aaa_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/vars/main.yaml new file mode 100644 index 00000000..3e7e9546 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_aaa_role/vars/main.yaml @@ -0,0 +1,2 @@ +test_roles: + - dellemc.os10.os10_aaa diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/01_acl_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/01_acl_config.j2 new file mode 100644 index 00000000..f3a5d7b8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/01_acl_config.j2 @@ -0,0 +1,23 @@ +idempotent: true + +os10_acl: + - name: ssh + type: ipv4 + description: acl + remark: + - description: 1 + number: 2 + state: present + entries: + - number: 14 + permit: true + protocol: tcp + source: any + src_condition: neq 6 + destination: any + dest_condition: eq 4 + other_options: count + state: present + lineterminal: + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/02_acl_stage.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/02_acl_stage.j2 new file mode 100644 index 00000000..db65b97f --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/02_acl_stage.j2 @@ -0,0 +1,17 @@ +idempotent: false + +os10_acl: + - name: ssh + type: ipv4 + description: acl + stage_ingress: + - name: "{{ os10_interface_1 }}" + state: present + - name: "{{ os10_interface_2 }}" + state: present + stage_egress: + - name: "{{ os10_interface_3 }}" + state: present + lineterminal: + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/03_acl_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/03_acl_update.j2 new file mode 100644 index 00000000..0d9f1834 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/03_acl_update.j2 @@ -0,0 +1,31 @@ +idempotent: false + +os10_acl: + - name: ssh + type: ipv4 + description: acl ssh + remark: + - description: acl remark + number: 3 + state: present + entries: + - number: 15 + permit: false + protocol: udp + source: any + src_condition: gt 4 + destination: any + dest_condition: lt 5 + other_options: fragment + state: present + stage_ingress: + - name: "{{ os10_interface_1 }}" + state: present + - name: "{{ os10_interface_2 }}" + state: present + stage_egress: + - name: "{{ os10_interface_3 }}" + state: present + lineterminal: + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/04_acl_suboptions_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/04_acl_suboptions_absent.j2 new file mode 100644 index 00000000..afa89bbf --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/04_acl_suboptions_absent.j2 @@ -0,0 +1,30 @@ +idempotent: false +os10_acl: + - name: ssh + type: ipv4 + description: acl ssh + remark: + - description: acl remark + number: 3 + state: absent + entries: + - number: 15 + permit: false + protocol: udp + source: any + src_condition: gt 4 + destination: any + dest_condition: lt 5 + other_options: fragment + state: absent + stage_ingress: + - name: "{{ os10_interface_1 }}" + state: absent + - name: "{{ os10_interface_2 }}" + state: absent + stage_egress: + - name: "{{ os10_interface_3 }}" + state: absent + lineterminal: + state: absent + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/05_acl_suboptions_stateless.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/05_acl_suboptions_stateless.j2 new file mode 100644 index 00000000..518758d1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/05_acl_suboptions_stateless.j2 @@ -0,0 +1,34 @@ +idempotent: false + +os10_acl: + - name: ssh + type: ipv4 + description: acl ssh + remark: + - description: acl remark + number: 3 + entries: + - number: 14 + permit: true + protocol: tcp + source: any + src_condition: neq 6 + destination: any + dest_condition: eq 4 + other_options: count + - number: 15 + permit: false + protocol: udp + source: any + src_condition: gt 4 + destination: any + dest_condition: lt 5 + other_options: fragment + stage_ingress: + - name: "{{ os10_interface_1 }}" + - name: "{{ os10_interface_2 }}" + stage_egress: + - name: "{{ os10_interface_3 }}" + lineterminal: + state: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/06_acl_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/06_acl_absent.j2 new file mode 100644 index 00000000..9bce3bf0 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/06_acl_absent.j2 @@ -0,0 +1,7 @@ +idempotent: false + +os10_acl: + - name: ssh + type: ipv4 + description: acl ssh + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/07_acl_stateless.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/07_acl_stateless.j2 new file mode 100644 index 00000000..9381300e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/07_acl_stateless.j2 @@ -0,0 +1,24 @@ +idempotent: false +os10_acl: + - name: ssh + type: ipv4 + description: acl ssh + remark: + - description: acl remark + number: 3 + entries: + - number: 14 + permit: true + protocol: tcp + source: any + src_condition: neq 6 + destination: any + dest_condition: eq 4 + other_options: count + stage_ingress: + - name: "{{ os10_interface_1 }}" + - name: "{{ os10_interface_2 }}" + stage_egress: + - name: "{{ os10_interface_3 }}" + lineterminal: + state: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/teardown.j2 new file mode 100644 index 00000000..2fcc4b18 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/templates/acl_basic/steps/teardown.j2 @@ -0,0 +1,29 @@ +os10_acl: + - name: ssh + type: ipv4 + description: acl ssh + remark: + - description: acl remark + number: 3 + state: absent + entries: + - number: 15 + permit: false + protocol: udp + source: any + src_condition: gt 4 + destination: any + dest_condition: lt 5 + other_options: fragment + state: absent + stage_ingress: + - name: "{{ os10_interface_1 }}" + state: absent + - name: "{{ os10_interface_2 }}" + state: absent + stage_egress: + - name: "{{ os10_interface_3 }}" + state: absent + lineterminal: + state: absent + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tests/acl_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tests/acl_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/tests/acl_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/vars/main.yaml new file mode 100644 index 00000000..b40350ab --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_acl_role/vars/main.yaml @@ -0,0 +1,5 @@ +test_roles: + - dellemc.os10.os10_acl + +idempotent_roles: + - dellemc.os10.os10_acl diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/01_bgp_default_vrf_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/01_bgp_default_vrf_config.j2 new file mode 100644 index 00000000..947bca96 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/01_bgp_default_vrf_config.j2 @@ -0,0 +1,191 @@ +idempotent: false +os10_bgp: + asn: 12 + router_id: 90.1.1.4 + maxpath_ibgp: 2 + maxpath_ebgp: 2 + graceful_restart: true + log_neighbor_changes: true + fast_ext_fallover: true + always_compare_med: true + default_loc_pref: 1000 + as_notation: asdot + enforce_first_as: true + non_deterministic_med: true + outbound_optimization: true + confederation: + identifier: 25 + peers: 23 24 + peers_state: present + route_reflector: + client_to_client: true + cluster_id: 4294967295 + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: present + summary_only: true + dampening: + value: 15 750 2000 60 + route_map: qq + state: present + ibgp_redist_internal: + state: present + default_metric: 10 + distance_bgp: + value: 3 4 6 + state: present + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: present + summary_only: true + ibgp_redist_internal: + state: present + best_path: + as_path: ignore + as_path_state: present + ignore_router_id: true + med: + - attribute: confed + state: present + ipv4_network: + - address: 101.1.1.0/30 + state: present + ipv6_network: + - address: "2001:4898:5808:ffa0::/126" + state: present + neighbor: + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: present + address_family: + - type: ipv4 + activate: true + state: present + max_prefix: + count: 20 + threshold: 90 + warning: true + state: present + listen: + - subnet: 4.4.4.4/32 + limit: 4 + subnet_state: present + - subnet: 20::/64 + limit: 4 + subnet_state: present + - name: ibgp_pg + type: peergroup + weight: 10 + state: present + - type: ipv4 + interface: vlan20 + send_community: + - type: extended + state: present + address_family: + - type: l2vpn + activate: true + state: present + admin: up + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 11 + ip: 192.168.10.1 + peergroup: peer1 + peergroup_state: present + peergroup_type: ibgp + adv_interval: 40 + fall_over: present + password: bgppassword + route_reflector_client: true + adv_start: 100 + adv_start_state: present + conn_retry_timer: 20 + remove_pri_as: present + address_family: + - type: ipv4 + activate: true + state: present + max_prefix: + count: 10 + threshold: 40 + warning: true + state: present + default_originate: + route_map: aa + state: present + distribute_list: + in: XX + in_state: present + out: YY + out_state: present + send_community: + - type: standard + state: present + state: present + - type: ipv4 + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.12.3 + address_family: + - type: ipv4 + activate: true + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + add_path: both 3 + route_map: + - name: qq + filter: in + state: present + state: present + state: present + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: present + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: present + sender_loop_detect: true + password: bgppassword + address_family: + - type: ipv4 + activate: true + sender_loop_detect: true + state: present + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + - type: l2vpn + activate: true + sender_loop_detect: true + state: present + send_community: + - type: standard + state: present + admin: up + state: present + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: present + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/02_bgp_default_vrf_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/02_bgp_default_vrf_unconfig.j2 new file mode 100644 index 00000000..0e4f173c --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/02_bgp_default_vrf_unconfig.j2 @@ -0,0 +1,185 @@ +idempotent: false +os10_bgp: + asn: 12 + router_id: + maxpath_ibgp: + maxpath_ebgp: + graceful_restart: false + log_neighbor_changes: false + fast_ext_fallover: false + always_compare_med: false + default_loc_pref: + as_notation: asdot + enforce_first_as: false + non_deterministic_med: false + outbound_optimization: false + confederation: + identifier: 25 + peers: 23 24 + peers_state: absent + route_reflector: + client_to_client: false + cluster_id: + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: absent + summary_only: false + dampening: + value: 15 750 2000 60 + route_map: qq + state: absent + ibgp_redist_internal: + state: absent + default_metric: + distance_bgp: + value: 3 4 6 + state: absent + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: absent + summary_only: false + ibgp_redist_internal: + state: absent + best_path: + as_path: ignore + as_path_state: absent + ignore_router_id: false + med: + - attribute: confed + state: absent + neighbor: + - type: ipv4 + interface: vlan20 + send_community: + - type: extended + state: absent + address_family: + - type: l2vpn + activate: false + state: absent + admin: up + state: absent + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 11 + ip: 192.168.10.1 + peergroup: peer1 + peergroup_state: absent + peergroup_type: ibgp + adv_interval: 40 + fall_over: absent + password: bgppassword + route_reflector_client: false + adv_start: 100 + adv_start_state: absent + conn_retry_timer: 20 + remove_pri_as: absent + address_family: + - type: ipv4 + activate: false + state: absent + max_prefix: + count: 10 + threshold: 40 + warning: false + state: absent + default_originate: + route_map: aa + state: absent + distribute_list: + in: XX + in_state: absent + out: YY + out_state: absent + send_community: + - type: standard + state: absent + state: absent + - type: ipv4 + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.12.3 + address_family: + - type: ipv4 + activate: false + allow_as_in: 5 + next_hop_self: false + soft_reconf: false + add_path: both 3 + route_map: + - name: qq + filter: in + state: absent + state: absent + state: absent + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: absent + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: absent + sender_loop_detect: false + password: bgppassword + address_family: + - type: ipv4 + activate: false + sender_loop_detect: false + state: absent + allow_as_in: 5 + next_hop_self: false + soft_reconf: false + - type: l2vpn + activate: false + sender_loop_detect: false + state: absent + send_community: + - type: standard + state: absent + admin: up + state: absent + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: absent + address_family: + - type: ipv4 + activate: false + state: absent + max_prefix: + count: 20 + threshold: 90 + warning: false + state: absent + listen: + - subnet: 4.4.4.4/32 + limit: 4 + subnet_state: absent + - subnet: 20::/64 + limit: 4 + subnet_state: absent + - name: ibgp_pg + type: peergroup + weight: 10 + state: absent + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: absent + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: absent + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/03_bgp_non_default_vrf_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/03_bgp_non_default_vrf_config.j2 new file mode 100644 index 00000000..1ec5c308 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/03_bgp_non_default_vrf_config.j2 @@ -0,0 +1,153 @@ +idempotent: false +os10_bgp: + asn: 12 + vrfs: + - name: "GREEN" + router_id: 50.1.1.1 + maxpath_ibgp: 2 + maxpath_ebgp: 2 + graceful_restart: true + log_neighbor_changes: true + fast_ext_fallover: true + always_compare_med: true + default_loc_pref: 1000 + route_reflector: + client_to_client: true + cluster_id: 1 + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: present + dampening: + value: 15 750 2000 60 + route_map: qq + state: present + ibgp_redist_internal: + state: present + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: present + summary_only: true + ibgp_redist_internal: + state: present + best_path: + as_path: ignore + as_path_state: present + ignore_router_id: true + med: + - attribute: confed + state: present + - attribute: missing-as-worst + state: present + ipv4_network: + - address: 101.1.1.0/30 + state: present + ipv6_network: + - address: "2001:4898:5808:ffa0::/126" + state: present + neighbor: + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: present + - name: ibgp_pg + type: peergroup + weight: 10 + state: present + - type: ipv4 + interface: vlan10 + description: "U_site2 vlan" + send_community: + - type: extended + state: present + admin: up + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 11 + ip: 192.168.20.1 + name: peer1 + peergroup: peer1 + peergroup_state: present + peergroup_type: ibgp + adv_interval: 40 + fall_over: present + route_reflector_client: true + address_family: + - type: ipv4 + activate: true + state: present + send_community: + - type: standard + state: present + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.15.3 + address_family: + - type: ipv4 + activate: true + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + add_path: both 3 + route_map: + - name: qq + filter: in + state: present + state: present + state: present + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: present + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: present + address_family: + - type: ipv4 + activate: true + sender_loop_detect: true + state: present + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + send_community: + - type: standard + state: present + admin: up + state: present + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: present + - route_type: connected + route_map_name: bb + address_type: ipv4 + state: present + - route_type: l2vpn + route_map_name: cc + address_type: ipv4 + state: present + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: present + state: present + - name: "BLUE" + router_id: 6.6.6.6 + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/04_bgp_non_default_vrf_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/04_bgp_non_default_vrf_unconfig.j2 new file mode 100644 index 00000000..69d90add --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/04_bgp_non_default_vrf_unconfig.j2 @@ -0,0 +1,147 @@ +idempotent: false +os10_bgp: + asn: 12 + vrfs: + - name: "GREEN" + router_id: + maxpath_ibgp: + maxpath_ebgp: + graceful_restart: false + log_neighbor_changes: false + fast_ext_fallover: false + always_compare_med: false + default_loc_pref: 1000 + route_reflector: + client_to_client: false + cluster_id: + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: absent + dampening: + value: 15 750 2000 60 + route_map: qq + state: absent + ibgp_redist_internal: + state: absent + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: absent + summary_only: false + ibgp_redist_internal: + state: absent + best_path: + as_path: ignore + as_path_state: absent + ignore_router_id: false + med: + - attribute: confed + state: absent + - attribute: missing-as-worst + state: absent + neighbor: + - type: ipv4 + interface: vlan10 + description: "U_site2 vlan" + send_community: + - type: extended + state: absent + admin: up + state: absent + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 11 + ip: 192.168.20.1 + name: peer1 + peergroup: peer1 + peergroup_state: absent + peergroup_type: ibgp + adv_interval: 40 + fall_over: absent + route_reflector_client: false + address_family: + - type: ipv4 + activate: false + state: absent + send_community: + - type: standard + state: absent + state: absent + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.15.3 + address_family: + - type: ipv4 + activate: false + allow_as_in: 5 + next_hop_self: false + soft_reconf: false + add_path: both 3 + route_map: + - name: qq + filter: in + state: absent + state: absent + state: absent + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: absent + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: absent + address_family: + - type: ipv4 + activate: false + sender_loop_detect: false + state: absent + allow_as_in: 5 + next_hop_self: false + soft_reconf: false + send_community: + - type: standard + state: absent + admin: up + state: absent + - name: peer1 + type: peergroup + bfd: yes + state: absent + - name: ebgp_pg + type: peergroup + bfd: yes + state: absent + - name: ibgp_pg + type: peergroup + weight: 10 + state: absent + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: absent + - route_type: connected + route_map_name: bb + address_type: ipv4 + state: absent + - route_type: l2vpn + route_map_name: cc + address_type: ipv4 + state: absent + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: absent + state: present + - name: "BLUE" + router_id: + state: absent + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/05_bgp_default_non_default_vrf_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/05_bgp_default_non_default_vrf_config.j2 new file mode 100644 index 00000000..cd530af4 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/05_bgp_default_non_default_vrf_config.j2 @@ -0,0 +1,314 @@ +idempotent: true +os10_bgp: + asn: 12 + router_id: 90.1.1.4 + maxpath_ibgp: 2 + maxpath_ebgp: 2 + graceful_restart: true + always_compare_med: true + default_loc_pref: 1000 + as_notation: asdot + non_deterministic_med: true + outbound_optimization: true + confederation: + identifier: 25 + peers: 23 24 + peers_state: present + route_reflector: + cluster_id: 4294967295 + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: present + summary_only: true + dampening: + value: 15 750 2000 60 + route_map: qq + state: present + ibgp_redist_internal: + state: present + default_metric: 10 + distance_bgp: + value: 3 4 6 + state: present + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: present + summary_only: true + ibgp_redist_internal: + state: present + best_path: + as_path: ignore + as_path_state: present + ignore_router_id: true + med: + - attribute: confed + state: present + ipv4_network: + - address: 101.1.1.0/30 + state: present + ipv6_network: + - address: "2001:4898:5808:ffa0::/126" + state: present + neighbor: + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: present + address_family: + - type: ipv4 + state: present + max_prefix: + count: 20 + threshold: 90 + warning: true + state: present + listen: + - subnet: 4.4.4.4/32 + limit: 4 + subnet_state: present + - subnet: 20::/64 + limit: 4 + subnet_state: present + - name: ibgp_pg + type: peergroup + weight: 10 + state: present + - type: ipv4 + interface: vlan20 + send_community: + - type: extended + state: present + address_family: + - type: l2vpn + state: present + admin: up + state: present + - type: ipv4 + remote_asn: 11 + ip: 192.168.10.1 + peergroup: peer1 + peergroup_state: present + peergroup_type: ibgp + adv_interval: 40 + fall_over: present + route_reflector_client: true + adv_start: 100 + adv_start_state: present + conn_retry_timer: 20 + remove_pri_as: present + address_family: + - type: ipv4 + state: present + max_prefix: + count: 10 + threshold: 40 + warning: true + state: present + default_originate: + route_map: aa + state: present + distribute_list: + in: XX + in_state: present + out: YY + out_state: present + send_community: + - type: standard + state: present + state: present + - type: ipv4 + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.12.3 + address_family: + - type: ipv4 + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + add_path: both 3 + route_map: + - name: qq + filter: in + state: present + state: present + state: present + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: present + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: present + address_family: + - type: ipv4 + state: present + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + - type: l2vpn + state: present + send_community: + - type: standard + state: present + admin: up + state: present + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: present + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: present + vrfs: + - name: "GREEN" + router_id: 50.1.1.1 + maxpath_ibgp: 2 + maxpath_ebgp: 2 + graceful_restart: true + always_compare_med: true + default_loc_pref: 1000 + route_reflector: + cluster_id: 1 + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: present + dampening: + value: 15 750 2000 60 + route_map: qq + state: present + ibgp_redist_internal: + state: present + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: present + summary_only: true + ibgp_redist_internal: + state: present + best_path: + as_path: ignore + as_path_state: present + ignore_router_id: true + med: + - attribute: confed + state: present + - attribute: missing-as-worst + state: present + ipv4_network: + - address: 101.1.1.0/30 + state: present + ipv6_network: + - address: "2001:4898:5808:ffa0::/126" + state: present + neighbor: + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: present + - name: ibgp_pg + type: peergroup + weight: 10 + state: present + - type: ipv4 + interface: vlan10 + description: U_site2 vlan + send_community: + - type: extended + state: present + admin: up + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 11 + ip: 192.168.20.1 + name: peer1 + peergroup: peer1 + peergroup_state: present + peergroup_type: ibgp + adv_interval: 40 + fall_over: present + route_reflector_client: true + address_family: + - type: ipv4 + state: present + send_community: + - type: standard + state: present + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.15.3 + address_family: + - type: ipv4 + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + add_path: both 3 + route_map: + - name: qq + filter: in + state: present + state: present + state: present + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: present + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: present + address_family: + - type: ipv4 + state: present + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + send_community: + - type: standard + state: present + admin: up + state: present + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: present + - route_type: connected + route_map_name: bb + address_type: ipv4 + state: present + - route_type: l2vpn + route_map_name: cc + address_type: ipv4 + state: present + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: present + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/06_bgp_default_non_default_vrf_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/06_bgp_default_non_default_vrf_unconfig.j2 new file mode 100644 index 00000000..1fa12ee2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/06_bgp_default_non_default_vrf_unconfig.j2 @@ -0,0 +1,313 @@ +idempotent: false +os10_bgp: + asn: 12 + router_id: 90.1.1.4 + maxpath_ibgp: 2 + maxpath_ebgp: 2 + graceful_restart: true + log_neighbor_changes: true + always_compare_med: true + default_loc_pref: 1000 + as_notation: asdot + non_deterministic_med: true + outbound_optimization: true + confederation: + identifier: 25 + peers: 23 24 + peers_state: present + route_reflector: + cluster_id: 4294967295 + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: present + summary_only: true + dampening: + value: 15 750 2000 60 + route_map: qq + state: present + ibgp_redist_internal: + state: present + default_metric: 10 + distance_bgp: + value: 3 4 6 + state: present + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: present + summary_only: true + ibgp_redist_internal: + state: present + best_path: + as_path: ignore + as_path_state: present + ignore_router_id: true + med: + - attribute: confed + state: present + neighbor: + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: present + address_family: + - type: ipv4 + state: present + max_prefix: + count: 20 + threshold: 90 + warning: true + state: present + listen: + - subnet: 4.4.4.4/32 + limit: 4 + subnet_state: present + - subnet: 20::/64 + limit: 4 + subnet_state: present + - name: ibgp_pg + type: peergroup + weight: 10 + state: present + - type: ipv4 + interface: vlan20 + send_community: + - type: extended + state: present + address_family: + - type: l2vpn + activate: true + state: present + admin: up + state: present + - type: ipv4 + description: "U_site2-spine1" + remote_asn: 11 + ip: 192.168.10.1 + peergroup: peer1 + peergroup_state: present + peergroup_type: ibgp + adv_interval: 40 + fall_over: present + password: bgppassword + route_reflector_client: true + adv_start: 100 + adv_start_state: present + conn_retry_timer: 20 + remove_pri_as: present + address_family: + - type: ipv4 + activate: true + state: present + max_prefix: + count: 10 + threshold: 40 + warning: true + state: present + default_originate: + route_map: aa + state: present + distribute_list: + in: XX + in_state: present + out: YY + out_state: present + send_community: + - type: standard + state: present + state: present + - type: ipv4 + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.12.3 + address_family: + - type: ipv4 + activate: true + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + add_path: both 3 + route_map: + - name: qq + filter: in + state: present + state: present + state: present + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: present + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: present + sender_loop_detect: true + password: bgppassword + address_family: + - type: ipv4 + activate: true + sender_loop_detect: true + state: present + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + - type: l2vpn + activate: true + state: present + send_community: + - type: standard + state: present + admin: up + state: present + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: present + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: present + vrfs: + - name: "GREEN" + router_id: 50.1.1.1 + maxpath_ibgp: 2 + maxpath_ebgp: 2 + graceful_restart: true + always_compare_med: true + default_loc_pref: 1000 + route_reflector: + cluster_id: 1 + address_family_ipv4: + aggregate_address: + - ip_and_mask: 1.1.1.1/16 + state: present + dampening: + value: 15 750 2000 60 + route_map: qq + state: present + ibgp_redist_internal: + state: present + address_family_ipv6: + aggregate_address: + - ip_and_mask: 2001:4898:5808:ffa0::/126 + state: present + summary_only: true + ibgp_redist_internal: + state: present + best_path: + as_path: ignore + as_path_state: present + ignore_router_id: true + med: + - attribute: confed + state: present + - attribute: missing-as-worst + state: present + neighbor: + - name: peer1 + type: peergroup + bfd: yes + state: present + - name: ebgp_pg + type: peergroup + bfd: yes + state: present + - name: ibgp_pg + type: peergroup + weight: 10 + state: present + - type: ipv4 + interface: vlan10 + description: U_site2 vlan + send_community: + - type: extended + state: present + admin: up + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 11 + ip: 192.168.20.1 + name: peer1 + peergroup: peer1 + peergroup_state: present + peergroup_type: ibgp + adv_interval: 40 + fall_over: present + route_reflector_client: true + address_family: + - type: ipv4 + state: present + send_community: + - type: standard + state: present + state: present + - type: ipv4 + description: "U_site2 spine1" + remote_asn: 13 + local_as: 10 + weight: 10 + ip: 192.168.15.3 + address_family: + - type: ipv4 + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + add_path: both 3 + route_map: + - name: qq + filter: in + state: present + state: present + state: present + - type: ipv6 + remote_asn: 14 + ip: 2001:4898:5808:ffa2::1 + state: present + - type: ipv6 + description: "U_site2-spine1-Auto Discovered peers" + auto_peer: unnumbered-auto + ibgp_peergroup: ibgp_pg + ibgp_peergroup_state: present + address_family: + - type: ipv4 + state: present + allow_as_in: 5 + next_hop_self: true + soft_reconf: true + send_community: + - type: standard + state: present + admin: up + state: present + redistribute: + - route_type: static + route_map_name: aa + address_type: ipv4 + state: present + - route_type: connected + route_map_name: bb + address_type: ipv4 + state: present + - route_type: l2vpn + route_map_name: cc + address_type: ipv4 + state: present + bfd_all_neighbors: + interval: 200 + min_rx: 200 + multiplier: 3 + role: active + state: present + state: present + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/setup.j2 new file mode 100644 index 00000000..ccf217d3 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/setup.j2 @@ -0,0 +1,13 @@ +os10_vrf: + vrfdetails: + - vrf_name: GREEN + state: present + - vrf_name: BLUE + state: present +os10_vlan: + vlan 10: + description: "red" + state: present + vlan 20: + description: "yellow" + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/teardown.j2 new file mode 100644 index 00000000..1c0d524e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/templates/bgp_vrf/steps/teardown.j2 @@ -0,0 +1,13 @@ +os10_vrf: + vrfdetails: + - vrf_name: GREEN + state: absent + - vrf_name: BLUE + state: absent +os10_vlan: + vlan 10: + description: "red" + state: absent + vlan 20: + description: "yellow" + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tests/bgp_vrf.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tests/bgp_vrf.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/tests/bgp_vrf.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/vars/main.yaml new file mode 100644 index 00000000..63123891 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_bgp_role/vars/main.yaml @@ -0,0 +1,7 @@ +test_roles: + - dellemc.os10.os10_vrf + - dellemc.os10.os10_vlan + - dellemc.os10.os10_bgp + +idempotent_roles: + - dellemc.os10.os10_bgp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tasks/cli.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tasks/cli.yaml new file mode 100644 index 00000000..8c11e106 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- 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/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/bad_operator.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/bad_operator.yaml new file mode 100644 index 00000000..879a3d3f --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/bad_operator.yaml" + +- name: test bad operator + os10_command: + commands: + - show version + - show interface ethernet 1/1/1 + wait_for: + - "result[0] contains 'Description : blah'" + 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/os10/tests/integration/targets/os10_command/tests/cli/contains.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/contains.yaml new file mode 100644 index 00000000..1aa70582 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/contains.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/contains.yaml" + +- name: test contains operator + os10_command: + commands: + - show version + - show interface ethernet 1/1/1 + wait_for: + - "result[0] contains OS10 Enterprise" + - "result[1] contains Ethernet " + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + +- debug: msg="END cli/contains.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/invalid.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/invalid.yaml new file mode 100644 index 00000000..0eff6170 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/invalid.yaml @@ -0,0 +1,26 @@ +--- +- debug: msg="START cli/invalid.yaml" + +- name: run invalid command + os10_command: + commands: ['show foo'] + register: result + ignore_errors: yes + +- assert: + that: + - "'Error: Unrecognized command' in result.msg" + +- name: run commands that include invalid command + os10_command: + commands: + - show version + - show foo + register: result + ignore_errors: yes + +- assert: + that: + - "'Error: Unrecognized command' in result.msg" + +- debug: msg="END cli/invalid.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/output.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/output.yaml new file mode 100644 index 00000000..0c85c0f8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/output.yaml @@ -0,0 +1,27 @@ +--- +- debug: msg="START cli/output.yaml" + +- name: get output for single command + os10_command: + commands: ['show version'] + register: result + +- assert: + that: + - "result.changed == false" + - "result.stdout is defined" + +- name: get output for multiple commands + os10_command: + commands: + - show version + - show interface Eth 1/1/1 + 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/os10/tests/integration/targets/os10_command/tests/cli/timeout.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/timeout.yaml new file mode 100644 index 00000000..65e5a82e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_command/tests/cli/timeout.yaml @@ -0,0 +1,18 @@ +--- +- debug: msg="START cli/timeout.yaml" + +- name: test bad condition + os10_command: + commands: + - show version + wait_for: + - "result[0] contains bad_value_string" + 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/os10/tests/integration/targets/os10_config/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tasks/cli.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tasks/cli.yaml new file mode 100644 index 00000000..d675462d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/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/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel.yaml new file mode 100644 index 00000000..d376e6eb --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START cli/sublevel.yaml" + +- name: setup test + os10_config: + lines: + - 'no ip access-list test' + match: none + +- name: configure sub level command + os10_config: + lines: ['seq 5 permit ip any any count byte'] + parents: ['ip access-list test'] + register: result + +- assert: + that: + - "result.changed == true" + - "'ip access-list test' in result.updates" + - "'seq 5 permit ip any any count byte' in result.updates" + +- name: configure sub level command idempotent check + os10_config: + lines: ['seq 5 permit ip any any count byte'] + parents: ['ip access-list test'] + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os10_config: + lines: + - 'no ip access-list test' + match: none + +- debug: msg="END cli/sublevel.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_block.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_block.yaml new file mode 100644 index 00000000..ad598f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_block.yaml @@ -0,0 +1,58 @@ +--- +- debug: msg="START cli/sublevel_block.yaml" + +- name: setup + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + parents: ['router bgp 10'] + before: ['no router bgp'] + after: ['exit'] + match: none + +- name: configure sub level command using block resplace + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + parents: ['router bgp 10'] + replace: block + after: ['exit'] + register: result + +- assert: + that: + - "result.changed == true" + - "'router bgp 10' in result.updates" + - "'neighbor 1.1.1.1' in result.updates" + - "'neighbor 1.1.1.2' in result.updates" + - "'neighbor 1.1.1.3' in result.updates" + - "'neighbor 1.1.1.4' in result.updates" + +- name: check sub level command using block replace + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + parents: ['router bgp 10'] + replace: block + after: ['exit'] + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os10_config: + lines: + - no router bgp + match: none + +- debug: msg="END cli/sublevel_block.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_exact.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_exact.yaml new file mode 100644 index 00000000..0093e4c7 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_exact.yaml @@ -0,0 +1,62 @@ +--- +- debug: msg="START cli/sublevel_exact.yaml" + +- name: setup + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + - neighbor 1.1.1.5 + parents: ['router bgp 10'] + before: ['no router bgp'] + after: ['exit'] + match: none + +- name: configure sub level command using exact match + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + parents: ['router bgp 10'] + after: ['exit'] + match: exact + register: result + +- assert: + that: + - "result.changed == true" + - "'router bgp 10' in result.updates" + - "'neighbor 1.1.1.1' in result.updates" + - "'neighbor 1.1.1.2' in result.updates" + - "'neighbor 1.1.1.3' in result.updates" + - "'neighbor 1.1.1.4' in result.updates" + - "'neighbor 1.1.1.5' not in result.updates" + +- name: check sub level command using exact match + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + - neighbor 1.1.1.5 + parents: ['router bgp 10'] + after: ['exit'] + match: exact + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os10_config: + lines: + - no router bgp + match: none + +- debug: msg="END cli/sublevel_exact.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_strict.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_strict.yaml new file mode 100644 index 00000000..38865340 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/sublevel_strict.yaml @@ -0,0 +1,59 @@ +--- +- debug: msg="START cli/sublevel_strict.yaml" + +- name: setup + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + - neighbor 1.1.1.5 + parents: ['router bgp 10'] + before: ['no router bgp'] + after: ['exit'] + match: none + +- name: configure sub level command using strict match + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.2 + - neighbor 1.1.1.3 + - neighbor 1.1.1.4 + parents: ['router bgp 10'] + match: strict + register: result + +- assert: + that: + - "result.changed == false" + +- name: check sub level command using strict match + os10_config: + lines: + - neighbor 1.1.1.1 + - neighbor 1.1.1.3 + - neighbor 1.1.1.2 + parents: ['router bgp 10'] + after: ['exit'] + match: strict + register: result + +- assert: + that: + - "result.changed == true" + - "'router bgp 10' in result.updates" + - "'neighbor 1.1.1.1' not in result.updates" + - "'neighbor 1.1.1.2' in result.updates" + - "'neighbor 1.1.1.3' in result.updates" + - "'neighbor 1.1.1.4' not in result.updates" + - "'neighbor 1.1.1.5' not in result.updates" + +- name: teardown + os10_config: + lines: + - no router bgp + match: none + +- debug: msg="END cli/sublevel_strict.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel.yaml new file mode 100644 index 00000000..c90037b1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel.yaml @@ -0,0 +1,33 @@ +--- +- debug: msg="START cli/toplevel.yaml" + +- name: setup + os10_config: + lines: ['hostname {{ inventory_hostname_short }}'] + match: none + +- name: configure top level command + os10_config: + lines: ['hostname foo'] + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + os10_config: + lines: ['hostname foo'] + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os10_config: + lines: ['hostname {{ inventory_hostname_short }}'] + match: none + +- debug: msg="END cli/toplevel.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_after.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_after.yaml new file mode 100644 index 00000000..7a50790f --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_after.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START cli/toplevel_after.yaml" + +- name: setup + os10_config: + lines: + - "snmp-server contact ansible" + - "hostname {{ inventory_hostname_short }}" + match: none + +- name: configure top level command with before + os10_config: + lines: ['hostname foo'] + after: ['snmp-server contact bar'] + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + os10_config: + lines: ['hostname foo'] + after: ['snmp-server contact foo'] + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os10_config: + lines: + - "no snmp-server contact" + - "hostname {{ inventory_hostname_short }}" + match: none + +- debug: msg="END cli/toplevel_after.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_before.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_before.yaml new file mode 100644 index 00000000..3af72fa8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_before.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START cli/toplevel_before.yaml" + +- name: setup + os10_config: + lines: + - "snmp-server contact ansible" + - "hostname {{ inventory_hostname_short }}" + match: none + +- name: configure top level command with before + os10_config: + lines: ['hostname foo'] + before: ['snmp-server contact bar'] + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + os10_config: + lines: ['hostname foo'] + before: ['snmp-server contact foo'] + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + os10_config: + lines: + - "no snmp-server contact" + - "hostname {{ inventory_hostname_short }}" + match: none + +- debug: msg="END cli/toplevel_before.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_nonidempotent.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_nonidempotent.yaml new file mode 100644 index 00000000..14ee21c3 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_config/tests/cli/toplevel_nonidempotent.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START cli/toplevel_nonidempotent.yaml" + +- name: setup + os10_config: + lines: ['hostname {{ inventory_hostname_short }}'] + match: none + +- name: configure top level command + os10_config: + lines: ['hostname foo'] + match: strict + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + os10_config: + lines: ['hostname foo'] + match: strict + register: result + +- assert: + that: + - "result.changed == true" + +- name: teardown + os10_config: + lines: ['hostname {{ inventory_hostname_short }}'] + match: none + +- debug: msg="END cli/toplevel_nonidempotent.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/01_ecmp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/01_ecmp_configure.j2 new file mode 100644 index 00000000..52d49ff2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/01_ecmp_configure.j2 @@ -0,0 +1,4 @@ +idempotent: true +os10_ecmp: + ecmp_group_max_paths: 3 + trigger_threshold: 50 diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/02_ecmp_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/02_ecmp_update.j2 new file mode 100644 index 00000000..6c0bb03f --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/02_ecmp_update.j2 @@ -0,0 +1,4 @@ +idempotent: true +os10_ecmp: + ecmp_group_max_paths: 29 + trigger_threshold: 86 diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/03_ecmp_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/03_ecmp_unconfig.j2 new file mode 100644 index 00000000..0187b2c1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/03_ecmp_unconfig.j2 @@ -0,0 +1,4 @@ +idempotent: false +os10_ecmp: + ecmp_group_max_paths: + trigger_threshold: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/teardown.j2 new file mode 100644 index 00000000..d2cb816a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/templates/ecmp_basic/steps/teardown.j2 @@ -0,0 +1,3 @@ +os10_ecmp: + ecmp_group_max_paths: + trigger_threshold: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tests/ecmp_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tests/ecmp_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/tests/ecmp_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/vars/main.yaml new file mode 100644 index 00000000..1ee0bd40 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ecmp_role/vars/main.yaml @@ -0,0 +1,5 @@ +test_roles: + - dellemc.os10.os10_ecmp + +idempotent_roles: + - dellemc.os10.os10_ecmp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tasks/cli.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tasks/cli.yaml new file mode 100644 index 00000000..8c11e106 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- 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/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tests/cli/facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tests/cli/facts.yaml new file mode 100644 index 00000000..d68efadc --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_facts/tests/cli/facts.yaml @@ -0,0 +1,45 @@ +--- +- debug: msg="START cli/facts.yaml" + +- name: test all facts + os10_facts: + gather_subset: + - all + register: result + +- assert: + that: + - "result.changed == false" + - "result.ansible_facts is defined" + - "result.ansible_facts.ansible_net_interfaces is defined" + - "result.ansible_facts.ansible_net_memfree_mb is defined" + - "result.ansible_facts.ansible_net_model is defined" + - "result.ansible_facts.ansible_net_servicetag is defined" + - "result.ansible_facts.ansible_net_version is defined" + +- name: test all facts except hardware + os10_facts: + gather_subset: + - "!hardware" + register: result + +- assert: + that: + - "result.changed == false" + - "result.ansible_facts.ansible_net_interfaces is defined" + - "result.ansible_facts.ansible_net_memfree_mb is not defined" + +- name: test interface facts + os10_facts: + gather_subset: + - interfaces + register: result + +- assert: + that: + - "result.changed == false" + - "result.ansible_facts.ansible_net_interfaces is defined" + - "result.ansible_facts.ansible_net_memfree_mb is not defined" + + +- debug: msg="END cli/facts.yaml" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/01_flow_monitor_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/01_flow_monitor_configure.j2 new file mode 100644 index 00000000..fb184583 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/01_flow_monitor_configure.j2 @@ -0,0 +1,14 @@ +os10_flow_monitor: + session 1: + session_type: local + description: "Discription goes here" + port_match: + - interface_name: {{ os10_interface_1 }} + location: source + state: present + - interface_name: {{ os10_interface_2 }} + location: destination + state: present + flow_based: true + shutdown: up + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/02_flow_monitory_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/02_flow_monitory_update.j2 new file mode 100644 index 00000000..2f20dd25 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/02_flow_monitory_update.j2 @@ -0,0 +1,16 @@ +os10_flow_monitor: + session 1: + session_type: local + description: "session1 desc" + port_match: + - interface_name: {{ os10_interface_1 }} + location: source + state: present + - interface_name: {{ os10_interface_2 }} + location: destination + state: present + flow_based: true + shutdown: down + state: present + session 2: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/03_flow_monitor_options_default.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/03_flow_monitor_options_default.j2 new file mode 100644 index 00000000..00225e2f --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/03_flow_monitor_options_default.j2 @@ -0,0 +1,16 @@ +os10_flow_monitor: + session 1: + session_type: local + description: + port_match: + - interface_name: {{ os10_interface_1 }} + location: + state: present + - interface_name: {{ os10_interface_2 }} + location: destination + state: present + flow_based: + shutdown: + state: present + session 2: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/setup.j2 new file mode 100644 index 00000000..c7eeeae1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/setup.j2 @@ -0,0 +1,3 @@ +os10_interface: + {{ os10_interface_2 }}: + switchport: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/teardown.j2 new file mode 100644 index 00000000..94690f2a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/templates/flow_monitor_basic/steps/teardown.j2 @@ -0,0 +1,23 @@ +test_roles: + - dellemc.os10.os10_flow_monitor + - dellemc.os10.os10_interface +os10_interface: + {{ os10_interface_2 }}: + switchport: true + portmode: access +os10_flow_monitor: + session 1: + session_type: local + description: "Discription goes here" + port_match: + - interface_name: {{ os10_interface_1 }} + location: source + state: absent + - interface_name: {{ os10_interface_2 }} + location: destination + state: absent + flow_based: true + shutdown: up + state: absent + session 2: + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tests/flow_monitor_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tests/flow_monitor_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/tests/flow_monitor_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/vars/main.yaml new file mode 100644 index 00000000..8183f282 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_flow_monitor_role/vars/main.yaml @@ -0,0 +1,3 @@ +test_roles: + - dellemc.os10.os10_interface + - dellemc.os10.os10_flow_monitor diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/01_interface_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/01_interface_config.j2 new file mode 100644 index 00000000..bb4364d6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/01_interface_config.j2 @@ -0,0 +1,6 @@ +os10_interface: + {{ os10_interface_1 }}: + desc: "Connected to Core 2" + mtu: 2500 + admin: up + switchport: False diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/02_interface_dynamic_ip.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/02_interface_dynamic_ip.j2 new file mode 100644 index 00000000..725cbded --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/02_interface_dynamic_ip.j2 @@ -0,0 +1,14 @@ +os10_interface: + {{ os10_interface_1 }}: + desc: "DHCP Ip" + mtu: 2500 + admin: up + switchport: False + ip_type_dynamic: True + ipv6_type_dynamic: True + {{ os10_interface_2 }}: + desc: "IPV6 Auto config" + mtu: 2000 + admin: up + switchport: False + ipv6_autoconfig: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/03_interface_static_ip.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/03_interface_static_ip.j2 new file mode 100644 index 00000000..74273ab0 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/03_interface_static_ip.j2 @@ -0,0 +1,12 @@ +os10_interface: + {{ os10_interface_1 }}: + desc: "Static Ip" + mtu: 2500 + portmode: + admin: up + switchport: False + ip_and_mask: 10.9.0.4/31 + ipv6_and_mask: 2001:4898:5809:faa2::10/126 + ipv6_autoconfig: false + ip_type_dynamic: false + ipv6_type_dynamic: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/04_interface_flowcontrol.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/04_interface_flowcontrol.j2 new file mode 100644 index 00000000..c77200ea --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/04_interface_flowcontrol.j2 @@ -0,0 +1,14 @@ +os10_interface: + {{ os10_interface_1 }}: + desc: "Static Ip" + mtu: 2500 + portmode: + admin: up + switchport: False + ip_and_mask: 10.9.0.4/31 + ipv6_and_mask: 2001:4898:5809:faa2::10/126 + ipv6_autoconfig: false + flowcontrol: + mode: "receive" + enable: "on" + state: "present" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/05_interface_switchport.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/05_interface_switchport.j2 new file mode 100644 index 00000000..a38709cc --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/05_interface_switchport.j2 @@ -0,0 +1,17 @@ +os10_interface: + {{ os10_interface_3 }}: + desc: "Switch port" + mtu: 3000 + portmode: trunk + admin: up + switchport: true + {{ os10_interface_1 }}: + ip_and_mask: + ipv6_and_mask: + ipv6_autoconfig: false + state_ipv6: absent + {{ os10_interface_2 }}: + ip_and_mask: + ipv6_and_mask: + ipv6_autoconfig: false + state_ipv6: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/06_interface_vlan.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/06_interface_vlan.j2 new file mode 100644 index 00000000..ea4414de --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/06_interface_vlan.j2 @@ -0,0 +1,17 @@ +test_roles: + - dellemc.os10.os10_vlan + - dellemc.os10.os10_interface + +os10_vlan: + vlan 10: + state: present + +os10_interface: + vlan 10: + ip_and_mask: + ipv6_and_mask: 2001:4898:5808:ffaf::1/64 + state_ipv6: present + ip_helper: + - ip: 10.0.0.33 + state: present + admin: up diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/07_interface_range.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/07_interface_range.j2 new file mode 100644 index 00000000..310dcd39 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/07_interface_range.j2 @@ -0,0 +1,4 @@ +os10_interface: + range ethernet {{ os10_interface_1.split()[1] }},{{ os10_interface_2.split()[1] }},{{ os10_interface_3.split()[1] }}: + mtu: 2500 + admin: up diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/teardown.j2 new file mode 100644 index 00000000..e51374b7 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/templates/interface_basic/steps/teardown.j2 @@ -0,0 +1,45 @@ +test_roles: + - dellemc.os10.os10_vlan + - dellemc.os10.os10_interface + +os10_vlan: + vlan 10: + state: absent + +os10_interface: + {{ os10_interface_1 }}: + desc: + mtu: + portmode: access + admin: down + switchport: true + ip_and_mask: + ipv6_and_mask: + ip_type_dynamic: false + ipv6_type_dynamic: false + ipv6_autoconfig: false + flowcontrol: + mode: receive + enable: off + state: absent + {{ os10_interface_2 }}: + desc: + mtu: + portmode: access + admin: down + switchport: true + ip_and_mask: + ipv6_and_mask: + ip_type_dynamic: false + ipv6_type_dynamic: false + ipv6_autoconfig: false + flowcontrol: + mode: receive + enable: off + state: absent + {{ os10_interface_3 }}: + desc: + mtu: + portmode: access + admin: down + switchport: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tests/interface_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tests/interface_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/tests/interface_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/vars/main.yaml new file mode 100644 index 00000000..ff3aa0eb --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_interface_role/vars/main.yaml @@ -0,0 +1,2 @@ +test_roles: + - dellemc.os10.os10_interface diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/01_lag_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/01_lag_configure.j2 new file mode 100644 index 00000000..fc74977a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/01_lag_configure.j2 @@ -0,0 +1,12 @@ +os10_lag: + Po 12: + type: dynamic + min_links: 2 + max_bundle_size: 2 + lacp_system_priority: 2 + channel_members: + - port: {{ os10_interface_1 }} + mode: "active" + port_priority: 3 + lacp_rate_fast: true + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/02_lag_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/02_lag_update.j2 new file mode 100644 index 00000000..e8c2338e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/02_lag_update.j2 @@ -0,0 +1,12 @@ +os10_lag: + Po 12: + type: dynamic + min_links: 32 + max_bundle_size: 32 + lacp_system_priority: 5 + channel_members: + - port: {{ os10_interface_1 }} + mode: passive + port_priority: 4 + lacp_rate_fast: false + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/03_lag_options_reset.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/03_lag_options_reset.j2 new file mode 100644 index 00000000..03d18fd2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/03_lag_options_reset.j2 @@ -0,0 +1,12 @@ +os10_lag: + Po 12: + type: dynamic + min_links: + max_bundle_size: + lacp_system_priority: + channel_members: + - port: {{ os10_interface_1 }} + mode: + port_priority: + lacp_rate_fast: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/04_lag_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/04_lag_absent.j2 new file mode 100644 index 00000000..c9e7b820 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/04_lag_absent.j2 @@ -0,0 +1,12 @@ +os10_lag: + Po 12: + type: dynamic + min_links: 2 + max_bundle_size: 2 + lacp_system_priority: 2 + channel_members: + - port: {{ os10_interface_1 }} + mode: "active" + port_priority: 3 + lacp_rate_fast: true + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/teardown.j2 new file mode 100644 index 00000000..09b6c3ea --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/templates/lag_basic/steps/teardown.j2 @@ -0,0 +1,12 @@ +os10_lag: + Po 12: + type: dynamic + min_links: 2 + max_bundle_size: 2 + lacp_system_priority: + channel_members: + - port: {{ os10_interface_1 }} + mode: "active" + port_priority: 3 + lacp_rate_fast: true + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tests/lag_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tests/lag_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/tests/lag_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/vars/main.yaml new file mode 100644 index 00000000..4b1840fa --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lag_role/vars/main.yaml @@ -0,0 +1,2 @@ +test_roles: + - dellemc.os10.os10_lag diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/01_lldp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/01_lldp_configure.j2 new file mode 100644 index 00000000..aa806694 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/01_lldp_configure.j2 @@ -0,0 +1,44 @@ +os10_lldp: + enable: true + multiplier: 3 + reinit: 2 + timer: 5 + advertise: + med: + fast_start_repeat_count: 4 + application: + - name: guest-voice + network_policy_id: 0 + vlan_id: 2 + vlan_type: tag + l2_priority: 3 + code_point_value: 4 + state: present + - name: voice + network_policy_id: 1 + vlan_id: 3 + vlan_type: untag + l2_priority: 3 + code_point_value: 4 + state: present + local_interface: + "{{ os10_interface_1 }}": + mode: rx + mode_state: present + advertise: + med: + enable: true + tlv: inventory + tlv_state: present + application: + - network_policy_id: 4 + state: present + tlv: + - name: basic-tlv + value: management-address port-description + state: present + - name: dcbxp-appln + value: iscsi + state: present + - name: dcbxp + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/02_lldp_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/02_lldp_update.j2 new file mode 100644 index 00000000..8b0272ab --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/02_lldp_update.j2 @@ -0,0 +1,44 @@ +os10_lldp: + enable: true + multiplier: 10 + reinit: 10 + timer: 15 + advertise: + med: + fast_start_repeat_count: 10 + application: + - name: guest-voice + network_policy_id: 1 + vlan_id: 5 + vlan_type: untag + l2_priority: 7 + code_point_value: 20 + state: present + - name: voice + network_policy_id: 1 + vlan_id: 3 + vlan_type: untag + l2_priority: 3 + code_point_value: 4 + state: present + local_interface: + "{{ os10_interface_1 }}": + mode: transmit + mode_state: present + advertise: + med: + enable: true + tlv: network-policy + tlv_state: present + application: + - network_policy_id: 5 + state: present + tlv: + - name: basic-tlv + value: management-address port-description + state: present + - name: dcbxp-appln + value: iscsi + state: present + - name: dcbxp + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/03_lldp_options_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/03_lldp_options_absent.j2 new file mode 100644 index 00000000..7ded6af6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/03_lldp_options_absent.j2 @@ -0,0 +1,44 @@ +os10_lldp: + enable: false + multiplier: 3 + reinit: 2 + timer: 5 + advertise: + med: + fast_start_repeat_count: 4 + application: + - name: guest-voice + network_policy_id: 0 + vlan_id: 2 + vlan_type: tag + l2_priority: 3 + code_point_value: 4 + state: present + - name: voice + network_policy_id: 1 + vlan_id: 3 + vlan_type: untag + l2_priority: 3 + code_point_value: 4 + state: absent + local_interface: + "{{ os10_interface_1 }}": + mode: rx + mode_state: present + advertise: + med: + enable: true + tlv: inventory + tlv_state: present + application: + - network_policy_id: 4 + state: absent + tlv: + - name: basic-tlv + value: management-address port-description + state: present + - name: dcbxp-appln + value: iscsi + state: present + - name: dcbxp + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/teardown.j2 new file mode 100644 index 00000000..9f372d8a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/templates/lldp_basic/steps/teardown.j2 @@ -0,0 +1,46 @@ +os10_lldp: + enable: true + multiplier: + reinit: + timer: + advertise: + med: + fast_start_repeat_count: + application: + - name: guest-voice + network_policy_id: 0 + vlan_id: 2 + vlan_type: tag + l2_priority: 3 + code_point_value: 4 + state: absent + - name: voice + network_policy_id: 1 + vlan_id: 3 + vlan_type: untag + l2_priority: 3 + code_point_value: 4 + state: absent + local_interface: + "{{ os10_interface_1 }}": + mode: rx + mode_state: present + advertise: + med: + enable: true + tlv: inventory + tlv_state: absent + application: + - network_policy_id: 4 + state: absent + - network_policy_id: 5 + state: absent + tlv: + - name: basic-tlv + value: management-address port-description + state: present + - name: dcbxp-appln + value: iscsi + state: present + - name: dcbxp + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tests/lldp_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tests/lldp_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/tests/lldp_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/vars/main.yaml new file mode 100644 index 00000000..031311ec --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_lldp_role/vars/main.yaml @@ -0,0 +1,2 @@ +test_roles: + - dellemc.os10.os10_lldp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/01_logging_enable.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/01_logging_enable.j2 new file mode 100644 index 00000000..75a47735 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/01_logging_enable.j2 @@ -0,0 +1,6 @@ +idempotent: true +os10_logging: + console: + severity: log-err + log_file: + severity: log-err diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/02_logging_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/02_logging_update.j2 new file mode 100644 index 00000000..ea10cb8e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/02_logging_update.j2 @@ -0,0 +1,6 @@ +idempotent: true +os10_logging: + console: + severity: log-debug + log_file: + severity: log-debug diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/03_logging_disable.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/03_logging_disable.j2 new file mode 100644 index 00000000..f34f7ced --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/03_logging_disable.j2 @@ -0,0 +1,8 @@ +idempotent: true +os10_logging: + console: + enable: false + severity: log-err + log_file: + enable: false + severity: log-err diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/04_logging_server_add.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/04_logging_server_add.j2 new file mode 100644 index 00000000..d714efd2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/04_logging_server_add.j2 @@ -0,0 +1,12 @@ +idempotent: false +os10_logging: + logging: + - ip: 1.1.1.1 + state: present + console: + enable: True + severity: log-err + log_file: + enable: True + severity: log-err + source_interface: "{{ os10_interface_1 }}" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/05_logging_server_del.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/05_logging_server_del.j2 new file mode 100644 index 00000000..992bafac --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/05_logging_server_del.j2 @@ -0,0 +1,12 @@ +idempotent: false +os10_logging: + logging: + - ip: 1.1.1.1 + state: absent + console: + enable: True + severity: log-err + log_file: + enable: True + severity: log-err + source_interface: "{{ os10_interface_1 }}" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/teardown.j2 new file mode 100644 index 00000000..d8d31880 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/templates/logging_basic/steps/teardown.j2 @@ -0,0 +1,11 @@ +os10_logging: + logging: + - ip: 1.1.1.1 + state: absent + console: + enable: True + severity: log-notice + log_file: + enable: True + severity: log-notice + source_interface: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tests/logging_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tests/logging_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/tests/logging_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/vars/main.yaml new file mode 100644 index 00000000..55afbe1d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_logging_role/vars/main.yaml @@ -0,0 +1,5 @@ +test_roles: + - dellemc.os10.os10_logging + +idempotent_roles: + - dellemc.os10.os10_logging diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/01_ntp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/01_ntp_configure.j2 new file mode 100644 index 00000000..35d8889a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/01_ntp_configure.j2 @@ -0,0 +1,24 @@ +os10_ntp: + source: "{{ os10_interface_1 }}" + master: 5 + authenticate: true + authentication_key: + - key_num: 123 + key_string_type: 0 + key_string: test + state: present + trusted_key: + - key_num: 1323 + state: present + server: + - ip: 2.2.2.2 + key: 345 + prefer: true + state: present + intf: + "{{ os10_interface_1 }}": + disable: true + broadcast: true + vrf: + name: red + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/02_ntp_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/02_ntp_update.j2 new file mode 100644 index 00000000..f2b11184 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/02_ntp_update.j2 @@ -0,0 +1,20 @@ +os10_ntp: + master: 4 + authenticate: false + authentication_key: + - key_num: 456 + key_string_type: 0 + key_string: ntptest + state: present + trusted_key: + - key_num: 4626 + state: present + server: + - ip: 2.2.2.2 + key: 567 + prefer: false + state: present + intf: + "{{ os10_interface_1 }}": + disable: false + broadcast: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/03_ntp_suboptions_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/03_ntp_suboptions_absent.j2 new file mode 100644 index 00000000..56aff6af --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/03_ntp_suboptions_absent.j2 @@ -0,0 +1,14 @@ +os10_ntp: + authentication_key: + - key_num: 456 + key_string_type: 0 + key_string: ntptest + state: absent + trusted_key: + - key_num: 4626 + state: absent + server: + - ip: 2.2.2.2 + key: 567 + prefer: false + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/04_ntp_suboptions_stateless.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/04_ntp_suboptions_stateless.j2 new file mode 100644 index 00000000..61c78472 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/04_ntp_suboptions_stateless.j2 @@ -0,0 +1,11 @@ +os10_ntp: + authentication_key: + - key_num: 456 + key_string_type: 0 + key_string: ntptest + trusted_key: + - key_num: 4626 + server: + - ip: 2.2.2.2 + key: 567 + prefer: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/05_ntp_empty_string.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/05_ntp_empty_string.j2 new file mode 100644 index 00000000..a2326521 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/05_ntp_empty_string.j2 @@ -0,0 +1,16 @@ +os10_ntp: + authenticate: '' + authentication_key: + - key_num: 456 + key_string_type: 0 + key_string: ntptest + trusted_key: + - key_num: 4626 + server: + - ip: 2.2.2.2 + key: 567 + prefer: '' + intf: + "{{ os10_interface_1 }}": + disable: '' + broadcast: '' diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/setup.j2 new file mode 100644 index 00000000..7ea26a0a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/setup.j2 @@ -0,0 +1,4 @@ +os10_vrf: + vrfdetails: + - vrf_name: red + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/teardown.j2 new file mode 100644 index 00000000..a916200c --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/templates/ntp_basic/steps/teardown.j2 @@ -0,0 +1,32 @@ +test_roles: + - dellemc.os10.os10_ntp + - dellemc.os10.os10_vrf +os10_ntp: + source: + master: + authenticate: + authentication_key: + - key_num: 123 + key_string_type: 0 + key_string: test + state: absent + trusted_key: + - key_num: 1323 + state: absent + server: + - ip: 2.2.2.2 + key: 345 + prefer: true + state: absent + intf: + "{{ os10_interface_1 }}": + disable: false + broadcast: false + vrf: + name: red + state: absent + +os10_vrf: + vrfdetails: + - vrf_name: red + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tests/ntp_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tests/ntp_basic.yaml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/tests/ntp_basic.yaml @@ -0,0 +1 @@ +--- diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/vars/main.yaml new file mode 100644 index 00000000..b42240dd --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_ntp_role/vars/main.yaml @@ -0,0 +1,3 @@ +test_roles: + - dellemc.os10.os10_vrf + - dellemc.os10.os10_ntp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/01_prefix_list_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/01_prefix_list_config.j2 new file mode 100644 index 00000000..4e9d912b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/01_prefix_list_config.j2 @@ -0,0 +1,17 @@ +idempotent: true +os10_prefix_list: + - name: testpl + type: ipv4 + description: pl + entries: + - number: 19 + permit: true + net_num: 20.0.0.0 + mask: 16 + condition_list: + - condition: ge + prelen: 17 + - condition: le + prelen: 18 + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/02_prefix_list_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/02_prefix_list_update.j2 new file mode 100644 index 00000000..3481d358 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/02_prefix_list_update.j2 @@ -0,0 +1,17 @@ +idempotent: true +os10_prefix_list: + - name: testpl + type: ipv4 + description: prefixlistdesc + entries: + - number: 18 + permit: false + net_num: 20.0.0.0 + mask: 24 + condition_list: + - condition: le + prelen: 14 + - condition: ge + prelen: 13 + state: present + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/03_prefix_list_entry_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/03_prefix_list_entry_absent.j2 new file mode 100644 index 00000000..d14b8dda --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/03_prefix_list_entry_absent.j2 @@ -0,0 +1,17 @@ +idempotent: false +os10_prefix_list: + - name: testpl + type: ipv4 + description: pl + entries: + - number: 19 + permit: true + net_num: 20.0.0.0 + mask: 16 + condition_list: + - condition: ge + prelen: 17 + - condition: le + prelen: 18 + state: absent + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/04_prefix_list_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/04_prefix_list_absent.j2 new file mode 100644 index 00000000..b349bd90 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/04_prefix_list_absent.j2 @@ -0,0 +1,16 @@ +os10_prefix_list: + - name: testpl + type: ipv4 + description: pl + entries: + - number: 19 + permit: true + net_num: 20.0.0.0 + mask: 16 + condition_list: + - condition: ge + prelen: 17 + - condition: le + prelen: 18 + state: absent + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/teardown.j2 new file mode 100644 index 00000000..b349bd90 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/templates/prefix_list_basic/steps/teardown.j2 @@ -0,0 +1,16 @@ +os10_prefix_list: + - name: testpl + type: ipv4 + description: pl + entries: + - number: 19 + permit: true + net_num: 20.0.0.0 + mask: 16 + condition_list: + - condition: ge + prelen: 17 + - condition: le + prelen: 18 + state: absent + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tests/prefix_list_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tests/prefix_list_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/tests/prefix_list_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/vars/main.yaml new file mode 100644 index 00000000..706b6a87 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_prefix_list_role/vars/main.yaml @@ -0,0 +1,5 @@ +test_roles: + - dellemc.os10.os10_prefix_list + +idempotent_roles: + - dellemc.os10.os10_prefix_list diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/01_qos_config.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/01_qos_config.j2 new file mode 100644 index 00000000..eec0f565 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/01_qos_config.j2 @@ -0,0 +1,10 @@ +idempotent: true +os10_qos: + policy_map: + - name: testpolicy + type: qos + state: present + class_map: + - name: testclas + type: qos + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/02_qos_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/02_qos_update.j2 new file mode 100644 index 00000000..ba593683 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/02_qos_update.j2 @@ -0,0 +1,10 @@ +idempotent: true +os10_qos: + policy_map: + - name: testpolicy + type: + state: present + class_map: + - name: testclas + type: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/03_qos_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/03_qos_unconfig.j2 new file mode 100644 index 00000000..3310a13e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/03_qos_unconfig.j2 @@ -0,0 +1,10 @@ +idempotent: false +os10_qos: + policy_map: + - name: testpolicy + type: + state: absent + class_map: + - name: testclas + type: + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/teardown.j2 new file mode 100644 index 00000000..2e7960c6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/templates/qos_basic/steps/teardown.j2 @@ -0,0 +1,9 @@ +os10_qos: + policy_map: + - name: testpolicy + type: + state: absent + class_map: + - name: testclas + type: + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tests/qos_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tests/qos_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/tests/qos_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/vars/main.yaml new file mode 100644 index 00000000..9a1913c9 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_qos_role/vars/main.yaml @@ -0,0 +1,5 @@ +test_roles: + - dellemc.os10.os10_qos + +idempotent_roles: + - dellemc.os10.os10_qos diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/01_route_map_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/01_route_map_configure.j2 new file mode 100644 index 00000000..1c0adec0 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/01_route_map_configure.j2 @@ -0,0 +1,48 @@ +idempotent: true +os10_route_map: + as_path: + - access_list: aa + permit: true + regex: www + state: present + community_list: + - type: standard + name: qqq + permit: false + community: internet + state: present + extcommunity_list: + - type: standard + name: qqq + permit: false + community: "rt 22:33" + state: present + route_map: + - name: test + permit: true + seq_num: 1 + continue: 20 + match: + - ip_type: ipv4 + access_group: testaccess + prefix_list: testprefix + set: + local_pref: 1200 + metric_type: type-1 + metric: + 30 + origin: igp + weight: 50 + next_hop: + - type: ip + address: 10.1.1.1 + track_id: 3 + state: present + community: internet + comm_list: + add: qq + delete: qqq + extcommunity: "22:33" + extcomm_list: + add: aa + delete: aa + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/02_route_map_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/02_route_map_update.j2 new file mode 100644 index 00000000..fb464397 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/02_route_map_update.j2 @@ -0,0 +1,48 @@ +idempotent: true +os10_route_map: + as_path: + - access_list: aa + permit: false + regex: abc + state: present + community_list: + - type: standard + name: qqq + permit: false + regex: internet + state: present + extcommunity_list: + - type: standard + name: qqq + permit: false + community: "rt 22:35" + state: present + route_map: + - name: test + permit: false + seq_num: 5 + continue: 20 + match: + - ip_type: ipv4 + access_group: testaccess + prefix_list: testprefix + set: + local_pref: 1500 + metric_type: type-1 + metric: "- 20" + origin: egp + weight: 60 + next_hop: + - type: ip + address: 10.1.1.1 + track_id: 3 + state: present + community: no-export + comm_list: + add: commstd + delete: commex + extcommunity: "25:37" + extcomm_list: + add: commstd + delete: commex + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/03_route_map_options_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/03_route_map_options_unconfig.j2 new file mode 100644 index 00000000..a10c5d0a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/03_route_map_options_unconfig.j2 @@ -0,0 +1,48 @@ +idempotent: false +os10_route_map: + as_path: + - access_list: aa + permit: + regex: www + state: present + community_list: + - type: standard + name: qqq + permit: + community: internet + state: present + extcommunity_list: + - type: standard + name: qqq + permit: + community: "rt 22:33" + state: present + route_map: + - name: test + permit: + seq_num: + continue: + match: + - ip_type: ipv4 + access_group: testaccess + prefix_list: testprefix + set: + local_pref: + metric_type: + metric: + origin: + weight: + next_hop: + - type: ip + address: 10.1.1.1 + track_id: 3 + state: present + community: + comm_list: + add: + delete: + extcommunity: + extcomm_list: + add: + delete: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/04_route_map_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/04_route_map_unconfig.j2 new file mode 100644 index 00000000..181d8823 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/04_route_map_unconfig.j2 @@ -0,0 +1,47 @@ +os10_route_map: + as_path: + - access_list: aa + permit: true + regex: www + state: absent + community_list: + - type: standard + name: qqq + permit: false + community: internet + state: absent + extcommunity_list: + - type: standard + name: qqq + permit: false + community: "rt 22:33" + state: absent + route_map: + - name: test + permit: true + seq_num: 1 + continue: 20 + match: + - ip_type: ipv4 + access_group: testaccess + prefix_list: testprefix + set: + local_pref: 1200 + metric_type: type-1 + metric: + 30 + origin: igp + weight: 50 + next_hop: + - type: ip + address: 10.1.1.1 + track_id: 3 + state: absent + community: internet + comm_list: + add: qq + delete: qqq + extcommunity: "22:33" + extcomm_list: + add: aa + delete: aa + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/teardown.j2 new file mode 100644 index 00000000..e7380b3d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/templates/route_map_basic/steps/teardown.j2 @@ -0,0 +1,47 @@ +os10_route_map: + as_path: + - access_list: aa + permit: true + regex: www + state: absent + community_list: + - type: standard + name: qqq + permit: false + community: internet + state: absent + extcommunity_list: + - type: standard + name: qqq + permit: false + community: "rt 22:33" + state: absent + route_map: + - name: test + permit: true + seq_num: 1 + continue: 20 + match: + - ip_type: ipv4 + access_group: testaccess + prefix_list: testprefix + set: + local_pref: 1200 + metric_type: internal + metric: + 30 + origin: igp + weight: 50 + next_hop: + - type: ip + address: 10.1.1.1 + track_id: 3 + state: absent + community: internet + comm_list: + add: qq + delete: qqq + extcommunity: "22:33" + extcomm_list: + add: aa + delete: aa + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tests/route_map_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tests/route_map_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/tests/route_map_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/vars/main.yaml new file mode 100644 index 00000000..85313472 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_route_map_role/vars/main.yaml @@ -0,0 +1,5 @@ +test_roles: + - dellemc.os10.os10_route_map + +idempotent_roles: + - dellemc.os10.os10_route_map diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/01_snmp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/01_snmp_configure.j2 new file mode 100644 index 00000000..bbc97642 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/01_snmp_configure.j2 @@ -0,0 +1,135 @@ +test_roles: + - dellemc.os10.os10_snmp +os10_snmp: + snmp_source_interface: mgmt 1/1/1 + snmp_location: Chennai + snmp_community: + - name: public + access_mode: ro + access_list: + name: test_acl + state: present + - name: test + access_mode: ro + access_list: + name: test_acl + state: present + state: present + snmp_traps: + - name: all + state: present + snmp_engine_id: 123456789 + snmp_remote_engine_id: + - host: 1.1.1.1 + engine_id: '0xab' + - host: 1.1.1.1 + engine_id: '0xcd' + udpport: 200 + - host: 2.1.1.1 + engine_id: '0xef' + udpport: 200 + snmp_vrf: red + snmp_group: + - name: group_1 + version: 1 + write_view: + name: view_2 + - name: group_2 + version: 2c + state: present + access_list: + name: test_acl + read_view: + name: view_1 + write_view: + name: view_2 + notify_view: + name: view_3 + - name: group_3 + version: 3 + security_level: auth + read_view: + name: view_1 + write_view: + name: view_2 + state: present + - name: group_4 + version: 3 + security_level: priv + notify_view: + name: view_1 + state: present + snmp_host: + - ip: 1.1.1.1 + communitystring: c1 + version: "2c" + udpport: 4 + state: present + - ip: 2.2.2.2 + version: 1 + communitystring: c3 + state: present + - ip: 2.1.1.1 + version: 1 + communitystring: c3 + trap_categories: + dom: true + entity: true + snmp: true + state: present + - ip: 3.1.1.1 + version: 3 + security_level: priv + security_name: test + notification_type: informs + udpport: 200 + trap_categories: + dom: true + entity: true + envmon: true + lldp: true + state: present + snmp_view: + - name: view_1 + oid_subtree: 2 + include: true + state: present + snmp_user: + - name: user_1 + group_name: group_1 + version: 3 + authentication: + localized: false + algorithm: md5 + password: 9fc53d9d908118b2804fe80e3ba8763d + encryption: + algorithm: aes + password: d0452401a8c3ce42804fe80e3ba8763d + state: present + - name: user_2 + group_name: group_1 + version: 3 + authentication: + localized: true + algorithm: md5 + password: '0x9fc53d9d908118b2804fe80e3ba8763d' + encryption: + algorithm: aes + password: '0xd0452401a8c3ce42804fe80e3ba8763d' + state: present + - name: user_3 + group_name: group_1 + version: 2c + state: present + - name: user_4 + group_name: group_1 + version: 3 + state: present + - name: user_5 + group_name: group_2 + version: 2c + remote: + ip: 1.1.1.1 + udpport: 200 + access_list: test_acl + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/02_snmp_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/02_snmp_update.j2 new file mode 100644 index 00000000..8c43046d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/02_snmp_update.j2 @@ -0,0 +1,144 @@ +os10_snmp: + snmp_source_interface: mgmt 1/1/1 + snmp_location: Chennai + snmp_community: + - name: public + access_mode: ro + access_list: + name: test_acl + state: absent + - name: test + access_mode: ro + access_list: + name: test_acl + state: present + state: present + snmp_traps: + - name: all + state: present + snmp_engine_id: 123456789 + snmp_remote_engine_id: + - host: 1.1.1.1 + engine_id: '0xab' + - host: 1.1.1.1 + engine_id: '0xcd' + udpport: 200 + - host: 2.1.1.1 + engine_id: '0xef' + udpport: 200 + snmp_vrf: red + snmp_group: + - name: group_1 + version: 1 + access_list: + name: test_acl + read_view: + name: view_1 + write_view: + name: view_2 + - name: group_2 + version: 2c + state: present + access_list: + name: test_acl + read_view: + name: view_1 + write_view: + name: view_2 + notify_view: + name: view_3 + state: absent + - name: group_3 + version: 3 + security_level: auth + read_view: + name: view_1 + write_view: + name: view_2 + state: present + - name: group_4 + version: 3 + security_level: priv + notify_view: + name: view_1 + state: present + read_view: + name: view_1 + write_view: + name: view_2 + state: present + snmp_host: + - ip: 1.1.1.1 + communitystring: c1 + version: "2c" + udpport: 4 + state: present + - ip: 2.2.2.2 + version: 1 + communitystring: c3 + state: present + - ip: 2.1.1.1 + version: 1 + communitystring: c3 + trap_categories: + dom: true + entity: true + snmp: true + lldp: true + state: present + - ip: 3.1.1.1 + version: 3 + security_level: priv + security_name: test + notification_type: informs + udpport: 200 + trap_categories: + dom: true + entity: true + envmon: false + lldp: false + state: present + snmp_view: + - name: view_1 + oid_subtree: 2 + include: true + state: present + snmp_user: + - name: user_1 + group_name: group_1 + version: 3 + authentication: + localized: false + algorithm: md5 + password: 9fc53d9d908118b2804fe80e3ba8763d + encryption: + algorithm: aes + password: d0452401a8c3ce42804fe80e3ba8763d + state: present + - name: user_2 + group_name: group_1 + version: 3 + authentication: + localized: true + algorithm: md5 + password: '0x9fc53d9d908118b2804fe80e3ba8763d' + encryption: + algorithm: aes + password: '0xd0452401a8c3ce42804fe80e3ba8763d' + state: present + - name: user_3 + group_name: group_1 + version: 2c + state: present + - name: user_4 + group_name: group_1 + version: 3 + state: present + - name: user_5 + group_name: group_2 + version: 2c + remote: + ip: 1.1.1.1 + udpport: 200 + access_list: test_acl + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/03_snmp_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/03_snmp_unconfig.j2 new file mode 100644 index 00000000..4b4a8683 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/03_snmp_unconfig.j2 @@ -0,0 +1,147 @@ +os10_snmp: + snmp_source_interface: mgmt 1/1/1 + snmp_location: Chennai + snmp_community: + - name: public + access_mode: ro + access_list: + name: test_acl + state: absent + - name: test + access_mode: ro + access_list: + name: test_acl + state: present + state: absent + snmp_traps: + - name: all + state: absent + snmp_engine_id: + snmp_remote_engine_id: + - host: 1.1.1.1 + engine_id: '0xab' + - host: 1.1.1.1 + engine_id: '0xcd' + udpport: 200 + - host: 2.1.1.1 + engine_id: '0xef' + udpport: 200 + state: absent + snmp_vrf: red + snmp_group: + - name: group_1 + version: 1 + access_list: + name: test_acl + read_view: + name: view_1 + write_view: + name: view_2 + - name: group_2 + version: 2c + state: present + access_list: + name: test_acl + read_view: + name: view_1 + write_view: + name: view_2 + notify_view: + name: view_3 + state: absent + - name: group_3 + version: 3 + security_level: auth + read_view: + name: view_1 + write_view: + name: view_2 + state: present + - name: group_4 + version: 3 + security_level: priv + notify_view: + name: view_1 + state: absent + read_view: + name: view_1 + state: absent + write_view: + name: view_2 + state: absent + state: absent + snmp_host: + - ip: 1.1.1.1 + communitystring: c1 + version: "2c" + udpport: 4 + state: present + - ip: 2.2.2.2 + version: 1 + communitystring: c3 + state: present + - ip: 2.1.1.1 + version: 1 + communitystring: c3 + trap_categories: + dom: true + entity: true + snmp: true + lldp: true + state: present + - ip: 3.1.1.1 + version: 3 + security_level: priv + security_name: test + notification_type: informs + udpport: 200 + trap_categories: + dom: true + entity: true + envmon: false + lldp: false + state: absent + snmp_view: + - name: view_1 + oid_subtree: 2 + include: true + state: absent + snmp_user: + - name: user_1 + group_name: group_1 + version: 3 + authentication: + localized: false + algorithm: md5 + password: 9fc53d9d908118b2804fe80e3ba8763d + encryption: + algorithm: aes + password: d0452401a8c3ce42804fe80e3ba8763d + state: present + - name: user_2 + group_name: group_1 + version: 3 + authentication: + localized: true + algorithm: md5 + password: '0x9fc53d9d908118b2804fe80e3ba8763d' + encryption: + algorithm: aes + password: '0xd0452401a8c3ce42804fe80e3ba8763d' + state: present + - name: user_3 + group_name: group_1 + version: 2c + state: absent + - name: user_4 + group_name: group_1 + version: 3 + state: absent + - name: user_5 + group_name: group_2 + version: 2c + remote: + ip: 1.1.1.1 + udpport: 200 + access_list: test_acl + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/setup.j2 new file mode 100644 index 00000000..7ea26a0a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/setup.j2 @@ -0,0 +1,4 @@ +os10_vrf: + vrfdetails: + - vrf_name: red + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/teardown.j2 new file mode 100644 index 00000000..1a3ba013 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/templates/snmp_basic/steps/teardown.j2 @@ -0,0 +1,147 @@ +test_roles: + - dellemc.os10.os10_snmp + - dellemc.os10.os10_vrf +os10_vrf: + vrfdetails: + - vrf_name: "red" + state: "absent" +os10_snmp: + snmp_source_interface: + snmp_location: + snmp_community: + - name: public + access_mode: ro + access_list: + name: test_acl + state: absent + - name: test + access_mode: ro + access_list: + name: test_acl + state: absent + state: absent + snmp_traps: + - name: all + state: absent + snmp_engine_id: + snmp_remote_engine_id: + - host: 1.1.1.1 + engine_id: '0xab' + state: absent + - host: 1.1.1.1 + engine_id: '0xcd' + udpport: 200 + state: absent + - host: 2.1.1.1 + engine_id: '0xef' + udpport: 200 + state: absent + snmp_group: + - name: group_1 + version: 1 + write_view: + name: view_2 + state: absent + - name: group_2 + version: 2c + state: present + access_list: + name: test_acl + read_view: + name: view_1 + write_view: + name: view_2 + notify_view: + name: view_3 + state: absent + - name: group_3 + version: 3 + security_level: auth + read_view: + name: view_1 + write_view: + name: view_2 + state: present + state: absent + - name: group_4 + version: 3 + security_level: priv + notify_view: + name: view_1 + state: present + state: absent + snmp_host: + - ip: 1.1.1.1 + communitystring: c1 + version: "2c" + udpport: 4 + state: absent + - ip: 2.2.2.2 + version: 1 + communitystring: c3 + state: absent + - ip: 2.1.1.1 + version: 1 + communitystring: c3 + trap_categories: + dom: true + entity: true + snmp: true + state: absent + - ip: 3.1.1.1 + version: 3 + security_level: priv + security_name: test + notification_type: informs + udpport: 200 + trap_categories: + dom: true + entity: true + envmon: true + lldp: true + state: absent + snmp_view: + - name: view_1 + oid_subtree: 2 + include: true + state: absent + snmp_vrf: + snmp_user: + - name: user_1 + group_name: group_1 + version: 3 + authentication: + localized: false + algorithm: md5 + password: 9fc53d9d908118b2804fe80e3ba8763d + encryption: + algorithm: aes + password: d0452401a8c3ce42804fe80e3ba8763d + state: absent + - name: user_2 + group_name: group_1 + version: 3 + authentication: + localized: true + algorithm: md5 + password: '0x9fc53d9d908118b2804fe80e3ba8763d' + encryption: + algorithm: aes + password: '0xd0452401a8c3ce42804fe80e3ba8763d' + state: absent + - name: user_3 + group_name: group_1 + version: 2c + state: absent + - name: user_4 + group_name: group_1 + version: 3 + state: absent + - name: user_5 + group_name: group_2 + version: 2c + remote: + ip: 1.1.1.1 + udpport: 200 + access_list: test_acl + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tests/snmp_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tests/snmp_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/tests/snmp_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/vars/main.yaml new file mode 100644 index 00000000..0e3995a5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_snmp_role/vars/main.yaml @@ -0,0 +1,3 @@ +test_roles: + - dellemc.os10.os10_vrf + - dellemc.os10.os10_snmp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/01_system_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/01_system_configure.j2 new file mode 100644 index 00000000..13549985 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/01_system_configure.j2 @@ -0,0 +1,26 @@ +os10_system: + hostname: OS10 + hardware_forwarding: scaled-l3-hosts + hash_algo: + algo: + - name: lag + mode: crc + state: present + - name: ecmp + mode: xor + state: present + load_balance: + ingress_port: true + ip_selection: + - field: source-ip + state: present + ipv6_selection: + - field: source-ip + state: present + mac_selection: + - field: source-mac + state: present + tcp_udp_selection: + - field: l4-source-port + state: present + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/02_system_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/02_system_update.j2 new file mode 100644 index 00000000..7263204b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/02_system_update.j2 @@ -0,0 +1,26 @@ +os10_system: + hostname: OS10 + hardware_forwarding: scaled-l2 + hash_algo: + algo: + - name: ecmp + mode: random + state: present + - name: lag + mode: xor + state: present + load_balance: + ingress_port: true + ip_selection: + - field: destination-ip + state: present + ipv6_selection: + - field: destination-ip + state: present + mac_selection: + - field: destination-mac + state: present + tcp_udp_selection: + - field: l4-destination-port + state: present + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/03_system_unconfig.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/03_system_unconfig.j2 new file mode 100644 index 00000000..17c84d33 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/03_system_unconfig.j2 @@ -0,0 +1,26 @@ +os10_system: + hostname: OS10 + hardware_forwarding: + hash_algo: + algo: + - name: ecmp + mode: random + state: absent + - name: lag + mode: xor + state: present + load_balance: + ingress_port: + ip_selection: + - field: destination-ip + state: absent + ipv6_selection: + - field: destination-ip + state: absent + mac_selection: + - field: destination-mac + state: absent + tcp_udp_selection: + - field: l4-destination-port + state: absent + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/teardown.j2 new file mode 100644 index 00000000..480ce114 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/templates/system_basic/steps/teardown.j2 @@ -0,0 +1,25 @@ +os10_system: + hostname: + hardware_forwarding: + hash_algo: + algo: + - name: ecmp + mode: random + state: absent + - name: lag + mode: xor + state: absent + load_balance: + ingress_port: + ip_selection: + - field: destination-ip + state: absent + ipv6_selection: + - field: destination-ip + state: absent + mac_selection: + - field: destination-mac + state: absent + tcp_udp_selection: + - field: l4-destination-port + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tests/system_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tests/system_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/tests/system_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/vars/main.yaml new file mode 100644 index 00000000..d847941e --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_system_role/vars/main.yaml @@ -0,0 +1,2 @@ +test_roles: + - dellemc.os10.os10_system diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/01_uplink_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/01_uplink_configure.j2 new file mode 100644 index 00000000..fd7a9165 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/01_uplink_configure.j2 @@ -0,0 +1,32 @@ +test_roles: + - dellemc.os10.os10_uplink +os10_uplink: + uplink_state_group: + - id: 1 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel1" + state: "present" + - type: "downstream" + intf: "ethernet{{ os10_interface_1.split()[1] }},{{ os10_interface_2.split()[1] }}" + state: "present" + downstream: + disable_links: all + auto_recover: false + defer_time: 50 + state: "present" + - id: 2 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel2" + state: "present" + - type: "downstream" + intf: "{{ os10_interface_3 }}" + state: "present" + downstream: + disable_links: 10 + auto_recover: true + defer_time: 50 + state: "present" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/02_uplink_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/02_uplink_update.j2 new file mode 100644 index 00000000..d412e3e0 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/02_uplink_update.j2 @@ -0,0 +1,30 @@ +os10_uplink: + uplink_state_group: + - id: 1 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel1" + state: absent + - type: "downstream" + intf: "ethernet{{ os10_interface_1.split()[1] }},{{ os10_interface_2.split()[1] }}" + state: "present" + downstream: + disable_links: 10 + auto_recover: false + defer_time: 50 + state: "present" + - id: 2 + enable: false + uplink_type: + - type: "upstream" + intf: "port-channel2" + state: "present" + - type: "downstream" + intf: "{{ os10_interface_3 }}" + state: absent + downstream: + disable_links: 15 + auto_recover: false + defer_time: 40 + state: "present" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/03_uplink_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/03_uplink_absent.j2 new file mode 100644 index 00000000..b2d3da07 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/03_uplink_absent.j2 @@ -0,0 +1,30 @@ +os10_uplink: + uplink_state_group: + - id: 1 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel1" + state: "absent" + - type: "downstream" + intf: "ethernet{{ os10_interface_1.split()[1] }},{{ os10_interface_2.split()[1] }}" + state: "absent" + downstream: + disable_links: all + auto_recover: false + defer_time: 50 + state: "absent" + - id: 2 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel2" + state: "absent" + - type: "downstream" + intf: "{{ os10_interface_3 }}" + state: "absent" + downstream: + disable_links: 10 + auto_recover: true + defer_time: 50 + state: "absent" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/setup.j2 new file mode 100644 index 00000000..2f579616 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/setup.j2 @@ -0,0 +1,5 @@ +os10_lag: + Po 1: + state: present + Po 2: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/teardown.j2 new file mode 100644 index 00000000..dcd90471 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/templates/uplink_basic/steps/teardown.j2 @@ -0,0 +1,38 @@ +test_roles: + - dellemc.os10.os10_uplink + - dellemc.os10.os10_lag +os10_lag: + Po 1: + state: absent + Po 2: + state: absent +os10_uplink: + uplink_state_group: + - id: 1 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel1" + state: "absent" + - type: "downstream" + intf: "ethernet{{ os10_interface_1.split()[1] }},{{ os10_interface_2.split()[1] }}" + state: "absent" + downstream: + disable_links: all + auto_recover: false + defer_time: 50 + state: "absent" + - id: 2 + enable: True + uplink_type: + - type: "upstream" + intf: "port-channel2" + state: "absent" + - type: "downstream" + intf: "{{ os10_interface_3 }}" + state: "absent" + downstream: + disable_links: 10 + auto_recover: true + defer_time: 50 + state: "absent" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tests/uplink_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tests/uplink_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/tests/uplink_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/vars/main.yaml new file mode 100644 index 00000000..c3d3900d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_uplink_role/vars/main.yaml @@ -0,0 +1,3 @@ +test_roles: + - dellemc.os10.os10_lag + - dellemc.os10.os10_uplink diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks_old/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks_old/main.yaml new file mode 100644 index 00000000..4de62fb9 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tasks_old/main.yaml @@ -0,0 +1,15 @@ +--- +- 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/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/01_users_add.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/01_users_add.j2 new file mode 100644 index 00000000..b53a5bb0 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/01_users_add.j2 @@ -0,0 +1,9 @@ +os10_users: + - username: test + password: a1a2a3a4!@#$ + role: sysadmin + state: present + - username: u1 + password: a1a2a3a4!@#$ + role: netadmin + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/02_users_del.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/02_users_del.j2 new file mode 100644 index 00000000..abb30cfa --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/02_users_del.j2 @@ -0,0 +1,5 @@ +os10_users: + - username: test + password: a1a2a3a4!@#$ + role: sysadmin + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/teardown.j2 new file mode 100644 index 00000000..f817f7b2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/templates/users_basic/steps/teardown.j2 @@ -0,0 +1,9 @@ +os10_users: + - username: test + password: a1a2a3a4!@#$ + role: sysadmin + state: absent + - username: u1 + password: a1a2a3a4!@#$ + role: netadmin + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tests/users_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tests/users_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/tests/users_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/vars/main.yaml new file mode 100644 index 00000000..0a54dcad --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_users_role/vars/main.yaml @@ -0,0 +1,2 @@ +test_roles: + - dellemc.os10.os10_users diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/01_vlan_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/01_vlan_configure.j2 new file mode 100644 index 00000000..593fb33d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/01_vlan_configure.j2 @@ -0,0 +1,17 @@ +idempotent: true +os10_vlan: + vlan 100: + description: "Blue" + tagged_members: + - port: {{ os10_interface_1 }} + state: present + untagged_members: + - port: {{ os10_interface_2 }} + state: present + state: present + vlan 888: + description: "NSX_Cluster" + untagged_members: + - port: port-channel 1 + state: "present" + state: "present" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/02_vlan_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/02_vlan_update.j2 new file mode 100644 index 00000000..a2fd82f4 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/02_vlan_update.j2 @@ -0,0 +1,19 @@ +idempotent: true +os10_vlan: + vlan 100: + description: "Blue VLAN" + tagged_members: + - port: {{ os10_interface_1 }} + state: present + - port: {{ os10_interface_3 }} + state: present + untagged_members: + - port: {{ os10_interface_2 }} + state: present + state: present + vlan 888: + description: "NSX_Cluster" + untagged_members: + - port: port-channel 1 + state: "present" + state: "present" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/03_vlan_member_port_range.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/03_vlan_member_port_range.j2 new file mode 100644 index 00000000..bbff49b1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/03_vlan_member_port_range.j2 @@ -0,0 +1,17 @@ +idempotent: false +os10_vlan: + vlan 100: + description: "Blue VLAN" + tagged_members: + - port: range ethernet {{ os10_interface_1.split()[1] }},{{ os10_interface_3.split()[1] }} + state: present + untagged_members: + - port: range {{ os10_interface_2 }} + state: present + state: present + vlan 888: + description: "NSX_Cluster" + untagged_members: + - port: port-channel 1 + state: "present" + state: "present" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/04_vlan_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/04_vlan_absent.j2 new file mode 100644 index 00000000..2cc502d2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/04_vlan_absent.j2 @@ -0,0 +1,20 @@ +idempotent: false +os10_vlan: + default_vlan_id: 1 + vlan 100: + description: + tagged_members: + - port: {{ os10_interface_1 }} + state: present + - port: {{ os10_interface_3 }} + state: absent + untagged_members: + - port: {{ os10_interface_2 }} + state: present + state: present + vlan 888: + description: "NSX_Cluster" + untagged_members: + - port: port-channel 1 + state: "present" + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/setup.j2 new file mode 100644 index 00000000..81cff710 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/setup.j2 @@ -0,0 +1,3 @@ +os10_lag: + Po 1: + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/teardown.j2 new file mode 100644 index 00000000..e640d0c1 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/templates/vlan_basic/steps/teardown.j2 @@ -0,0 +1,25 @@ +test_roles: + - dellemc.os10.os10_vlan + - dellemc.os10.os10_lag +os10_lag: + Po 1: + state: absent +os10_vlan: + default_vlan_id: + vlan 100: + description: + tagged_members: + - port: {{ os10_interface_1 }} + state: absent + - port: {{ os10_interface_3 }} + state: absent + untagged_members: + - port: {{ os10_interface_2 }} + state: absent + state: absent + vlan 888: + description: "NSX_Cluster" + untagged_members: + - port: port-channel 1 + state: absent + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tests/vlan_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tests/vlan_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/tests/vlan_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/vars/main.yaml new file mode 100644 index 00000000..7acc287d --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlan_role/vars/main.yaml @@ -0,0 +1,6 @@ +test_roles: + - dellemc.os10.os10_lag + - dellemc.os10.os10_vlan + +idempotent_roles: + - dellemc.os10.os10_vlan diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/defaults/main.yaml new file mode 100644 index 00000000..967b3f14 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_idempotency: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/01_vlt_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/01_vlt_configure.j2 new file mode 100644 index 00000000..90ca5988 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/01_vlt_configure.j2 @@ -0,0 +1,15 @@ +idempotent: true +test_roles: + - dellemc.os10.os10_vlt +os10_vlt: + domain: 1 + backup_destination: "192.168.211.175" + destination_type: "ipv4" + discovery_intf: {{ os10_interface_1.split()[1] }} + discovery_intf_state: present + peer_routing: True + vlt_mac: aa:aa:aa:aa:aa:aa + vlt_peers: + Po 12: + peer_lag: 13 + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/02_vlt_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/02_vlt_update.j2 new file mode 100644 index 00000000..e1406d21 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/02_vlt_update.j2 @@ -0,0 +1,14 @@ +idempotent: false +os10_vlt: + domain: 1 + backup_destination: "192.168.211.175" + destination_type: "ipv4" + backup_destination_vrf: + discovery_intf: {{ os10_interface_1.split()[1] }} + discovery_intf_state: absent + peer_routing: false + vlt_mac: aa:aa:aa:aa:aa:ab + vlt_peers: + Po 12: + peer_lag: 14 + state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/03_vlt_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/03_vlt_absent.j2 new file mode 100644 index 00000000..1d667cca --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/03_vlt_absent.j2 @@ -0,0 +1,12 @@ +os10_vlt: + domain: 1 + backup_destination: "192.168.211.175" + destination_type: "ipv4" + discovery_intf: {{ os10_interface_1.split()[1] }} + discovery_intf_state: present + peer_routing: True + vlt_mac: aa:aa:aa:aa:aa:aa + vlt_peers: + Po 12: + peer_lag: 13 + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/setup.j2 new file mode 100644 index 00000000..17245d04 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/setup.j2 @@ -0,0 +1,7 @@ +os10_lag: + Po 12: + state: present + +os10_interface: + {{ os10_interface_1 }}: + switchport: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/teardown.j2 new file mode 100644 index 00000000..4460af86 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/templates/vlt_basic/steps/teardown.j2 @@ -0,0 +1,23 @@ +test_roles: + - dellemc.os10.os10_vlt + - dellemc.os10.os10_lag + - dellemc.os10.os10_interface +os10_interface: + {{ os10_interface_1 }}: + portmode: access + switchport: true +os10_lag: + Po 12: + state: absent +os10_vlt: + domain: 1 + backup_destination: "192.168.211.175" + destination_type: "ipv4" + discovery_intf: {{ os10_interface_1.split()[1] }} + discovery_intf_state: present + peer_routing: True + vlt_mac: aa:aa:aa:aa:aa:aa + vlt_peers: + Po 12: + peer_lag: 13 + state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tests/vlt_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tests/vlt_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/tests/vlt_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/vars/main.yaml new file mode 100644 index 00000000..e18e8364 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vlt_role/vars/main.yaml @@ -0,0 +1,7 @@ +test_roles: + - dellemc.os10.os10_interface + - dellemc.os10.os10_lag + - dellemc.os10.os10_vlt + +idempotent_roles: + - dellemc.os10.os10_vlt diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/01_vrrp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/01_vrrp_configure.j2 new file mode 100644 index 00000000..0f95b515 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/01_vrrp_configure.j2 @@ -0,0 +1,43 @@ +test_roles: + - dellemc.os10.os10_vrrp +os10_vrrp: + vrrp: + delay_reload: 2 + version: 3 + {{ os10_interface_1 }}: + vrrp_group: + - group_id: 2 + type: ipv6 + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: present + virtual_address: + - ip: 2001:4828:5808:ffa3::9 + state: present + - ip: 3001:4828:5808:ffa3::9 + state: present + - ip: 4001:4828:5808:ffa3::9 + state: absent + adv_interval_centisecs: 200 + state: present + - group_id: 4 + virtual_address: + - ip: 4.1.1.1 + state: present + - ip: 4.1.1.2 + state: present + - ip: 4.1.1.3 + state: absent + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: present + adv_interval_centisecs: 200 + state: present + vlan100: + vrrp_active_active_mode: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/02_vrrp_update.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/02_vrrp_update.j2 new file mode 100644 index 00000000..b3fc61ce --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/02_vrrp_update.j2 @@ -0,0 +1,41 @@ +os10_vrrp: + vrrp: + delay_reload: 2 + version: 3 + {{ os10_interface_1 }}: + vrrp_group: + - group_id: 2 + type: ipv6 + priority: 200 + preempt: true + track_interface: + - resource_id: 3 + priority_cost: 30 + state: present + virtual_address: + - ip: 2001:4828:5808:ffa3::9 + state: present + - ip: 3001:4828:5808:ffa3::9 + state: absent + - ip: 4001:4828:5808:ffa3::9 + state: absent + adv_interval_centisecs: 300 + state: present + - group_id: 4 + virtual_address: + - ip: 4.1.1.1 + state: present + - ip: 4.1.1.2 + state: absent + - ip: 4.1.1.3 + state: absent + priority: 140 + preempt: true + track_interface: + - resource_id: 3 + priority_cost: 20 + state: present + adv_interval_centisecs: 300 + state: present + vlan100: + vrrp_active_active_mode: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/03_vrrp_options_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/03_vrrp_options_absent.j2 new file mode 100644 index 00000000..f013293a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/03_vrrp_options_absent.j2 @@ -0,0 +1,41 @@ +os10_vrrp: + vrrp: + delay_reload: 2 + version: 3 + {{ os10_interface_1 }}: + vrrp_group: + - group_id: 2 + type: ipv6 + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: absent + virtual_address: + - ip: 2001:4828:5808:ffa3::9 + state: present + - ip: 3001:4828:5808:ffa3::9 + state: present + - ip: 4001:4828:5808:ffa3::9 + state: absent + adv_interval_centisecs: 200 + state: present + - group_id: 4 + virtual_address: + - ip: 4.1.1.1 + state: present + - ip: 4.1.1.2 + state: present + - ip: 4.1.1.3 + state: absent + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: absent + adv_interval_centisecs: 200 + state: present + vlan100: + vrrp_active_active_mode: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/04_vrrp_absent.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/04_vrrp_absent.j2 new file mode 100644 index 00000000..8e79b319 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/04_vrrp_absent.j2 @@ -0,0 +1,41 @@ +os10_vrrp: + vrrp: + delay_reload: 2 + version: 3 + {{ os10_interface_1 }}: + vrrp_group: + - group_id: 2 + type: ipv6 + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: present + virtual_address: + - ip: 2001:4828:5808:ffa3::9 + state: present + - ip: 3001:4828:5808:ffa3::9 + state: present + - ip: 4001:4828:5808:ffa3::9 + state: absent + adv_interval_centisecs: 200 + state: absent + - group_id: 4 + virtual_address: + - ip: 4.1.1.1 + state: present + - ip: 4.1.1.2 + state: present + - ip: 4.1.1.3 + state: absent + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: present + adv_interval_centisecs: 200 + state: absent + vlan100: + vrrp_active_active_mode: true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/setup.j2 new file mode 100644 index 00000000..dd6b16b4 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/setup.j2 @@ -0,0 +1,3 @@ +os10_interface: + {{ os10_interface_1 }}: + switchport: false diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/teardown.j2 new file mode 100644 index 00000000..2d876f55 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/templates/vrrp_basic/steps/teardown.j2 @@ -0,0 +1,47 @@ +test_roles: + - dellemc.os10.os10_vrrp + - dellemc.os10.os10_vlan +os10_vlan: + vlan 100: + state: absent +os10_vrrp: + vrrp: + delay_reload: 0 + version: + {{ os10_interface_1 }}: + vrrp_group: + - group_id: 2 + type: ipv6 + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: absent + virtual_address: + - ip: 2001:4828:5808:ffa3::9 + state: absent + - ip: 3001:4828:5808:ffa3::9 + state: absent + - ip: 4001:4828:5808:ffa3::9 + state: absent + adv_interval_centisecs: 200 + state: absent + - group_id: 4 + virtual_address: + - ip: 4.1.1.1 + state: absent + - ip: 4.1.1.2 + state: absent + - ip: 4.1.1.3 + state: absent + priority: 120 + preempt: false + track_interface: + - resource_id: 3 + priority_cost: 25 + state: absent + adv_interval_centisecs: 200 + state: absent + vlan100: + vrrp_active_active_mode: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tests/vrrp_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tests/vrrp_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/tests/vrrp_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/vars/main.yaml new file mode 100644 index 00000000..1eb402bf --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_vrrp_role/vars/main.yaml @@ -0,0 +1,3 @@ +test_roles: + - dellemc.os10.os10_interface + - dellemc.os10.os10_vrrp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/defaults/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/01_xstp_rstp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/01_xstp_rstp_configure.j2 new file mode 100644 index 00000000..f1a85dbd --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/01_xstp_rstp_configure.j2 @@ -0,0 +1,14 @@ +test_roles: + - dellemc.os10.os10_xstp +os10_xstp: + type: rstp + enable: true + path_cost: false + mac_flush_timer: 5 + rstp: + max_age: 7 + hello_time: 8 + forward_time: 9 + force_version: stp + bridge_priority: 8192 + mac_flush_threshold: 6 diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/02_xstp_rstp_defaults.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/02_xstp_rstp_defaults.j2 new file mode 100644 index 00000000..f6c324bd --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/02_xstp_rstp_defaults.j2 @@ -0,0 +1,12 @@ +os10_xstp: + type: rstp + enable: true + path_cost: false + mac_flush_timer: + rstp: + max_age: + hello_time: + forward_time: + force_version: stp + bridge_priority: + mac_flush_threshold: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/03_xstp_pvst_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/03_xstp_pvst_configure.j2 new file mode 100644 index 00000000..07ed32db --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/03_xstp_pvst_configure.j2 @@ -0,0 +1,16 @@ +os10_xstp: + type: rapid-pvst + enable: true + path_cost: true + mac_flush_timer: 5 + pvst: + vlan: + - range_or_id: 10 + max_age: 10 + enable: true + hello_time: 8 + forward_time: 8 + bridge_priority: 8192 + mac_flush_threshold: 6 + root: secondary + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/04_xstp_pvst_defaults.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/04_xstp_pvst_defaults.j2 new file mode 100644 index 00000000..82469210 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/04_xstp_pvst_defaults.j2 @@ -0,0 +1,16 @@ +os10_xstp: + type: rapid-pvst + enable: true + path_cost: false + mac_flush_timer: + pvst: + vlan: + - range_or_id: 10 + max_age: + enable: + hello_time: + forward_time: + bridge_priority: + mac_flush_threshold: + root: + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/05_xstp_mstp_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/05_xstp_mstp_configure.j2 new file mode 100644 index 00000000..ded2976b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/05_xstp_mstp_configure.j2 @@ -0,0 +1,24 @@ +os10_xstp: + type: mst + enable: true + path_cost: true + mac_flush_timer: 5 + mstp: + max_age: 8 + max_hops: 7 + hello_time: 8 + forward_time: 8 + force_version: stp + mstp_instances: + - number_or_range: 1 + enable: true + root: secondary + mac_flush_threshold: 8 + bridge_priority: 8192 + mst_config: + name: cfg1 + revision: 3 + cfg_list: + - number: 1 + vlans: 4,5 + vlans_state: present diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/06_xstp_mstp_defaults.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/06_xstp_mstp_defaults.j2 new file mode 100644 index 00000000..c39becdc --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/06_xstp_mstp_defaults.j2 @@ -0,0 +1,24 @@ +os10_xstp: + type: mst + enable: true + path_cost: false + mac_flush_timer: + mstp: + max_age: + max_hops: + hello_time: + forward_time: + force_version: + mstp_instances: + - number_or_range: 1 + enable: + root: + mac_flush_threshold: + bridge_priority: + mst_config: + name: cfg1 + revision: + cfg_list: + - number: 1 + vlans: 4,5 + vlans_state: absent diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/07_xstp_interface_configure.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/07_xstp_interface_configure.j2 new file mode 100644 index 00000000..2ec48bc2 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/07_xstp_interface_configure.j2 @@ -0,0 +1,25 @@ +os10_xstp: + type: rstp + enable: true + path_cost: true + mac_flush_timer: + intf: + {{ os10_interface_1 }}: + edge_port: true + bpdu_filter: true + bpdu_guard: true + guard: loop + enable: true + link_type: point-to-point + msti: + - instance_number: 1 + priority: 32 + cost: 1 + rstp: + priority: 32 + cost: 7 + vlan: + - range_or_id: 6 + priority: 16 + cost: 8 + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/08_xstp_interface_defaults.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/08_xstp_interface_defaults.j2 new file mode 100644 index 00000000..b28ea451 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/08_xstp_interface_defaults.j2 @@ -0,0 +1,25 @@ +os10_xstp: + type: rstp + enable: true + path_cost: true + mac_flush_timer: + intf: + {{ os10_interface_1 }}: + edge_port: + bpdu_filter: + bpdu_guard: + guard: + enable: false + link_type: + msti: + - instance_number: 1 + priority: + cost: + rstp: + priority: + cost: + vlan: + - range_or_id: 6 + priority: + cost: + diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/setup.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/setup.j2 new file mode 100644 index 00000000..e01f16e4 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/setup.j2 @@ -0,0 +1,4 @@ +os10_interface: + {{ os10_interface_1 }}: + switchport: true + portmode: access diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/teardown.j2 b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/teardown.j2 new file mode 100644 index 00000000..e1e5ffa8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/templates/xstp_basic/steps/teardown.j2 @@ -0,0 +1,60 @@ +os10_xstp: + type: + enable: true + path_cost: false + mac_flush_timer: + rstp: + max_age: + hello_time: + forward_time: + force_version: + bridge_priority: + mac_flush_threshold: + pvst: + vlan: + - range_or_id: 10 + max_age: + enable: true + hello_time: + forward_time: + bridge_priority: + mac_flush_threshold: + root: + mstp: + max_age: + max_hops: + hello_time: + forward_time: + force_version: + mstp_instances: + - number_or_range: 1 + enable: true + root: + mac_flush_threshold: + bridge_priority: + mst_config: + name: + revision: + cfg_list: + - number: 1 + vlans: 4,5 + vlans_state: absent + intf: + {{ os10_interface_1 }}: + edge_port: + bpdu_filter: + bpdu_guard: + guard: + enable: true + link_type: + msti: + - instance_number: 1 + priority: + cost: + rstp: + priority: + cost: + vlan: + - range_or_id: 6 + priority: + cost: diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tests/xstp_basic.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tests/xstp_basic.yaml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/tests/xstp_basic.yaml diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/vars/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/vars/main.yaml new file mode 100644 index 00000000..001043cd --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/os10_xstp_role/vars/main.yaml @@ -0,0 +1,3 @@ +test_roles: + - dellemc.os10.os10_interface + - dellemc.os10.os10_xstp diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/main.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/main.yaml new file mode 100644 index 00000000..88be0f20 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: prepare_test_facts.yaml, tags: ['role']} +- { include: tests.yaml, tags: ['role']} diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/prepare_test_facts.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/prepare_test_facts.yaml new file mode 100644 index 00000000..a86b71f6 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/prepare_test_facts.yaml @@ -0,0 +1,14 @@ +--- +- block: + - name: Collect interface list + import_role: + name: os10_template + tasks_from: show_ip_interface_brief.yaml + register: result + - name: Set interface list + set_fact: + os10_interface_1: "{{ ip_interface_facts[0].INTERFACE_NAME | lower }}" + os10_interface_2: "{{ ip_interface_facts[1].INTERFACE_NAME | lower }}" + os10_interface_3: "{{ ip_interface_facts[2].INTERFACE_NAME | lower }}" + + when: prepare_os10_role_tests_task | default(True) | bool diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/include_os10_role.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/include_os10_role.yaml new file mode 100644 index 00000000..395d2fe8 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/include_os10_role.yaml @@ -0,0 +1,20 @@ +- include_role: + name: "{{ os10_role_name }}" + +- debug: msg="Role completed {{ os10_role_name }}" + notify: "os10_role completed" + +- block: + - name: "Testing idempotency for {{ os10_role_name }}" + include_role: + name: "{{ os10_role_name }}" + - name: "idempotency result for {{ os10_role_name }}" + fail: + msg: "idempotency test failed for {{ os10_role_name }}" + when: output.changed + + when: > + ( test_idempotency is defined and test_idempotency and + idempotent_roles is defined and os10_role_name in idempotent_roles and + idempotent is defined and idempotent + ) diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/run_test_case.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/run_test_case.yaml new file mode 100644 index 00000000..c84b1033 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/run_test_case.yaml @@ -0,0 +1,62 @@ +- name: set test case + set_fact: + role_testcase: "{{ role_testcase_path | basename | splitext | first }}" + +- name: set test case output dir + set_fact: + testcase_outdir: "{{ output_dir }}/{{ role_name }}/{{ role_testcase_path }}" + + +- name: Prepare testcase output dir + file: + path: "{{ testcase_outdir }}" + state: directory + +- name: Source testcase variables + include_vars: "{{ item }}" + vars: + params: + files: + - "{{ role_testcase }}.yaml" + paths: + - "vars" + loop: "{{ query('first_found', params, errors='ignore') }}" + +- name: Include Testcase tasks + include: "{{ role_testcase_path }}" + +- name: Identifying steps + block: + - name: Identifying steps + find: + paths: "{{ role_path }}/templates/{{ role_testcase }}/steps" + patterns: "*.j2" + register: step_files + - set_fact: teststeps_files="{{ step_files.files | map(attribute='path') | map('basename') | list }}" + - set_fact: teststeps="{{ teststeps_files | map('splitext') | map('first') | reject('equalto', 'setup') | reject('equalto', 'teardown') | list | sort }}" + when: teststeps is not defined + +- name: Check if setup step exists + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/setup.j2" + ignore_errors: true + register: setup_template + +- name: Setup Testcase + include: testcase/run_test_step.yaml role_teststep=setup idempotent=false + when: setup_template.stat.exists == true + +- name: Run Test Steps + block: + - name: Run Test Steps + include: testcase/run_test_step.yaml idempotent=false + with_items: "{{ teststeps }}" + loop_control: + loop_var: role_teststep + always: + - name: Check teardown + stat: path="{{ role_path }}/templates/{{ role_testcase }}/steps/teardown.j2" + ignore_errors: true + register: teardown_template + - name: Run teardown + include: testcase/run_test_step.yaml role_teststep=teardown idempotent=false + when: teardown_template.stat.exists == true diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/run_test_step.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/run_test_step.yaml new file mode 100644 index 00000000..624325e5 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/testcase/run_test_step.yaml @@ -0,0 +1,26 @@ +--- +- name: Running step {{ role_teststep }} + debug: msg="{{ role_teststep }}" + +- name: Set step vars file + set_fact: + teststep_var_template: "{{ role_testcase }}/steps/{{ role_teststep }}.j2" + teststep_vars_file: "{{ testcase_outdir }}/{{ role_teststep }}.yaml" + +- name: Preparing step variables + template: + src: "{{ teststep_var_template }}" + dest: "{{ teststep_vars_file }}" + +- name: Load step variables + include_vars: + file: "{{ teststep_vars_file }}" + +- name: Including roles for the step + include: testcase/include_os10_role.yaml os10_role_name="{{ step_role }}" + # include_role: + # name: "{{ step_role }}" + with_items: "{{ test_roles }}" + loop_control: + loop_var: step_role + when: test_roles is defined diff --git a/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/tests.yaml b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/tests.yaml new file mode 100644 index 00000000..572c2538 --- /dev/null +++ b/ansible_collections/dellemc/os10/tests/integration/targets/role_test/tasks/tests.yaml @@ -0,0 +1,14 @@ +- 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: testcase/run_test_case.yaml + with_items: "{{ test_items }}" + loop_control: + loop_var: role_testcase_path |