diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/dellemc/enterprise_sonic/tests | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/enterprise_sonic/tests')
224 files changed, 8799 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/hosts b/ansible_collections/dellemc/enterprise_sonic/tests/regression/hosts new file mode 100644 index 000000000..b8ec3e04b --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/hosts @@ -0,0 +1,13 @@ +sonic1 ansible_host=100.94.81.17 ansible_user=admin ansible_password=admin +sonic2 ansible_host=100.94.81.19 ansible_user=admin ansible_password=admin +#sonic2 ansible_user=admin ansible_password=admin + +[datacenter] +sonic1 +sonic2 + +[datacenter:vars] +ansible_network_os=dellemc.enterprise_sonic.sonic +ansible_python_interpreter=/usr/bin/python3 +ansible_httpapi_use_ssl=true +ansible_httpapi_validate_certs=false diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/image-upgrade.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/image-upgrade.yaml new file mode 100644 index 000000000..0891c1e6c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/image-upgrade.yaml @@ -0,0 +1,31 @@ +--- +- name: "Test SONiC CLI" + hosts: datacenter + gather_facts: no + connection: ssh + vars: + build_number: 120 + tasks: + - name: Download Image from build server + get_url: + #url: "http://10.14.1.208/work/sonic_archive1/dell_sonic_3.1.x_share/{{ build_number }}/sonic-broadcom.bin" + #url: http://devopsweb.force10networks.com/tftpboot/SONIC/dell_sonic_3.1.x_share/last_good/sonic-broadcom.bin + url: http://10.14.1.69/tftpboot/SONIC/dell_sonic_3.1.x_share/{{ build_number }}/sonic-broadcom.bin + dest: /tmp/sonic-broadcom-{{ build_number }}.bin + mode: '0777' + - name: Install the downloaded image + become: true + command: sonic_installer install /tmp/sonic-broadcom-{{ build_number }}.bin -y + register: output + - name: wait for 3 seconds + pause: + seconds: 3 + - name: Unconditionally reboot the machine with all defaults + become: true + reboot: + - name: "Wait for system to get ready" + command: "show system status" + register: result + until: result.stdout.find("System is ready") >= 0 + retries: 15 + delay: 15 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/defaults/main.yml new file mode 100644 index 000000000..93dd85447 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/defaults/main.yml @@ -0,0 +1,66 @@ +--- +idempotnet_condition: "{{ 'Passed' if (idempotent_task_output.failed == false and + idempotent_task_output.commands == empty and + idempotent_task_output.changed == false) + else 'Failed' + }}" +action_condition: "{{ 'Passed' if (action_task_output.failed == false and + action_task_output.commands != empty and + action_task_output.changed == true) + else 'Failed' + }}" +cli_test_condition: "{{ 'Passed' if(cli_tests_output.failed == false and + cli_tests_output.changed == false + ) + else 'Failed' + }}" + +single_run_condition: "{{ 'Passed' if(single_run_task_output.failed == false and + single_run_task_output.commands != empty and + single_run_task_output.changed == true + ) + else 'Failed' + }}" + +single_run_idem_condition: "{{ 'Passed' if (single_run_task_output.failed == false and + single_run_task_output.commands == empty and + single_run_task_output.changed == false) + else 'Failed' + }}" + +REPORT_DIR: "/var/www/html/ansible/regression" +empty: [] + +module_name1: debug + +std_name: STANDARD +native_name: NATIVE + +interface_mode: STANDARD + +default_interface_cli_std: default interface range Eth 1/5-1/10 +default_interface_cli_native: default interface range Ethernet20-40 + +default_interface_cli: + - "{{ default_interface_cli_std if std_name in interface_mode else default_interface_cli_native }}" + +native_eth1: Ethernet20 +native_eth2: Ethernet24 +native_eth3: Ethernet28 +native_eth4: Ethernet32 +native_eth5: Ethernet36 +native_eth6: Ethernet40 + +std_eth1: Eth1/5 +std_eth2: Eth1/6 +std_eth3: Eth1/7 +std_eth4: Eth1/8 +std_eth5: Eth1/9 +std_eth6: Eth1/10 + +interface1: "{{ std_eth1 if std_name in interface_mode else native_eth1 }}" +interface2: "{{ std_eth2 if std_name in interface_mode else native_eth2 }}" +interface3: "{{ std_eth3 if std_name in interface_mode else native_eth3 }}" +interface4: "{{ std_eth4 if std_name in interface_mode else native_eth4 }}" +interface5: "{{ std_eth5 if std_name in interface_mode else native_eth5 }}" +interface6: "{{ std_eth6 if std_name in interface_mode else native_eth6 }}" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/meta/main.yaml new file mode 100644 index 000000000..a84afac66 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/meta/main.yaml @@ -0,0 +1,3 @@ +--- +collections: + - dellemc.enterprise_sonic
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/action.facts.report.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/action.facts.report.yaml new file mode 100644 index 000000000..8c8ee5e51 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/action.facts.report.yaml @@ -0,0 +1,10 @@ +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.1': { + 'status': action_condition, + 'module_stderr': action_task_output.module_stderr | default(action_task_output.msg | default('No Error')), + 'before': action_task_output.before | default('Not defined'), + 'after': action_task_output.after | default('Not defined'), + 'commands': action_task_output.commands | default('Not defined'), + 'configs': item.input | default('Not defined'), + }}}, recursive=True) }}" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli.contains.test.facts.report.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli.contains.test.facts.report.yaml new file mode 100644 index 000000000..66e263e60 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli.contains.test.facts.report.yaml @@ -0,0 +1,11 @@ +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.3': { + 'status': cli_contains_condition, + 'module_stderr': cli_tests_output.module_stderr | default(cli_tests_output.msg | default('No Error')), + 'commands': cli_tests_output.commands | default('Not defined'), + 'configs': item.input | default('Not defined'), + 'msg': cli_tests_output.msg | default('Not defined'), + }}}, recursive=True) }}" + # no_log: true +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli.test.facts.report.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli.test.facts.report.yaml new file mode 100644 index 000000000..b8165d1b9 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli.test.facts.report.yaml @@ -0,0 +1,11 @@ +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.3': { + 'status': cli_test_condition, + 'module_stderr': cli_tests_output.module_stderr | default(cli_tests_output.msg | default('No Error')), + 'commands': cli_tests_output.commands | default('Not defined'), + 'configs': item.input | default('Not defined'), + 'msg': cli_tests_output.msg | default('Not defined'), + }}}, recursive=True) }}" + # no_log: true +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli_tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli_tasks_template.yaml new file mode 100644 index 000000000..4c5fa8e7f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/cli_tasks_template.yaml @@ -0,0 +1,14 @@ +- debug: msg="{{ base_cfg_path + item.name }}.cfg" + +- name: "Push CLI for validation" + vars: + ansible_connection: network_cli + sonic_config: + src: "{{ base_cfg_path + item.name }}.cfg" + register: cli_tests_output + ignore_errors: yes + +- debug: var=cli_tests_output +- import_role: + name: common + tasks_from: cli.test.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/idempotent.facts.report.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/idempotent.facts.report.yaml new file mode 100644 index 000000000..adeec696c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/idempotent.facts.report.yaml @@ -0,0 +1,12 @@ +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.2': { + 'status': idempotnet_condition, + 'module_stderr': idempotent_task_output.module_stderr | default(idempotent_task_output.msg | default('No Error')), + 'before': idempotent_task_output.before | default('Not defined'), + 'after': idempotent_task_output.after | default('Not defined'), + 'commands': idempotent_task_output.commands | default('Not defined'), + 'configs': item.input | default('Not defined'), + 'msg': idempotent_task_output.msg | default('Not defined'), + }}}, recursive=True) }}" + # no_log: true
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/main.yml new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/main.yml @@ -0,0 +1 @@ + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/single.run.facts.report.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/single.run.facts.report.yaml new file mode 100644 index 000000000..e950b0104 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/tasks/single.run.facts.report.yaml @@ -0,0 +1,10 @@ +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.1': { + 'status': single_run_task_status, + 'module_stderr': single_run_task_output.module_stderr | default(single_run_task_output.msg | default('No Error')), + 'before': single_run_task_output.before | default('Not defined'), + 'after': single_run_task_output.after | default('Not defined'), + 'commands': single_run_task_output.commands | default('Not defined'), + 'configs': item.input | default('Not defined'), + }}}, recursive=True) }}" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/templates/task_template.j2 b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/templates/task_template.j2 new file mode 100644 index 000000000..9ad1384b0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/templates/task_template.j2 @@ -0,0 +1,14 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_{{module_name}}: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- debug: var=action_task_output + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.1': action_condition }}, recursive=True) }}" + #no_log: true + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/templates/task_template1.j2 b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/templates/task_template1.j2 new file mode 100644 index 000000000..1afb48590 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/common/templates/task_template1.j2 @@ -0,0 +1,14 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_{{module_name}}: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- debug: var=action_task_output + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.1': action_condition }}, recursive=True) }}" + #no_log: true +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/defaults/main.yml new file mode 100644 index 000000000..291f615ee --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/defaults/main.yml @@ -0,0 +1,54 @@ +--- +ansible_connection: httpapi +module_name: aaa +tests: + - name: test_case_01 + description: aaa properties + state: merged + input: + authentication: + data: + fail_through: true + group: tacacs+ + local: true + + - name: test_case_02 + description: Update created aaa properties + state: merged + input: + authentication: + data: + fail_through: false + + - name: test_case_03 + description: Update aaa properties - change group + state: merged + input: + authentication: + data: + fail_through: true + group: radius + local: true + + - name: test_case_04 + description: Delete aaa properties + state: deleted + input: + authentication: + data: + group: radius + + - name: test_case_05 + description: aaa properties + state: merged + input: + authentication: + data: + fail_through: true + group: radius + local: true + +test_delete_all: + - name: del_all_test_case_01 + description: Delete aaa properties + state: deleted diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/meta/main.yaml new file mode 100644 index 000000000..d0ceaf6f5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/main.yml new file mode 100644 index 000000000..fdcaa9a43 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/main.yml @@ -0,0 +1,17 @@ +- debug: msg="sonic_aaa Test started ..." + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "test_delete_all {{ module_name }} stated ..." + include_tasks: tasks_template_del.yaml + loop: "{{ test_delete_all }}" + when: test_delete_all is defined + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/preparation_tests.yaml new file mode 100644 index 000000000..e8a964f3f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old radius server configurations + sonic_aaa: + config: {} + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/tasks_template.yaml new file mode 100644 index 000000000..3b9f6b982 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_aaa: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_aaa: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/tasks_template_del.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/tasks_template_del.yaml new file mode 100644 index 000000000..b50cc26cd --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_aaa/tasks/tasks_template_del.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_aaa: + state: "{{ item.state }}" + config: + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_aaa: + state: "{{ item.state }}" + config: + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/defaults/main.yml new file mode 100644 index 000000000..2e553a033 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/defaults/main.yml @@ -0,0 +1,6 @@ +--- +ansible_connection: httpapi + +preparations_tests: + init_prefix: + - "no ip prefix-list p1"
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/invalid.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/invalid.yaml new file mode 100644 index 000000000..8e7f1513b --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/invalid.yaml @@ -0,0 +1,28 @@ +--- +- name: "Test sonic_api with invalid payload" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet64/config/description + method: "PATCH" + status_code: 204 + body: {"openconfig-interfaces:descriptio": "hi "} + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" + +- name: "Test sonic_api with invalid url" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet64/config/ + method: "PATCH" + status_code: 204 + body: {"openconfig-interfaces:description": "hi "} + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == true" + - "result.msg is defined" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/main.yaml new file mode 100644 index 000000000..8e9893d86 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/main.yaml @@ -0,0 +1,10 @@ +--- +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- include_tasks: test_get.yaml +- include_tasks: test_patch.yaml +- include_tasks: test_post.yaml +- include_tasks: test_put.yaml +- include_tasks: test_delete.yaml +- include_tasks: invalid.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/patch.txt b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/patch.txt new file mode 100644 index 000000000..cacbc086f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/patch.txt @@ -0,0 +1,8 @@ +{"openconfig-if-ip:ipv4": { + "addresses": { + "address": [ + { + "ip": "1.1.1.1", + "config": {"ip": "1.1.1.1", "prefix-length": 24} + }]}} + } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/preparation_tests.yaml new file mode 100644 index 000000000..a9be2b6d3 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/preparation_tests.yaml @@ -0,0 +1,6 @@ +- name: "remove prefix" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_prefix }}" +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_delete.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_delete.yaml new file mode 100644 index 000000000..6b646cd53 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_delete.yaml @@ -0,0 +1,12 @@ +--- + - name: "Test delete_api and check whether it returns code 204" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet64/subinterfaces/subinterface=0/openconfig-if-ip:ipv4/addresses/address=1.1.1.1/config/prefix-length + method: "DELETE" + status_code: 204 + register: result + + - assert: + that: + - "result.changed == true" + - "204 in result.response[0]" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_get.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_get.yaml new file mode 100644 index 000000000..b705840bb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_get.yaml @@ -0,0 +1,11 @@ +--- +- name: "check whether get_api returns code 200" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet8 + method: "GET" + status_code: 200 + register: result +- assert: + that: + - "result.changed == false" + - "200 in result.response[0]" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_patch.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_patch.yaml new file mode 100644 index 000000000..0e779612d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_patch.yaml @@ -0,0 +1,13 @@ +--- + - name: "Test patch_api and check whether code 204 is returned" + sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet64/config/description + method: "PATCH" + status_code: 204 + body: {"openconfig-interfaces:description": "hi "} + register: result + + - assert: + that: + - "result.changed == true" + - "204 in result.response[0]" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_post.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_post.yaml new file mode 100644 index 000000000..503838885 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_post.yaml @@ -0,0 +1,27 @@ +--- + - name: "Test post_api and check whether code 201 is returned" + sonic_api: + url: data/openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set=p1 + method: "POST" + body: {"openconfig-routing-policy:config": {"name": "p1", "mode": "IPV4" }} + status_code: 201 + register: result + + - assert: + that: + - "result.changed == true" + - "201 in result.response[0]" + + - name: "Test post_api to create same prefix-set and check whether play is failed" + sonic_api: + url: data/openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set=p1 + method: "POST" + body: {"openconfig-routing-policy:config": {"name": "p1", "mode": "IPV4" }} + status_code: 201 + register: result + ignore_errors: yes + + - assert: + that: + - "result.failed == true" + - "result.msg is defined" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_put.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_put.yaml new file mode 100644 index 000000000..4b0a7abe8 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_api/tasks/test_put.yaml @@ -0,0 +1,13 @@ +--- + - name: "Test put_api and check whether code 204 is returned" + sonic_api: + url: data/openconfig-network-instance:network-instances/network-instance=Vlan100 + method: "PUT" + body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100", "config": {"name": "Vlan100"}}]} + status_code: 204 + register: result + + - assert: + that: + - "result.changed == true" + - "204 in result.response[0]" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/defaults/main.yml new file mode 100644 index 000000000..0eb7a6cb0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/defaults/main.yml @@ -0,0 +1,250 @@ +--- +ansible_connection: httpapi +module_name: bgp + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +bgp_as_1: 51 +bgp_as_2: 52 +bgp_as_3: 53 + +preparations_tests: + init_vrf: + - "ip vrf {{vrf_1}}" + - "ip vrf {{vrf_2}}" + +tests_cli: + - name: cli_test_case_01 + description: creates bestpath BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.4 + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + max_med: + on_startup: + timer: 667 + med_val: 7878 + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.5 + vrf_name: "{{vrf_1}}" + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + max_med: + on_startup: + timer: 889 + med_val: 8854 + +tests: + - name: test_case_01 + description: creates BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.4 + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.5 + vrf_name: "{{vrf_1}}" + - name: test_case_02 + description: Updates BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.30 + log_neighbor_changes: True + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.31 + vrf_name: "{{vrf_1}}" + log_neighbor_changes: True + - name: test_case_03 + description: Deletes BGP properties + state: deleted + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.30 + log_neighbor_changes: True + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.31 + vrf_name: "{{vrf_1}}" + log_neighbor_changes: True + - name: test_case_04 + description: creates bestpath BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.4 + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + max_med: + on_startup: + timer: 889 + med_val: 8854 + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.5 + vrf_name: "{{vrf_1}}" + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + max_med: + on_startup: + timer: 556 + med_val: 5567 + - name: test_case_05 + description: Update bestpath BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.51 + bestpath: + as_path: + confed: False + ignore: False + compare_routerid: False + med: + confed: False + max_med: + on_startup: + timer: 776 + med_val: 7768 + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.52 + vrf_name: "{{vrf_1}}" + bestpath: + as_path: + multipath_relax: False + multipath_relax_as_set: False + compare_routerid: False + med: + missing_as_worst: False + max_med: + on_startup: + timer: 445 + med_val: 4458 + - name: test_case_06 + description: Update1 bestpath BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.51 + bestpath: + as_path: + confed: True + ignore: True + compare_routerid: True + med: + confed: True + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.52 + vrf_name: "{{ vrf_1 }}" + bestpath: + as_path: + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + missing_as_worst: True + - name: test_case_07 + description: Deletes BGP properties + state: deleted + input: + - bgp_as: "{{ bgp_as_1 }}" + bestpath: + as_path: + confed: False + ignore: False + compare_routerid: False + med: + confed: False + max_med: + on_startup: + timer: 889 + med_val: 8854 + - bgp_as: "{{ bgp_as_2 }}" + vrf_name: "{{vrf_1}}" + bestpath: + as_path: + multipath_relax: True + multipath_relax_as_set: False + compare_routerid: True + med: + missing_as_worst: False + max_med: + on_startup: + timer: 889 + med_val: 8854 + - name: test_case_08 + description: Update1 bestpath BGP properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + router_id: 110.2.2.51 + bestpath: + as_path: + confed: True + ignore: True + compare_routerid: True + med: + confed: True + - bgp_as: "{{ bgp_as_2 }}" + router_id: 110.2.2.52 + vrf_name: "{{ vrf_1 }}" + bestpath: + as_path: + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + missing_as_worst: True + - bgp_as: "{{ bgp_as_3 }}" + router_id: 120.2.2.52 + vrf_name: "{{ vrf_2 }}" + bestpath: + as_path: + multipath_relax: True + multipath_relax_as_set: True + compare_routerid: True + med: + missing_as_worst: True + - name: test_case_09 + description: Deletes BGP properties + state: deleted + input: + - bgp_as: "{{ bgp_as_2 }}" + vrf_name: "{{vrf_1}}" + - name: test_case_10 + description: Deletes all BGP properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..8a52f1273 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/cleanup_tests.yaml @@ -0,0 +1,6 @@ +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/main.yml new file mode 100644 index 000000000..29d5392d6 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/main.yml @@ -0,0 +1,28 @@ +- debug: msg="sonic_interfaces Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} CLI validation started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests_cli }}" + +- name: "Test CLI validation started ..." + include_role: + name: common + tasks_from: cli_tasks_template.yaml + loop: "{{ tests_cli }}" + +- name: Clean up test + include_tasks: cleanup_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/preparation_tests.yaml new file mode 100644 index 000000000..ec5f139d8 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/preparation_tests.yaml @@ -0,0 +1,11 @@ +- name: "initialize VRFs" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_vrf }}" + +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/tasks_template.yaml new file mode 100644 index 000000000..7a7394e20 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..720006565 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp/templates/cli_test_case_01.cfg @@ -0,0 +1,18 @@ +router bgp 52 vrf VrfReg1 + router-id 110.2.2.5 + log-neighbor-changes + bestpath as-path multipath-relax as-set + bestpath as-path ignore + bestpath as-path confed + bestpath med missing-as-worst confed + bestpath compare-routerid + timers 60 180 +router bgp 51 + router-id 110.2.2.4 + log-neighbor-changes + bestpath as-path multipath-relax as-set + bestpath as-path ignore + bestpath as-path confed + bestpath med missing-as-worst confed + bestpath compare-routerid + timers 60 180 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/defaults/main.yml new file mode 100644 index 000000000..ba23b3f57 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/defaults/main.yml @@ -0,0 +1,324 @@ +--- +ansible_connection: httpapi +module_name: bgp_af + + +bgp_as_1: 51 +bgp_as_2: 52 + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +preparations_tests: + init_route_map: + - route-map rmap_reg1 permit 11 + - route-map rmap_reg2 permit 11 + - route-map rmap_reg3 permit 11 + init_vrf: + - "ip vrf {{vrf_1}}" + - "ip vrf {{vrf_2}}" + init_bgp: + - bgp_as: "{{bgp_as_1}}" + router_id: 111.2.2.41 + log_neighbor_changes: False + - bgp_as: "{{bgp_as_2}}" + router_id: 111.2.2.42 + log_neighbor_changes: True + vrf_name: VrfReg1 +tests: + - name: test_case_01 + description: BGP AF properties + state: merged + input: + - bgp_as: "{{ bgp_as_1 }}" + address_family: + afis: + - afi: ipv4 + safi: unicast + - afi: ipv6 + safi: unicast + - afi: l2vpn + safi: evpn + - bgp_as: "{{ bgp_as_2 }}" + vrf_name: "{{vrf_1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + - afi: ipv6 + safi: unicast + - afi: l2vpn + safi: evpn + - name: test_case_02 + description: Update created BGP AF properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 2 + ibgp: 3 + redistribute: + - metric: "20" + protocol: connected + route_map: rmap_reg1 + - metric: "26" + protocol: ospf + route_map: rmap_reg2 + - metric: "25" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_reg3 + - metric: "27" + protocol: ospf + route_map: rmap_reg1 + - metric: "28" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + advertise_pip: True + advertise_pip_ip: "1.1.1.1" + advertise_pip_peer_ip: "2.2.2.2" + advertise_svi_ip: True + advertise_all_vni: True + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 + - bgp_as: "{{bgp_as_2}}" + vrf_name: "{{vrf_1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 1 + ibgp: 2 + redistribute: + - metric: "20" + protocol: connected + route_map: rmap_reg1 + - metric: "26" + protocol: ospf + route_map: rmap_reg2 + - metric: "25" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 2 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_reg3 + - metric: "27" + protocol: ospf + route_map: rmap_reg1 + - metric: "28" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 + - name: test_case_03 + description: Update2 created BGP AF properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + vrf_name: default + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 2 + ibgp: 3 + redistribute: + - metric: "30" + protocol: connected + route_map: rmap_reg1 + - metric: "36" + protocol: ospf + route_map: rmap_reg2 + - metric: "35" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "31" + protocol: connected + route_map: rmap_reg3 + - metric: "37" + protocol: ospf + route_map: rmap_reg1 + - metric: "38" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + advertise_pip: False + advertise_pip_ip: "3.3.3.3" + advertise_pip_peer_ip: "4.4.4.4" + advertise_svi_ip: False + advertise_all_vni: False + route_advertise_list: + - advertise_afi: ipv6 + route_map: rmap_reg2 + - bgp_as: "{{bgp_as_2}}" + vrf_name: "{{vrf_1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 4 + ibgp: 5 + redistribute: + - metric: "40" + protocol: connected + route_map: rmap_reg1 + - metric: "41" + protocol: ospf + route_map: rmap_reg2 + - metric: "42" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 9 + ibgp: 8 + redistribute: + - metric: "43" + protocol: connected + route_map: rmap_reg3 + - metric: "44" + protocol: ospf + route_map: rmap_reg1 + - metric: "45" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + route_advertise_list: + - advertise_afi: ipv6 + route_map: rmap_reg2 + - name: test_case_04 + description: Delete BGP AF properties + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + vrf_name: default + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 4 + ibgp: 3 + redistribute: + - metric: "30" + protocol: connected + route_map: rmap_reg1 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "37" + protocol: ospf + route_map: rmap_reg1 + - metric: "38" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + advertise_pip: False + advertise_pip_ip: "3.3.3.3" + advertise_pip_peer_ip: "4.4.4.4" + advertise_svi_ip: False + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 + - bgp_as: "{{bgp_as_2}}" + vrf_name: "{{vrf_1}}" + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 4 + ibgp: 3 + redistribute: + - metric: "41" + protocol: ospf + route_map: rmap_reg2 + - metric: "42" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 4 + ibgp: 6 + redistribute: + - metric: "43" + protocol: connected + route_map: rmap_reg3 + - afi: l2vpn + safi: evpn + route_advertise_list: + - advertise_afi: ipv4 + - name: test_case_05 + description: Delete1 BGP AF properties + state: deleted + input: + - bgp_as: "{{ bgp_as_1 }}" + vrf_name: default + address_family: + afis: + - afi: ipv4 + safi: unicast + redistribute: + - afi: ipv6 + safi: unicast + redistribute: + - bgp_as: "{{bgp_as_2}}" + vrf_name: "{{vrf_1}}" + address_family: + afis: + - afi: l2vpn + safi: evpn + route_advertise_list: + - name: test_case_06 + description: Delete2 BGP AF properties + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + vrf_name: default + address_family: + afis: + - name: test_case_07 + description: Delete3 BGP AF properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..002f8ab74 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/cleanup_tests.yaml @@ -0,0 +1,10 @@ +- name: Deletes old bgp_af + sonic_bgp_af: + config: [] + state: deleted + ignore_errors: yes +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/main.yml new file mode 100644 index 000000000..287404c2a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/main.yml @@ -0,0 +1,15 @@ +- debug: msg="sonic_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports + +- name: "cleanup {{ module_name }} started ..." + include_tasks: cleanup_tests.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/preparation_tests.yaml new file mode 100644 index 000000000..82a2f308c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/preparation_tests.yaml @@ -0,0 +1,20 @@ +- name: "initialize route maps" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_route_map }}" +- name: "initialize VRFs" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_vrf }}" +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes +- name: Create bgp + sonic_bgp: + config: "{{ preparations_tests.init_bgp }}" + state: merged + ignore_errors: yes
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/tasks_template.yaml new file mode 100644 index 000000000..9fe7149d6 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_af/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp_af: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_af: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml new file mode 100644 index 000000000..f2e31e4a2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/defaults/main.yml @@ -0,0 +1,78 @@ +--- +ansible_connection: httpapi +module_name: bgp_as_paths + +bgp_as_1: 51 +bgp_as_2: 52 + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +tests: + - name: test_case_01 + description: BGP properties + state: merged + input: + - name: test + members: + - "11" + permit: True + - name: test_1 + members: + - "101.101" + permit: False + - name: test_case_02 + description: Update created BGP properties + state: merged + input: + - name: test + members: + - "11" + - "22" + - "33" + - 44 + permit: True + - name: test_1 + members: + - "101.101" + - "201.201" + - "301.301" + permit: False + - name: test_2 + members: + - '111\\:' + - '11\\d+' + - '113\\*' + - '114\\' + permit: True + - name: test_case_03 + description: Delete BGP properties + state: deleted + input: + - name: test + members: + - "33" + - name: test_1 + members: + - "101.101" + - "201.201" + - "301.301" + permit: False + - name: test_2 + members: + - '111\\:' + - '11\\d+' + - '113\\*' + - '114\\' + permit: True + - name: test_case_04 + description: Delete BGP properties + state: deleted + input: + - name: test + members: + permit: + - name: test_case_05 + description: Delete BGP properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/main.yml new file mode 100644 index 000000000..51c65668c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/main.yml @@ -0,0 +1,13 @@ +- debug: msg="sonic_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/preparation_tests.yaml new file mode 100644 index 000000000..f524c06f3 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old bgp as paths + sonic_bgp_as_paths: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/tasks_template.yaml new file mode 100644 index 000000000..70dbcdff4 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_as_paths/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp_as_paths: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: true + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_as_paths: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: true + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/defaults/main.yml new file mode 100644 index 000000000..eb32d2759 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/defaults/main.yml @@ -0,0 +1,101 @@ +--- +ansible_connection: httpapi +module_name: bgp_communities + +tests: + - name: test_case_01 + description: BGP Communities properties + state: merged + input: + - name: test + type: expanded + permit: false + match: ANY + members: + regex: + - "11" + - "12" + - name: test2 + type: standard + permit: true + match: ALL + members: + regex: + - "21" + - "22" + - name: test_case_02 + description: Update created BGP properties + state: merged + input: + - name: test + type: expanded + permit: false + match: ANY + members: + regex: + - "12" + - "13" + - 14 + - name: test2 + type: standard + permit: true + match: ALL + members: + regex: + - "23" + - "24" + - 25 + - name: test_case_03 + description: Update1 created BGP properties + state: merged + input: + - name: test + type: expanded + permit: true + match: ANY + members: + regex: + - "11" + - "12" + - name: test2 + type: standard + permit: false + match: ALL + members: + regex: + - "21" + - "22" + - name: test_case_04 + description: Delete BGP properties + state: deleted + input: + - name: test + type: expanded + members: + regex: + - "12" + - "13" + - name: test2 + type: standard + match: ALL + members: + regex: + - "23" + - "24" + - name: test_case_05 + description: Delete1 BGP properties + state: deleted + input: + - name: test + type: expanded + members: + regex: + - name: test_case_06 + description: Delete2 BGP properties + state: deleted + input: + - name: test + - name: test_case_07 + description: Delete2 BGP properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/main.yml new file mode 100644 index 000000000..94d190b38 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/main.yml @@ -0,0 +1,13 @@ +- debug: msg="{{ module_name }} Test started ..." + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/preparation_tests.yaml new file mode 100644 index 000000000..d204af4eb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old bgp sonic_bgp_communities + sonic_bgp_communities: + config: [] + state: deleted + ignore_errors: yes
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/tasks_template.yaml new file mode 100644 index 000000000..e875d051c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_communities/tasks/tasks_template.yaml @@ -0,0 +1,23 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp_communities: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: true + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_communities: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: true + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml + +- debug: var=action_task_output
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/defaults/main.yml new file mode 100644 index 000000000..be6e96a86 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/defaults/main.yml @@ -0,0 +1,321 @@ +--- +ansible_connection: httpapi +module_name: sonic_bgp_ext_communities + +tests: "{{ merged_tests + deleted_tests }}" + +merged_tests: + - name: test_case_01 + description: BGP Communities properties + state: merged + input: + - name: test_ext + type: expanded + permit: false + match: any + members: + regex: + - "11" + - "12" + - name: test_std + type: standard + permit: true + match: all + members: + route_target: + - "101:101" + - "201:201" + route_origin: + - "301:301" + - "401:401" + - name: test_case_02 + description: Update permit BGP Communities properties + state: merged + input: + - name: test_ext + type: expanded + permit: false + match: any + members: + regex: + - "13" + - "14" + - name: test_std + type: standard + permit: true + match: all + members: + route_target: + - "2201:101" + - "3301:201" + - "11.1.1.1:223" + - "11.1.1.2:224" + route_origin: + - "4401:301" + - "5501:401" + - name: test_case_03 + description: Update permit BGP Communities properties + state: merged + input: + - name: test_ext + type: expanded + permit: false + match: any + members: + regex: + - "15" + - "16" + - name: test_std + type: standard + permit: true + match: all + members: + route_target: + - "2202:101" + - "3302:201" + - "11.1.1.1:225" + - "11.1.1.2:226" + - "11.1.1.3:225" + - "11.1.1.4:226" + - name: test_case_04 + description: Update match BGP Communities properties + state: merged + input: + - name: test_ext + type: expanded + permit: false + match: any + members: + regex: + - "15" + - "16" + - name: test_std + type: standard + permit: true + match: all + members: + route_origin: + - "4403.301" + - "5503.401" + - name: test_case_05 + description: Create empty Communities properties + state: merged + input: + - name: test_ext1 + type: expanded + permit: true + match: any + - name: test_std1 + type: standard + permit: false + match: any + - name: test_case_06 + description: test BGP Communities properties + state: merged + input: + - name: test_comm112 + type: expanded + permit: true + match: any + members: + regex: + - "15" + - "16" + - name: test_comm + type: standard + permit: false + match: any + members: + route_origin: + - "4403.301" + - "5503.401" + +deleted_tests: + # Ethernet testcases started... + - name: del_test_case_0111 + description: BGP Communities properties + state: merged + input: + - name: test_ext + type: expanded + permit: false + match: any + members: + regex: + - "11" + - "12" + - "13" + - "14" + - "15" + - "16" + - name: test_std + type: standard + permit: true + match: all + members: + route_target: + - "101.101" + - "201.201" + - "102.101" + - "202.201" + - "1.1.1.1.101" + - "1.1.1.2.201" + route_origin: + - "301.301" + - "401.401" + - "302.301" + - "402.401" + - "303.301" + - "403.401" + - name: test_std11 + type: standard + permit: true + match: all + members: + route_target: + - "101.101" + - "201.201" + - "102.101" + - "202.201" + - "103.101" + - "203.201" + - "1.1.1.1.101" + - "1.1.1.2.201" + - "1.1.1.1.102" + - "1.1.1.2.203" + route_origin: + - "301.301" + - "401.401" + - "302.301" + - "402.401" + - "303.301" + - "403.401" + - name: test_std12 + type: standard + permit: true + match: all + members: + route_target: + - "101.101" + - "201.201" + - "102.101" + - "202.201" + - "103.101" + - "203.201" + - "1.1.1.1.101" + - "1.1.1.2.201" + - "1.1.1.1.102" + - "1.1.1.2.203" + route_origin: + - "301.301" + - "401.401" + - "302.301" + - "402.401" + - "303.301" + - "403.401" + - name: test_std12 + type: standard + permit: true + match: all + members: + route_target: + - "101.101" + - "201.201" + - "102.101" + - "202.201" + - "103.101" + - "203.201" + - "1.1.1.1.101" + - "1.1.1.2.201" + - "1.1.1.1.102" + - "1.1.1.2.203" + route_origin: + - "301.301" + - "401.401" + - "302.301" + - "402.401" + - "303.301" + - "403.401" + - name: test_std12 + type: standard + permit: true + match: all + members: + route_target: + - "103.101" + - "203.201" + - "1.1.1.1:102" + - "1.1.1.2.203" + route_origin: + - "301.301" + - "401.401" + - name: del_test_case_01 + description: BGP Communities properties + state: deleted + input: + - name: test_ext + type: expanded + members: + regex: + - "11" + - "12" + - name: test_std + type: standard + members: + route_target: + - "101:101" + - "201:201" + route_origin: + - "301:301" + - "401:401" + - name: test_std1 + type: standard + members: + route_target: + - "101:101" + - "201:201" + route_origin: + - "301:301" + - "401:401" + - name: test_case_02 + description: BGP Communities properties + state: deleted + input: + - name: test_ext + type: expanded + members: + regex: + - name: test_std + type: standard + members: + route_target: + - "1.1.1.1.101" + - name: test_std11 + type: standard + members: + route_origin: + - "301.301" + - "401.401" + - "1.1.1.1.101" + - name: del_test_case_03 + description: Update created BGP properties + state: deleted + input: + - name: test_ext + - name: test_std + type: standard + members: + route_target: + - name: test_std11 + type: standard + members: + route_origin: + - name: test_std12 + type: standard + members: + route_origin: + route_target: + - name: del_test_case_04 + description: Update created BGP properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/main.yml new file mode 100644 index 000000000..d2ae6b415 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/main.yml @@ -0,0 +1,13 @@ +- debug: msg="{{ module_name }} Test started ..." + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +# - name: Display all variables/facts known for a host +# debug: +# var: ansible_facts.test_reports +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/preparation_tests.yaml new file mode 100644 index 000000000..e4a98edb2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old bgp sonic_bgp_communities + sonic_bgp_ext_communities: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/tasks_template.yaml new file mode 100644 index 000000000..380ef22f5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_ext_communities/tasks/tasks_template.yaml @@ -0,0 +1,23 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp_ext_communities: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: true + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_ext_communities: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: true + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml + +- debug: var=action_task_output
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/defaults/main copy.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/defaults/main copy.yml new file mode 100644 index 000000000..353861255 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/defaults/main copy.yml @@ -0,0 +1,316 @@ +--- +ansible_connection: httpapi +module_name: sonic_bgp_neighbors + +bgp_as_1: 51 +bgp_as_2: 52 + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +preparations_tests: + init_route_map: + - route-map rmap_reg1 permit 11 + - route-map rmap_reg2 permit 11 + - route-map rmap_reg3 permit 11 + - route-map rmap_reg4 permit 11 + - route-map rmap_reg5 permit 11 + init_vrf: + - "ip vrf {{vrf_1}}" + - "ip vrf {{vrf_2}}" + init_bgp: + - bgp_as: "{{bgp_as_1}}" + router_id: 111.2.2.41 + log_neighbor_changes: False + - bgp_as: "{{bgp_as_2}}" + router_id: 111.2.2.42 + log_neighbor_changes: True + vrf_name: VrfReg1 + +negative_tests: + - name: negative_test_case_01 + description: allowas_in beyond value + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: Ethernet12 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 11 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - name: negative_test_case_02 + description: BGP properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: Ethernet12 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 11 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg2 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + +tests: "{{ merged_tests }}" + +deleted_tests: + - name: test_case_del_01 + description: Delete peer group BGP properties + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + peergroup: + - name: SPINE + - name: SPINE1 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peergroup: + - name: SPINE + - name: SPINE1 + + + +merged_tests: + - name: test_case_01 + description: BGP properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: Ethernet12 + remote_as: 5 + peer_group: SPINE + advertisement_interval: 10 + timers: + keepalive: 40 + holdtime: 50 + bfd: true + capability: + dynamic: true + extended_nexthop: true + - neighbor: 192.168.1.4 + - neighbor: 2::2 + - neighbor: Ethernet8 + - neighbor: 192.168.1.5 + remote_as: 6 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - neighbor: 3::3 + remote_as: 7 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: Ethernet24 + remote_as: 11 + peer_group: SPINE + advertisement_interval: 10 + timers: + keepalive: 40 + holdtime: 50 + bfd: true + capability: + dynamic: true + extended_nexthop: true + - neighbor: 192.168.2.2 + - neighbor: Ethernet28 + remote_as: 12 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - name: test_case_02 + description: Update BGP properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peergroup: + - name: SPINE + - name: SPINE1 + neighbors: + - neighbor: Ethernet12 + remote_as: 111 + peer_group: SPINE + advertisement_interval: 11 + timers: + keepalive: 41 + holdtime: 51 + bfd: false + capability: + dynamic: false + extended_nexthop: false + - neighbor: 192.168.1.4 + - neighbor: Ethernet8 + - neighbor: 192.168.1.5 + remote_as: 112 + peer_group: SPINE1 + advertisement_interval: 21 + timers: + keepalive: 22 + holdtime: 23 + capability: + dynamic: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peergroup: + - name: SPINE + - name: SPINE1 + neighbors: + - neighbor: Ethernet24 + remote_as: 213 + peer_group: SPINE1 + advertisement_interval: 44 + timers: + keepalive: 55 + holdtime: 44 + bfd: false + capability: + dynamic: false + extended_nexthop: false + - neighbor: 192.168.2.2 + - neighbor: Ethernet28 + remote_as: 214 + peer_group: SPINE + advertisement_interval: 45 + timers: + keepalive: 33 + holdtime: 34 + capability: + dynamic: false + - neighbor: 3::3 + remote_as: 215 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - name: test_case_03 + description: BGP ipv6 properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: 2::2 + - neighbor: 11::11 + remote_as: external + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - neighbor: 3::3 + remote_as: 7 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: 192.168.2.2 + - neighbor: Ethernet28 + remote_as: 12 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + capability: + dynamic: true + - name: test_case_04 + description: BGP remote-as properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: Ethernet8 + remote_as: internal + - neighbor: 11::11 + remote_as: external + - neighbor: 67.1.1.1 + remote_as: 7 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: Ethernet8 + remote_as: 1345 + - neighbor: 11::11 + remote_as: 2345 + - neighbor: 67.1.1.1 + remote_as: external + - name: test_case_05 + description: BGP remote-as properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: Ethernet8 + remote_as: external + - neighbor: 11::11 + remote_as: internal + - neighbor: 67.1.1.1 + remote_as: internal + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peergroup: + - name: SPINE + neighbors: + - neighbor: Ethernet8 + remote_as: internal + - neighbor: 11::11 + remote_as: external + - neighbor: 67.1.1.1 + remote_as: 1123
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/defaults/main.yml new file mode 100644 index 000000000..140eeeae5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/defaults/main.yml @@ -0,0 +1,880 @@ +--- +ansible_connection: httpapi +module_name: sonic_bgp_neighbors + +bgp_as_1: 51 +bgp_as_2: 52 + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +preparations_tests: + init_route_map: + - route-map rmap_reg1 permit 11 + - route-map rmap_reg2 permit 11 + - route-map rmap_reg3 permit 11 + - route-map rmap_reg4 permit 11 + - route-map rmap_reg5 permit 11 + init_prefix_list: + - ip prefix-list p1 seq 1 permit 1.1.1.1/1 + - ip prefix-list p2 seq 2 permit 2.2.2.2/2 + init_vrf: + - "ip vrf {{vrf_1}}" + - "ip vrf {{vrf_2}}" + init_bgp: + - bgp_as: "{{bgp_as_1}}" + router_id: 111.2.2.41 + log_neighbor_changes: False + - bgp_as: "{{bgp_as_1}}" + router_id: 111.2.2.41 + log_neighbor_changes: False + vrf_name: VrfReg1 + - bgp_as: "{{bgp_as_2}}" + router_id: 111.2.2.52 + log_neighbor_changes: True + vrf_name: VrfReg2 + + +tests: "{{ merged_tests + deleted_tests }}" + +action_tests: + - name: test_case_action_01 + description: Delete peer group BGP NEIGHBORS NEIGHBORS properties + state: merged + input: [] + +deleted_tests: + - name: test_case_del_01 + description: Delete BGP NEIGHBORS additional attributes + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: "{{ interface1 }}" + auth_pwd: + pwd: "U2FsdGVkX19eY7P3qRyyjaFsQgjoSQE71IX6IeBRios=" + encrypted: true + dont_negotiate_capability: false + ebgp_multihop: + enabled: false + multihop_ttl: 2 + enforce_first_as: false + enforce_multihop: false + local_address: '1::1' + local_as: + nbr_description: "description 2" + override_capability: false + passive: false + port: 4 + solo: false + - neighbor: 192.168.1.5 + disable_connected_check: false + shutdown_msg: "msg2" + ttl_security: 8 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + neighbors: + - neighbor: "{{ interface1 }}" + auth_pwd: + pwd: "U2FsdGVkX19eY7P3qRyyjaFsQgjoSQE71IX6IeBRios=" + encrypted: true + nbr_description: 'description 3' + strict_capability_match: false + v6only: false + + - name: test_case_del_02 + description: Delete BGP peer-group prefix-list attributes + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE3 + address_family: + afis: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: false + prefix_limit: + max_prefixes: 2 + prevent_teardown: false + warning_threshold: 88 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: false + prefix_limit: + max_prefixes: 3 + warning_threshold: 77 + restart_timer: 10 + prefix_list_in: p1 + prefix_list_out: p2 + - afi: l2vpn + safi: evpn + prefix_limit: + max_prefixes: 4 + warning_threshold: 66 + restart_timer: 15 + prefix_list_in: p2 + prefix_list_out: p1 + + - name: test_case_del_03 + description: BGP NEIGHBORS remote-as properties + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + remote_as: + peer_type: internal + address_family: + afis: + - afi: ipv4 + safi: unicast + allowas_in: + origin: false + neighbors: + - neighbor: "{{ interface1 }}" + remote_as: + peer_type: internal + - neighbor: 11::11 + remote_as: + peer_type: external + - neighbor: 67.1.1.1 + remote_as: + peer_as: 7 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + remote_as: + peer_as: 1232 + capability: + dynamic: true + extended_nexthop: true + neighbors: + - neighbor: "{{ interface1 }}" + remote_as: + peer_as: 1234 + - neighbor: 11::11 + remote_as: + peer_as: 4332 + - neighbor: 67.1.1.1 + remote_as: + peer_type: external + + - name: test_case_del_04 + description: BGP NEIGHBORS remote-as properties + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: "{{ interface1 }}" + - neighbor: 11::11 + - neighbor: 67.1.1.1 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + neighbors: + - neighbor: "{{ interface1 }}" + - neighbor: 11::11 + - neighbor: 67.1.1.1 + + - name: test_case_del_05 + description: BGP NEIGHBORS delete neighbor peergroup, bfd, and timers + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + bfd: + enabled: false + check_failure: false + profile: "profile 2" + timers: + keepalive: 40 + holdtime: 50 + connect_retry: 60 + neighbors: + - neighbor: "{{ interface2 }}" + peer_group: SPINE + bfd: + enabled: false + check_failure: false + profile: "profile 3" + timers: + keepalive: 41 + holdtime: 51 + connect_retry: 61 + - neighbor: 3::3 + peer_group: SPINE + - neighbor: 192.168.1.5 + peer_group: SPINE1 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + bfd: + enabled: false + check_failure: false + profile: "profile 2" + timers: + keepalive: 40 + holdtime: 50 + connect_retry: 60 + neighbors: + - neighbor: "{{ interface4 }}" + peer_group: SPINE + - neighbor: "{{ interface3 }}" + peer_group: SPINE1 + bfd: + enabled: false + check_failure: false + profile: "profile 4" + timers: + keepalive: 55 + holdtime: 44 + connect_retry: 33 + - neighbor: 3::3 + peer_group: SPINE + + - name: test_case_del_06 + description: Delete peer group additional attributes + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + auth_pwd: + pwd: "U2FsdGVkX19eY7P3qRyyjaFsQgjoSQE71IX6IeBRios=" + encrypted: true + dont_negotiate_capability: false + ebgp_multihop: + enabled: false + multihop_ttl: 2 + enforce_first_as: false + enforce_multihop: false + local_address: '1.1.1.1' + local_as: + as: 3 + no_prepend: false + replace_as: false + pg_description: "description 2" + override_capability: false + passive: false + solo: false + - name: SPINE1 + disable_connected_check: false + shutdown_msg: "msg2" + strict_capability_match: false + ttl_security: 8 + + - name: test_case_del_07 + description: Delete peer group BGP NEIGHBORS properties + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE1 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + - name: SPINE1 + + - name: test_case_del_08 + description: BGP NEIGHBORS remote-as properties + state: deleted + input: [] + +merged_tests: + - name: test_case_01 + description: BGP NEIGHBORS properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + remote_as: + peer_as: 12 + bfd: + enabled: true + check_failure: true + profile: "profile 1" + advertisement_interval: 10 + timers: + keepalive: 40 + holdtime: 50 + connect_retry: 60 + capability: + dynamic: true + extended_nexthop: true + address_family: + afis: + - afi: ipv4 + safi: unicast + allowas_in: + value: 2 + neighbors: + - neighbor: "{{ interface2 }}" + remote_as: + peer_as: 12 + peer_group: SPINE + advertisement_interval: 10 + timers: + keepalive: 40 + holdtime: 50 + connect_retry: 60 + bfd: + enabled: true + check_failure: true + profile: "profile 1" + capability: + dynamic: true + extended_nexthop: true + - neighbor: 192.168.1.4 + - neighbor: 2::2 + - neighbor: "{{ interface1 }}" + - neighbor: 192.168.1.5 + remote_as: + peer_as: 6 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - neighbor: 3::3 + remote_as: + peer_as: 7 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + remote_as: + peer_type: internal + bfd: + enabled: true + check_failure: true + profile: "profile 1" + advertisement_interval: 15 + timers: + keepalive: 50 + holdtime: 40 + connect_retry: 60 + capability: + dynamic: true + extended_nexthop: true + address_family: + afis: + - afi: ipv6 + safi: unicast + allowas_in: + value: 3 + neighbors: + - neighbor: "{{ interface3 }}" + remote_as: + peer_as: 11 + peer_group: SPINE + advertisement_interval: 10 + timers: + keepalive: 40 + holdtime: 50 + connect_retry: 60 + bfd: + enabled: true + check_failure: true + profile: "profile 2" + capability: + dynamic: true + extended_nexthop: true + - neighbor: 192.168.2.2 + - neighbor: "{{ interface4 }}" + remote_as: + peer_as: 12 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - name: test_case_02 + description: Update BGP NEIGHBORS properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + bfd: + enabled: false + check_failure: false + profile: "profile 2" + - name: SPINE1 + remote_as: + peer_type: external + bfd: + enabled: true + check_failure: true + profile: "profile 2" + advertisement_interval: 15 + timers: + keepalive: 30 + holdtime: 60 + connect_retry: 90 + capability: + dynamic: true + extended_nexthop: true + address_family: + afis: + - afi: ipv4 + safi: unicast + allowas_in: + origin: true + neighbors: + - neighbor: "{{ interface2 }}" + remote_as: + peer_as: 111 + peer_group: SPINE + advertisement_interval: 11 + timers: + keepalive: 41 + holdtime: 51 + connect_retry: 61 + bfd: + enabled: false + check_failure: false + profile: "profile 3" + capability: + dynamic: false + extended_nexthop: false + - neighbor: 192.168.1.4 + - neighbor: "{{ interface1 }}" + - neighbor: 192.168.1.5 + remote_as: + peer_as: 112 + peer_group: SPINE1 + advertisement_interval: 21 + timers: + keepalive: 22 + holdtime: 23 + connect_retry: 24 + capability: + dynamic: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + bfd: + enabled: false + check_failure: false + profile: "profile 2" + - name: SPINE1 + remote_as: + peer_type: internal + bfd: + enabled: true + check_failure: true + profile: "profile 2" + advertisement_interval: 30 + timers: + keepalive: 10 + holdtime: 20 + connect_retry: 30 + capability: + dynamic: true + extended_nexthop: true + address_family: + afis: + - afi: ipv6 + safi: unicast + allowas_in: + origin: true + neighbors: + - neighbor: "{{ interface3 }}" + remote_as: + peer_as: 212 + peer_group: SPINE1 + advertisement_interval: 44 + timers: + keepalive: 55 + holdtime: 44 + connect_retry: 33 + bfd: + enabled: false + check_failure: false + profile: "profile 4" + capability: + dynamic: false + extended_nexthop: false + - neighbor: 192.168.2.2 + - neighbor: "{{ interface4 }}" + remote_as: + peer_as: 214 + peer_group: SPINE + advertisement_interval: 45 + timers: + keepalive: 33 + holdtime: 34 + connect_retry: 35 + capability: + dynamic: false + - neighbor: 3::3 + remote_as: + peer_as: 215 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - name: test_case_03 + description: BGP NEIGHBORS ipv6 properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + remote_as: + peer_as: 1123 + neighbors: + - neighbor: 2::2 + - neighbor: 11::11 + remote_as: + peer_type: external + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - neighbor: 3::3 + remote_as: + peer_as: 556 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + remote_as: + peer_type: external + address_family: + afis: + - afi: ipv6 + safi: unicast + allowas_in: + value: 4 + neighbors: + - neighbor: 192.168.2.2 + - neighbor: "{{ interface4 }}" + remote_as: + peer_as: 557 + peer_group: SPINE + advertisement_interval: 20 + timers: + keepalive: 30 + holdtime: 20 + connect_retry: 10 + capability: + dynamic: true + - name: test_case_04 + description: BGP NEIGHBORS remote-as properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + remote_as: + peer_type: internal + neighbors: + - neighbor: "{{ interface1 }}" + remote_as: + peer_type: internal + - neighbor: 11::11 + remote_as: + peer_type: external + - neighbor: 67.1.1.1 + remote_as: + peer_as: 7 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + remote_as: + peer_as: 1321 + address_family: + afis: + - afi: l2vpn + safi: evpn + allowas_in: + value: 4 + neighbors: + - neighbor: "{{ interface1 }}" + remote_as: + peer_as: 1234 + - neighbor: 11::11 + remote_as: + peer_as: 4332 + - neighbor: 67.1.1.1 + remote_as: + peer_type: external + - name: test_case_05 + description: BGP NEIGHBORS remote-as properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + neighbors: + - neighbor: "{{ interface1 }}" + remote_as: + peer_type: external + - neighbor: 11::11 + remote_as: + peer_type: internal + - neighbor: 67.1.1.1 + remote_as: + peer_type: internal + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + peer_group: + - name: SPINE + capability: + dynamic: true + extended_nexthop: true + neighbors: + - neighbor: "{{ interface1 }}" + remote_as: + peer_type: internal + - neighbor: 11::11 + remote_as: + peer_type: external + - neighbor: 67.1.1.1 + remote_as: + peer_as: 1123 + - name: test_case_06 + description: BGP NEIGHBORS configure additional attributes + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + auth_pwd: + pwd: "U2FsdGVkX19eY7P3qRyyjaFsQgjoSQE71IX6IeBRios=" + encrypted: true + dont_negotiate_capability: true + ebgp_multihop: + enabled: true + multihop_ttl: 1 + enforce_first_as: true + enforce_multihop: true + local_address: "{{ interface5 }}" + local_as: + as: 2 + no_prepend: true + replace_as: true + pg_description: "description 1" + override_capability: true + passive: true + solo: true + - name: SPINE1 + disable_connected_check: true + shutdown_msg: "msg1" + strict_capability_match: true + ttl_security: 5 + neighbors: + - neighbor: "{{ interface1 }}" + auth_pwd: + pwd: "U2FsdGVkX19eY7P3qRyyjaFsQgjoSQE71IX6IeBRios=" + encrypted: true + dont_negotiate_capability: true + ebgp_multihop: + enabled: true + multihop_ttl: 1 + enforce_first_as: true + enforce_multihop: true + local_address: "{{ interface5 }}" + local_as: + as: 2 + no_prepend: true + replace_as: true + nbr_description: "description 1" + override_capability: true + passive: true + port: 3 + solo: true + - neighbor: 192.168.1.5 + disable_connected_check: true + shutdown_msg: "msg1" + ttl_security: 5 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + neighbors: + - neighbor: "{{ interface1 }}" + auth_pwd: + pwd: "U2FsdGVkX19eY7P3qRyyjaFsQgjoSQE71IX6IeBRios=" + encrypted: true + nbr_description: 'description 2' + strict_capability_match: true + v6only: true + - name: test_case_07 + description: BGP NEIGHBORS modify additional attributes + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE + dont_negotiate_capability: false + ebgp_multihop: + enabled: false + multihop_ttl: 2 + enforce_first_as: false + enforce_multihop: false + local_address: '1.1.1.1' + local_as: + as: 3 + no_prepend: false + replace_as: false + pg_description: "description 2" + override_capability: false + passive: false + solo: false + - name: SPINE1 + disable_connected_check: false + shutdown_msg: "msg2" + strict_capability_match: false + ttl_security: 8 + neighbors: + - neighbor: "{{ interface1 }}" + dont_negotiate_capability: false + ebgp_multihop: + enabled: false + multihop_ttl: 2 + enforce_first_as: false + enforce_multihop: false + local_address: '1::1' + local_as: + as: 3 + no_prepend: false + replace_as: false + nbr_description: "description 2" + override_capability: false + passive: false + port: 4 + solo: false + - neighbor: 192.168.1.5 + disable_connected_check: false + shutdown_msg: "msg2" + ttl_security: 8 + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + neighbors: + - neighbor: "{{ interface1 }}" + nbr_description: 'description 3' + strict_capability_match: false + v6only: false + - name: test_case_08 + description: Configure BGP peer-group prefix-list attributes + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE3 + address_family: + afis: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: true + prefix_limit: + max_prefixes: 1 + prevent_teardown: true + warning_threshold: 80 + prefix_list_in: p1 + prefix_list_out: p2 + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: true + prefix_limit: + max_prefixes: 2 + warning_threshold: 70 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - afi: l2vpn + safi: evpn + prefix_limit: + max_prefixes: 3 + warning_threshold: 60 + restart_timer: 8 + prefix_list_in: p1 + prefix_list_out: p2 + - name: test_case_09 + description: Modify BGP peer-group prefix-list attributes + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + peer_group: + - name: SPINE3 + address_family: + afis: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: false + prefix_limit: + max_prefixes: 2 + prevent_teardown: false + warning_threshold: 88 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: false + prefix_limit: + max_prefixes: 3 + warning_threshold: 77 + restart_timer: 10 + prefix_list_in: p1 + prefix_list_out: p2 + - afi: l2vpn + safi: evpn + prefix_limit: + max_prefixes: 4 + warning_threshold: 66 + restart_timer: 15 + prefix_list_in: p2 + prefix_list_out: p1 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/action_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/action_template.yaml new file mode 100644 index 000000000..98dee21eb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/action_template.yaml @@ -0,0 +1,10 @@ +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_neighbors: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..d8f20a117 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/cleanup_tests.yaml @@ -0,0 +1,10 @@ +- name: Deletes old bgp_neighbors + sonic_bgp_neighbors: + config: [] + state: deleted + ignore_errors: yes +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/main.yml new file mode 100644 index 000000000..c622e0b37 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/main.yml @@ -0,0 +1,19 @@ +- debug: msg="sonic_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "Test action {{ module_name }} started ..." + include_tasks: action_template.yaml + loop: "{{ action_tests }}" + +- name: "Cleanup {{ module_name }} started ..." + include_tasks: cleanup_tests.yaml + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/preparation_tests.yaml new file mode 100644 index 000000000..c5917c78b --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/preparation_tests.yaml @@ -0,0 +1,38 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize route maps" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_route_map }}" + ignore_errors: yes +- name: "initialize prefix_lists" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_prefix_list }}" + ignore_errors: yes +- name: "initialize VRFs" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_vrf }}" + ignore_errors: yes +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes +- name: Create bgp + sonic_bgp: + config: "{{ preparations_tests.init_bgp }}" + state: merged + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/tasks_template.yaml new file mode 100644 index 000000000..d170be5d5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp_neighbors: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_neighbors: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/defaults/main.yml new file mode 100644 index 000000000..dcb7b46e5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/defaults/main.yml @@ -0,0 +1,468 @@ +--- +ansible_connection: httpapi +module_name: sonic_bgp_neighbors_af + +bgp_as_1: 51 +bgp_as_2: 52 + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +preparations_tests: + init_route_map: + - route-map rmap_reg1 permit 11 + - route-map rmap_reg2 permit 11 + - route-map rmap_reg3 permit 11 + - route-map rmap_reg4 permit 11 + - route-map rmap_reg5 permit 11 + init_prefix_list: + - ip prefix-list p1 seq 1 permit 1.1.1.1/1 + - ip prefix-list p2 seq 2 permit 2.2.2.2/2 + init_vrf: + - "ip vrf {{vrf_1}}" + - "ip vrf {{vrf_2}}" + init_bgp: + - bgp_as: "{{bgp_as_1}}" + router_id: 111.2.2.41 + log_neighbor_changes: False + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + router_id: 111.2.2.42 + log_neighbor_changes: True + init_bgp_neighbors: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 12.1.1.1 + - neighbor: 13.1.1.1 + - neighbor: 14.1.1.1 + - neighbor: 15.1.1.1 + - neighbor: "{{ interface3 }}" + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{vrf_1}}" + neighbors: + - neighbor: 21.1.1.1 + - neighbor: 22.1.1.1 + - neighbor: 23.1.1.1 + - neighbor: 24.1.1.1 + - neighbor: "{{ interface4 }}" + +negative_tests: + - name: negative_test_case_01 + description: allowas_in beyond value + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: "{{ interface3 }}" + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 11 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - name: negative_test_case_02 + description: BGP NEIGHBORS AF properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: "{{ interface3 }}" + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 11 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg2 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true +tests1: + - name: test_case_02 + description: Update BGP NEIGHBORS AF properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 12.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + origin: true + route_map: + - name: rmap_reg1 + direction: in + route_reflector_client: false + route_server_client: true + - afi: ipv6 + safi: unicast + allowas_in: + value: 3 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: false + - afi: l2vpn + safi: evpn + allowas_in: + value: 4 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{ vrf_1 }}" + neighbors: + - neighbor: "{{ interface4 }}" + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 4 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - afi: ipv6 + safi: unicast + allowas_in: + value: 7 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: false + - afi: l2vpn + safi: evpn + allowas_in: + origin: true + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + + +tests: + - name: test_case_01 + description: BGP NEIGHBORS AF properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 12.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 7 + route_map: + - name: rmap_reg1 + direction: in + route_reflector_client: false + route_server_client: true + activate: true + - afi: ipv6 + safi: unicast + allowas_in: + value: 7 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: false + activate: false + - afi: l2vpn + safi: evpn + allowas_in: + origin: true + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + activate: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{ vrf_1 }}" + neighbors: + - neighbor: "{{ interface4 }}" + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 4 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + activate: false + - afi: ipv6 + safi: unicast + allowas_in: + value: 5 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: false + activate: true + - afi: l2vpn + safi: evpn + allowas_in: + origin: true + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + activate: false + - name: test_case_02 + description: Update BGP NEIGHBORS AF properties + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 12.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + origin: true + route_map: + - name: rmap_reg1 + direction: in + route_reflector_client: false + route_server_client: true + - afi: ipv6 + safi: unicast + allowas_in: + value: 3 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: false + - afi: l2vpn + safi: evpn + allowas_in: + value: 4 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - bgp_as: "{{bgp_as_1}}" + vrf_name: "{{ vrf_1 }}" + neighbors: + - neighbor: "{{ interface4 }}" + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 4 + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - afi: ipv6 + safi: unicast + allowas_in: + value: 7 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: false + - afi: l2vpn + safi: evpn + allowas_in: + origin: true + route_map: + - name: rmap_reg1 + direction: in + - name: rmap_reg1 + direction: out + route_reflector_client: true + route_server_client: true + - name: test_case_03 + description: BGP NEIGHBORS AF + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 12.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 7 + route_map: + - name: rmap_reg1 + direction: out + route_reflector_client: false + route_server_client: true + - name: test_case_04 + description: Change route map + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 12.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 7 + route_map: + - name: rmap_reg2 + direction: out + route_reflector_client: false + route_server_client: true + - name: test_case_05 + description: Configure BGP neighbor prefix-list attributes + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 15.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: true + prefix_limit: + max_prefixes: 1 + prevent_teardown: true + warning_threshold: 80 + prefix_list_in: p1 + prefix_list_out: p2 + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: true + prefix_limit: + max_prefixes: 2 + warning_threshold: 70 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - afi: l2vpn + safi: evpn + prefix_limit: + max_prefixes: 3 + warning_threshold: 60 + restart_timer: 8 + prefix_list_in: p1 + prefix_list_out: p2 + - name: test_case_06 + description: Modify BGP neighbor prefix-list attributes + state: merged + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 15.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: false + prefix_limit: + max_prefixes: 2 + prevent_teardown: false + warning_threshold: 88 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: false + prefix_limit: + max_prefixes: 3 + warning_threshold: 77 + restart_timer: 10 + prefix_list_in: p1 + prefix_list_out: p2 + - afi: l2vpn + safi: evpn + prefix_limit: + max_prefixes: 4 + warning_threshold: 66 + restart_timer: 15 + prefix_list_in: p2 + prefix_list_out: p1 + - name: test_case_07 + description: Delete BGP neighbor prefix-list attributes + state: deleted + input: + - bgp_as: "{{bgp_as_1}}" + neighbors: + - neighbor: 15.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: false + prefix_limit: + max_prefixes: 2 + prevent_teardown: false + warning_threshold: 88 + restart_timer: 5 + prefix_list_in: p2 + prefix_list_out: p1 + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: false + prefix_limit: + max_prefixes: 3 + warning_threshold: 77 + restart_timer: 10 + prefix_list_in: p1 + prefix_list_out: p2 + - afi: l2vpn + safi: evpn + prefix_limit: + max_prefixes: 4 + warning_threshold: 66 + restart_timer: 15 + prefix_list_in: p2 + prefix_list_out: p1 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..453ed64e2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/cleanup_tests.yaml @@ -0,0 +1,15 @@ +- name: Deletes old bgp_neighbors_af + sonic_bgp_neighbors_af: + config: [] + state: deleted + ignore_errors: yes +- name: Deletes old bgp_neighbors + sonic_bgp_neighbors: + config: [] + state: deleted + ignore_errors: yes +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/main.yml new file mode 100644 index 000000000..012bf4aee --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/main.yml @@ -0,0 +1,21 @@ +- debug: msg="sonic_interfaces Test started ..." + +- debug: var=interface1 + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "Cleanup {{ module_name }} started ..." + include_tasks: cleanup_tests.yaml + +# - name: "Test nagative {{ module_name }} started ..." +# include_tasks: negative_tasks_template.yaml +# loop: "{{ negative_tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/preparation_tests.yaml new file mode 100644 index 000000000..93f74215a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/preparation_tests.yaml @@ -0,0 +1,43 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize route maps" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_route_map }}" + ignore_errors: yes +- name: "initialize prefix lists" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_prefix_list }}" + ignore_errors: yes +- name: "initialize VRFs" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_vrf }}" + ignore_errors: yes +- name: Deletes old bgp + sonic_bgp: + config: [] + state: deleted + ignore_errors: yes +- name: Create bgp + sonic_bgp: + config: "{{ preparations_tests.init_bgp }}" + state: merged + ignore_errors: yes +- name: Create bgp neighbors + sonic_bgp_neighbors: + config: "{{ preparations_tests.init_bgp_neighbors }}" + state: merged + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/tasks_template.yaml new file mode 100644 index 000000000..1ac758bef --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_bgp_neighbors_af/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_bgp_neighbors_af: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_bgp_neighbors_af: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/defaults/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/defaults/main.yaml new file mode 100644 index 000000000..ae1e7fb67 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/defaults/main.yaml @@ -0,0 +1 @@ +ansible_connection: network_cli
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/bad_operator.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/bad_operator.yaml new file mode 100644 index 000000000..79150a754 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/bad_operator.yaml @@ -0,0 +1,33 @@ +--- + + - name: Test sonic commands with wait_for negative case + sonic_command: + commands: + - 'show platform' + - 'show system' + wait_for: + - result[0] contains Fel + register: result + ignore_errors: yes + + - assert: + that: + - "result.failed == True" + - "result.failed_conditions is defined" + - "result.msg is defined" + + - name: Test sonic commands with wait_for and match=any + sonic_command: + commands: + - 'show platform' + - 'show system' + wait_for: + - result[0] contains Fel + - result[1] contains sonic + match: any + register: result + + - assert: + that: + - "result.failed == False" + - "result.changed == False" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/cli_command.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/cli_command.yaml new file mode 100644 index 000000000..f6294f30c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/cli_command.yaml @@ -0,0 +1,26 @@ +--- + + - block: + + - name: get output for single command + register: result + cli_command: + command: show system + + - assert: + that: + - result.changed == false + - result.stdout is defined + + - name: send invalid command + register: result + ignore_errors: true + cli_command: + command: show foo + + - assert: + that: + - result.failed == true + - result.msg is defined + + when: ansible_connection == 'network_cli' diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/contains.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/contains.yaml new file mode 100644 index 000000000..40a7f3109 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/contains.yaml @@ -0,0 +1,29 @@ +--- + + + - name: Test sonic single command with wait_for + sonic_command: + commands: 'show platform ' + wait_for: + - result[0] contains Del + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" + + - name: Test sonic multiple command with wait_for + sonic_command: + commands: + - 'show platform' + - 'show system' + wait_for: + - result[0] contains Dell + - result[1] contains sonic + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/invalid.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/invalid.yaml new file mode 100644 index 000000000..0f5278bb0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/invalid.yaml @@ -0,0 +1,25 @@ +--- +- name: run invalid command + register: result + ignore_errors: true + sonic_command: + commands: + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- name: run commands that include invalid command + register: result + ignore_errors: true + sonic_command: + commands: + - show system + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/main.yaml new file mode 100644 index 000000000..8dd58fbe7 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/main.yaml @@ -0,0 +1,12 @@ +--- + +- include_tasks: output.yaml +- include_tasks: contains.yaml +- include_tasks: bad_operator.yaml +- include_tasks: invalid.yaml +- include_tasks: cli_command.yaml +- include_tasks: test_local.yaml + vars: + ansible_connection: local +- include_tasks: timeout.yaml +- include_tasks: prompt.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/output.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/output.yaml new file mode 100644 index 000000000..5f6840cfc --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/output.yaml @@ -0,0 +1,24 @@ +--- + + - name: Test sonic single command + sonic_command: + commands: 'show interface status' + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" + + - name: Test sonic multiple commands + sonic_command: + commands: + - 'show platform' + - 'show system' + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout | length == 2" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/prompt.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/prompt.yaml new file mode 100644 index 000000000..0bf3fc031 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/prompt.yaml @@ -0,0 +1,15 @@ +--- + + + - name: Test sonic command with prompt handling + sonic_command: + commands: + - command: 'image remove all' + prompt: '\[y/N\]:$' + answer: 'N' + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/test_local.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/test_local.yaml new file mode 100644 index 000000000..e765756b8 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/test_local.yaml @@ -0,0 +1,16 @@ +--- + + - block: + + - name: test failure for local connection + register: result + cli_command: + command: show platform + ignore_errors: true + + - assert: + that: + - result.failed == true + - "'Connection type local is not valid for this module' in result.msg" + when: + ansible_connection == 'local' diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/timeout.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/timeout.yaml new file mode 100644 index 000000000..1f1f2ffd0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_command/tasks/timeout.yaml @@ -0,0 +1,30 @@ +--- + +- name: test bad condition + register: result + ignore_errors: true + sonic_command: + commands: + - show system + wait_for: + - result[0] contains bad_value_string + +- assert: + that: + - result.failed == true + - result.msg is defined + +- name: test bad condition with less retries + register: result + ignore_errors: true + sonic_command: + commands: + - show system + retries: 5 + wait_for: + - result[0] contains bad_value_string + +- assert: + that: + - result.failed == true + - result.msg is defined diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/defaults/main.yml new file mode 100644 index 000000000..38be9bc71 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/defaults/main.yml @@ -0,0 +1,83 @@ +--- +module_name: sonic_config +ansible_connection: network_cli +idempotent_condition: "{{ 'Passed' if ( idempotent_task_output.failed == false and + idempotent_task_output.commands is not defined and + idempotent_task_output.changed == false) + else 'Failed' + }}" +action_condition: "{{ 'Passed' if ( action_task_output.failed == false and + action_task_output.commands is defined and + action_task_output.changed == true) + else 'Failed' + }}" + +prompt_tc_condition: "{{ 'Passed' if ( prompt_tc.commands is defined ) + else 'Failed' + }}" + +backup_condition: "{{ 'Passed' if (backup_tc.stat.exists == true) + else 'Failed' + }}" + +replace_or_exact_condition: "{{ 'Passed' if ( replace_tc.commands is defined and replace_tc.commands |length>2) else 'Failed' }}" + +empty: [] + +bgp_as_1: 51 +bgp_as_2: 52 + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +snmp_location: snmp_chennai +snmp_contact: snmp_devops + +preparations_tests: + clean_cfg_lines: + - no interface PortChannel 11 + - no interface PortChannel 1 + - no interface PortChannel 2 + - no snmp-server community abcd + - no snmp-server community efgh + - no snmp-server community ijkl + - no snmp-server community mnop + - no snmp-server community qrst + - no snmp-server community uvwx + - no snmp-server location + - no snmp-server contact + - interface Vlan 11 + clean_interfaces: + - parent: interface Ethernet8 + lines: + - no description + +tests: + # Ethernet testcases started... + - name: test_case_01 + description: Configure ip access-list using 'before' and 'after' option on SONIC device + input: + lines: + - mtu 4444 + parents: ['interface PortChannel 11'] + before: ['snmp-server community abcd'] + after: ['snmp-server community efgh'] + - name: test_case_02 + description: Test sonic config module with single CLI + input: + before: 'snmp-server community ijkl' + commands: 'snmp-server community mnop' + - name: test_case_03 + description: Test sonic config module with multiple CLI + input: + commands: ['snmp-server community qrst', 'snmp-server community uvwx'] + - name: test_case_04 + description: Configure interface description using parents option on SONIC device + input: + lines: + - description 'hi' + parents: ['interface Ethernet8'] + - name: test_case_05 + description: Configure cli using source file + input: + src: snmp.j2 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/backup.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/backup.yaml new file mode 100644 index 000000000..c6bb35424 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/backup.yaml @@ -0,0 +1,16 @@ +- name: create configurable backup path + sonic_config: + backup: yes + backup_options: + filename: backup.cfg + dir_path: /tmp/ + register: backup_file + +- name: Verify file is created or not + stat: path={{backup_file.backup_path}} + register: backup_tc + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'backup_test_case.1': backup_condition }}, recursive=True) }}" + no_log: true diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/main.yml new file mode 100644 index 000000000..933bb71fc --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/main.yml @@ -0,0 +1,24 @@ +- debug: msg="sonic_config Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "Test Prompt validation started ..." + include_tasks: prompt.yaml + +- name: "Test sublevel command using replace in {{ module_name }} started ..." + include_tasks: replace_tasks_template.yaml + +- name: "Test sublevel command using match in {{ module_name }} started ..." + include_tasks: match_template.yaml + +- name: "Test backup option in {{ module_name }} started ..." + include_tasks: backup.yaml + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/match_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/match_template.yaml new file mode 100644 index 000000000..a92a809cd --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/match_template.yaml @@ -0,0 +1,64 @@ +- name: Configure sub level command using default match on SONIC device + sonic_config: + lines: ['switchport access Vlan 11', 'mtu 1500', 'no shutdown'] + parents: ['interface PortChannel 2'] + register: action_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'match_test_case.1': action_condition }}, recursive=True) }}" + no_log: true + +- name: Configure sub level command using default match on SONIC device idempotent + sonic_config: + lines: ['switchport access Vlan 11', 'mtu 1500', 'no shutdown'] + parents: ['interface PortChannel 2'] + register: idempotent_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'match_test_case.2': idempotent_condition }}, recursive=True) }}" + when: item.idemponent is not defined or item.idemponent != false + no_log: true + +- name: Rerun same configure task interchanging positions of sublevel commands using "match=strict" on SONIC device + sonic_config: + lines: ['mtu 1500', 'switchport access Vlan 11', 'no shutdown'] + parents: ['interface PortChannel 2'] + match: strict + register: action_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'match_test_case.3': action_condition }}, recursive=True) }}" + no_log: true + +- name: Configure sublevel command using "match=exact" on SONIC device + sonic_config: + lines: ['switchport access Vlan 11', 'mtu 1500', 'no shutdown', 'graceful-shutdown'] + parents: ['interface PortChannel 2'] + match: exact + register: replace_tc + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'match_test_case.4': replace_or_exact_condition }}, recursive=True) }}" + no_log: true + +- name: Rerun sublevel command using "match=exact" on SONIC device idempotent + sonic_config: + lines: ['switchport access Vlan 11', 'mtu 1500', 'no shutdown', 'graceful-shutdown'] + parents: ['interface PortChannel 2'] + match: exact + register: idempotent_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'match_test_case.5': idempotent_condition }}, recursive=True) }}" + when: item.idemponent is not defined or item.idemponent != false + no_log: true diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/preparation_tests.yaml new file mode 100644 index 000000000..5187a4fa4 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/preparation_tests.yaml @@ -0,0 +1,11 @@ +- name: "clean_cfg_lines" + sonic_config: + commands: "{{ preparations_tests.clean_cfg_lines }}" + register: prep_tasks + +- name: "parent based clean cfg" + sonic_config: + lines: "{{ item.lines }}" + parents: "{{ item.parent }}" + register: prep_tasks + with_items: "{{preparations_tests.clean_interfaces}}" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/prompt.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/prompt.yaml new file mode 100644 index 000000000..ac5f7057f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/prompt.yaml @@ -0,0 +1,12 @@ +- name: Test sonic config with prompt handling + sonic_config: + commands: + - command: 'do image remove all' + prompt: '\[y/N\]:$' + answer: 'N' + register: prompt_tc + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'prompt_test_case.1': prompt_tc_condition }}, recursive=True) }}" + no_log: true diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/replace_tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/replace_tasks_template.yaml new file mode 100644 index 000000000..9ab50b361 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/replace_tasks_template.yaml @@ -0,0 +1,38 @@ +- name: Configure sub level command using "default" option on SONIC device + sonic_config: + lines: ['mtu 1312', 'no shutdown', 'no graceful-shutdown'] + parents: ['interface PortChannel 1'] + register: action_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'replace_test_case.1': action_condition }}, recursive=True) }}" + no_log: true + +- name: Configure sub level command using replace "block" option on SONIC device + sonic_config: + lines: ['mtu 1312', 'no shutdown', 'graceful-shutdown'] + parents: ['interface PortChannel 1'] + replace: block + register: replace_tc + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'replace_test_case.2': replace_or_exact_condition }}, recursive=True) }}" + no_log: true + +- name: Configure sub level command using replace "block" option on SONIC device idempotent + sonic_config: + lines: ['mtu 1312', 'no shutdown', 'graceful-shutdown'] + parents: ['interface PortChannel 1'] + replace: block + register: idempotent_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {'replace_test_case.3': idempotent_condition }}, recursive=True) }}" + when: item.idemponent is not defined or item.idemponent != false + no_log: true diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/tasks_template.yaml new file mode 100644 index 000000000..fa2e7ace5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_config: "{{ item.input }}" + register: action_task_output + ignore_errors: true + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.1': action_condition }}, recursive=True) }}" + no_log: true + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_config: "{{ item.input }}" + register: idempotent_task_output + ignore_errors: true + when: item.idemponent is not defined or item.idemponent != false + +- set_fact: + ansible_facts: + test_reports: "{{ ansible_facts['test_reports']| default({})| combine({module_name: {item.name+'.2': idempotent_condition }}, recursive=True) }}" + when: item.idemponent is not defined or item.idemponent != false + no_log: true diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/templates/snmp.j2 b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/templates/snmp.j2 new file mode 100644 index 000000000..cd93c9b53 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/templates/snmp.j2 @@ -0,0 +1,6 @@ +{% if snmp_location is defined and snmp_location %} +snmp-server location "{{ snmp_location }}" +{% endif %} +{% if snmp_contact is defined and snmp_contact %} +snmp-server contact "{{ snmp_contact }}" +{% endif %} diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/templates/src.txt b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/templates/src.txt new file mode 100644 index 000000000..fbfeac922 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_config/templates/src.txt @@ -0,0 +1,3 @@ +interface ethernet 40 +description hello +mtu 1800 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/defaults/main.yml new file mode 100644 index 000000000..d391e690d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/defaults/main.yml @@ -0,0 +1,153 @@ +--- +ansible_connection: httpapi +module_name: interfaces + +po1: PortChannel50 +po2: PortChannel51 + +lo1: Loopback 100 +lo2: Loopback 101 + +vlan1: 500 +vlan2: 501 + +preparations_tests: + add_vlans_input: + - vlan_id: "{{ vlan1 }}" + - vlan_id: "{{ vlan2 }}" + add_lag_interfaces: + - name: "{{ po1 }}" + - name: "{{ po2 }}" + delete_port_configurations: + - "no interface {{ lo1 }}" + - "no interface {{ lo2 }}" + +tests: + + # Ethernet testcases started... + - name: test_case_01 + description: Update interface parameters + state: merged + input: + - name: "{{ interface1 }}" + description: ansible Ethernet4 descr + mtu: 6445 + enabled: false + - name: test_case_02 + description: Update interface parameters + state: merged + input: + - name: "{{ interface1 }}" + description: ansible Ethernet4 descr + mtu: 6444 + enabled: true + - name: "{{ interface3 }}" + description: ansible Ethernet12 descr + mtu: 6000 + enabled: true + - name: "{{ interface2 }}" + description: ansible Ethernet8 descr + mtu: 5666 + enabled: false + - name: "{{ interface4 }}" + description: ansible Ethernet16 descr + mtu: 5222 + enabled: true + - name: test_case_03 + description: Update interface parameters + state: deleted + input: + - name: "{{ interface1 }}" + description: + - name: "{{ interface3 }}" + mtu: + - name: "{{ interface2 }}" + enabled: + - name: "{{ interface4 }}" + - name: test_case_04 + description: Update interface parameters + state: merged + input: + - name: "{{ interface1 }}" + description: ansible Ethernet4 descr + mtu: 6444 + enabled: true + - name: "{{ interface3 }}" + description: ansible Ethernet12 descr + - name: "{{ interface4 }}" + description: ansible eth56 descr +# Loopback test cases started + - name: test_case_05 + description: Loopback interface parameters + state: merged + input: + - name: "{{ lo1 }}" # Loopback: mtu, desc, enabled not configurable in sonic-os + - name: "{{ lo2 }}" # Loopback: mtu, desc, enabled not configurable in sonic-os + - name: test_case_06 + description: Loopback delete interface parameters + state: deleted + input: + - name: "{{ lo1 }}" # Loopback: mtu, desc, enabled not configurable in sonic-os + - name: test_case_07 + description: Loopback delete interface parameters + state: deleted + input: + - name: "{{ lo1 }}" # Loopback: mtu, desc, enabled not configurable in sonic-os + - name: "{{ lo2 }}" # Loopback: mtu, desc, enabled not configurable in sonic-os +# Vlan test cases started + - name: test_case_08 + description: Update interface parameters + state: merged + input: + - name: "Vlan{{ vlan1 }}" # Vlan: desc, enabled not configurable in sonic-os + mtu: 5000 + - name: "Vlan{{ vlan2 }}" + mtu: 5001 + - name: test_case_09 + description: Update interface parameters + state: deleted + input: + - name: "Vlan{{ vlan1 }}" + mtu: + - name: "Vlan{{ vlan2 }}" + - name: test_case_10 + description: Update interface parameters + state: merged + input: + - name: "Vlan{{ vlan1 }}" + mtu: 6676 + - name: "Vlan{{ vlan2 }}" + mtu: 5113 +# Portchannel testcase started + - name: test_case_12 + description: Update interface parameters + state: merged + input: + - name: "{{ po1 }}" + mtu: 3434 + enabled: true + - name: "{{ po2 }}" + description: ansible PortChannel51 descr + mtu: 5454 + enabled: true + - name: test_case_13 + description: Update interface parameters + state: deleted + input: + - name: "{{ po1 }}" + - name: "{{ po2 }}" + - name: test_case_14 + description: Update interface parameters + state: merged + input: + - name: "{{ po1 }}" + mtu: 3434 + enabled: true + - name: "{{ po2 }}" + description: ansible PortChannel51 descr + mtu: 5454 + enabled: true + - name: test_case_15 + description: Update interface parameters + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/main.yml new file mode 100644 index 000000000..51c65668c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/main.yml @@ -0,0 +1,13 @@ +- debug: msg="sonic_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/preparation_tests.yaml new file mode 100644 index 000000000..ce4482513 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/preparation_tests.yaml @@ -0,0 +1,44 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize default interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ default_interface_cli }}" + register: output + ignore_errors: yes +- name: "delete loopback interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.delete_port_configurations }}" + register: output + ignore_errors: yes +- name: delete VLANs + sonic_vlans: + config: [] + state: deleted + ignore_errors: yes +- name: delete existing portchannels + sonic_lag_interfaces: + config: [] + state: deleted + ignore_errors: yes +- name: create VLANs + sonic_vlans: + config: "{{ preparations_tests.add_vlans_input }}" + state: merged + ignore_errors: yes +- name: create sonic_lag_interfaces "merged" state + sonic_lag_interfaces: + config: "{{ preparations_tests.add_lag_interfaces }}" + state: merged + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/tasks_template.yaml new file mode 100644 index 000000000..debf1a6ce --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_interfaces/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/defaults/main.yml new file mode 100644 index 000000000..8117a89cc --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/defaults/main.yml @@ -0,0 +1,101 @@ +--- +ansible_connection: httpapi +module_name: l2_interfaces + +preparations_tests: + add_vlans_input: + - vlan_id: 500 + - vlan_id: 501 + - vlan_id: 502 + - vlan_id: 503 + - vlan_id: 504 + - vlan_id: 505 + - vlan_id: 400 + - vlan_id: 401 + - vlan_id: 402 + delete_port_configurations: + - name: "{{ interface1 }}" + - name: "{{ interface2 }}" + - name: "{{ interface3 }}" + add_lag_interfaces: + - name: PortChannel100 + - name: PortChannel101 + +tests: + # merge test cases started + - name: test_case_01 + description: Add access and trunk VLANs + state: merged + input: + - name: "{{ interface1 }}" + access: + vlan: 400 + - name: "{{ interface2 }}" + trunk: + allowed_vlans: + - vlan: 501 + - vlan: 502 + - name: "{{ interface4 }}" + access: + vlan: 401 + trunk: + allowed_vlans: + - vlan: 504 + - vlan: 505 + - name: PortChannel100 + access: + vlan: 400 + - name: "{{ interface3 }}" + trunk: + allowed_vlans: + - vlan: 501 + - vlan: 502 + - name: test_case_02 + description: Update trunk VLANs + state: merged + input: + - name: "{{ interface3 }}" + trunk: + allowed_vlans: + - vlan: 502 + - vlan: 503 + access: + vlan: 402 + # delete test cases started + - name: test_case_03 + description: Delete Access VLAN + state: deleted + input: + - name: "{{ interface1 }}" + access: + - name: test_case_04 + description: Delete specific trunk VLANs + state: deleted + input: + - name: "{{ interface3 }}" + trunk: + allowed_vlans: + - vlan: 502 + - name: test_case_05 + description: Delete access VLANs from both associations + state: deleted + input: + - name: "{{ interface3 }}" + access: + vlan: + - name: test_case_06 + description: Delete all trunk VLANs + state: deleted + input: + - name: "{{ interface3 }}" + trunk: + allowed_vlans: + - name: test_case_07 + description: Delete all associations in specific interface + state: deleted + input: + - name: "{{ interface2 }}" + - name: test_case_08 + description: Delete All associations in all interfaces + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/main.yml new file mode 100644 index 000000000..be018feae --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/main.yml @@ -0,0 +1,12 @@ +- debug: msg="sonic_l2_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/preparation_tests.yaml new file mode 100644 index 000000000..125612321 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/preparation_tests.yaml @@ -0,0 +1,35 @@ +--- +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize default interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ default_interface_cli }}" + register: output + ignore_errors: yes +- name: create sonic_lag_interfaces "merged" state + sonic_lag_interfaces: + config: "{{ preparations_tests.add_lag_interfaces }}" + state: merged + ignore_errors: yes +- name: Delete VLANs Inputs + sonic_vlans: + config: "{{ preparations_tests.add_vlans_input }}" + state: deleted + register: merge_vlans_output + ignore_errors: yes +- name: create VLANs + sonic_vlans: + config: "{{ preparations_tests.add_vlans_input }}" + state: merged + register: merge_vlans_output + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/tasks_template.yaml new file mode 100644 index 000000000..8c883e5da --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l2_interfaces/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_l2_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_l2_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/defaults/main.yml new file mode 100644 index 000000000..de6322049 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/defaults/main.yml @@ -0,0 +1,244 @@ +--- +ansible_connection: httpapi +module_name: l3_interfaces + +preparations_tests: + delete_port_configurations: + - name: "{{ interface1 }}" + - name: "{{ interface2 }}" + - name: "{{ interface3 }}" + - name: "{{ interface4 }}" + init_loopback: + - "interface Loopback 100" + - "interface Loopback 101" + - "interface Portchannel 100" + - "interface Portchannel 101" + - "interface Vlan 100" + - "interface Vlan 101" + - "interface Vlan 102" + - "interface Vlan 501" + +tests: + # Vlan testcases started... + - name: test_case_01 + description: Update interface parameters + state: merged + input: + - name: Loopback100 + ipv4: + addresses: + - address: 101.1.1.1/32 + - address: 102.1.1.1/32 + secondary: True + - name: vlan 100 + ipv6: + enabled: true + addresses: + - address: 150::1/32 + - name: po 100 + ipv4: + addresses: + - address: 180.1.1.1/16 + - name: vlan 102 + ipv4: + anycast_addresses: + - 1.1.1.1/16 + - name: test_case_02 + description: Update interface parameters + state: merged + input: + - name: Loopback100 + ipv4: + addresses: + - address: 99.1.1.1/32 + - address: 103.1.1.1/32 + secondary: True + ipv6: + enabled: false + addresses: + - address: 101::1/128 + - name: vlan 100 + ipv4: + addresses: + - address: 150.1.1.1/16 + - name: po 100 + ipv6: + enabled: true + addresses: + - address: 180::1/16 + - name: vlan 102 + ipv4: + anycast_addresses: + - 11.12.13.14/12 + - name: test_case_03 + description: Update interface parameters + state: merged + input: + - name: loopback 100 + ipv4: + addresses: + - address: 102.1.1.1/32 + secondary: True + ipv6: + addresses: + - address: 102::1/128 + - name: vlan 100 + ipv4: + addresses: + - address: 152.1.1.1/16 + ipv6: + enabled: true + addresses: + - address: 152::1/16 + - name: po 100 + ipv4: + addresses: + - address: 182.1.1.1/16 + ipv6: + enabled: true + addresses: + - address: 182::1/16 + - name: test_case_04 + description: Update interface parameters + state: merged + input: + - name: "{{ interface1 }}" + ipv4: + addresses: + - address: 80.1.1.1/16 + - name: "{{ interface2 }}" + ipv6: + enabled: true + addresses: + - address: 90::1/16 + - name: test_case_05 + description: Update interface parameters + state: merged + input: + - name: "{{ interface1 }}" + ipv4: + addresses: + - address: 81.1.1.1/16 + - name: "{{ interface2 }}" + ipv6: + enabled: false + addresses: + - address: 90::1/16 + - address: 91::1/16 + - name: test_case_06 + description: Update interface parameters + state: merged + input: + - name: "{{ interface1 }}" + ipv4: + addresses: + - address: 83.1.1.1/16 + ipv6: + enabled: true + addresses: + - address: 83::1/16 + - address: 84::1/16 + - name: "{{ interface2 }}" + ipv4: + addresses: + - address: 91.1.1.1/16 + ipv6: + addresses: + - address: 90::1/16 + - address: 91::1/16 + - address: 92::1/16 + - address: 93::1/16 + - name: test_case_07 + description: Update interface parameters + state: deleted + input: + - name: "{{ interface1 }}" + ipv4: + addresses: + - address: 82.1.1.1/16 + - name: "{{ interface2 }}" + ipv6: + enabled: false + addresses: + - address: 91::1/16 + - name: vlan 102 + ipv4: + anycast_addresses: + - 1.1.1.1/16 + - name: test_case_08 + description: Update interface parameters + state: deleted + input: + - name: "{{ interface1 }}" + - name: "{{ interface2 }}" + - name: Vlan100 + - name: test_case_09 + description: Logical interfaces config + state: merged + input: + - name: Vlan101 + ipv4: + addresses: + - address: 104.1.1.1/16 + ipv6: + addresses: + - address: 1041::1/16 + - address: 1042::1/16 + - name: Loopback101 + ipv4: + addresses: + - address: 204.1.1.1/32 + ipv6: + addresses: + - address: 2041::1/128 + - address: 2042::1/128 + - name: PortChannel101 + ipv4: + addresses: + - address: 214.1.1.1/16 + ipv6: + addresses: + - address: 3041::1/16 + - address: 3042::1/16 + - name: test_case_10 + description: Naming tests + state: merged + input: + - name: vlan 501 + ipv4: + addresses: + - address: 105.1.1.1/16 + ipv6: + enabled: true + addresses: + - address: 1051::1/16 + - address: 1052::1/16 + - name: lo101 + ipv4: + addresses: + - address: 204.1.1.7/32 + ipv6: + enabled: true + addresses: + - address: 2041::1/128 + - address: 2042::1/128 + - name: portchannel 100 # po100 or portchannel100 + ipv4: + addresses: + - address: 64.1.1.1/16 + ipv6: + enabled: true + addresses: + - address: 3051::1/16 + - address: 3052::1/16 + - name: test_case_11 + description: Naming tests + state: deleted + input: + - name: vlan 501 + - name: lo101 + - name: portchannel 100 # po100 or portchannel100 + - name: test_case_12 + description: Update interface parameters + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/main.yml new file mode 100644 index 000000000..51c65668c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/main.yml @@ -0,0 +1,13 @@ +- debug: msg="sonic_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/preparation_tests.yaml new file mode 100644 index 000000000..66700d53e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/preparation_tests.yaml @@ -0,0 +1,28 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: Deletes old l3 interfaces + sonic_l3_interfaces: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize default interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ default_interface_cli }}" + register: output + ignore_errors: yes +- name: "initialize init_loopback" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_loopback }}" + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/tasks_template.yaml new file mode 100644 index 000000000..c2d30198e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_l3_interfaces/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_l3_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_l3_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/defaults/main.yml new file mode 100644 index 000000000..3f77cabab --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/defaults/main.yml @@ -0,0 +1,89 @@ +--- +ansible_connection: httpapi +module_name: lag_interfaces + +preparations_tests: + delete_port_configurations: + - name: "{{ interface1 }}" + - name: "{{ interface2 }}" + - name: "{{ interface3 }}" + - name: "{{ interface4 }}" + +tests: + # Ethernet testcases started... + - name: test_case_01 + description: Update Ethernet interface parameters + state: merged + input: + - name: PortChannel43 + mode: static + - name: PortChannel44 + mode: lacp + - name: test_case_02 + description: Update interface parameters + state: merged + input: + - name: PortChannel40 + mode: static + members: + interfaces: + - member: "{{ interface1 }}" + - name: PortChannel41 + mode: lacp + members: + interfaces: + - member: "{{ interface3 }}" + - name: PortChannel43 + mode: static + - name: test_case_03 + description: Update interface parameters + state: merged + input: + - name: PortChannel40 + mode: static + members: + interfaces: + - member: "{{ interface1 }}" + - member: "{{ interface2 }}" + - name: PortChannel41 + mode: lacp + members: + interfaces: + - member: "{{ interface3 }}" + - member: "{{ interface4 }}" + - name: PortChannel42 + - name: test_case_04 + description: Delete interface parameters + state: deleted + input: + - name: PortChannel40 + members: + interfaces: + - member: "{{ interface1 }}" + - name: PortChannel41 + members: + interfaces: + - name: PortChannel42 + - name: test_case_05 + description: Update interface parameters + state: merged + input: + - name: portchannel 40 + members: + interfaces: + - member: "{{ interface1 }}" + - name: po41 + members: + interfaces: + - member: "{{ interface3 }}" + - name: test_case_06 + description: Create standalone portchannels + state: merged + input: + - name: portchannel42 + - name: portchannel 12 + - name: po10 + - name: test_case_07 + description: Update interface parameters + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/meta/main.yaml new file mode 100644 index 000000000..78f79f8ca --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/main.yml new file mode 100644 index 000000000..1338f5f8d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/main.yml @@ -0,0 +1,13 @@ +- debug: msg="sonic_interfaces Test started ..." + +- name: Preparation test, default lag-interface configs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/preparation_tests.yaml new file mode 100644 index 000000000..55b64d5ff --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/preparation_tests.yaml @@ -0,0 +1,22 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize default interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ default_interface_cli }}" + register: output + ignore_errors: yes +- name: Delete all port channels + sonic_lag_interfaces: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/tasks_template.yaml new file mode 100644 index 000000000..927677433 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_lag_interfaces/tasks/tasks_template.yaml @@ -0,0 +1,22 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_lag_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_lag_interfaces: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/defaults/main.yml new file mode 100644 index 000000000..a2df2d365 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/defaults/main.yml @@ -0,0 +1,107 @@ +--- +ansible_connection: httpapi +module_name: mclag +preparations_tests: + add_vlans_input: + - vlan_id: 4 + - vlan_id: 5 + - vlan_id: 6 + - vlan_id: 2 + add_lag_interfaces: + - name: Po10 + - name: Po11 + - name: Po12 + - name: Po13 + +merged_tests: + - name: test_case_01 + description: MCLAG properties + state: merged + input: + domain_id: 1 + source_address: 3.3.3.3 + peer_address: 1.1.1.1 + peer_link: "{{ interface1 }}" + keepalive: 3 + session_timeout: 300 + system_mac: 00:00:00:01:01:01 + + - name: test_case_02 + description: Update created MCLAG properties + state: merged + input: + domain_id: 1 + source_address: 3.3.3.4 + peer_address: 1.1.1.2 + peer_link: "{{ interface2 }}" + keepalive: 2 + session_timeout: 350 + system_mac: 00:00:00:11:11:11 + + - name: test_case_03 + description: Update MCLAG properties - associate vlans and portchannels + state: merged + input: + domain_id: 1 + unique_ip: + vlans: + - vlan: vlan4 + - vlan: vlan5 + members: + portchannels: + - lag: Po10 + - lag: Po11 + +delete_all: + - name: del_all_test_case_01 + description: Delete MCLAG properties + state: deleted + +updated_tests: + - name: test_case_05 + description: Create new MCLAG with all properties including vlans and portchannels + state: merged + input: + domain_id: 2 + source_address: 3.3.3.5 + peer_address: 1.1.1.3 + peer_link: "{{ interface3 }}" + keepalive: 3 + session_timeout: 300 + system_mac: 00:00:00:01:01:01 + unique_ip: + vlans: + - vlan: vlan2 + - vlan: vlan6 + members: + portchannels: + - lag: Po13 + - lag: Po12 + + - name: del_test_case_01 + description: Delete MCLAG properties + state: deleted + input: + domain_id: 2 + source_address: 3.3.3.3 + peer_address: 1.1.1.1 + peer_link: "{{ interface3 }}" + keepalive: 3 + session_timeout: 300 + system_mac: 00:00:00:01:01:01 + unique_ip: + vlans: + - vlan: vlan2 + members: + portchannels: + - lag: Po13 + + - name: del_test_case_02 + description: Delete MCLAG associated vlans and portchannels + state: deleted + input: + domain_id: 2 + unique_ip: + vlans: + members: + portchannels: diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/meta/main.yaml new file mode 100644 index 000000000..d0ceaf6f5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/main.yml new file mode 100644 index 000000000..071ef9495 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/main.yml @@ -0,0 +1,22 @@ +- debug: msg="sonic_mclag Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ merged_tests }}" + +- name: "delete_all {{ module_name }} stated ..." + include_tasks: tasks_template_del.yaml + loop: "{{ delete_all }}" + when: delete_all is defined + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ updated_tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/preparation_tests.yaml new file mode 100644 index 000000000..843a1e834 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/preparation_tests.yaml @@ -0,0 +1,21 @@ +--- +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: create sonic_lag_interfaces "merged" state + sonic_lag_interfaces: + config: "{{ preparations_tests.add_lag_interfaces }}" + state: merged + ignore_errors: yes +- name: create VLANs Inputs + sonic_vlans: + config: "{{ preparations_tests.add_vlans_input }}" + state: merged + ignore_errors: yes +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/tasks_template.yaml new file mode 100644 index 000000000..add970c4f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_mclag: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_mclag: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/tasks_template_del.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/tasks_template_del.yaml new file mode 100644 index 000000000..9001d50aa --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_mclag/tasks/tasks_template_del.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_mclag: + state: "{{ item.state }}" + config: + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_mclag: + state: "{{ item.state }}" + config: + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/defaults/main.yml new file mode 100644 index 000000000..860297d6c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/defaults/main.yml @@ -0,0 +1,209 @@ +--- +ansible_connection: httpapi +module_name: ntp + +po1: Portchannel 100 +vlan1: Vlan 100 +lo1: Loopback 100 + +mgmt_vrf: mgmt + +ntp_ip_server_1: 10.11.0.1 +ntp_ip_server_2: 10.11.0.2 +ntp_ip_server_3: 10.11.0.3 +ntp_host_server: pool.ntp.org + +preparations_tests: + delete_interfaces: + - "no interface {{ po1 }}" + - "no interface {{ vlan1 }}" + - "no interface {{ lo1 }}" + init_interfaces: + - "interface {{ po1 }}" + - "interface {{ vlan1 }}" + - "interface {{ lo1 }}" + delete_mgmt_vrf: + - "no ip vrf mgmt" + create_mgmt_vrf: + - "ip vrf mgmt" + +tests: + - name: test_case_01 + description: Configure a NTP source interface + state: merged + input: + source_interfaces: + - "{{ interface1 }}" + + - name: test_case_02 + description: Create a NTP server + state: merged + input: + servers: + - address: "{{ ntp_ip_server_1 }}" + + - name: test_case_03 + description: Configure NTP source interfaces + state: merged + input: + source_interfaces: + - "{{ interface1 }}" + - "{{ po1 }}" + - "{{ vlan1 }}" + - "{{ lo1 }}" + + - name: test_case_04 + description: Create NTP servers + state: merged + input: + servers: + - address: "{{ ntp_ip_server_1 }}" + minpoll: 6 + maxpoll: 9 + - address: "{{ ntp_ip_server_2 }}" + minpoll: 5 + maxpoll: 8 + - address: "{{ ntp_host_server }}" + minpoll: 8 + maxpoll: 10 + + - name: test_case_05 + description: Configure NTP source interfaces and servers + state: merged + input: + source_interfaces: + - "{{ interface2 }}" + - "{{ po1 }}" + servers: + - address: "{{ ntp_ip_server_1 }}" + minpoll: 6 + maxpoll: 9 + - address: "{{ ntp_ip_server_3 }}" + minpoll: 7 + maxpoll: 10 + + - name: test_case_06 + description: Delete a NTP source interface + state: deleted + input: + source_interfaces: + - "{{ interface1 }}" + + - name: test_case_07 + description: Delete a NTP server + state: deleted + input: + servers: + - address: "{{ ntp_ip_server_1 }}" + + - name: test_case_08 + description: Delete several NTP source interfaces + state: deleted + input: + source_interfaces: + - "{{ interface2 }}" + - "{{ po1 }}" + + - name: test_case_09 + description: Delete several NTP servers + state: deleted + input: + servers: + - address: "{{ ntp_ip_server_1 }}" + - address: "{{ ntp_ip_server_3 }}" + + - name: test_case_10 + description: Delete NTP source interfaces and servers + state: deleted + input: + source_interfaces: + - "{{ interface2 }}" + - "{{ vlan1 }}" + - "{{ lo1 }}" + servers: + - address: "{{ ntp_ip_server_1 }}" + - address: "{{ ntp_host_server }}" + + - name: test_case_11 + description: Configure NTP VRF + state: merged + input: + vrf: "{{ mgmt_vrf }}" + + - name: test_case_12 + description: Delete NTP VRF + state: deleted + input: + vrf: "{{ mgmt_vrf }}" + + - name: test_case_13 + description: Enable NTP authentication + state: merged + input: + enable_ntp_auth: true + + - name: test_case_14 + description: Create NTP authentication keys + state: merged + input: + ntp_keys: + - key_id: 2 + key_type: NTP_AUTH_SHA1 + key_value: U2FsdGVkX197E9oiCGzwZlZxZpF5f/ZI8v+SGJdQvmA= + encrypted: true + - key_id: 6 + key_type: NTP_AUTH_MD5 + key_value: U2FsdGVkX1/wWVxmcp59mJQO6uzhFEHIxScdCbIqJh4= + encrypted: true + + - name: test_case_15 + description: Configure NTP trusted keys + state: merged + input: + trusted_keys: + - 2 + - 6 + + - name: test_case_16 + description: Create NTP servers with key + state: merged + input: + servers: + - address: "{{ ntp_ip_server_1 }}" + key_id: 2 + minpoll: 6 + maxpoll: 9 + + - name: test_case_17 + description: Delete NTP trusted keys + state: deleted + input: + trusted_keys: + - 2 + - 6 + + - name: test_case_18 + description: Delete NTP server + state: deleted + input: + servers: + - address: "{{ ntp_ip_server_1 }}" + + - name: test_case_19 + description: Delete NTP authentication keys + state: deleted + input: + ntp_keys: + - key_id: 2 + - key_id: 6 + + - name: test_case_20 + description: Delete NTP authentication + state: deleted + input: + enable_ntp_auth: true + + - name: test_case_21 + description: Delete all NTP configurations + state: deleted + input: {} diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..bb31455eb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/cleanup_tests.yaml @@ -0,0 +1,15 @@ +- name: Delete interfaces + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.delete_interfaces }}" + register: output + ignore_errors: yes + +- name: Delete MGMT VRF + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.delete_mgmt_vrf }}" + register: output + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/main.yml new file mode 100644 index 000000000..ba1574e3f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/main.yml @@ -0,0 +1,16 @@ +- debug: msg="sonic_ntp Test started ..." + +- name: Preparations tests + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "Cleanup test {{ module_name }} started" + include_tasks: cleanup_tests.yaml + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/preparation_tests.yaml new file mode 100644 index 000000000..f74a2019a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/preparation_tests.yaml @@ -0,0 +1,21 @@ +- name: Delete existing NTP configurations + sonic_ntp: + config: {} + state: deleted + ignore_errors: yes + +- name: Initialize interfaces + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_interfaces }}" + register: output + ignore_errors: yes + +- name: Create MGMT VRF + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.create_mgmt_vrf }}" + register: output + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/tasks_template.yaml new file mode 100644 index 000000000..c580db844 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_ntp/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_ntp: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_ntp: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/defaults/main.yml new file mode 100644 index 000000000..402088be5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/defaults/main.yml @@ -0,0 +1,57 @@ +--- +ansible_connection: httpapi +module_name: port_breakout + +preparations_tests: + delete_port_breakouts: + - "no interface breakout port 1/97" + - "no interface breakout port 1/98" + - "no interface breakout port 1/99" + - "no interface breakout port 1/100" + - "no interface breakout port 1/101" + - "no interface breakout port 1/102" + +tests_cli: + - name: cli_test_case_01 + description: Configure breakout mode for ports + state: merged + input: + - name: 1/97 + mode: 4x25G + - name: 1/98 + mode: 1x40G + +tests: + - name: test_case_01 + description: Configure breakout mode for ports + state: merged + input: + - name: 1/97 + mode: 4x25G + - name: 1/98 + mode: 1x40G + - name: 1/99 + mode: 4x25G + - name: 1/100 + mode: 4x10G + - name: 1/101 + mode: 1x40G + - name: 1/102 + mode: 4x25G + - name: test_case_02 + description: Update breakout mode for ports + state: merged + input: + - name: 1/97 + mode: 1x40G + - name: 1/98 + mode: 4x10G + - name: test_case_03 + description: delete specific port breakout mode + state: deleted + input: + - name: 1/98 + - name: test_case_04 + description: deleting all the port breakout modes + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/meta/main.yaml new file mode 100644 index 000000000..0b356217e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..fc7e76dda --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/cleanup_tests.yaml @@ -0,0 +1,6 @@ +- name: Deletes old bgp + sonic_port_breakout: + config: [] + state: deleted + ignore_errors: yes + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/main.yml new file mode 100644 index 000000000..2dea65315 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/main.yml @@ -0,0 +1,31 @@ +- debug: msg="sonic_port_breakout Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} CLI validation started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests_cli }}" + +- name: "Test CLI validation started ..." + include_role: + name: common + tasks_from: cli_tasks_template.yaml + loop: "{{ tests_cli }}" + +# - name: Preparations test +# include_tasks: preparation_tests.yaml + +# - name: "Test {{ module_name }} started ..." +# include_tasks: tasks_template.yaml +# loop: "{{ tests }}" + +# - name: Cleanup tests +# include_tasks: cleanup_tests.yaml + +# - name: Display all variables/facts known for a host +# debug: +# var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/preparation_tests.yaml new file mode 100644 index 000000000..14ceb14ce --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old port breakouts + sonic_port_breakout: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/tasks_template.yaml new file mode 100644 index 000000000..04ab1b456 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_port_breakout: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_port_breakout: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..c08c5950c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_port_breakout/templates/cli_test_case_01.cfg @@ -0,0 +1,2 @@ +interface breakout port 1/97 mode 4x25G +interface breakout port 1/98 mode 1x40G diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/defaults/main.yml new file mode 100644 index 000000000..be5199910 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/defaults/main.yml @@ -0,0 +1,122 @@ +--- +ansible_connection: httpapi +module_name: sonic_prefix_lists + +tests: + - name: test_case_01 + description: Add initial prefix list configuration + state: merged + input: + - afi: ipv4 + name: pf1 + prefixes: + - action: deny + sequence: 10 + prefix: 1.2.3.0/24 + ge: 25 + le: 27 + - afi: ipv4 + name: pf2 + prefixes: + - action: deny + prefix: 10.20.30.0/24 + sequence: 20 + ge: 26 + - action: permit + prefix: 10.20.30.128/25 + sequence: 50 + ge: 27 + le: 29 + - afi: ipv4 + name: pf3 + prefixes: + - action: deny + prefix: 1.2.3.128/25 + sequence: 30 + le: 27 + - afi: ipv6 + name: pf4 + prefixes: + - action: permit + sequence: 40 + prefix: 50:60::/64 + + - name: test_case_02 + description: Add another prefix set to the existing configuration + state: merged + input: + - afi: ipv4 + name: pf5 + prefixes: + - action: permit + prefix: 15.25.35.0/24 + sequence: 15 + + - name: test_case_03 + description: Add a prefix to an existing prefix set + state: merged + input: + - afi: ipv4 + name: pf3 + prefixes: + - action: permit + prefix: 1.2.3.192/26 + sequence: 40 + ge: 28 + le: 30 + + - name: test_case_04 + description: Modify "action" attributes for an existing prefix + state: merged + input: + - afi: ipv4 + name: pf2 + prefixes: + - action: permit + prefix: 10.20.30.0/24 + sequence: 20 + ge: 26 + - action: deny + prefix: 10.20.30.128/25 + sequence: 50 + ge: 27 + le: 29 + + - name: test_case_05 + description: Delete prefixes from existing prefix sets + state: deleted + input: + - afi: ipv4 + name: pf2 + prefixes: + - action: deny + prefix: 10.20.30.0/24 + sequence: 20 + ge: 26 + - afi: ipv4 + name: pf3 + prefixes: + - action: permit + prefix: 1.2.3.192/26 + sequence: 40 + ge: 28 + le: 30 + - afi: ipv4 + name: pf5 + prefixes: + - action: permit + prefix: 15.25.35.0/24 + sequence: 15 + + - name: test_case_06 + description: Delete prefix sets from the existing configuration + state: deleted + input: + - name: pf1 + - name: pf4 + afi: ipv6 + + - name: test_case_07 + description: Delete all prefix set configuration + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/meta/main.yaml new file mode 100644 index 000000000..0b356217e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..1a25238c5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/cleanup_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes all prefix lists + sonic_prefix_lists: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/main.yml new file mode 100644 index 000000000..6414ec4e2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/main.yml @@ -0,0 +1,15 @@ +- debug: msg="sonic_prefix_lists Test started ..." + +- name: Preparation test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "Cleanup {{ module_name }} started ..." + include_tasks: cleanup_tests.yaml + +- name: Display Test Report Output + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/preparation_tests.yaml new file mode 100644 index 000000000..6db3bac98 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/preparation_tests.yaml @@ -0,0 +1,7 @@ +- name: "Delete old prefix lists" + vars: + ansible_connection: httpapi + sonic_prefix_lists: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/tasks_template.yaml new file mode 100644 index 000000000..4e5b0f4e3 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_prefix_lists/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_prefix_lists: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_prefix_lists: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/defaults/main.yml new file mode 100644 index 000000000..6a79dc88d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/defaults/main.yml @@ -0,0 +1,114 @@ +--- +ansible_connection: httpapi +module_name: radius_server + +preparations_tests: + delete_radius_server: + - name: delete_all + description: Configure radius server + state: deleted + input: +tests: + - name: test_case_01 + description: Add new host configuration + state: merged + input: + auth_type: chap + timeout: 12 + nas_ip: 10.11.12.13 + retransmit: 5 + statistics: true + servers: + host: + - name: my_host1 + auth_type: chap + priority: 3 + vrf: mgmt + timeout: 12 + port: 55 + source_interface: "{{ interface1 }}" + retransmit: 7 + - name: my_host2 + auth_type: pap + priority: 4 + vrf: mgmt + timeout: 15 + port: 56 + source_interface: "{{ interface2 }}" + retransmit: 8 + - name: my_host3 + auth_type: mschapv2 + priority: 6 + vrf: mgmt + timeout: 20 + port: 57 + source_interface: "{{ interface3 }}" + retransmit: 9 + - name: test_case_02 + description: Update specific params of radius server + state: merged + input: + auth_type: mschapv2 + timeout: 24 + servers: + host: + - name: my_host + auth_type: mschapv2 + port: 45 + timeout: 9 + vrf: mgmt + - name: test_case_03 + description: Delete specific params of radius server + state: deleted + input: + key: login + timeout: 24 + servers: + host: + - name: my_host + - name: test_case_04 + description: Delete all hosts configurations + state: deleted + input: + servers: + host: + - name: test_case_05 + description: Add new host configuration + state: merged + input: + auth_type: chap + timeout: 12 + nas_ip: 10.11.12.13 + retransmit: 5 + statistics: true + servers: + host: + - name: my_host1 + auth_type: chap + priority: 3 + vrf: mgmt + timeout: 12 + port: 55 + source_interface: "{{ interface1 }}" + retransmit: 7 + - name: my_host2 + auth_type: pap + priority: 4 + vrf: mgmt + timeout: 15 + port: 56 + source_interface: "{{ interface2 }}" + retransmit: 8 + - name: my_host3 + auth_type: mschapv2 + priority: 6 + vrf: mgmt + timeout: 20 + port: 57 + source_interface: "{{ interface3 }}" + retransmit: 9 + +test_delete_all: + - name: test_case_06 + description: delete all the configurations of radius server + state: deleted diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/meta/main.yaml new file mode 100644 index 000000000..0b356217e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..bbe930699 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/cleanup_tests.yaml @@ -0,0 +1,6 @@ +- name: Deletes old bgp + sonic_radius_server: + config: {} + state: deleted + ignore_errors: yes + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/main.yml new file mode 100644 index 000000000..18bebfbaf --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/main.yml @@ -0,0 +1,16 @@ +- debug: msg="sonic_radius_server Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "test_delete_all {{ module_name }} stated ..." + include_tasks: tasks_template_del.yaml + loop: "{{ test_delete_all }}" + when: test_delete_all is defined diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/preparation_tests.yaml new file mode 100644 index 000000000..f1a64aa74 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old radius server configurations + sonic_radius_server: + config: {} + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/tasks_template.yaml new file mode 100644 index 000000000..66281d525 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_radius_server: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_radius_server: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/tasks_template_del.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/tasks_template_del.yaml new file mode 100644 index 000000000..1cfb7c04e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/tasks/tasks_template_del.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_radius_server: + state: "{{ item.state }}" + config: + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_radius_server: + state: "{{ item.state }}" + config: + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_radius_server/templates/cli_test_case_01.cfg diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/defaults/main.yml new file mode 100644 index 000000000..64d2485fe --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/defaults/main.yml @@ -0,0 +1,172 @@ +--- +ansible_connection: httpapi +module_name: static_routes + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +preparations_tests: + init_vrf: + - 'ip vrf {{vrf_1}}' + - 'ip vrf {{vrf_2}}' +tests: + - name: test_case_01 + description: Add new static routes configuration + state: merged + input: + - vrf_name: 'default' + static_list: + - prefix: '2.0.0.0/8' + next_hops: + - index: + interface: '{{ interface1 }}' + metric: 1 + tag: 2 + track: 3 + - vrf_name: '{{vrf_1}}' + static_list: + - prefix: '3.0.0.0/8' + next_hops: + - index: + blackhole: True + interface: '{{ interface1 }}' + nexthop_vrf: '{{vrf_2}}' + next_hop: '5.0.0.0' + metric: 1 + tag: 2 + track: 3 + - index: + interface: '{{ interface1 }}' + nexthop_vrf: '{{vrf_2}}' + next_hop: '4.0.0.0' + metric: 4 + tag: 5 + track: 6 + - vrf_name: '{{vrf_2}}' + static_list: + - prefix: '1.0.0.0/8' + next_hops: + - index: + interface: '{{ interface2 }}' + nexthop_vrf: '{{vrf_1}}' + - index: + interface: '{{ interface3 }}' + next_hop: '2.0.0.0' + - prefix: '7.0.0.0/8' + next_hops: + - index: + nexthop_vrf: '{{vrf_1}}' + next_hop: '3.0.0.0' + - name: test_case_02 + description: Modify static routes configuration + state: merged + input: + - vrf_name: 'default' + static_list: + - prefix: '2.0.0.0/8' + next_hops: + - index: + interface: '{{ interface1 }}' + metric: 10 + tag: 20 + track: 30 + - index: + next_hop: '3.0.0.0' + metric: 8 + tag: 10 + track: 12 + - vrf_name: '{{vrf_1}}' + static_list: + - prefix: '3.0.0.0/8' + next_hops: + - index: + blackhole: True + interface: '{{ interface1 }}' + nexthop_vrf: '{{vrf_2}}' + next_hop: '5.0.0.0' + metric: 11 + tag: 22 + track: 33 + - vrf_name: '{{vrf_2}}' + static_list: + - prefix: '1.0.0.0/8' + next_hops: + - index: + interface: '{{ interface2 }}' + nexthop_vrf: '{{vrf_1}}' + metric: 6 + tag: 7 + track: 8 + - prefix: '7.0.0.0/8' + next_hops: + - index: + nexthop_vrf: '{{vrf_1}}' + next_hop: '3.0.0.0' + metric: 9 + tag: 10 + track: 11 + - name: test_case_03 + description: Delete static routes metric, tag, and track configuration + state: deleted + input: + - vrf_name: 'default' + static_list: + - prefix: '2.0.0.0/8' + next_hops: + - index: + interface: '{{ interface1 }}' + metric: 10 + tag: 20 + track: 30 + - index: + next_hop: '3.0.0.0' + metric: 8 + tag: 10 + track: 12 + - vrf_name: '{{vrf_1}}' + static_list: + - prefix: '3.0.0.0/8' + next_hops: + - index: + blackhole: True + interface: '{{ interface1 }}' + nexthop_vrf: '{{vrf_2}}' + next_hop: '5.0.0.0' + metric: 11 + tag: 22 + track: 33 + - index: + interface: '{{ interface1 }}' + nexthop_vrf: '{{vrf_2}}' + next_hop: '4.0.0.0' + - name: test_case_04 + description: Delete static route index configuration + state: deleted + input: + - vrf_name: 'default' + static_list: + - prefix: '2.0.0.0/8' + next_hops: + - index: + interface: '{{ interface1 }}' + - index: + next_hop: '3.0.0.0' + - vrf_name: '{{vrf_2}}' + static_list: + - prefix: '1.0.0.0/8' + next_hops: + - index: + interface: '{{ interface3 }}' + next_hop: '2.0.0.0' + - name: test_case_05 + description: Delete static route prefix configuration + state: deleted + input: + - vrf_name: '{{vrf_1}}' + - vrf_name: '{{vrf_2}}' + static_list: + - prefix: '7.0.0.0/8' + - name: test_case_06 + description: Delete all static routes configuration + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/meta/main.yaml new file mode 100644 index 000000000..0b356217e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/main.yml new file mode 100644 index 000000000..c87965de1 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/main.yml @@ -0,0 +1,11 @@ +- debug: msg="sonic_static_routes Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/preparation_tests.yaml new file mode 100644 index 000000000..d504873a7 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/preparation_tests.yaml @@ -0,0 +1,11 @@ +- name: "initialize VRFs" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_vrf }}" + +- name: Deletes old static routes configurations + sonic_static_routes: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/tasks_template.yaml new file mode 100644 index 000000000..9695897c5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_static_routes: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_static_routes: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/tasks_template_del.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/tasks_template_del.yaml new file mode 100644 index 000000000..bbf2331df --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_static_routes/tasks/tasks_template_del.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_static_routes: + state: "{{ item.state }}" + config: + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_static_routes: + state: "{{ item.state }}" + config: + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/defaults/main.yml new file mode 100644 index 000000000..c5146db97 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/defaults/main.yml @@ -0,0 +1,47 @@ +--- +ansible_connection: httpapi +module_name: system +tests: + - name: test_case_01 + description: System properties + state: merged + input: + hostname: SONIC-test + interface_naming: standard + anycast_address: + ipv4: false + ipv6: false + + - name: test_case_02 + description: Update created System properties + state: merged + input: + hostname: SONIC-new + + - name: test_case_03 + description: Update System properties - associate mac address + state: merged + input: + anycast_address: + mac_address: 00:09:5B:EC:EE:F2 + + - name: del_test_case_01 + description: Delete System properties + state: deleted + input: + hostname: SONIC-new + interface_naming: standard + anycast_address: + ipv4: false + + - name: del_test_case_02 + description: Delete System associated anycast mac address + state: deleted + input: + anycast_address: + mac_address: 00:09:5B:EC:EE:F2 + +test_delete_all: + - name: del_all_test_case_01 + description: Delete System properties + state: deleted diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/meta/main.yaml new file mode 100644 index 000000000..d0ceaf6f5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..816050f91 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/cleanup_tests.yaml @@ -0,0 +1,13 @@ +#standard_command: interface-naming standard +#native_command: no interface-naming standard +#command: "{{ statandard_command if std_name in interface_mode else native_command }}" +#command: "{{ 'interface-naming standard' if std_name in interface_mode else 'no interface-naming standard' }}" +- name: Change the interface mode to old + vars: + ansible_connection: network_cli + command: interface-naming standard + no_command: no interface-naming standard + when: interface_mode == native_mode + sonic_config: + commands: "{{ command if std_name in interface_mode else no_command }}" + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/main.yml new file mode 100644 index 000000000..7f6652f11 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/main.yml @@ -0,0 +1,20 @@ +- debug: msg="sonic_system Test started ..." + +- name: Preparation Tests + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "test_delete_all {{ module_name }} stated ..." + include_tasks: tasks_template_del.yaml + loop: "{{ test_delete_all }}" + when: test_delete_all is defined + +- name: "Cleanup test {{ module_name }} started" + include_tasks: cleanup_tests.yaml + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/preparation_tests.yaml new file mode 100644 index 000000000..eaf12cdf2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes system configurations + sonic_system: + config: {} + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/tasks_template.yaml new file mode 100644 index 000000000..fc1e58b3f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_system: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_system: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/tasks_template_del.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/tasks_template_del.yaml new file mode 100644 index 000000000..1ac0e555c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_system/tasks/tasks_template_del.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_system: + state: "{{ item.state }}" + config: + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_system: + state: "{{ item.state }}" + config: + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/defaults/main.yml new file mode 100644 index 000000000..0f9b3e3c4 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/defaults/main.yml @@ -0,0 +1,91 @@ +--- +ansible_connection: httpapi +module_name: tacacs_server + +preparations_tests: + delete_tacacs_server: + - name: delete_all + description: Configure tacacs server + state: deleted + input: +tests: + - name: test_case_01 + description: Add new host configuration + state: merged + input: + auth_type: chap + source_interface: "{{ interface1 }}" + timeout: 12 + servers: + host: + - name: my_host + auth_type: chap + port: 55 + timeout: 12 + priority: 3 + - name: my_host1 + auth_type: login + port: 60 + timeout: 14 + priority: 4 + - name: my_host2 + auth_type: login + port: 60 + timeout: 14 + priority: 4 + - name: test_case_02 + description: Update specific params of tacacs server + state: merged + input: + auth_type: login + source_interface: "{{ interface2 }}" + timeout: 24 + servers: + host: + - name: my_host + auth_type: mschap + port: 45 + timeout: 9 + priority: 5 + vrf: default + - name: test_case_03 + description: Delete specific params of tacacs server + state: deleted + input: + key: login + timeout: 24 + servers: + host: + - name: my_host + - name: test_case_04 + description: Delete all hosts configurations + state: deleted + input: + servers: + host: + - name: test_case_05 + description: merge parameter of tacacs servers + state: merged + input: + servers: + host: + - name: my_host + auth_type: chap + port: 55 + timeout: 12 + priority: 3 + - name: my_host1 + auth_type: login + port: 60 + timeout: 14 + priority: 4 + - name: my_host2 + auth_type: login + port: 60 + timeout: 14 + priority: 4 + +test_delete_all: + - name: test_case_06 + description: delete all the configurations of tacacs server + state: deleted diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/meta/main.yaml new file mode 100644 index 000000000..0b356217e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..fd49cbd26 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/cleanup_tests.yaml @@ -0,0 +1,6 @@ +- name: Deletes old bgp + sonic_tacacs_server: + config: {} + state: deleted + ignore_errors: yes + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/main.yml new file mode 100644 index 000000000..4020d0771 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/main.yml @@ -0,0 +1,16 @@ +- debug: msg="sonic_tacacs_server Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: "test_delete_all {{ module_name }} stated ..." + include_tasks: tasks_template_del.yaml + loop: "{{ test_delete_all }}" + when: test_delete_all is defined diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/preparation_tests.yaml new file mode 100644 index 000000000..7c009d68d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes old tacacs server configurations + sonic_tacacs_server: + config: {} + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/tasks_template.yaml new file mode 100644 index 000000000..a73dd9ba6 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_tacacs_server: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_tacacs_server: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/tasks_template_del.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/tasks_template_del.yaml new file mode 100644 index 000000000..cf15eee9b --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/tasks/tasks_template_del.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_tacacs_server: + state: "{{ item.state }}" + config: + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_tacacs_server: + state: "{{ item.state }}" + config: + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_tacacs_server/templates/cli_test_case_01.cfg diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/defaults/main.yml new file mode 100644 index 000000000..342cb2d40 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/defaults/main.yml @@ -0,0 +1,96 @@ +--- +ansible_connection: httpapi +module_name: users + +tests_cli: + - name: cli_test_case_01 + description: Configure users + state: merged + expected_cli: + - username sysadmin password + - username operator1 password + input: + - name: sysadmin + role: admin + password: admin + update_password: always + - name: operator1 + role: operator + password: admin + update_password: always + +tests_single_run: + - name: test_case_sr_01 + description: Configure users + state: merged + task_condition_type: action + input: + - name: user1 + role: admin + password: admin + update_password: always + - name: user2 + role: operator + password: admin + update_password: always + - name: user2 + role: operator + password: admin + update_password: on_create + - name: test_case_sr_02 + description: Validate users creation + state: merged + task_condition_type: idempotent + input: + - name: user1 + role: admin + password: admin + update_password: on_create + - name: user2 + role: operator + password: admin + update_password: on_create + - name: user2 + role: operator + password: admin + update_password: on_create + + +tests: + - name: test_case_01 + description: Configure users + state: merged + input: + - name: user1 + role: admin + password: admin + update_password: on_create + - name: user2 + role: operator + password: admin + update_password: on_create + - name: user3 + role: admin + password: admin + update_password: on_create + - name: test_case_02 + description: Configure users role + state: merged + input: + - name: user1 + role: operator + password: admin + update_password: on_create + - name: user2 + role: admin + password: admin + update_password: on_create + - name: test_case_03 + description: Delete user + state: deleted + input: + - name: user1 + - name: test_case_04 + description: Update users role + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/meta/main.yaml new file mode 100644 index 000000000..0b356217e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common } diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/cli_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/cli_tests.yaml new file mode 100644 index 000000000..1e9bfc240 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/cli_tests.yaml @@ -0,0 +1,14 @@ +- name: Test sonic multiple command with wait_for + vars: + ansible_connection: network_cli + sonic_command: + commands: + - show running-configuration + register: cli_contains_output + +- set_fact: + cli_contains_condition: "{{ 'username operator1 password' in cli_contains_output.stdout.0 }}" + +- import_role: + name: common + tasks_from: cli.contains.test.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/main.yml new file mode 100644 index 000000000..987174b91 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/main.yml @@ -0,0 +1,39 @@ +- debug: msg="sonic_users Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +# - name: CLI test test +# include_tasks: cli_tests.yaml + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} Single run validation started ..." + include_tasks: single_run_template.yaml + loop: "{{ tests_single_run }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +# - name: "Test CLI validation started ..." +# include_role: +# name: common +# tasks_from: cli_tasks_template.yaml +# loop: "{{ tests_cli }}" + +# - name: Preparations test +# include_tasks: preparation_tests.yaml + + + +# - name: Preparations test +# include_tasks: preparation_tests.yaml + +# - name: Display all variables/facts known for a host +# debug: +# var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/preparation_tests.yaml new file mode 100644 index 000000000..3fe82414c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/preparation_tests.yaml @@ -0,0 +1,5 @@ +- name: Deletes all users except admin + sonic_users: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/single_run_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/single_run_template.yaml new file mode 100644 index 000000000..b6f7eab53 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/single_run_template.yaml @@ -0,0 +1,19 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_users: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: single_run_task_output + ignore_errors: yes + +- set_fact: + single_run_task_status: "{{ single_run_idem_condition }}" + when: item.task_condition_type == "idempotent" + +- set_fact: + single_run_task_status: "{{ single_run_condition }}" + when: item.task_condition_type != "idempotent" + +- import_role: + name: common + tasks_from: single.run.facts.report.yaml + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/tasks_template.yaml new file mode 100644 index 000000000..9713e0a95 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_users: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_users: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..0a2ceda7c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_users/templates/cli_test_case_01.cfg @@ -0,0 +1,2 @@ +username operator1 password $6$E3pDmCbrbYNEw952$6y9rQNgNRVCU4Fgu7QnNa.AYHuDqpzwYiTuR8QG0TUwcAbR/VFK1gZX1EEHpeE0wjgBf6USnLXcgBj8TIS5mg. role operator +username sysadmin password $6$UuxErB15tyodQ3SG$j02rdRERouNP3hed8w0Un5EO3tAhpoQqj6WlvJOU/.zuN3NzdoY/x1sahmgExMeOPeUtaSO.XdheJghewZG2y1 role admin diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/defaults/main.yml new file mode 100644 index 000000000..b7deed026 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/defaults/main.yml @@ -0,0 +1,42 @@ +--- +ansible_connection: httpapi +module_name: vlans + +preparations_tests: + add_vlans_input: + - vlan_id: 500 + - vlan_id: 501 + - vlan_id: 502 + - vlan_id: 503 + + +tests: + # merge test cases started + - name: test_case_01 + description: Add access and trunk VLANs + state: merged + input: + - vlan_id: 500 + description: "vlan500 description" + - vlan_id: 501 + description: "vlan501 description" + - name: test_case_02 + description: Update trunk VLANs + state: merged + input: + - vlan_id: 500 + description: "modified vlan500 description" + - vlan_id: 502 + - vlan_id: 503 + # delete test cases started + - name: test_case_03 + description: Delete Access VLAN + state: deleted + input: + - vlan_id: 500 + description: "modified vlan500 description" + - vlan_id: 501 + - name: test_case_04 + description: Delete specific trunk VLANs + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/main.yml new file mode 100644 index 000000000..be018feae --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/main.yml @@ -0,0 +1,12 @@ +- debug: msg="sonic_l2_interfaces Test started ..." + +- name: Preparations test, creates VLANs + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Display all variables/facts known for a host + debug: + var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/preparation_tests.yaml new file mode 100644 index 000000000..464180f6f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/preparation_tests.yaml @@ -0,0 +1,23 @@ +--- +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize default interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ default_interface_cli }}" + register: output + ignore_errors: yes +- name: Delete VLANs Inputs + sonic_vlans: + config: "{{ preparations_tests.add_vlans_input }}" + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/tasks_template.yaml new file mode 100644 index 000000000..2e0c41355 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vlans/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_vlans: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_vlans: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/defaults/main.yml new file mode 100644 index 000000000..afbfd754c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/defaults/main.yml @@ -0,0 +1,139 @@ +--- +ansible_connection: httpapi +module_name: vrf + +vrf_1: VrfReg1 +vrf_2: VrfReg2 + +po1: Portchannel 100 +vlan1: Vlan 100 +looopback1: Loopback 100 + +po2: Portchannel 101 +vlan2: Vlan 101 +looopback2: Loopback 101 + +preparations_tests: + delete_interfaces: + - "no interface {{ po1 }}" + - "no interface {{ vlan1 }}" + - "no interface {{ looopback1 }}" + - "no interface {{ po2 }}" + - "no interface {{ vlan2 }}" + - "no interface {{ looopback2 }}" + init_interfaces: + - "interface {{ po1 }}" + - "interface {{ vlan1 }}" + - "interface {{ looopback1 }}" + - "interface {{ po2 }}" + - "interface {{ vlan2 }}" + - "interface {{ looopback2 }}" + +tests_cli: + - name: cli_test_case_01 + description: creates VRF properties + state: merged + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + - name: "{{ interface1 }}" + - name: "{{ po1 }}" + - name: "{{ vlan1 }}" + - name: "{{ looopback1 }}" + - name: "{{ vrf_2 }}" + +tests: + - name: test_case_01 + description: creates VRF properties + state: merged + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + - name: "{{ interface1 }}" + - name: "{{ po1 }}" + - name: "{{ vrf_2 }}" + + - name: test_case_02 + description: Update VRF properties + state: merged + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + - name: "{{ vlan1 }}" + - name: "{{ vrf_2 }}" + members: + interfaces: + - name: "{{ interface2 }}" + - name: "{{ po2 }}" + + - name: test_case_03 + description: Update VRF properties + state: merged + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + - name: "{{ interface1 }}" + - name: "{{ po1 }}" + - name: "{{ looopback1 }}" + - name: "{{ vrf_2 }}" + members: + interfaces: + - name: "{{ interface2 }}" + - name: "{{ po2 }}" + - name: "{{ vlan2 }}" + - name: "{{ looopback2 }}" + + - name: del_test_case_04 + description: Delete VRF properties + state: deleted + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + - name: "{{ interface1 }}" + - name: "{{ vrf_2 }}" + members: + interfaces: + - name: "{{ interface2 }}" + - name: "{{ po2 }}" + + - name: del_test_case_05 + description: Delete VRF properties + state: deleted + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + + - name: del_test_case_06 + description: Delete VRF properties + state: deleted + input: + - name: "{{ vrf_2 }}" + + - name: test_case_07 + description: Merged VRF properties + state: merged + input: + - name: "{{ vrf_1 }}" + members: + interfaces: + - name: "{{ interface1 }}" + - name: "{{ po1 }}" + - name: "{{ looopback1 }}" + - name: "{{ vrf_2 }}" + members: + interfaces: + - name: "{{ interface2 }}" + - name: "{{ po2 }}" + - name: "{{ vlan2 }}" + - name: "{{ looopback2 }}" + + - name: del_test_case_08 + description: Delete VRF properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..c6a26a684 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/cleanup_tests.yaml @@ -0,0 +1,6 @@ +- name: Deletes old vrf + sonic_vrfs: + config: [] + state: deleted + ignore_errors: yes + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/main.yml new file mode 100644 index 000000000..8e165bc67 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/main.yml @@ -0,0 +1,34 @@ +- debug: msg="sonic_vrfs Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} CLI validation started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests_cli }}" + +- name: "Test CLI validation started ..." + include_role: + name: common + tasks_from: cli_tasks_template.yaml + loop: "{{ tests_cli }}" + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: Cleanup tests + include_tasks: cleanup_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +- name: Cleanup tests + include_tasks: cleanup_tests.yaml + +# - name: Display all variables/facts known for a host +# debug: +# var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/preparation_tests.yaml new file mode 100644 index 000000000..c6a33af48 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/preparation_tests.yaml @@ -0,0 +1,34 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize default interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ default_interface_cli }}" + register: output + ignore_errors: yes +- name: Deletes old VRFs + sonic_vrfs: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_interfaces }}" + register: output + ignore_errors: yes +- name: Deletes old VRFs + sonic_vrfs: + config: [] + state: deleted + ignore_errors: yes diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/tasks_template.yaml new file mode 100644 index 000000000..85fdccc0a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_vrfs: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_vrfs: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..35cd6ded0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vrfs/templates/cli_test_case_01.cfg @@ -0,0 +1,10 @@ +ip vrf VrfReg1 +ip vrf VrfReg2 +interface Vlan100 + ip vrf forwarding VrfReg1 +interface Loopback 100 + ip vrf forwarding VrfReg1 +interface PortChannel 100 + ip vrf forwarding VrfReg1 +interface {{ interface1 }} + ip vrf forwarding VrfReg1 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/defaults/main.yml new file mode 100644 index 000000000..f2687a09d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/defaults/main.yml @@ -0,0 +1,121 @@ +--- +ansible_connection: httpapi +module_name: vxlan + +vrf1: VrfReg1 +vrf2: VrfReg2 + +po1: Portchannel 100 +vlan1: 105 +looopback1: Loopback 100 +po2: Portchannel 101 +vlan2: 106 +looopback2: Loopback 101 + +preparations_tests: + delete_interfaces: + - "no interface Vlan {{ vlan1 }}" + - "no interface Vlan {{ vlan2 }}" + init_interfaces: + - "interface Vlan {{ vlan1 }}" + - "interface Vlan {{ vlan2 }}" + - "exit" + - "ip vrf {{vrf1}}" + - "ip vrf {{vrf2}}" + +tests_cli: + - name: cli_test_case_01 + description: creates VXLAN properties + state: merged + input: + - name: vtep1 + source_ip: 1.1.1.1 + primary_ip: 2.2.2.2 + evpn_nvo: nvo5 + vlan_map: + - vni: 101 + vlan: "{{vlan1}}" + - vni: 102 + vlan: "{{vlan2}}" + vrf_map: + - vni: 101 + vrf: "{{vrf1}}" + - vni: 102 + vrf: "{{vrf2}}" + +tests: + - name: test_case_01 + description: creates Vxlan properties + state: merged + input: + - name: vtep1 + - name: test_case_02 + description: Update VRF properties + state: merged + input: + - name: vtep1 + source_ip: 1.1.1.1 + primary_ip: 2.2.2.2 + evpn_nvo: nvo5 + - name: test_case_03 + description: Update VRF properties + state: merged + input: + - name: vtep1 + vlan_map: + - vni: 101 + vlan: "{{vlan1}}" + - name: test_case_04 + description: Update VRF properties + state: merged + input: + - name: vtep1 + vrf_map: + - vni: 101 + vrf: "{{vrf1}}" + - name: test_case_05 + description: Update VRF properties + state: merged + input: + - name: vtep1 + source_ip: 1.1.1.1 + primary_ip: 2.2.2.2 + evpn_nvo: nvo5 + vlan_map: + - vni: 102 + vlan: "{{vlan2}}" + vrf_map: + - vni: 102 + vrf: "{{vrf2}}" + - name: del_test_case_06 + description: Delete VRF properties + state: deleted + input: + - name: vtep1 + source_ip: 1.1.1.1 + primary_ip: 2.2.2.2 + evpn_nvo: nvo5 + vlan_map: + - vni: 101 + vlan: "{{vlan1}}" + - vni: 102 + vlan: "{{vlan2}}" + vrf_map: + - vni: 101 + vrf: "{{vrf1}}" + - vni: 102 + vrf: "{{vrf2}}" + - name: del_test_case_07 + description: Delete VRF properties + state: deleted + input: + - name: vtep1 + - name: test_case_08 + description: Recreate Vxlan + state: merged + input: + - name: vtep1 + - name: del_test_case_09 + description: Delete VRF properties + state: deleted + input: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/meta/main.yaml new file mode 100644 index 000000000..611fd54d2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/meta/main.yaml @@ -0,0 +1,5 @@ +--- +collections: + - dellemc.enterprise_sonic +dependencies: + - { role: common }
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/cleanup_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/cleanup_tests.yaml new file mode 100644 index 000000000..42f3ebb98 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/cleanup_tests.yaml @@ -0,0 +1,6 @@ +- name: Deletes old bgp + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/main.yml new file mode 100644 index 000000000..721097cad --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/main.yml @@ -0,0 +1,34 @@ +- debug: msg="sonic_interfaces Test started ..." + +- set_fact: + base_cfg_path: "{{ playbook_dir + '/roles/' + role_name + '/' + 'templates/' }}" + +# - name: Preparations test +# include_tasks: preparation_tests.yaml + +# - name: "Test {{ module_name }} CLI validation started ..." +# include_tasks: tasks_template.yaml +# loop: "{{ tests_cli }}" + +# - name: "Test CLI validation started ..." +# include_role: +# name: common +# tasks_from: cli_tasks_template.yaml +# loop: "{{ tests_cli }}" + +- name: Cleanup tests + include_tasks: cleanup_tests.yaml + +- name: Preparations test + include_tasks: preparation_tests.yaml + +- name: "Test {{ module_name }} started ..." + include_tasks: tasks_template.yaml + loop: "{{ tests }}" + +# - name: Cleanup tests +# include_tasks: cleanup_tests.yaml + +# - name: Display all variables/facts known for a host +# debug: +# var: hostvars[inventory_hostname].ansible_facts.test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/preparation_tests.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/preparation_tests.yaml new file mode 100644 index 000000000..5946f3f4c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/preparation_tests.yaml @@ -0,0 +1,29 @@ +- name: Delete existing mclag + sonic_mclag: + config: + state: deleted + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes +- name: "initialize interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.delete_interfaces }}" + register: output + ignore_errors: yes +- name: "initialize interfaces" + vars: + ansible_connection: network_cli + sonic_config: + commands: "{{ preparations_tests.init_interfaces }}" + register: output + ignore_errors: yes +- name: Deletes old vxlans + sonic_vxlans: + config: [] + state: deleted + ignore_errors: yes
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/tasks_template.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/tasks_template.yaml new file mode 100644 index 000000000..73d8250d3 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/tasks/tasks_template.yaml @@ -0,0 +1,21 @@ +- name: "{{ item.name}} , {{ item.description}}" + sonic_vxlans: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: action_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: action.facts.report.yaml + +- name: "{{ item.name}} , {{ item.description}} Idempotent" + sonic_vxlans: + config: "{{ item.input }}" + state: "{{ item.state }}" + register: idempotent_task_output + ignore_errors: yes + +- import_role: + name: common + tasks_from: idempotent.facts.report.yaml
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/templates/cli_test_case_01.cfg b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/templates/cli_test_case_01.cfg new file mode 100644 index 000000000..ebdcb7c02 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/sonic_vxlan/templates/cli_test_case_01.cfg @@ -0,0 +1,8 @@ +interface vxlan vtep1 + source-ip 1.1.1.1 + map vni 101 vlan 105 + map vni 102 vlan 106 + map vni 101 vrf VrfReg1 + map vni 102 vrf VrfReg2 +! + diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/defaults/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/defaults/main.yml new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/defaults/main.yml diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/meta/main.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/meta/main.yaml new file mode 100644 index 000000000..a84afac66 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/meta/main.yaml @@ -0,0 +1,3 @@ +--- +collections: + - dellemc.enterprise_sonic
\ No newline at end of file diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/tasks/main.yml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/tasks/main.yml new file mode 100644 index 000000000..a116ce79d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/tasks/main.yml @@ -0,0 +1,12 @@ +- set_fact: + time: "{{ lookup('pipe', 'date +%H-%M-%S') }}" + date: "{{ lookup('pipe', 'date +%Y-%m-%d') }}" + report_dir: "{{ lookup('env', 'ANSIBLE_SONIC_REPORT_DIR') | default(REPORT_DIR, true) }}" +- debug: var=report_dir +- blockinfile: + path: "{{ report_dir }}/regression-{{ file_suffix }}.html" + block: "{{ lookup('template', 'regression_html_report.j2')}}" + mode: 00777 + create: true + marker: "" + delegate_to: localhost diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/templates/regression_html_report.j2 b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/templates/regression_html_report.j2 new file mode 100644 index 000000000..0695c86bc --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/roles/test_reports/templates/regression_html_report.j2 @@ -0,0 +1,328 @@ +#jinja2: trim_blocks: True, lstrip_blocks: True + +<style> +.table { + width: 100%; + max-width: 100%; + margin-bottom: 1rem; +} + +.table th, +.table td { + padding: 0.75rem; + vertical-align: top; + border-top: 1px solid #eceeef; +} + +.table thead th { + vertical-align: bottom; + border-bottom: 2px solid #eceeef; +} + +.table tbody + tbody { + border-top: 2px solid #eceeef; +} + +.table .table { + background-color: #fff; +} + +.table-sm th, +.table-sm td { + padding: 0.3rem; +} + +.table-bordered { + border: 1px solid #eceeef; +} + +.table-bordered th, +.table-bordered td { + border: 1px solid #eceeef; +} + +.table-bordered thead th, +.table-bordered thead td { + border-bottom-width: 2px; +} + +.table-striped tbody tr:nth-of-type(odd) { + background-color: rgba(0, 0, 0, 0.05); +} + +.table-hover tbody tr:hover { + background-color: rgba(0, 0, 0, 0.075); +} + +.table-active, +.table-active > th, +.table-active > td { + background-color: rgba(0, 0, 0, 0.075); +} + +.table-hover .table-active:hover { + background-color: rgba(0, 0, 0, 0.075); +} + +.table-hover .table-active:hover > td, +.table-hover .table-active:hover > th { + background-color: rgba(0, 0, 0, 0.075); +} + +.table-success, +.table-success > th, +.table-success > td { + background-color: #dff0d8; +} + +.table-hover .table-success:hover { + background-color: #d0e9c6; +} + +.table-hover .table-success:hover > td, +.table-hover .table-success:hover > th { + background-color: #d0e9c6; +} + +.table-info, +.table-info > th, +.table-info > td { + background-color: #d9edf7; +} + +.table-hover .table-info:hover { + background-color: #c4e3f3; +} + +.table-hover .table-info:hover > td, +.table-hover .table-info:hover > th { + background-color: #c4e3f3; +} + +.table-warning, +.table-warning > th, +.table-warning > td { + background-color: #fcf8e3; +} + +.table-hover .table-warning:hover { + background-color: #faf2cc; +} + +.table-hover .table-warning:hover > td, +.table-hover .table-warning:hover > th { + background-color: #faf2cc; +} + +.table-danger, +.table-danger > th, +.table-danger > td { + background-color: #f2dede; +} + +.table-hover .table-danger:hover { + background-color: #ebcccc; +} + +.table-hover .table-danger:hover > td, +.table-hover .table-danger:hover > th { + background-color: #ebcccc; +} + +.thead-inverse th { + color: #fff; + background-color: #292b2c; +} + +.thead-default th { + color: #464a4c; + background-color: #eceeef; +} + +.table-inverse { + color: #fff; + background-color: #292b2c; +} + +.table-inverse th, +.table-inverse td, +.table-inverse thead th { + border-color: #fff; +} + +.table-inverse.table-bordered { + border: 0; +} + +.table-responsive { + display: block; + width: 100%; + overflow-x: auto; + -ms-overflow-style: -ms-autohiding-scrollbar; +} + +.table-responsive.table-bordered { + border: 0; +} + +.passed { +color: green; +} +.failed { +color: red; +} + + +</style> + +<h2 style="color:blue;">Regression report </h2> +<h3 style="color:blue;"> Date: <i style="color:black;">{{ date}} </i> Time: <i style="color:black;">{{ time }}</i></h3> + +{% set complete_passed = [0] %} +{% set complete_failed = [0] %} +{% set complete_total = [0] %} +<h3 style="color:blue;">Summary report </h3> +<table class="table table-striped table-bordered"> + <thead> + <tr> + <th>Module</th> + <th>Total testcases</th> + <th>Passed</th> + <th>Failed</th> + </tr> + </thead> +<tbody> + +{% for module_name, test_data_list in ansible_facts.test_reports.items() %} +{% set passed = [0] %} +{% set failed = [0] %} +{% set total = [0] %} +{% for testcase_name, test_data in test_data_list.items() %} +{% if total.append(total.pop() + 1) %}{% endif %} +{% if complete_total.append(complete_total.pop() + 1) %}{% endif %} + +{% if 'Passed' in test_data.status %} +{% if passed.append(passed.pop() + 1) %}{% endif %} +{% if complete_passed.append(complete_passed.pop() + 1) %}{% endif %} +{% endif %} + +{% if 'Failed' in test_data.status %} +{% if failed.append(failed.pop() + 1) %}{% endif %} +{% if complete_failed.append(complete_failed.pop() + 1) %}{% endif %} +{% endif %} +{% endfor %} +<tr> +<td>{{ module_name }}</td> +<td>{{ total[0] }}</td> +<td>{{ passed[0] }}</td> +<td>{{ failed[0] }}</td> +</tr> +{% endfor %} +</tbody> +</table> + +<h2> Testcase Complete Summary: Total: {{ complete_total[0] }}, Passed: {{ complete_passed[0] }}, Failed: {{ complete_failed[0] }} </h2> + + +</br> +</br> +</br> + + + + + + + + + + + + + + + + + + + + + +{% for module_name, test_data_list in ansible_facts.test_reports.items() %} +{% set passed = [0] %} +{% set failed = [0] %} +{% set total = [0] %} + +{% for testcase_name, test_data in test_data_list.items() %} +{% if total.append(total.pop() + 1) %}{% endif %} + +{% if 'Passed' in test_data.status %} +{% if passed.append(passed.pop() + 1) %}{% endif %} +{% endif %} + +{% if 'Failed' in test_data.status %} +{% if failed.append(failed.pop() + 1) %}{% endif %} +{% endif %} +{% endfor %} +<h3 style="color:blue;">Detailed report of <i style="color:black;"> {{module_name }} </i> </h3> +<h2> Testcase summary: Total: {{ total[0] }}, Passed: {{ passed[0] }}, Failed: {{ failed[0] }} </h2> +<table class="table table-striped table-bordered"> + <thead> + <tr> + <th>Testcase name</th> + <th>Status</th> + <th>User Input</th> + <th>Commands</th> + <th>Before</th> + <th>After</th> + <th>Module exception</th> + </tr> + </thead> +<tbody> +{% for name, test_data in test_data_list.items() %} +<tr> +<td>{{ name}}</td> +<td>{{ test_data.status | default('Template Error')}}</td> +{% if 'Passed' in test_data.status %} +<td></td> +<td></td> +<td></td> +<td></td> +<td></td> +<td></td> +{% else %} +<td>Input: {{ test_data.configs | default('Template Error') | to_nice_json(indent=3) }}</td> +<td>Commands: {{ test_data.commands | default('Template Error') | to_nice_json(indent=3) }}</td> +<td>Before: {{ test_data.before | default('Template Error') | to_nice_json(indent=3) }}</td> +<td>After: {{ test_data.after | default('Template Error') | to_nice_json(indent=3) }}</td> +<td>Error: {{ test_data.module_stderr | default('Template Error') | to_nice_json(indent=3) }}</td> +{% endif %} +</tr> +{% endfor %} +</tbody> +</table> +{% endfor %} + +<h2> Testcase Complete Summary: Total: {{ complete_total[0] }}, Passed: {{ complete_passed[0] }}, Failed: {{ complete_failed[0] }} </h2> + + +<script> +window.onload = function() { +var ele = document.getElementsByTagName('table'); +for(var tb = 0; tb < ele.length;tb++) { + tbody = ele[tb].getElementsByTagName('tbody') + for(var tbd = 0; tbd < tbody.length;tbd++) { + tr = tbody[tbd].getElementsByTagName('tr'); + for (var trs = 0; trs < tr.length;trs++) { + td = tr[trs].getElementsByTagName('td') + if(td[1].innerHTML === 'Passed') { + td[1].className ='passed'; + } + if(td[1].innerHTML === 'Failed') { + td[1].className ='failed'; + } + } + } + } +} +</script> diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/regression/test.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/regression/test.yaml new file mode 100644 index 000000000..c34c286cc --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/regression/test.yaml @@ -0,0 +1,39 @@ +--- +- name: "Test SONiC CLI" + hosts: sonic1 + gather_facts: no + connection: httpapi + vars: + file_suffix: "{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}" + collections: + - dellemc.enterprise_sonic + roles: + #- sonic_api + #- sonic_command + #- sonic_config + + - sonic_interfaces + - sonic_l2_interfaces + - sonic_lag_interfaces + - sonic_mclag + - sonic_vlans + - sonic_l3_interfaces + - sonic_bgp_communities + - sonic_bgp_ext_communities + - sonic_bgp_as_paths + - sonic_bgp + - sonic_bgp_af + - sonic_bgp_neighbors + - sonic_bgp_neighbors_af + - sonic_vrfs + - sonic_vxlan + - sonic_port_breakout + - sonic_users + - sonic_aaa + - sonic_tacacs_server + - sonic_radius_server + - sonic_system + - sonic_prefix_lists + - sonic_static_routes + - sonic_ntp + - test_reports diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.10.txt b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.10.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.10.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.11.txt b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.11.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.11.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.12.txt b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.12.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.12.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.13.txt b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.13.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.13.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.14.txt b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.14.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.14.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.9.txt b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.9.txt new file mode 100644 index 000000000..c2cf4ded5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/sanity/ignore-2.9.txt @@ -0,0 +1 @@ +plugins/action/sonic.py action-plugin-docs #action plugin for base class diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh new file mode 100755 index 000000000..ac35117ec --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh @@ -0,0 +1,2 @@ +#!/bin/sh +pytest -vvvv test_diff_util.py diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml new file mode 100644 index 000000000..ddab89945 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml @@ -0,0 +1,43 @@ +--- +want: + name: tacacs + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + name: radius + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +diff: + name: tacacs + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml new file mode 100644 index 000000000..f7bd8a521 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml @@ -0,0 +1,46 @@ +--- +test_keys: + - config: + - method +want: + method: tacacs + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + method: radius + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +diff: + method: tacacs + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml new file mode 100644 index 000000000..e09fe74a8 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml @@ -0,0 +1,38 @@ +--- +want: + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + auth_type: pap + key: pap + source_interface: Eth 11 + timeout: 12 + host: + name: my_host1 + auth_type: pap + key: pap + port: 55 + timeout: 11 + priority: 2 + vrf: default +diff: + auth_type: chap + key: chap + source_interface: Eth 12 + host: + name: my_host + auth_type: chap + key: chap + timeout: 12 + priority: 3 + vrf: mgmt diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml new file mode 100644 index 000000000..0d754337a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml @@ -0,0 +1,28 @@ +--- +want: + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +diff: {} diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml new file mode 100644 index 000000000..8a3e2e4a3 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml @@ -0,0 +1,29 @@ +--- +want: + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + key: chap + host: + name: my_host + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +diff: + auth_type: chap + source_interface: Eth 12 + timeout: 12 + host: + auth_type: chap + key: chap diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml new file mode 100644 index 000000000..78c65d27a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml @@ -0,0 +1,18 @@ +--- +want: + auth_type: chap + key: + source_interface: Eth 12 + timeout: 12 + host: + auth_type: + port: + timeout: 15 +have: + key: chap +diff: + auth_type: chap + source_interface: Eth 12 + timeout: 12 + host: + timeout: 15 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml new file mode 100644 index 000000000..b2307a034 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml @@ -0,0 +1,30 @@ +--- +skeleton: True +want: + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + key: pap + host: + name: my_host1 + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +diff: + auth_type: chap + source_interface: Eth 12 + timeout: 12 + host: + auth_type: chap + key: chap diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml new file mode 100644 index 000000000..b2317f779 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml @@ -0,0 +1,34 @@ +--- +want: + - name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True +have: + - name: vrf1 + router_id: 100.2.2.30 + log_neighbor_changes: False + - name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - name: vrf3 + router_id: 102.2.2.30 + log_neighbor_changes: True +diff: + - name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml new file mode 100644 index 000000000..e3e9701c6 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml @@ -0,0 +1,50 @@ +--- +test_keys: + - config: + - vrf_name + - bgp_as +want: + - bgp_as: 51 + vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - bgp_as: 52 + vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - bgp_as: 53 + vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - bgp_as: 54 + vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True +have: + - bgp_as: 50 + vrf_name: vrf1 + - bgp_as: 51 + vrf_name: vrf1 + router_id: 100.2.2.30 + log_neighbor_changes: False + - bgp_as: 52 + vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - bgp_as: 53 + vrf_name: vrf3 + router_id: 102.2.2.30 + log_neighbor_changes: True +diff: + - bgp_as: 51 + vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - bgp_as: 53 + vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - bgp_as: 54 + vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml new file mode 100644 index 000000000..3d4494b9d --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml @@ -0,0 +1,37 @@ +--- +test_keys: + - config: + - vrf_name +want: + - vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True +have: + - vrf_name: vrf1 + router_id: 100.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf3 + router_id: 102.2.2.30 + log_neighbor_changes: True +diff: + - vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml new file mode 100644 index 000000000..b5826a5ab --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml @@ -0,0 +1,31 @@ +--- +test_keys: + - config: + - vrf_name +want: + - vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True +have: + - vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True +diff: [] diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml new file mode 100644 index 000000000..b491385ea --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml @@ -0,0 +1,40 @@ +--- +test_keys: + - config: + - vrf_name +want: + - vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf5 + router_id: 114.2.2.30 + log_neighbor_changes: True +have: + - vrf_name: default + router_id: 100.2.2.30 + log_neighbor_changes: False +diff: + - vrf_name: vrf1 + router_id: 110.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf5 + router_id: 114.2.2.30 + log_neighbor_changes: True diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml new file mode 100644 index 000000000..b15fea916 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml @@ -0,0 +1,48 @@ +--- +test_keys: + - config: + - vrf_name +want: + - vrf_name: vrf1 + router_id: + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + log_neighbor_changes: + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf5 + router_id: 114.2.2.30 + log_neighbor_changes: True + best_path: + as_path: + med: + value: 5 + id: i1 +have: + - vrf_name: default + router_id: 100.2.2.30 + log_neighbor_changes: False + +diff: + - vrf_name: vrf1 + log_neighbor_changes: True + - vrf_name: vrf2 + router_id: 111.2.2.30 + - vrf_name: vrf3 + router_id: 112.2.2.30 + log_neighbor_changes: False + - vrf_name: vrf4 + router_id: 113.2.2.30 + log_neighbor_changes: True + - vrf_name: vrf5 + router_id: 114.2.2.30 + log_neighbor_changes: True + best_path: + as_path: + value: 5 + id: i1 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml new file mode 100644 index 000000000..b2ead5709 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml @@ -0,0 +1,61 @@ +--- +skeleton: True +want: + - name: radius + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt + - name: tacacs + auth_type: chap + key: chap + source_interface: Eth 12 + timeout: 12 + host: + name: my_host + auth_type: chap + key: chap + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt +have: + - name: radius + key: pap + host: + name: my_host1 + port: 55 + timeout: 12 + priority: 3 + vrf: mgmt + - name: tacacs + auth_type: pap + source_interface: Eth 11 + timeout: 11 + host: + name: my_host_03 + auth_type: pap + timeout: 13 + priority: 4 +diff: + - name: radius + auth_type: chap + source_interface: Eth 12 + timeout: 12 + host: + auth_type: chap + key: chap + - name: tacacs + key: chap + host: + key: chap + port: 55 + vrf: mgmt diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml new file mode 100644 index 000000000..77565dfff --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml @@ -0,0 +1,163 @@ +--- +test_keys: + - marks: + - year + - subjects: + - code +want: + - name: test1 + marks: + - year: 1 + subjects: + - code: M + mark: 55 + - code: E + mark: 76 + - code: S + mark: 57 + - year: 2 + subjects: + - code: M + mark: 85 + - code: E + mark: 56 + - code: S + mark: 87 + - year: 3 + subjects: + - code: M + mark: 55 + - code: E + mark: 96 + - code: S + mark: 57 + - year: 4 + subjects: + - code: M + mark: 65 + - code: E + mark: 56 + - code: S + mark: 67 + - name: test2 + marks: + - year: 1 + subjects: + - code: M + mark: 55 + - code: E + mark: 76 + - code: S + mark: 57 + - year: 2 + subjects: + - code: M + mark: 85 + - code: E + mark: 56 + - code: S + mark: 87 + - code: G + mark: 58 + - name: test3 + marks: + - year: 1 + subjects: + - code: M + mark: 56 +have: + - name: test1 + marks: + - year: 1 + subjects: + - code: M + mark: 75 + - code: E + mark: 76 + - code: S + mark: 77 + - year: 2 + subjects: + - code: M + mark: 85 + - code: E + mark: 86 + - code: S + mark: 87 + - year: 3 + subjects: + - code: M + mark: 95 + - code: E + mark: 96 + - code: S + mark: 97 + - year: 4 + subjects: + - code: M + mark: 65 + - code: E + mark: 66 + - code: S + mark: 67 + - name: test2 + marks: + - year: 1 + subjects: + - code: M + mark: 75 + - code: E + mark: 76 + - code: S + mark: 77 + - year: 2 + subjects: + - code: M + mark: 85 + - code: E + mark: 86 + - code: S + mark: 87 +diff: + - name: test1 + marks: + - year: 1 + subjects: + - code: M + mark: 55 + - code: S + mark: 57 + - year: 2 + subjects: + - code: E + mark: 56 + - year: 3 + subjects: + - code: M + mark: 55 + - code: S + mark: 57 + - year: 4 + subjects: + - code: E + mark: 56 + - name: test2 + marks: + - year: 1 + subjects: + - code: M + mark: 55 + - code: S + mark: 57 + - year: 2 + subjects: + - code: E + mark: 56 + - code: G + mark: 58 + - name: test3 + marks: + - year: 1 + subjects: + - code: M + mark: 56 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml new file mode 100644 index 000000000..a6d40b8b0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml @@ -0,0 +1,252 @@ +--- +test_keys: + - config: + - vrf_name + - bgp_as + - afis: + - afi + - safi + - redistribute: + - protocol + - route_advertise_list: + - advertise_afi +want: + - bgp_as: 51 + vrf_name: vrf1 + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 2 + ibgp: 3 + redistribute: + - metric: "20" + protocol: connected + route_map: rmap_reg1 + - metric: "26" + protocol: ospf + route_map: rmap_reg2 + - metric: "25" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_reg3 + - metric: "27" + protocol: ospf + route_map: rmap_reg1 + - metric: "28" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + advertise_all_vni: True + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 + - advertise_afi: ipv6 + route_map: rmap_reg2 + - bgp_as: 52 + vrf_name: vrf2 + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 3 + ibgp: 2 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_reg1 + - metric: "27" + protocol: ospf + route_map: rmap_reg2.1 + - metric: "25" + protocol: static + route_map: rmap_reg3.1 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "22" + protocol: connected + route_map: rmap_rega + - metric: "28" + protocol: ospf + route_map: rmap_regb.1 + - metric: "28" + protocol: static + route_map: rmap_regc.1 + - afi: l2vpn + safi: evpn + route_advertise_list: + - advertise_afi: ipv6 + route_map: rmap_reg2 +have: + - bgp_as: 50 + vrf_name: vrf1 + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 2 + ibgp: 3 + redistribute: + - metric: "20" + protocol: connected + route_map: rmap_reg1 + - metric: "26" + protocol: ospf + route_map: rmap_reg2 + - metric: "25" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_reg3 + - metric: "27" + protocol: ospf + route_map: rmap_reg1 + - metric: "28" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + advertise_all_vni: True + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 + - advertise_afi: ipv6 + route_map: rmap_reg2 + - bgp_as: 52 + vrf_name: vrf2 + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 1 + ibgp: 2 + redistribute: + - metric: "20" + protocol: connected + route_map: rmap_reg1 + - metric: "26" + protocol: ospf + route_map: rmap_reg2 + - metric: "25" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 2 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_rega + - metric: "27" + protocol: ospf + route_map: rmap_regb + - metric: "28" + protocol: static + route_map: rmap_regc + - afi: l2vpn + safi: evpn + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 +diff: + - bgp_as: 51 + vrf_name: vrf1 + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 2 + ibgp: 3 + redistribute: + - metric: "20" + protocol: connected + route_map: rmap_reg1 + - metric: "26" + protocol: ospf + route_map: rmap_reg2 + - metric: "25" + protocol: static + route_map: rmap_reg3 + - afi: ipv6 + safi: unicast + max_path: + ebgp: 3 + ibgp: 4 + redistribute: + - metric: "21" + protocol: connected + route_map: rmap_reg3 + - metric: "27" + protocol: ospf + route_map: rmap_reg1 + - metric: "28" + protocol: static + route_map: rmap_reg2 + - afi: l2vpn + safi: evpn + advertise_all_vni: True + route_advertise_list: + - advertise_afi: ipv4 + route_map: rmap_reg1 + - advertise_afi: ipv6 + route_map: rmap_reg2 + - bgp_as: 52 + vrf_name: vrf2 + address_family: + afis: + - afi: ipv4 + safi: unicast + max_path: + ebgp: 3 + redistribute: + - metric: "21" + protocol: connected + - metric: "27" + protocol: ospf + route_map: rmap_reg2.1 + - protocol: static + route_map: rmap_reg3.1 + - afi: ipv6 + safi: unicast + max_path: + ibgp: 4 + redistribute: + - metric: "22" + protocol: connected + - metric: "28" + protocol: ospf + route_map: rmap_regb.1 + - protocol: static + route_map: rmap_regc.1 + - afi: l2vpn + safi: evpn + route_advertise_list: + - advertise_afi: ipv6 + route_map: rmap_reg2 diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py new file mode 100644 index 000000000..65f384a1e --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py @@ -0,0 +1,87 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +import unittest +import os +import yaml + +import sys +sys.path.append('/root/.ansible/collections') + +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import ( + get_diff, +) + + +class TestDiffUtils(unittest.TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + def read_and_compare(self, file_name): + file_name = os.path.join(os.path.dirname(__file__), file_name) + file_stream = open(file_name, "r") + data = yaml.full_load(file_stream) + file_stream.close() + + want = data.get('want', []) + have = data.get('have', []) + diff_exp = data.get('diff', []) + test_keys = data.get('test_keys', None) + is_skeleton = data.get('skeleton', None) + + diff_act = get_diff(want, have, test_keys, is_skeleton=is_skeleton) + + self.assertEqual(diff_exp, diff_act) + + def test_01_dict_diff_with_key_name(self): + self.read_and_compare("test_01_dict_diff_with_key_name.yaml") + + def test_02_dict_diff_with_key_other(self): + self.read_and_compare("test_02_dict_diff_with_key_other.yaml") + + def test_03_dict_diff_without_key(self): + self.read_and_compare("test_03_dict_diff_without_key.yaml") + + def test_04_dict_diff_with_similar_dict(self): + self.read_and_compare("test_04_dict_diff_with_similar_dict.yaml") + + def test_05_dict_diff_left_only(self): + self.read_and_compare("test_05_dict_diff_left_only.yaml") + + def test_06_dict_diff_left_only_with_none(self): + self.read_and_compare("test_06_dict_diff_left_only_with_none.yaml") + + def test_07_dict_diff_skeleton_only(self): + self.read_and_compare("test_07_dict_diff_skeleton_only.yaml") + + def test_08_list_diff_with_key_name(self): + self.read_and_compare("test_08_list_diff_with_key_name.yaml") + + def test_09_list_diff_with_multi_keys(self): + self.read_and_compare("test_09_list_diff_with_multi_keys.yaml") + + def test_10_list_diff_with_key_other(self): + self.read_and_compare("test_10_list_diff_with_key_other.yaml") + + def test_11_list_diff_with_similar_list(self): + self.read_and_compare("test_11_list_diff_with_similar_list.yaml") + + def test_12_list_diff_with_left_only(self): + self.read_and_compare("test_12_list_diff_with_left_only.yaml") + + def test_13_list_diff_with_left_only_with_none(self): + self.read_and_compare("test_13_list_diff_with_left_only_with_none.yaml") + + def test_14_list_diff_skeleton_only(self): + self.read_and_compare("test_14_list_diff_skeleton_only.yaml") + + def test_15_list_of_list_diff(self): + self.read_and_compare("test_15_list_of_list_diff.yaml") + + def test_16_complex_list_with_dict_diff(self): + self.read_and_compare("test_16_complex_list_with_dict_diff.yaml") |