summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_vrf
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets/vyos_vrf')
-rw-r--r--tests/integration/targets/vyos_vrf/aliases1
-rw-r--r--tests/integration/targets/vyos_vrf/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_vrf/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_vrf/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/_populate_config.yaml23
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/_remove_config.yaml4
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/deleted.yaml50
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/gathered.yaml27
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/merged.yaml59
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/merged_protocols.yaml117
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/overridden.yaml50
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/replaced.yaml52
-rw-r--r--tests/integration/targets/vyos_vrf/tests/httpapi/rtt.yaml82
-rw-r--r--tests/integration/targets/vyos_vrf/vars/main.yaml2
14 files changed, 496 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_vrf/aliases b/tests/integration/targets/vyos_vrf/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_vrf/defaults/main.yaml b/tests/integration/targets/vyos_vrf/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_vrf/tasks/httpapi.yaml b/tests/integration/targets/vyos_vrf/tasks/httpapi.yaml
new file mode 100644
index 0000000..0ed3e42
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_vrf/tasks/main.yaml b/tests/integration/targets/vyos_vrf/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..69222b6
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,23 @@
+---
+- name: Populate VRF configuration
+ vyos.rest.vyos_vrf:
+ config:
+ bind_to_all: true
+ instances:
+ - name: vrf1
+ description: red
+ table_id: 101
+ vni: 501
+ disable: true
+ - name: vrf2
+ description: blah2
+ table_id: 102
+ vni: 102
+ address_family:
+ - afi: ipv4
+ disable_forwarding: true
+ nht_no_resolve_via_default: true
+ - afi: ipv6
+ disable_forwarding: true
+ nht_no_resolve_via_default: true
+ state: merged
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..da63347
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: Remove VRF configuration
+ vyos.rest.vyos_vrf:
+ state: deleted
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..22eb43f
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/deleted.yaml
@@ -0,0 +1,50 @@
+---
+- debug:
+ msg: START vyos_vrf deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete specific VRF
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather and verify vrf1 deleted
+ register: result
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.instances | length == 1
+ - result.gathered.instances[0].name == "vrf2"
+
+ - name: Delete all VRF configuration
+ register: result
+ vyos.rest.vyos_vrf:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete all VRF (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vrf:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..83f543d
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/gathered.yaml
@@ -0,0 +1,27 @@
+---
+- debug:
+ msg: START vyos_vrf gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather VRF configuration
+ register: result
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered.bind_to_all == true
+ - result.gathered.instances | length == 2
+ - result.gathered.instances[0].name == "vrf1"
+ - result.gathered.instances[0].table_id == 101
+ - result.gathered.instances[0].vni == 501
+ - result.gathered.instances[0].disable == true
+ - result.gathered.instances[1].name == "vrf2"
+ - result.gathered.instances[1].table_id == 102
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..2655ce3
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/merged.yaml
@@ -0,0 +1,59 @@
+---
+- debug:
+ msg: START vyos_vrf merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge VRF configuration
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ bind_to_all: true
+ instances:
+ - name: vrf1
+ description: red
+ table_id: 101
+ vni: 501
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.after.instances | length == 1
+ - result.after.instances[0].name == "vrf1"
+ - result.after.instances[0].table_id == 101
+
+ - name: Merge VRF configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ bind_to_all: true
+ instances:
+ - name: vrf1
+ description: red
+ table_id: 101
+ vni: 501
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ - name: Merge second VRF instance
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf2
+ table_id: 102
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+ - result.after.instances | length == 2
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/merged_protocols.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/merged_protocols.yaml
new file mode 100644
index 0000000..f600f84
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/merged_protocols.yaml
@@ -0,0 +1,117 @@
+---
+- debug:
+ msg: START vyos_vrf merged protocols integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge VRF with BGP
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ table_id: 101
+ protocols:
+ bgp:
+ system_as: 65001
+ neighbor:
+ - address: 10.0.0.1
+ remote_as: 65002
+ description: peer1
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge VRF with BGP (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ table_id: 101
+ protocols:
+ bgp:
+ system_as: 65001
+ neighbor:
+ - address: 10.0.0.1
+ remote_as: 65002
+ description: peer1
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ - name: Merge VRF with OSPF and static routes
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ table_id: 101
+ protocols:
+ ospf:
+ areas:
+ - area_id: "0"
+ networks:
+ - 10.0.0.0/24
+ parameters:
+ router_id: 10.0.0.1
+ static:
+ routes:
+ - dest: 192.168.10.0/24
+ next_hops:
+ - 10.0.0.254
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather and verify protocols
+ register: result
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.instances[0].protocols.bgp.system_as == 65001
+ - result.gathered.instances[0].protocols.ospf.areas | length == 1
+ - result.gathered.instances[0].protocols.static.routes | length == 1
+
+ - name: Change an already-set OSPF router_id
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ table_id: 101
+ protocols:
+ ospf:
+ areas:
+ - area_id: "0"
+ networks:
+ - 10.0.0.0/24
+ parameters:
+ router_id: 10.0.0.99
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather and verify router_id was actually changed
+ register: result
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.instances[0].protocols.ospf.parameters.router_id == "10.0.0.99"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..da72aac
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/overridden.yaml
@@ -0,0 +1,50 @@
+---
+- debug:
+ msg: START vyos_vrf overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override with single VRF
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf3
+ table_id: 200
+ vni: 2000
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather and verify override
+ register: result
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.instances | length == 1
+ - result.gathered.instances[0].name == "vrf3"
+ - result.gathered.instances[0].table_id == 200
+
+ - name: Override (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf3
+ table_id: 200
+ vni: 2000
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..53714fc
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/replaced.yaml
@@ -0,0 +1,52 @@
+---
+- debug:
+ msg: START vyos_vrf replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace vrf1 configuration
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ description: updated
+ table_id: 101
+ vni: 999
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Gather and verify replacement
+ register: result
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.instances[0].vni == 999
+ - result.gathered.instances[0].description == "updated"
+ - result.gathered.instances[0].disable is not defined or result.gathered.instances[0].disable == false
+
+ - name: Replace vrf1 (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vrf:
+ config:
+ instances:
+ - name: vrf1
+ description: updated
+ table_id: 101
+ vni: 999
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_vrf/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..9d16bc6
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/tests/httpapi/rtt.yaml
@@ -0,0 +1,82 @@
+---
+- debug:
+ msg: START vyos_vrf round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_vrf:
+ config:
+ bind_to_all: true
+ instances:
+ - name: vrf1
+ description: red
+ table_id: 101
+ vni: 501
+ protocols:
+ bgp:
+ system_as: 65001
+ neighbor:
+ - address: 10.0.0.1
+ remote_as: 65002
+ ospf:
+ areas:
+ - area_id: "0"
+ networks:
+ - 10.0.0.0/24
+ parameters:
+ router_id: 10.0.0.1
+ static:
+ routes:
+ - dest: 192.168.10.0/24
+ next_hops:
+ - 10.0.0.254
+ state: merged
+
+ - name: RTT - Gather
+ register: gathered
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - gathered.gathered.bind_to_all == true
+ - gathered.gathered.instances[0].name == "vrf1"
+ - gathered.gathered.instances[0].table_id == 101
+ - gathered.gathered.instances[0].protocols.bgp.system_as == 65001
+ - gathered.gathered.instances[0].protocols.ospf.parameters.router_id == "10.0.0.1"
+ - gathered.gathered.instances[0].protocols.static.routes[0].dest == "192.168.10.0/24"
+
+ - name: RTT - Modify description and add BGP neighbor
+ vyos.rest.vyos_vrf:
+ config:
+ bind_to_all: true
+ instances:
+ - name: vrf1
+ description: red-updated
+ table_id: 101
+ vni: 501
+ protocols:
+ bgp:
+ system_as: 65001
+ neighbor:
+ - address: 10.0.0.1
+ remote_as: 65002
+ - address: 10.0.0.2
+ remote_as: 65003
+ state: replaced
+
+ - name: RTT - Gather after modify
+ register: gathered2
+ vyos.rest.vyos_vrf:
+ state: gathered
+
+ - assert:
+ that:
+ - gathered2.gathered.instances[0].description == "red-updated"
+ - gathered2.gathered.instances[0].protocols.bgp.neighbor | length == 2
+ - gathered2.gathered.instances[0].protocols.ospf is not defined
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vrf/vars/main.yaml b/tests/integration/targets/vyos_vrf/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_vrf/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here