summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorGomathiselviS <gomathiselvi@gmail.com>2021-02-24 12:16:02 -0500
committerGitHub <noreply@github.com>2021-02-24 17:16:02 +0000
commita679a918cb0474a0eb5db73f925e612b4863c177 (patch)
tree14756d2a168b6fadc3ed8289acabc33ac565fe39 /tests/integration
parentdf81f31331b2b1b4ab894da44532cb3ea245f83a (diff)
downloadvyos-ansible-old-a679a918cb0474a0eb5db73f925e612b4863c177.tar.gz
vyos-ansible-old-a679a918cb0474a0eb5db73f925e612b4863c177.zip
Add vyos_bgp_global resource module (#125)
Add vyos_bgp_global resource module Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/vyos_bgp_global/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_bgp_global/meta/main.yaml3
-rw-r--r--tests/integration/targets/vyos_bgp_global/tasks/cli.yaml19
-rw-r--r--tests/integration/targets/vyos_bgp_global/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg30
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml37
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml12
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/_preconfig.yaml10
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml11
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml42
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml26
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml49
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml24
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml71
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml16
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml32
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml45
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml72
-rw-r--r--tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml56
-rw-r--r--tests/integration/targets/vyos_bgp_global/vars/main.yaml150
20 files changed, 712 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_bgp_global/defaults/main.yaml b/tests/integration/targets/vyos_bgp_global/defaults/main.yaml
new file mode 100644
index 0000000..852a6be
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: '[^_].*'
+test_items: []
diff --git a/tests/integration/targets/vyos_bgp_global/meta/main.yaml b/tests/integration/targets/vyos_bgp_global/meta/main.yaml
new file mode 100644
index 0000000..7413320
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_vyos_tests
diff --git a/tests/integration/targets/vyos_bgp_global/tasks/cli.yaml b/tests/integration/targets/vyos_bgp_global/tasks/cli.yaml
new file mode 100644
index 0000000..93eb2fe
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tasks/cli.yaml
@@ -0,0 +1,19 @@
+---
+- name: Collect all cli test cases
+ find:
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_bgp_global/tasks/main.yaml b/tests/integration/targets/vyos_bgp_global/tasks/main.yaml
new file mode 100644
index 0000000..b957d2f
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- include: cli.yaml
+ tags:
+ - network_cli
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..2338b03
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg
@@ -0,0 +1,30 @@
+set policy access-list 20 description 'acl20'
+set policy access-list 40 description 'acl40'
+set policy route-map map01 description 'map01'
+set protocols bgp 65536 aggregate-address 192.0.2.0/24 'summary-only'
+set protocols bgp 65536 aggregate-address 203.0.113.0/24 'as-set'
+set protocols bgp 65536 maximum-paths ebgp '20'
+set protocols bgp 65536 maximum-paths ibgp '55'
+set protocols bgp 65536 neighbor 192.0.2.25 'disable-connected-check'
+set protocols bgp 65536 neighbor 192.0.2.25 timers holdtime '30'
+set protocols bgp 65536 neighbor 192.0.2.25 timers keepalive '10'
+set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'as-path'
+set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'med'
+set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'next-hop'
+set protocols bgp 65536 neighbor 203.0.113.5 ebgp-multihop '2'
+set protocols bgp 65536 neighbor 203.0.113.5 remote-as '101'
+set protocols bgp 65536 neighbor 203.0.113.5 update-source '192.0.2.25'
+set protocols bgp 65536 neighbor 5001::64 distribute-list export '20'
+set protocols bgp 65536 neighbor 5001::64 distribute-list import '40'
+set protocols bgp 65536 neighbor 5001::64 maximum-prefix '34'
+set protocols bgp 65536 network 192.1.13.0/24 'backdoor'
+set protocols bgp 65536 parameters bestpath as-path 'confed'
+set protocols bgp 65536 parameters bestpath 'compare-routerid'
+set protocols bgp 65536 parameters confederation identifier '66'
+set protocols bgp 65536 parameters confederation peers '20'
+set protocols bgp 65536 parameters confederation peers '55'
+set protocols bgp 65536 parameters default 'no-ipv4-unicast'
+set protocols bgp 65536 parameters router-id '192.1.2.9'
+set protocols bgp 65536 redistribute connected route-map 'map01'
+set protocols bgp 65536 redistribute kernel metric '45'
+set protocols bgp 65536 timers keepalive '35'
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml
new file mode 100644
index 0000000..ec237d9
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml
@@ -0,0 +1,37 @@
+---
+- name: setup
+ vyos.vyos.vyos_config:
+ lines:
+ - set policy access-list 20 description 'acl20'
+ - set policy access-list 40 description 'acl40'
+ - set policy route-map map01 description 'map01'
+ - set protocols bgp 65536 aggregate-address 192.0.2.0/24 'summary-only'
+ - set protocols bgp 65536 aggregate-address 203.0.113.0/24 'as-set'
+ - set protocols bgp 65536 maximum-paths ebgp '20'
+ - set protocols bgp 65536 maximum-paths ibgp '55'
+ - set protocols bgp 65536 neighbor 192.0.2.25 'disable-connected-check'
+ - set protocols bgp 65536 neighbor 192.0.2.25 timers holdtime '30'
+ - set protocols bgp 65536 neighbor 192.0.2.25 timers keepalive '10'
+ - set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'as-path'
+ - set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'med'
+ - set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'next-hop'
+ - set protocols bgp 65536 neighbor 203.0.113.5 ebgp-multihop '2'
+ - set protocols bgp 65536 neighbor 203.0.113.5 remote-as '101'
+ - set protocols bgp 65536 neighbor 203.0.113.5 update-source '192.0.2.25'
+ - set protocols bgp 65536 neighbor 5001::64 distribute-list export '20'
+ - set protocols bgp 65536 neighbor 5001::64 distribute-list import '40'
+ - set protocols bgp 65536 neighbor 5001::64 maximum-prefix '34'
+ - set protocols bgp 65536 network 192.1.13.0/24 'backdoor'
+ - set protocols bgp 65536 parameters bestpath as-path 'confed'
+ - set protocols bgp 65536 parameters bestpath 'compare-routerid'
+ - set protocols bgp 65536 parameters confederation identifier '66'
+ - set protocols bgp 65536 parameters confederation peers '20'
+ - set protocols bgp 65536 parameters confederation peers '55'
+ - set protocols bgp 65536 parameters default 'no-ipv4-unicast'
+ - set protocols bgp 65536 parameters router-id '192.1.2.9'
+ - set protocols bgp 65536 redistribute connected route-map 'map01'
+ - set protocols bgp 65536 redistribute kernel metric '45'
+ - set protocols bgp 65536 timers keepalive '35'
+ ignore_errors: true
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml
new file mode 100644
index 0000000..59f3d92
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml
@@ -0,0 +1,12 @@
+---
+- name: setup
+ vyos.vyos.vyos_config:
+ lines:
+ - set protocols bgp 65536 neighbor 5001::64 address-family 'ipv6-unicast'
+ - set protocols bgp 65536 neighbor 5001::64 ebgp-multihop '2'
+ - set protocols bgp 65536 neighbor 5001::64 maximum-prefix '34'
+ - set protocols bgp 65536 neighbor 5001::64 remote-as '65535'
+ - set protocols bgp 65536 neighbor 5001::64 update-source '2001:db8::1'
+ ignore_errors: true
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_preconfig.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_preconfig.yaml
new file mode 100644
index 0000000..8ab69e0
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_preconfig.yaml
@@ -0,0 +1,10 @@
+---
+- name: setup
+ vyos.vyos.vyos_config:
+ lines:
+ - set policy access-list 20 description 'acl20'
+ - set policy access-list 40 description 'acl40'
+ - set policy route-map map01 description 'map01'
+ ignore_errors: true
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..07d4aa4
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,11 @@
+---
+- name: Remove pre-existing bgp processes
+ vyos.vyos.vyos_config:
+ lines:
+ - delete protocols bgp 65536
+ - delete policy access-list 20
+ - delete policy access-list 40
+ - delete policy route-map map01
+ ignore_errors: true
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml
new file mode 100644
index 0000000..e1a7754
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml
@@ -0,0 +1,42 @@
+---
+- debug:
+ msg: START vyos_bgp_global deleted integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Delete the provided configuration
+ register: result
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ state: deleted
+
+ - become: true
+ vyos.vyos.vyos_facts:
+ gather_network_resources: bgp_global
+
+ - assert:
+ that:
+ - result.commands|length == 9
+ - result.changed == true
+ - result.commands|symmetric_difference(deleted.commands) == []
+ - result.after == ansible_facts['network_resources']['bgp_global']
+
+ - name: Delete the existing configuration with the provided running configuration
+ (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_bgp_global: *id001
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml
new file mode 100644
index 0000000..9792125
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml
@@ -0,0 +1,26 @@
+---
+- debug:
+ msg: START vyos_bgp_global replaced integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_af.yaml
+
+- block:
+
+ - name: Delete the existing configuration, in presence of an af under neighbor.
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ state: deleted
+
+ - assert:
+ that:
+ - result.msg == 'Use the _bgp_address_family module to delete the address_family under neighbor 5001::64, before replacing/deleting the neighbor.'
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..7e52d1c
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: START vyos_bgp_global empty_config integration tests on connection={{
+ ansible_connection }}
+
+- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_bgp_global:
+ config:
+ state: merged
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_bgp_global:
+ config:
+ state: replaced
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Parsed with empty running_config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_bgp_global:
+ running_config:
+ state: parsed
+
+- assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state
+ parsed'
+
+- name: Rendered with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_bgp_global:
+ config:
+ state: rendered
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml
new file mode 100644
index 0000000..7ec1da8
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml
@@ -0,0 +1,24 @@
+---
+- debug:
+ msg: START vyos_bgp_global gathered integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather config from the device in structured format.
+ register: result
+ vyos.vyos.vyos_bgp_global:
+ state: gathered
+
+ - become: true
+ vyos.vyos.vyos_facts:
+ gather_network_resources: bgp_global
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered == ansible_facts['network_resources']['bgp_global']
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml
new file mode 100644
index 0000000..8a09c01
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml
@@ -0,0 +1,71 @@
+---
+- debug:
+ msg: START vyos_bgp_global merged integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _preconfig.yaml
+
+- block:
+
+ - name: Merge the provided configuration with the exisiting running configuration
+ register: result
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ aggregate_address:
+ - prefix: "203.0.113.0/24"
+ as_set: true
+ - prefix: "192.0.2.0/24"
+ summary_only: true
+ network:
+ - address: "192.1.13.0/24"
+ backdoor: true
+ redistribute:
+ - protocol: "kernel"
+ metric: 45
+ - protocol: "connected"
+ route_map: "map01"
+ maximum_paths:
+ - path: "ebgp"
+ count: 20
+ - path: "ibgp"
+ count: 55
+ timers:
+ keepalive: 35
+ bgp_params:
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ router_id: "192.1.2.9"
+ state: merged
+
+ - become: true
+ vyos.vyos.vyos_facts:
+ gather_network_resources: bgp_global
+
+ - assert:
+ that:
+ - result.commands|length == 12
+ - result.changed == true
+ - result.commands|symmetric_difference(merged.commands) == []
+ - result.after == ansible_facts['network_resources']['bgp_global']
+ - result.before == {}
+ - result.after == merged.after
+
+ - name: Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_bgp_global: *id001
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml
new file mode 100644
index 0000000..419df6a
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- debug:
+ msg: START vyos_bgp_global parsed integration tests on connection={{ ansible_connection
+ }}
+
+- name: Provide the running configuration for parsing (config to be parsed)
+ become: true
+ register: result
+ vyos.vyos.vyos_bgp_global:
+ running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+ state: parsed
+
+- assert:
+ that:
+ - result.changed == false
+ - result.parsed == populate.global
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml
new file mode 100644
index 0000000..9588e80
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml
@@ -0,0 +1,32 @@
+---
+- debug:
+ msg: START vyos_bgp_global purged integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Purge the provided configuration
+ register: result
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ state: purged
+
+ - become: true
+ vyos.vyos.vyos_facts:
+ gather_network_resources: bgp_global
+
+ - assert:
+ that:
+ - result.commands|length == 1
+ - result.changed == true
+ - "'delete protocols bgp 65536' in result.commands"
+ - ansible_facts.network_resources.bgp_global == []
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml
new file mode 100644
index 0000000..3a44a5e
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml
@@ -0,0 +1,45 @@
+---
+- debug:
+ msg: START vyos_bgp_global merged integration tests on connection={{
+ ansible_connection }}
+
+- block:
+
+ - name: Render given bgp_global configuration
+ register: result
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ aggregate_address:
+ - prefix: "203.0.113.0/24"
+ as_set: true
+ - prefix: "192.0.2.0/24"
+ summary_only: true
+ network:
+ - address: "192.1.13.0/24"
+ backdoor: true
+ redistribute:
+ - protocol: "kernel"
+ metric: 45
+ - protocol: "connected"
+ route_map: "map01"
+ maximum_paths:
+ - path: "ebgp"
+ count: 20
+ - path: "ibgp"
+ count: 55
+ timers:
+ keepalive: 35
+ bgp_params:
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ router_id: "192.1.2.9"
+ state: rendered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml
new file mode 100644
index 0000000..2a8b407
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml
@@ -0,0 +1,72 @@
+---
+- debug:
+ msg: START vyos_bgp_global replaced integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Replace the existing configuration with the provided running configuration
+ register: result
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ network:
+ - address: "203.0.113.0/24"
+ route_map: map01
+ redistribute:
+ - protocol: "static"
+ route_map: "map01"
+ bgp_params:
+ always_compare_med: true
+ dampening:
+ start_suppress_time: 5
+ max_suppress_time: 20
+ half_life: 33
+ re_use: 60
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ neighbor:
+ - address: "192.0.2.43"
+ disable_connected_check: true
+ advertisement_interval: 72
+ capability:
+ dynamic: true
+ timers:
+ holdtime: 30
+ keepalive: 10
+ - address: "203.0.113.0"
+ capability:
+ orf: "receive"
+ state: replaced
+
+ - become: true
+ vyos.vyos.vyos_facts:
+ gather_network_resources: bgp_global
+
+ - assert:
+ that:
+ - result.commands|length == 24
+ - result.changed == true
+ - result.commands|symmetric_difference(replaced.commands) == []
+ - result.after == ansible_facts['network_resources']['bgp_global']
+
+ - name: Replace the existing configuration with the provided running configuration
+ (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_bgp_global: *id001
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml
new file mode 100644
index 0000000..abcb177
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml
@@ -0,0 +1,56 @@
+---
+- debug:
+ msg: START vyos_bgp_global replaced integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_af.yaml
+
+- block:
+
+ - name: Replace the existing af configuration with the provided running configuration
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_bgp_global: &id001
+ config:
+ as_number: "65536"
+ network:
+ - address: "203.0.113.0/24"
+ route_map: map01
+ redistribute:
+ - protocol: "static"
+ route_map: "map01"
+ bgp_params:
+ always_compare_med: true
+ dampening:
+ start_suppress_time: 5
+ max_suppress_time: 20
+ half_life: 33
+ re_use: 60
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ neighbor:
+ - address: "192.0.2.43"
+ disable_connected_check: true
+ advertisement_interval: 72
+ capability:
+ dynamic: true
+ timers:
+ holdtime: 30
+ keepalive: 10
+ - address: "203.0.113.0"
+ capability:
+ orf: "receive"
+ state: replaced
+
+ - assert:
+ that:
+ - result.msg == 'Use the _bgp_address_family module to delete the address_family under neighbor 5001::64, before replacing/deleting the neighbor.'
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/vars/main.yaml b/tests/integration/targets/vyos_bgp_global/vars/main.yaml
new file mode 100644
index 0000000..fec5e43
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/vars/main.yaml
@@ -0,0 +1,150 @@
+---
+merged:
+ commands:
+ - set protocols bgp 65536 redistribute kernel metric 45
+ - set protocols bgp 65536 redistribute connected route-map map01
+ - set protocols bgp 65536 network 192.1.13.0/24 backdoor
+ - set protocols bgp 65536 aggregate-address 203.0.113.0/24 as-set
+ - set protocols bgp 65536 aggregate-address 192.0.2.0/24 summary-only
+ - set protocols bgp 65536 parameters bestpath as-path confed
+ - set protocols bgp 65536 parameters bestpath compare-routerid
+ - set protocols bgp 65536 parameters default no-ipv4-unicast
+ - set protocols bgp 65536 parameters router-id 192.1.2.9
+ - set protocols bgp 65536 maximum-paths ebgp 20
+ - set protocols bgp 65536 maximum-paths ibgp 55
+ - set protocols bgp 65536 timers keepalive 35
+ after:
+ aggregate_address:
+ - prefix: "192.0.2.0/24"
+ summary_only: true
+ - prefix: "203.0.113.0/24"
+ as_set: true
+ as_number: 65536
+ bgp_params:
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ router_id: "192.1.2.9"
+ maximum_paths:
+ - count: 20
+ path: "ebgp"
+ - count: 55
+ path: "ibgp"
+ network:
+ - address: "192.1.13.0/24"
+ backdoor: true
+ redistribute:
+ - protocol: "connected"
+ route_map: "map01"
+ - metric: 45
+ protocol: "kernel"
+ timers:
+ keepalive: 35
+
+replaced:
+ commands:
+ - delete protocols bgp 65536 timers
+ - delete protocols bgp 65536 maximum-paths
+ - delete protocols bgp 65536 parameters router-id 192.1.2.9
+ - delete protocols bgp 65536 parameters confederation
+ - delete protocols bgp 65536 aggregate-address
+ - delete protocols bgp 65536 network 192.1.13.0/24
+ - delete protocols bgp 65536 redistribute kernel
+ - delete protocols bgp 65536 redistribute connected
+ - delete protocols bgp 65536 neighbor 5001::64
+ - delete protocols bgp 65536 neighbor 203.0.113.5
+ - delete protocols bgp 65536 neighbor 192.0.2.25
+ - set protocols bgp 65536 neighbor 192.0.2.43 disable-connected-check
+ - set protocols bgp 65536 neighbor 192.0.2.43 advertisement-interval 72
+ - set protocols bgp 65536 neighbor 192.0.2.43 capability dynamic
+ - set protocols bgp 65536 neighbor 192.0.2.43 timers holdtime 30
+ - set protocols bgp 65536 neighbor 192.0.2.43 timers keepalive 10
+ - set protocols bgp 65536 neighbor 203.0.113.0 capability orf prefix-list receive
+ - set protocols bgp 65536 redistribute static route-map map01
+ - set protocols bgp 65536 network 203.0.113.0/24 route-map map01
+ - set protocols bgp 65536 parameters always-compare-med
+ - set protocols bgp 65536 parameters dampening half-life 33
+ - set protocols bgp 65536 parameters dampening max-suppress-time 20
+ - set protocols bgp 65536 parameters dampening re-use 60
+ - set protocols bgp 65536 parameters dampening start-suppress-time 5
+
+deleted:
+ commands:
+ - delete protocols bgp 65536 timers
+ - delete protocols bgp 65536 maximum-paths
+ - delete protocols bgp 65536 parameters
+ - delete protocols bgp 65536 aggregate-address
+ - delete protocols bgp 65536 network
+ - delete protocols bgp 65536 redistribute
+ - delete protocols bgp 65536 neighbor 5001::64
+ - delete protocols bgp 65536 neighbor 203.0.113.5
+ - delete protocols bgp 65536 neighbor 192.0.2.25
+
+rendered:
+ commands:
+ - set interfaces ethernet eth1 firewall in name 'INBOUND'
+ - set interfaces ethernet eth1 firewall out name 'OUTBOUND'
+ - set interfaces ethernet eth1 firewall local name 'LOCAL'
+ - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'
+ - set interfaces ethernet eth2 firewall in name 'INBOUND'
+ - set interfaces ethernet eth2 firewall out name 'OUTBOUND'
+ - set interfaces ethernet eth2 firewall local name 'LOCAL'
+ - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'
+
+populate:
+ global:
+ aggregate_address:
+ - prefix: "192.0.2.0/24"
+ summary_only: true
+ - prefix: "203.0.113.0/24"
+ as_set: true
+ as_number: 65536
+ bgp_params:
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ confederation:
+ - identifier: 66
+ - peers: 20
+ - peers: 55
+ default:
+ no_ipv4_unicast: true
+ router_id: "192.1.2.9"
+ maximum_paths:
+ - count: 20
+ path: "ebgp"
+ - count: 55
+ path: "ibgp"
+ neighbor:
+ - address: "192.0.2.25"
+ disable_connected_check: true
+ timers:
+ holdtime: 30
+ keepalive: 10
+ - address: "203.0.113.5"
+ attribute_unchanged:
+ as_path: true
+ med: true
+ next_hop: true
+ ebgp_multihop: 2
+ remote_as: 101
+ update_source: "192.0.2.25"
+ - address: "5001::64"
+ distribute_list:
+ - acl: 20
+ action: "export"
+ - acl: 40
+ action: "import"
+ maximum_prefix: 34
+ network:
+ - address: "192.1.13.0/24"
+ backdoor: true
+ redistribute:
+ - protocol: "connected"
+ route_map: "map01"
+ - metric: 45
+ protocol: "kernel"
+ timers:
+ keepalive: 35