diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index 00358b57e9..a8f8c2a316 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -265,6 +265,27 @@ rescue: - set_fact: test_failed=true + - block: + - include_role: + name: nxos_bgp + when: "limit_to in ['*', 'nxos_bgp']" + rescue: + - set_fact: test_failed=true + + - block: + - include_role: + name: nxos_bgp_af + when: "limit_to in ['*', 'nxos_bgp_af']" + rescue: + - set_fact: test_failed=true + + - block: + - include_role: + name: nxos_bgp_neighbor + when: "limit_to in ['*', 'nxos_bgp_neighbor']" + rescue: + - set_fact: test_failed=true + ########### - debug: var=failed_modules when: test_failed diff --git a/test/integration/targets/nxos_bgp/defaults/main.yaml b/test/integration/targets/nxos_bgp/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_bgp/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_bgp/meta/main.yml b/test/integration/targets/nxos_bgp/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_bgp/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_bgp/tasks/cli.yaml b/test/integration/targets/nxos_bgp/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/nxos_bgp/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_bgp/tasks/main.yaml b/test/integration/targets/nxos_bgp/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_bgp/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_bgp/tasks/nxapi.yaml b/test/integration/targets/nxos_bgp/tasks/nxapi.yaml new file mode 100644 index 0000000000..ea525379f7 --- /dev/null +++ b/test/integration/targets/nxos_bgp/tasks/nxapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_bgp/tests/cli/sanity.yaml b/test/integration/targets/nxos_bgp/tests/cli/sanity.yaml new file mode 100644 index 0000000000..c2d626b6f6 --- /dev/null +++ b/test/integration/targets/nxos_bgp/tests/cli/sanity.yaml @@ -0,0 +1,135 @@ +--- +- debug: msg="START TRANSPORT:CLI nxos_bgp sanity test" + +- set_fact: neighbor_down_fib_accelerate="true" + when: (titanium is defined) and not ((titanium | search('true'))) + +- set_fact: reconnect_interval="55" + when: (titanium is defined) and not ((titanium | search('true'))) + +- name: "Enable feature BGP" + nxos_feature: + feature: bgp + state: enabled + provider: "{{ cli }}" + ignore_errors: yes + +- name: "Setup" + nxos_bgp: &remove + asn: 65535 + state: absent + provider: "{{ cli }}" + ignore_errors: yes + register: result + +- block: + - name: "Configure BGP defaults" + nxos_bgp: &configure_default + asn: 65535 + router_id: 1.1.1.1 + state: present + provider: "{{ cli }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence" + nxos_bgp: *configure_default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Configure BGP non defaults" + nxos_bgp: &configure_non_default + asn: 65535 + router_id: 1.1.1.1 + bestpath_always_compare_med: true + bestpath_aspath_multipath_relax: true + bestpath_compare_routerid: true + bestpath_cost_community_ignore: true + bestpath_med_confed: true + bestpath_med_missing_as_worst: true + bestpath_med_non_deterministic: true + cluster_id: 10.0.0.1 + confederation_id: 99 + disable_policy_batching: true + enforce_first_as: false + fast_external_fallover: false + flush_routes: true + graceful_restart_helper: true + graceful_restart_timers_restart: 130 + graceful_restart_timers_stalepath_time: 310 + isolate: false + log_neighbor_changes: true + maxas_limit: 50 + neighbor_down_fib_accelerate: "{{neighbor_down_fib_accelerate|default(omit)}}" + reconnect_interval: "{{reconnect_interval|default(omit)}}" + shutdown: true + timer_bestpath_limit: 255 + timer_bgp_hold: 110 + timer_bgp_keepalive: 45 + event_history_cli: size_medium + event_history_detail: size_large + event_history_events: size_medium + event_history_periodic: size_small + suppress_fib_pending: true + state: present + provider: "{{ cli }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *configure_non_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Disable feature bgp" + nxos_feature: + feature: bgp + state: disabled + provider: "{{ cli }}" + + rescue: + - name: "Cleanup BGP" + nxos_bgp: *remove + ignore_errors: yes + + - name: "Disable feature bgp" + nxos_feature: + feature: bgp + state: disabled + provider: "{{ cli }}" + ignore_errors: yes + + always: + - debug: msg="END TRANSPORT:CLI nxos_bgp sanity test" diff --git a/test/integration/targets/nxos_bgp/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_bgp/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..34bf7b4e2d --- /dev/null +++ b/test/integration/targets/nxos_bgp/tests/nxapi/sanity.yaml @@ -0,0 +1,135 @@ +--- +- debug: msg="START TRANSPORT:NXAPI nxos_bgp sanity test" + +- set_fact: neighbor_down_fib_accelerate="true" + when: (titanium is defined) and not ((titanium | search('true'))) + +- set_fact: reconnect_interval="55" + when: (titanium is defined) and not ((titanium | search('true'))) + +- name: "Enable feature BGP" + nxos_feature: + feature: bgp + state: enabled + provider: "{{ nxapi }}" + ignore_errors: yes + +- name: "Setup" + nxos_bgp: &remove + asn: 65535 + state: absent + provider: "{{ nxapi }}" + ignore_errors: yes + register: result + +- block: + - name: "Configure BGP defaults" + nxos_bgp: &configure_default + asn: 65535 + router_id: 1.1.1.1 + state: present + provider: "{{ nxapi }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence" + nxos_bgp: *configure_default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Configure BGP non defaults" + nxos_bgp: &configure_non_default + asn: 65535 + router_id: 1.1.1.1 + bestpath_always_compare_med: true + bestpath_aspath_multipath_relax: true + bestpath_compare_routerid: true + bestpath_cost_community_ignore: true + bestpath_med_confed: true + bestpath_med_missing_as_worst: true + bestpath_med_non_deterministic: true + cluster_id: 10.0.0.1 + confederation_id: 99 + disable_policy_batching: true + enforce_first_as: false + fast_external_fallover: false + flush_routes: true + graceful_restart_helper: true + graceful_restart_timers_restart: 130 + graceful_restart_timers_stalepath_time: 310 + isolate: false + log_neighbor_changes: true + maxas_limit: 50 + neighbor_down_fib_accelerate: "{{neighbor_down_fib_accelerate|default(omit)}}" + reconnect_interval: "{{reconnect_interval|default(omit)}}" + shutdown: true + timer_bestpath_limit: 255 + timer_bgp_hold: 110 + timer_bgp_keepalive: 45 + event_history_cli: size_medium + event_history_detail: size_large + event_history_events: size_medium + event_history_periodic: size_small + suppress_fib_pending: true + state: present + provider: "{{ nxapi }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *configure_non_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Disable feature bgp" + nxos_feature: + feature: bgp + state: disabled + provider: "{{ nxapi }}" + + rescue: + - name: "Cleanup BGP" + nxos_bgp: *remove + ignore_errors: yes + + - name: "Disable feature bgp" + nxos_feature: + feature: bgp + state: disabled + provider: "{{ nxapi }}" + ignore_errors: yes + + always: + - debug: msg="END TRANSPORT:NXAPI nxos_bgp sanity test" diff --git a/test/integration/targets/nxos_bgp_af/defaults/main.yaml b/test/integration/targets/nxos_bgp_af/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_bgp_af/meta/main.yml b/test/integration/targets/nxos_bgp_af/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_bgp_af/tasks/cli.yaml b/test/integration/targets/nxos_bgp_af/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_bgp_af/tasks/main.yaml b/test/integration/targets/nxos_bgp_af/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_bgp_af/tasks/nxapi.yaml b/test/integration/targets/nxos_bgp_af/tasks/nxapi.yaml new file mode 100644 index 0000000000..ea525379f7 --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/tasks/nxapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_bgp_af/tests/cli/sanity.yaml b/test/integration/targets/nxos_bgp_af/tests/cli/sanity.yaml new file mode 100644 index 0000000000..25627d94ba --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/tests/cli/sanity.yaml @@ -0,0 +1,149 @@ +--- +- debug: msg="START TRANSPORT:CLI nxos_bgp_af sanity test" + +- set_fact: advertise_l2vpn_evpn="true" + when: platform | search('N9K') + +- name: "Enable feature BGP" + nxos_feature: + feature: bgp + state: enabled + provider: "{{ cli }}" + ignore_errors: yes + +- name: "Enable feature nv overlay" + nxos_feature: + feature: nv overlay + state: enabled + provider: "{{ cli }}" + ignore_errors: yes + +- name: "Setup" + nxos_bgp: &remove + asn: 65535 + state: absent + provider: "{{ cli }}" + ignore_errors: yes + +- block: + - name: "Enable nv overlay evpn" + nxos_config: + lines: + - nv overlay evpn + provider: "{{ cli }}" + when: platform | search('N9K') + + - name: "Configure BGP_AF defaults" + nxos_bgp_af: &configure_default + asn: 65535 + vrf: TESTING + afi: ipv4 + safi: unicast + advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" + state: present + provider: "{{ cli }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence" + nxos_bgp_af: *configure_default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Configure BGP_AF non defaults" + nxos_bgp_af: &configure_non_default + asn: 65535 + vrf: TESTING + afi: ipv4 + safi: unicast + additional_paths_install: true + additional_paths_receive: true + additional_paths_selection: RouteMap + additional_paths_send: true + advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" + client_to_client: false + dampen_igp_metric: 200 + dampening_half_time: 1 + dampening_max_suppress_time: 4 + dampening_reuse_time: 2 + dampening_suppress_time: 3 + default_information_originate: true + default_metric: 50 + distance_ebgp: 30 + distance_ibgp: 60 + distance_local: 90 + maximum_paths: 9 + maximum_paths_ibgp: 9 + next_hop_route_map: RouteMap + suppress_inactive: true + table_map: RouteMap + table_map_filter: true + state: present + provider: "{{ cli }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_af: *configure_non_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + rescue: + - name: "Cleanup BGP" + nxos_bgp: *remove + ignore_errors: yes + + always: + - name: "Disable feature bgp" + nxos_feature: &disable_bgp + feature: bgp + state: disabled + provider: "{{ cli }}" + + - name: "Disable feature nv overlay" + nxos_feature: &disable_nvoverlay + feature: nv overlay + state: disabled + provider: "{{ cli }}" + ignore_errors: yes + + - name: "Remove nv overlay evpn" + nxos_config: + lines: + - no nv overlay evpn + provider: "{{ cli }}" + when: platform | search('N9K') + + - debug: msg="END TRANSPORT:CLI nxos_bgp_af sanity test" diff --git a/test/integration/targets/nxos_bgp_af/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_bgp_af/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..d712fbc758 --- /dev/null +++ b/test/integration/targets/nxos_bgp_af/tests/nxapi/sanity.yaml @@ -0,0 +1,149 @@ +--- +- debug: msg="START TRANSPORT:NXAPI nxos_bgp_af sanity test" + +- set_fact: advertise_l2vpn_evpn="true" + when: platform | search('N9K') + +- name: "Enable feature BGP" + nxos_feature: + feature: bgp + state: enabled + provider: "{{ nxapi }}" + ignore_errors: yes + +- name: "Enable feature nv overlay" + nxos_feature: + feature: nv overlay + state: enabled + provider: "{{ nxapi }}" + ignore_errors: yes + +- name: "Setup" + nxos_bgp: &remove + asn: 65535 + state: absent + provider: "{{ nxapi }}" + ignore_errors: yes + +- block: + - name: "Enable nv overlay evpn" + nxos_config: + lines: + - nv overlay evpn + provider: "{{ nxapi }}" + when: platform | search('N9K') + + - name: "Configure BGP_AF defaults" + nxos_bgp_af: &configure_default + asn: 65535 + vrf: TESTING + afi: ipv4 + safi: unicast + advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" + state: present + provider: "{{ nxapi }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence" + nxos_bgp_af: *configure_default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Configure BGP_AF non defaults" + nxos_bgp_af: &configure_non_default + asn: 65535 + vrf: TESTING + afi: ipv4 + safi: unicast + additional_paths_install: true + additional_paths_receive: true + additional_paths_selection: RouteMap + additional_paths_send: true + advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" + client_to_client: false + dampen_igp_metric: 200 + dampening_half_time: 1 + dampening_max_suppress_time: 4 + dampening_reuse_time: 2 + dampening_suppress_time: 3 + default_information_originate: true + default_metric: 50 + distance_ebgp: 30 + distance_ibgp: 60 + distance_local: 90 + maximum_paths: 9 + maximum_paths_ibgp: 9 + next_hop_route_map: RouteMap + suppress_inactive: true + table_map: RouteMap + table_map_filter: true + state: present + provider: "{{ nxapi }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_af: *configure_non_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + rescue: + - name: "Cleanup BGP" + nxos_bgp: *remove + ignore_errors: yes + + always: + - name: "Disable feature bgp" + nxos_feature: &disable_bgp + feature: bgp + state: disabled + provider: "{{ nxapi }}" + + - name: "Disable feature nv overlay" + nxos_feature: &disable_nvoverlay + feature: nv overlay + state: disabled + provider: "{{ nxapi }}" + ignore_errors: yes + + - name: "Remove nv overlay evpn" + nxos_config: + lines: + - no nv overlay evpn + provider: "{{ cli }}" + when: platform | search('N9K') + + - debug: msg="END TRANSPORT:NXAPI nxos_bgp_af sanity test" diff --git a/test/integration/targets/nxos_bgp_neighbor/defaults/main.yaml b/test/integration/targets/nxos_bgp_neighbor/defaults/main.yaml new file mode 100644 index 0000000000..5f709c5aac --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_bgp_neighbor/meta/main.yml b/test/integration/targets/nxos_bgp_neighbor/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml b/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml new file mode 100644 index 0000000000..d675462dd0 --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_bgp_neighbor/tasks/main.yaml b/test/integration/targets/nxos_bgp_neighbor/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml b/test/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml new file mode 100644 index 0000000000..ea525379f7 --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/tasks/nxapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_bgp_neighbor/tests/cli/sanity.yaml b/test/integration/targets/nxos_bgp_neighbor/tests/cli/sanity.yaml new file mode 100644 index 0000000000..40a5045b5b --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/tests/cli/sanity.yaml @@ -0,0 +1,203 @@ +--- +- debug: msg="START TRANSPORT:CLI nxos_bgp_neighbor sanity test" + +- set_fact: intname="{{ nxos_int1 }}" + +- set_fact: log_neighbor_changes="enable" + when: (titanium is defined) and not ((titanium | search('true'))) + +- set_fact: remove_private_as="all" + when: (titanium is defined) and not ((titanium | search('true'))) + +- name: "Enable feature BGP" + nxos_feature: + feature: bgp + state: enabled + provider: "{{ cli }}" + ignore_errors: yes + +- name: "Setup" + nxos_bgp: &remove + asn: 65535 + state: absent + provider: "{{ cli }}" + ignore_errors: yes + +- block: + - name: "Configure BGP neighbor defaults" + nxos_bgp_neighbor: &configure_default + asn: 65535 + neighbor: 3.3.3.3 + local_as: 20 + remote_as: 30 + description: "just a description" + update_source: "{{ intname.capitalize() }}" + state: present + provider: "{{ cli }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Configure BGP neighbor non-defaults" + nxos_bgp_neighbor: &configure_non_default + asn: 65535 + neighbor: 3.3.3.3 + description: "tested by ansible" + connected_check: true + capability_negotiation: true + dynamic_capability: true + ebgp_multihop: 2 + log_neighbor_changes: "{{log_neighbor_changes|default(omit)}}" + low_memory_exempt: true + remote_as: 12.1 + remove_private_as: "{{remove_private_as|default(omit)}}" + shutdown: true + suppress_4_byte_as: true + timers_keepalive: 90 + timers_holdtime: 270 + update_source: loopback151 + state: present + provider: "{{ cli }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_non_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor 3des password" + nxos_bgp_neighbor: &configure_3des_password + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + pwd: '386c0565965f89de' + pwd_type: 3des + provider: "{{ cli }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_3des_password + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor type 7 password" + nxos_bgp_neighbor: &configure_type7_password + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + pwd: '386c0565965f89de' + pwd_type: cisco_type_7 + provider: "{{ cli }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_type7_password + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor transport type passive" + nxos_bgp_neighbor: &configure_transport_passive + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + transport_passive_only: true + provider: "{{ cli }}" + register: result + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_transport_passive + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor transport type default" + nxos_bgp_neighbor: &configure_transport_default + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + transport_passive_only: false + provider: "{{ cli }}" + register: result + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_transport_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + rescue: + - name: "Cleanup BGP" + nxos_bgp: *remove + ignore_errors: yes + + always: + - name: "Disable feature bgp" + nxos_feature: &disable_bgp + feature: bgp + state: disabled + provider: "{{ cli }}" + +- debug: msg="END TRANSPORT:CLI nxos_bgp_neighbor sanity test" diff --git a/test/integration/targets/nxos_bgp_neighbor/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_bgp_neighbor/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..ae2070f634 --- /dev/null +++ b/test/integration/targets/nxos_bgp_neighbor/tests/nxapi/sanity.yaml @@ -0,0 +1,203 @@ +--- +- debug: msg="START TRANSPORT:NXAPI nxos_bgp_neighbor sanity test" + +- set_fact: intname="{{ nxos_int1 }}" + +- set_fact: log_neighbor_changes="enable" + when: (titanium is defined) and not ((titanium | search('true'))) + +- set_fact: remove_private_as="all" + when: (titanium is defined) and not ((titanium | search('true'))) + +- name: "Enable feature BGP" + nxos_feature: + feature: bgp + state: enabled + provider: "{{ nxapi }}" + ignore_errors: yes + +- name: "Setup" + nxos_bgp: &remove + asn: 65535 + state: absent + provider: "{{ nxapi }}" + ignore_errors: yes + +- block: + - name: "Configure BGP neighbor defaults" + nxos_bgp_neighbor: &configure_default + asn: 65535 + neighbor: 3.3.3.3 + local_as: 20 + remote_as: 30 + description: "just a description" + update_source: "{{ intname.capitalize() }}" + state: present + provider: "{{ nxapi }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_default + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp: *remove + register: result + + - assert: *false + + - name: "Configure BGP neighbor non-defaults" + nxos_bgp_neighbor: &configure_non_default + asn: 65535 + neighbor: 3.3.3.3 + description: "tested by ansible" + connected_check: true + capability_negotiation: true + dynamic_capability: true + ebgp_multihop: 2 + log_neighbor_changes: "{{log_neighbor_changes|default(omit)}}" + low_memory_exempt: true + remote_as: 12.1 + remove_private_as: "{{remove_private_as|default(omit)}}" + shutdown: true + suppress_4_byte_as: true + timers_keepalive: 90 + timers_holdtime: 270 + update_source: loopback151 + state: present + provider: "{{ nxapi }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_non_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor 3des password" + nxos_bgp_neighbor: &configure_3des_password + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + pwd: '386c0565965f89de' + pwd_type: 3des + provider: "{{ nxapi }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_3des_password + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor type 7 password" + nxos_bgp_neighbor: &configure_type7_password + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + pwd: '386c0565965f89de' + pwd_type: cisco_type_7 + provider: "{{ nxapi }}" + register: result + + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_type7_password + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor transport type passive" + nxos_bgp_neighbor: &configure_transport_passive + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + transport_passive_only: true + provider: "{{ nxapi }}" + register: result + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_transport_passive + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + - name: "Configure BGP neighbor transport type default" + nxos_bgp_neighbor: &configure_transport_default + asn: 65535 + neighbor: 3.3.3.3 + remote_as: 30 + transport_passive_only: false + provider: "{{ nxapi }}" + register: result + - assert: *true + + - name: "Check Idempotence" + nxos_bgp_neighbor: *configure_transport_default + register: result + + - assert: *false + + - name: "Remove BGP" + nxos_bgp: *remove + register: result + + - assert: *true + + rescue: + - name: "Cleanup BGP" + nxos_bgp: *remove + ignore_errors: yes + + always: + - name: "Disable feature bgp" + nxos_feature: &disable_bgp + feature: bgp + state: disabled + provider: "{{ nxapi }}" + +- debug: msg="END TRANSPORT:NXAPI nxos_bgp_neighbor sanity test" diff --git a/test/integration/targets/nxos_evpn_global/tests/cli/nv_overlay_evpn.yaml b/test/integration/targets/nxos_evpn_global/tests/cli/nv_overlay_evpn.yaml deleted file mode 100644 index 5c5f06072c..0000000000 --- a/test/integration/targets/nxos_evpn_global/tests/cli/nv_overlay_evpn.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -- debug: msg="START cli/nv_overlay_evpn" - -- name: setup - nxos_config: - lines: no nv overlay evpn - match: none - provider: "{{ cli }}" - -- name: enable nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: yes - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: yes - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == false" - -- name: disable nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: no - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: no - provider: "{{ cli }}" - register: result - -- assert: - that: - - "result.changed == false" - -- debug: msg="END cli/nv_overlay_evpn" diff --git a/test/integration/targets/nxos_evpn_global/tests/cli/sanity.yaml b/test/integration/targets/nxos_evpn_global/tests/cli/sanity.yaml new file mode 100644 index 0000000000..ac3290b580 --- /dev/null +++ b/test/integration/targets/nxos_evpn_global/tests/cli/sanity.yaml @@ -0,0 +1,73 @@ +--- +- debug: msg="START TRANSPORT:CLI nxos_evpn_global sanity test" + +- name: "Setup" + nxos_config: &remove_evpn_config + lines: no nv overlay evpn + match: none + provider: "{{ cli }}" + ignore_errors: yes + +- name: "Disable feature nv overlay" + nxos_feature: &disable_feature_nv_overlay + feature: nv overlay + state: disabled + provider: "{{ cli }}" + ignore_errors: yes + +- block: + - name: "Enable feature nv overlay" + nxos_feature: &enable_feature_nv_overlay + feature: nv overlay + state: enabled + provider: "{{ cli }}" + ignore_errors: yes + + - name: "Enable nv overlay evpn" + nxos_evpn_global: &enable_evpn + nv_overlay_evpn: true + provider: "{{ cli }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "CHECK IDEMPOTENCE - enable nv overlay evpn" + nxos_evpn_global: *enable_evpn + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Disable nv overlay evpn" + nxos_evpn_global: &disable_evpn + nv_overlay_evpn: false + provider: "{{ cli }}" + register: result + + - assert: *true + + - name: "CHECK DEMPOTENCE - Disable nv overlay evpn" + nxos_evpn_global: *disable_evpn + register: result + + - assert: *false + + when: not (platform | search('N3K')) + + rescue: + - debug: msg="TRANSPORT:CLI nxos_evpn_global sanity test - FALURE ENCOUNTERED" + + always: + + - name: "Cleanup - Disable nv overlay evpn" + nxos_config: *remove_evpn_config + ignore_errors: yes + + - name: "Cleanup - Disable feature nv overlay" + nxos_feature: *disable_feature_nv_overlay + ignore_errors: yes + + - debug: msg="END TRANSPORT:CLI nxos_evpn_global sanity test" diff --git a/test/integration/targets/nxos_evpn_global/tests/nxapi/nv_overlay_evpn.yaml b/test/integration/targets/nxos_evpn_global/tests/nxapi/nv_overlay_evpn.yaml deleted file mode 100644 index af058f1192..0000000000 --- a/test/integration/targets/nxos_evpn_global/tests/nxapi/nv_overlay_evpn.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -- debug: msg="START nxapi/nv_overlay_evpn" - -- name: setup - nxos_config: - lines: no nv overlay evpn - match: none - provider: "{{ nxapi }}" - -- name: enable nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: yes - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: yes - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == false" - -- name: disable nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: no - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == true" - -- name: verify nv overlay evpn - nxos_evpn_global: - nv_overlay_evpn: no - provider: "{{ nxapi }}" - register: result - -- assert: - that: - - "result.changed == false" - -- debug: msg="END nxapi/nv_overlay_evpn" diff --git a/test/integration/targets/nxos_evpn_global/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_evpn_global/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..d368a20df6 --- /dev/null +++ b/test/integration/targets/nxos_evpn_global/tests/nxapi/sanity.yaml @@ -0,0 +1,73 @@ +--- +- debug: msg="START TRANSPORT:NXAPI nxos_evpn_global sanity test" + +- name: "Setup" + nxos_config: &remove_evpn_config + lines: no nv overlay evpn + match: none + provider: "{{ nxapi }}" + ignore_errors: yes + +- name: "Disable feature nv overlay" + nxos_feature: &disable_feature_nv_overlay + feature: nv overlay + state: disabled + provider: "{{ nxapi }}" + ignore_errors: yes + +- block: + - name: "Enable feature nv overlay" + nxos_feature: &enable_feature_nv_overlay + feature: nv overlay + state: enabled + provider: "{{ nxapi }}" + ignore_errors: yes + + - name: "Enable nv overlay evpn" + nxos_evpn_global: &enable_evpn + nv_overlay_evpn: true + provider: "{{ nxapi }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "CHECK IDEMPOTENCE - enable nv overlay evpn" + nxos_evpn_global: *enable_evpn + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: "Disable nv overlay evpn" + nxos_evpn_global: &disable_evpn + nv_overlay_evpn: false + provider: "{{ nxapi }}" + register: result + + - assert: *true + + - name: "CHECK DEMPOTENCE - Disable nv overlay evpn" + nxos_evpn_global: *disable_evpn + register: result + + - assert: *false + + when: not (platform | search('N3K')) + + rescue: + - debug: msg="TRANSPORT:NXAPI nxos_evpn_global sanity test - FALURE ENCOUNTERED" + + always: + + - name: "Cleanup - Disable nv overlay evpn" + nxos_config: *remove_evpn_config + ignore_errors: yes + + - name: "Cleanup - Disable feature nv overlay" + nxos_feature: *disable_feature_nv_overlay + ignore_errors: yes + + - debug: msg="END TRANSPORT:NXAPI nxos_evpn_global sanity test" diff --git a/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml b/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml index 5595f61d18..a90e51f62a 100644 --- a/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml +++ b/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml @@ -24,6 +24,10 @@ # Items from those subsets are present - "result.ansible_facts.ansible_net_filesystems is defined" + - "result.ansible_facts.ansible_net_interfaces is defined" + - "result.ansible_facts.ansible_net_config is defined" + - "result.ansible_facts.ansible_net_model is defined" + # Check that these facts not only are present, but are valid (positive integers) - "result.ansible_facts.ansible_net_memfree_mb > 1" - "result.ansible_facts.ansible_net_memtotal_mb > 1" diff --git a/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml b/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml index 111b779932..dd03425384 100644 --- a/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml +++ b/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml @@ -23,6 +23,8 @@ # Items from those subsets are present - "result.ansible_facts.ansible_net_filesystems is defined" #hw - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw + - "result.ansible_facts.ansible_net_model is defined" #default + - "result.ansible_facts.ansible_net_interfaces is defined" #interfaces # FIXME # - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces diff --git a/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml b/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml index 11a7af1c61..d35d544701 100644 --- a/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml +++ b/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml @@ -16,9 +16,9 @@ # Correct subsets are present - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + # ... and not present - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" diff --git a/test/integration/targets/nxos_facts/tests/cli/sanity.yaml b/test/integration/targets/nxos_facts/tests/cli/sanity.yaml new file mode 100644 index 0000000000..8ef2d46163 --- /dev/null +++ b/test/integration/targets/nxos_facts/tests/cli/sanity.yaml @@ -0,0 +1,78 @@ +--- +- debug: msg="START TRANSPORT:CLI nxos_facts sanity test" + +- name: "nxos_facts gather hardware facts" + nxos_facts: + gather_subset: hardware + provider: "{{ cli }}" + register: result + +- assert: + that: + # _facts modules should never report a change + - "result.changed == false" + + # Correct subsets are present + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + + # Other facts are not present + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + + # Items from those subsets are present + - "result.ansible_facts.ansible_net_filesystems is defined" + + # Check that these facts not only are present, but are valid (positive integers) + - "result.ansible_facts.ansible_net_memfree_mb > 1" + - "result.ansible_facts.ansible_net_memtotal_mb > 1" + +- name: "nxos_facts gather config facts" + nxos_facts: + gather_subset: config + provider: "{{ cli }}" + register: result + +- assert: + that: + # _facts modules should never report a change + - "result.changed == false" + + # Correct subsets are present + - "'config' in result.ansible_facts.ansible_net_gather_subset" + + # Other facts are not present + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + + # Items from those subsets are present + - "result.ansible_facts.ansible_net_config is defined" + +- name: "nxos_facts gather config and hardware facts" + nxos_facts: + gather_subset: + - hardware + - config + provider: "{{ cli }}" + register: result + +- assert: + that: + # _facts modules should never report a change + - "result.changed == false" + + # Correct subsets are present + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'config' in result.ansible_facts.ansible_net_gather_subset" + + # Other facts are not present + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + + # Items from those subsets are present + - "result.ansible_facts.ansible_net_filesystems is defined" + - "result.ansible_facts.ansible_net_config is defined" + + # Check that these facts not only are present, but are valid (positive integers) + - "result.ansible_facts.ansible_net_memfree_mb > 1" + - "result.ansible_facts.ansible_net_memtotal_mb > 1" + +- debug: msg="END TRANSPORT:CLI nxos_facts sanity test" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml b/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml index cde952b8fe..d3fac5a141 100644 --- a/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml +++ b/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml @@ -25,6 +25,10 @@ # Items from those subsets are present - "result.ansible_facts.ansible_net_filesystems is defined" + - "result.ansible_facts.ansible_net_interfaces is defined" + - "result.ansible_facts.ansible_net_config is defined" + - "result.ansible_facts.ansible_net_model is defined" + # Check that these facts not only are present, but are valid (positive integers) - "result.ansible_facts.ansible_net_memfree_mb > 1" - "result.ansible_facts.ansible_net_memtotal_mb > 1" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml b/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml index 857f53ea8c..412993abb4 100644 --- a/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml +++ b/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml @@ -23,6 +23,8 @@ # Items from those subsets are present - "result.ansible_facts.ansible_net_filesystems is defined" #hw - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw + - "result.ansible_facts.ansible_net_model is defined" #default + - "result.ansible_facts.ansible_net_interfaces is defined" #interfaces # FIXME # - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces diff --git a/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml b/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml index 1123e10852..8abe3dd6f5 100644 --- a/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml +++ b/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml @@ -17,9 +17,9 @@ # Correct subsets are present - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + # ... and not present - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" diff --git a/test/integration/targets/nxos_facts/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_facts/tests/nxapi/sanity.yaml new file mode 100644 index 0000000000..adbf415697 --- /dev/null +++ b/test/integration/targets/nxos_facts/tests/nxapi/sanity.yaml @@ -0,0 +1,78 @@ +--- +- debug: msg="START TRANSPORT:NXAPI nxos_facts sanity test" + +- name: "nxos_facts gather hardware facts" + nxos_facts: + gather_subset: hardware + provider: "{{ nxapi }}" + register: result + +- assert: + that: + # _facts modules should never report a change + - "result.changed == false" + + # Correct subsets are present + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + + # Other facts are not present + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + + # Items from those subsets are present + - "result.ansible_facts.ansible_net_filesystems is defined" + + # Check that these facts not only are present, but are valid (positive integers) + - "result.ansible_facts.ansible_net_memfree_mb > 1" + - "result.ansible_facts.ansible_net_memtotal_mb > 1" + +- name: "nxos_facts gather config facts" + nxos_facts: + gather_subset: config + provider: "{{ nxapi }}" + register: result + +- assert: + that: + # _facts modules should never report a change + - "result.changed == false" + + # Correct subsets are present + - "'config' in result.ansible_facts.ansible_net_gather_subset" + + # Other facts are not present + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + + # Items from those subsets are present + - "result.ansible_facts.ansible_net_config is defined" + +- name: "nxos_facts gather config and hardware facts" + nxos_facts: + gather_subset: + - hardware + - config + provider: "{{ nxapi }}" + register: result + +- assert: + that: + # _facts modules should never report a change + - "result.changed == false" + + # Correct subsets are present + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'config' in result.ansible_facts.ansible_net_gather_subset" + + # Other facts are not present + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + + # Items from those subsets are present + - "result.ansible_facts.ansible_net_filesystems is defined" + - "result.ansible_facts.ansible_net_config is defined" + + # Check that these facts not only are present, but are valid (positive integers) + - "result.ansible_facts.ansible_net_memfree_mb > 1" + - "result.ansible_facts.ansible_net_memtotal_mb > 1" + +- debug: msg="END TRANSPORT:NXAPI nxos_facts sanity test" diff --git a/test/integration/targets/nxos_feature/tests/cli/configure.yaml b/test/integration/targets/nxos_feature/tests/cli/configure.yaml index 0eab6de003..61fa71a8bc 100644 --- a/test/integration/targets/nxos_feature/tests/cli/configure.yaml +++ b/test/integration/targets/nxos_feature/tests/cli/configure.yaml @@ -3,13 +3,13 @@ - name: setup nxos_config: - lines: no feature vn-segment-vlan-based + lines: no feature bgp match: none provider: "{{ cli }}" -- name: enable vn-segment-vlan-based +- name: enable bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: enabled provider: "{{ cli }}" register: result @@ -18,9 +18,9 @@ that: - "result.changed == true" -- name: verify vn-segment-vlan-based +- name: verify bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: enabled provider: "{{ cli }}" register: result @@ -29,9 +29,9 @@ that: - "result.changed == false" -- name: disable vn-segment-vlan-based +- name: disable bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: disabled provider: "{{ cli }}" register: result @@ -40,9 +40,9 @@ that: - "result.changed == true" -- name: verify vn-segment-vlan-based +- name: verify bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: disabled provider: "{{ cli }}" register: result @@ -53,7 +53,7 @@ - name: teardown nxos_config: - lines: no feature vn-segment-vlan-based + lines: no feature bgp match: none provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml b/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml index 074b6c2813..7c5d003cb5 100644 --- a/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml +++ b/test/integration/targets/nxos_feature/tests/nxapi/configure.yaml @@ -3,13 +3,13 @@ - name: setup nxos_config: - lines: no feature vn-segment-vlan-based + lines: no feature bgp match: none provider: "{{ nxapi }}" -- name: enable vn-segment-vlan-based +- name: enable bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: enabled provider: "{{ nxapi }}" register: result @@ -18,9 +18,9 @@ that: - "result.changed == true" -- name: verify vn-segment-vlan-based +- name: verify bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: enabled provider: "{{ nxapi }}" register: result @@ -29,9 +29,9 @@ that: - "result.changed == false" -- name: disable vn-segment-vlan-based +- name: disable bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: disabled provider: "{{ nxapi }}" register: result @@ -40,9 +40,9 @@ that: - "result.changed == true" -- name: verify vn-segment-vlan-based +- name: verify bgp nxos_feature: - feature: vn-segment-vlan-based + feature: bgp state: disabled provider: "{{ nxapi }}" register: result @@ -53,7 +53,7 @@ - name: teardown nxos_config: - lines: no feature vn-segment-vlan-based + lines: no feature bgp match: none provider: "{{ nxapi }}" diff --git a/test/integration/targets/prepare_nxos_tests/tasks/main.yml b/test/integration/targets/prepare_nxos_tests/tasks/main.yml index 9dfbd13a03..bd9abf9e8f 100644 --- a/test/integration/targets/prepare_nxos_tests/tasks/main.yml +++ b/test/integration/targets/prepare_nxos_tests/tasks/main.yml @@ -1,13 +1,31 @@ --- -# NXAPI is enabled differently on NX-OS platforms. -# Try both commands to enable NXAPI and ignore any errors. -- name: enable nxapi on remote device - nxos_feature: - feature: nxapi - state: enabled +# There is a bug currently where the nxapi server can get +# stuck in a bad state when enabling/disabling rapidly by +# the integration tests. +# +# Toggle the command off/on as mitigation. +- name: Toggle feature nxapi - Disable + nxos_config: + lines: + - no feature nxapi provider: "{{ cli }}" ignore_errors: yes +# Pause after disabling nxapi +- pause: + seconds: 3 + +- name: Toggle feature nxapi - Enable + nxos_config: + lines: + - feature nxapi + provider: "{{ cli }}" + ignore_errors: yes + +# Pause after enabling nxapi +- pause: + seconds: 3 + # Gather the list of interfaces on this device and make the list # available for integration tests that need them. # @@ -52,3 +70,7 @@ # Set platform to N9K-F for fretta - set_fact: platform="N9K-F" when: (platform | match("N9K")) and (fretta | search("true")) + +# Check if platform is titanium +- set_fact: titanium={% for row in nxos_inventory_output.stdout_lines[0]['TABLE_inv']['ROW_inv'] if 'NX-OSv' in row['desc']%}"true"{% endfor %} + when: platform | match("N7K")