summaryrefslogtreecommitdiff
path: root/tests/integration/targets
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-03-02 22:43:17 +1000
committerGitHub <noreply@github.com>2025-03-02 07:43:17 -0500
commitad249c39c3259df8c2536dd80f62723eb9c364ef (patch)
tree36d1a9ef0a9eb4d60dea2c970c1c0f077c604791 /tests/integration/targets
parentcfc4c93253d57de953c4cae7acc5f2b2890614ac (diff)
downloadvyos.vyos-ad249c39c3259df8c2536dd80f62723eb9c364ef.tar.gz
vyos.vyos-ad249c39c3259df8c2536dd80f62723eb9c364ef.zip
T7012 ospf_interfaces integration tests (#387)
* T7012 init strucuture for ospf_interfaces integration tests * ospf_interfaces unit and integration tests fixes for 1.3- * fixes to v1.4 ospf_interfaces parsers * T7012 integration tests and 1.4+ support for ospf_interfaces
Diffstat (limited to 'tests/integration/targets')
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml8
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml7
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml7
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/_get_version.yaml31
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg9
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_3.cfg (renamed from tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg)4
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_4.cfg6
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml13
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml14
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml5
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml2
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml45
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml53
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml48
14 files changed, 183 insertions, 69 deletions
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml
index e637858..4a9d2cd 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml
@@ -1,5 +1,13 @@
---
+- name: Run preflight setup
+ ansible.builtin.import_tasks: pre_tasks.yml
+ failed_when: false
+
- name: Run CLI tests
ansible.builtin.include_tasks: cli.yaml
tags:
- network_cli
+
+- name: Run post-test cleanup tasks
+ ansible.builtin.import_tasks: post_tasks.yml
+ failed_when: false
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml b/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml
new file mode 100644
index 0000000..0883ef4
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml
@@ -0,0 +1,7 @@
+---
+- name: Demolish environment
+ vyos.vyos.vyos_config:
+ lines: |-
+ delete interfaces bonding bond2
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml b/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml
new file mode 100644
index 0000000..af74ff7
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml
@@ -0,0 +1,7 @@
+---
+- name: Setup environment
+ vyos.vyos.vyos_config:
+ lines: |-
+ set interfaces bonding bond2
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_get_version.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_get_version.yaml
new file mode 100644
index 0000000..a769149
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_get_version.yaml
@@ -0,0 +1,31 @@
+- name: make sure to get facts
+ vyos.vyos.vyos_facts:
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ register: vyos_facts
+ when: vyos_version is not defined
+
+- name: debug vyos_facts
+ debug:
+ var: vyos_facts
+
+- name: pull version from facts
+ set_fact:
+ vyos_version: "{{ vyos_facts.ansible_facts.ansible_net_version.split('-')[0].split(' ')[-1] }}"
+ when: vyos_version is not defined
+
+- name: fix '.0' versions
+ set_fact:
+ vyos_version: "{{ vyos_version }}.0"
+ when: vyos_version.count('.') == 1
+
+- name: include correct vars
+ include_vars: pre-v1_4.yaml
+ when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: include correct vars
+ include_vars: v1_4.yaml
+ when: vyos_version is version('1.4.0', '>=', version_type='semver')
+
+# - name: include common vars
+# include_vars: main.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg
deleted file mode 100644
index 48f286e..0000000
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-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'
-set interfaces ethernet eth0
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_3.cfg
index aa57677..b8112dd 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_3.cfg
@@ -1,6 +1,6 @@
set interfaces ethernet eth0 ip ospf cost '50'
set interfaces ethernet eth0 ip ospf priority '26'
-set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore'
+set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33'
set interfaces bonding bond2 ip ospf transmit-delay '45'
-set interfaces bonding bond2 ipv6 ospfv3 'passive'
+set interfaces bonding bond2 ipv6 ospfv3 passive
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_4.cfg b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_4.cfg
new file mode 100644
index 0000000..269a5ab
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config_1_4.cfg
@@ -0,0 +1,6 @@
+set protocols ospf interface eth0 cost '50'
+set protocols ospf interface eth0 priority '26'
+set protocols ospfv3 interface eth0 mtu-ignore
+set protocols ospfv3 interface eth0 instance-id '33'
+set protocols ospf interface bond2 transmit-delay '45'
+set protocols ospfv3 interface bond2 passive
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml
index 4a24ff9..ccd0f67 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml
@@ -1,14 +1,11 @@
---
- ansible.builtin.include_tasks: _remove_config.yaml
-- name: Setup
+- name: ensure facts
+ include_tasks: _get_version.yaml
+
+- name: Setup {{ vyos_version }}
vyos.vyos.vyos_config:
- lines:
- - set interfaces ethernet eth0 ip ospf cost 50
- - set interfaces ethernet eth0 ip ospf priority 26
- - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
- - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
- - set interfaces bonding bond2 ip ospf transmit-delay 45
- - set interfaces bonding bond2 ipv6 ospfv3 passive
+ lines: "{{ populate_commands }}"
vars:
ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml
index 1d0b96d..74d79f6 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml
@@ -1,15 +1,9 @@
---
+- name: ensure facts
+ include_tasks: _get_version.yaml
+
- name: Remove pre-existing OSPF processes
vyos.vyos.vyos_config:
- lines:
- - delete interfaces ethernet eth0 ip ospf
- - delete interfaces ethernet eth0 ipv6 ospfv3
- - delete interfaces ethernet eth1 ip ospf
- - delete interfaces ethernet eth1 ipv6 ospfv3
- - delete interfaces bonding bond1 ip ospf
- - delete interfaces bonding bond1 ipv6 ospfv3
- - delete interfaces bonding bond2 ip ospf
- - delete interfaces bonding bond2 ipv6 ospfv3
- - delete interfaces bonding bond2
+ lines: "{{ remove_commands }}"
vars:
ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml
index 0d13f76..cb70065 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml
@@ -2,10 +2,13 @@
- debug:
msg: START vyos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection }}
+- name: ensure facts
+ include_tasks: _get_version.yaml
+
- name: Provide the running configuration for parsing (config to be parsed)
register: result
vyos.vyos.vyos_ospf_interfaces:
- running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ running_config: "{{ lookup('file', parsed_config_file) }}"
state: parsed
- assert:
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml
index 42da6ac..c74248e 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml
@@ -2,6 +2,8 @@
- debug:
msg: START vyos_ospf_interfaces rtt integration tests on connection={{ ansible_connection }}
+- include_tasks: _populate.yaml
+
- include_tasks: _remove_config.yaml
- block:
diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml
index 5c618ee..06260fe 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml
@@ -1,12 +1,6 @@
---
merged:
- commands:
- - set interfaces ethernet eth0 ip ospf cost 50
- - set interfaces ethernet eth0 ip ospf priority 26
- - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
- - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
- - set interfaces bonding bond2 ip ospf transmit-delay 45
- - set interfaces bonding bond2 ipv6 ospfv3 passive
+ commands: "{{ merged_commands }}"
after:
- address_family:
- afi: ipv4
@@ -24,16 +18,7 @@ merged:
name: eth0
replaced:
- commands:
- - set interfaces ethernet eth0 ip ospf transmit-delay 50
- - set interfaces ethernet eth0 ip ospf network point-to-point
- - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39
- - delete interfaces ethernet eth0 ip ospf cost 50
- - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
- - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
- - set interfaces bonding bond2 ip ospf bandwidth 70
- - set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key ********
-
+ commands: "{{ replaced_commands }}"
after:
- address_family:
- afi: ipv4
@@ -56,16 +41,7 @@ replaced:
name: eth0
overridden:
- commands:
- - delete interfaces bonding bond2 ip ospf
- - delete interfaces bonding bond2 ipv6 ospfv3
- - set interfaces ethernet eth0 ip ospf transmit-delay 50
- - set interfaces ethernet eth0 ip ospf network point-to-point
- - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39
- - delete interfaces ethernet eth0 ip ospf cost 50
- - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
- - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
-
+ commands: "{{ overridden_commands }}"
after:
- address_family:
- afi: ipv4
@@ -77,9 +53,7 @@ overridden:
name: eth0
deleted:
- commands:
- - delete interfaces bonding bond2 ip ospf
- - delete interfaces bonding bond2 ipv6 ospfv3
+ commands: "{{ deleted_commands }}"
after:
- address_family:
- afi: ipv4
@@ -91,15 +65,8 @@ deleted:
name: eth0
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'
+ commands: "{{ rendered_commands }}"
+
round_trip:
after:
- name: eth0
diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml
new file mode 100644
index 0000000..a9e0342
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml
@@ -0,0 +1,53 @@
+---
+merged_commands:
+ - set interfaces ethernet eth0 ip ospf cost 50
+ - set interfaces ethernet eth0 ip ospf priority 26
+ - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
+ - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
+ - set interfaces bonding bond2 ip ospf transmit-delay 45
+ - set interfaces bonding bond2 ipv6 ospfv3 passive
+
+populate_commands:
+ - set interfaces ethernet eth0 ip ospf cost 50
+ - set interfaces ethernet eth0 ip ospf priority 26
+ - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
+ - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
+ - set interfaces bonding bond2 ip ospf transmit-delay 45
+ - set interfaces bonding bond2 ipv6 ospfv3 passive
+
+remove_commands:
+ - delete interfaces ethernet eth0 ip ospf
+ - delete interfaces ethernet eth0 ipv6 ospfv3
+ - delete interfaces ethernet eth1 ip ospf
+ - delete interfaces ethernet eth1 ipv6 ospfv3
+ - delete interfaces bonding bond1 ip ospf
+ - delete interfaces bonding bond1 ipv6 ospfv3
+ - delete interfaces bonding bond2 ip ospf
+ - delete interfaces bonding bond2 ipv6 ospfv3
+ - delete interfaces bonding bond2
+
+parsed_config_file: "_parsed_config_1_3.cfg"
+
+replaced_commands:
+ - set interfaces ethernet eth0 ip ospf transmit-delay 50
+ - set interfaces ethernet eth0 ip ospf network point-to-point
+ - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39
+ - delete interfaces ethernet eth0 ip ospf cost 50
+ - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
+ - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
+ - set interfaces bonding bond2 ip ospf bandwidth 70
+ - set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key ********
+
+overridden_commands:
+ - delete interfaces bonding bond2 ip ospf
+ - delete interfaces bonding bond2 ipv6 ospfv3
+ - set interfaces ethernet eth0 ip ospf transmit-delay 50
+ - set interfaces ethernet eth0 ip ospf network point-to-point
+ - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39
+ - delete interfaces ethernet eth0 ip ospf cost 50
+ - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
+ - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
+
+deleted_commands:
+ - delete interfaces bonding bond2 ip ospf
+ - delete interfaces bonding bond2 ipv6 ospfv3
diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml
new file mode 100644
index 0000000..15b7f5a
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml
@@ -0,0 +1,48 @@
+---
+merged_commands:
+ - set protocols ospf interface eth0 cost 50
+ - set protocols ospf interface eth0 priority 26
+ - set protocols ospfv3 interface eth0 mtu-ignore
+ - set protocols ospfv3 interface eth0 instance-id 33
+ - set protocols ospfv3 interface bond2 passive
+ - set protocols ospf interface bond2 transmit-delay 45
+
+populate_commands:
+ - set protocols ospf interface eth0 cost 50
+ - set protocols ospf interface eth0 priority 26
+ - set protocols ospfv3 interface eth0 mtu-ignore
+ - set protocols ospfv3 interface eth0 instance-id 33
+ - set protocols ospfv3 interface bond2 passive
+ - set protocols ospf interface bond2 transmit-delay 45
+
+remove_commands:
+ - delete protocols ospf interface eth0
+ - delete protocols ospf interface bond2
+ - delete protocols ospfv3 interface bond2
+ - delete protocols ospfv3 interface eth0
+
+parsed_config_file: "_parsed_config_1_4.cfg"
+
+replaced_commands:
+ - set protocols ospf interface eth0 transmit-delay 50
+ - set protocols ospf interface eth0 network point-to-point
+ - set protocols ospfv3 interface eth0 dead-interval 39
+ - delete protocols ospf interface eth0 cost 50
+ - delete protocols ospfv3 interface eth0 instance-id 33
+ - delete protocols ospfv3 interface eth0 mtu-ignore
+ - set protocols ospf interface bond2 bandwidth 70
+ - set protocols ospf interface bond2 authentication md5 key-id 10 md5-key ********
+
+overridden_commands:
+ - delete protocols ospf interface bond2
+ - delete protocols ospfv3 interface bond2
+ - set protocols ospf interface eth0 transmit-delay 50
+ - set protocols ospf interface eth0 network point-to-point
+ - set protocols ospfv3 interface eth0 dead-interval 39
+ - delete protocols ospf interface eth0 cost 50
+ - delete protocols ospfv3 interface eth0 instance-id 33
+ - delete protocols ospfv3 interface eth0 mtu-ignore
+
+deleted_commands:
+ - delete protocols ospf interface bond2
+ - delete protocols ospfv3 interface bond2