<commit_before>---
- debug: msg="START connection={{ ansible_connection }} nxos_bgp sanity test"
- debug: msg="Using provider={{ connection.transport }}"
  when: ansible_connection == "local"

- set_fact: neighbor_down_fib_accelerate="true"
  when: not titanium

- set_fact: reconnect_interval="55"
  when: not titanium

- name: "Enable feature BGP"
  nxos_feature:
    feature: bgp
    state: enabled
    provider: "{{ connection }}"
  ignore_errors: yes

- name: "Setup"
  nxos_bgp: &remove
    asn: 65535
    state: absent
    provider: "{{ connection }}"
  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: "{{ connection }}"
    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: "{{ connection }}"
    register: result

  - assert: *true

  - name: "Check Idempotence"
    nxos_bgp: *configure_non_default
    register: result

  - assert: *false

  - name: "Remove BGP"<commit_msg>Add minor conditional checks to nxos_bgp sanity test (#35476)<commit_after>---
- debug: msg="START connection={{ ansible_connection }} nxos_bgp sanity test"
- debug: msg="Using provider={{ connection.transport }}"
  when: ansible_connection == "local"

- set_fact: neighbor_down_fib_accelerate="true"
  when: (not titanium) and ((imagetag != 'N1') and (imagetag != 'D1'))

- set_fact: reconnect_interval="55"
  when: (not titanium) and ((imagetag != 'N1') and (imagetag != 'D1'))

- set_fact: isolate="false"
  when: platform is not match("N35")

- name: "Enable feature BGP"
  nxos_feature:
    feature: bgp
    state: enabled
    provider: "{{ connection }}"
  ignore_errors: yes

- name: "Setup"
  nxos_bgp: &remove
    asn: 65535
    state: absent
    provider: "{{ connection }}"
  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: "{{ connection }}"
    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: "{{isolate|default(omit)}}"
      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: "{{ connection }}"
    register: result

  - assert: *true

  - name: "Check Idempotence"
    nxos_bgp: *configure_non_default
    register: result

  - assert: *false

  - name: "Remove BGP"
{'fraction_non_alphanumeric': 0.09322337755467909, 'fraction_numerical': 0.01918250268913589, 'mean_word_length': 3.154132539091586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7587465', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1873, 'n_words': 416}