diff options
author | omnom62 <75066712+omnom62@users.noreply.github.com> | 2025-05-23 17:01:24 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-23 03:01:24 -0400 |
commit | 2879b9a4193aa3153f05b985e1f12d78cfbe6fd0 (patch) | |
tree | 02e4ef1a77cb051d8c38010fe2e41b129a3e3055 | |
parent | cd2f41d34ff22ea7719348ec18a30f1c499b72c8 (diff) | |
download | vyos.vyos-2879b9a4193aa3153f05b985e1f12d78cfbe6fd0.tar.gz vyos.vyos-2879b9a4193aa3153f05b985e1f12d78cfbe6fd0.zip |
Integration tests FDR (#416)
* clean-up for strreamlines e2e integration tests
* 1.4+ fix for snmp_server
* changes to integratio tests
* changelog fix
* fix ampty json on vyos.py get_config
* fix vyos get_config
* quick fix for teardwon in vyos_system test
* Update plugins/module_utils/network/vyos/vyos.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* copilot recommendations incorporated
* remove copilot mess
---------
Co-authored-by: John Doe <johndoe@email.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
6 files changed, 24 insertions, 6 deletions
diff --git a/changelogs/fragments/integration_tests_fixes.yml b/changelogs/fragments/integration_tests_fixes.yml new file mode 100644 index 00000000..5bb898d8 --- /dev/null +++ b/changelogs/fragments/integration_tests_fixes.yml @@ -0,0 +1,4 @@ +--- +trivial: + - prepare_vyos_firewall - Remove IP address from eth1 for lag tests + - vyos_snmp_server - add IP address for 1.4+ OS variants diff --git a/plugins/module_utils/network/vyos/vyos.py b/plugins/module_utils/network/vyos/vyos.py index f37294e6..5c157818 100644 --- a/plugins/module_utils/network/vyos/vyos.py +++ b/plugins/module_utils/network/vyos/vyos.py @@ -68,8 +68,12 @@ def get_capabilities(module): def get_config(module, flags=None, format=None): flags = [] if flags is None else flags global _DEVICE_CONFIGS - - if _DEVICE_CONFIGS != {} or module.params["match"] == "none": + # If _DEVICE_CONFIGS is non-empty and module.params["match"] is "none", + # return the cached device configurations. This avoids redundant calls + # to the connection when no specific match criteria are provided. + if _DEVICE_CONFIGS != {} and ( + module.params["match"] is not None and module.params["match"] == "none" + ): return to_text(_DEVICE_CONFIGS) else: connection = get_connection(module) diff --git a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml index 3a0e2cc4..276be083 100644 --- a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml +++ b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml @@ -5,7 +5,7 @@ set interfaces ethernet eth0 address dhcp set interfaces ethernet eth0 speed auto set interfaces ethernet eth0 duplex auto - set interfaces ethernet eth1 address 192.0.2.1/24 + set interfaces ethernet eth1 set interfaces ethernet eth2 delete interfaces loopback lo vars: diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml index f8aa82e8..5fade170 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml @@ -2,6 +2,7 @@ - name: setup vyos.vyos.vyos_config: lines: + - set interface ethernet eth1 address 192.0.2.1/24 - set interface ethernet eth2 address 20.1.1.1/24 - set service snmp community switches authorization rw - set service snmp community bridges client 1.1.1.1 diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml index 12cfb755..d30001f9 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml @@ -6,3 +6,12 @@ ignore_errors: true vars: ansible_connection: ansible.netcommon.network_cli + +- name: remove interfaces address + vyos.vyos.vyos_config: + lines: + - delete interface ethernet eth1 address + - delete interface ethernet eth2 address + ignore_errors: true + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/vyos_system/tests/cli/basic.yaml b/tests/integration/targets/vyos_system/tests/cli/basic.yaml index 29309e22..cf08f36f 100644 --- a/tests/integration/targets/vyos_system/tests/cli/basic.yaml +++ b/tests/integration/targets/vyos_system/tests/cli/basic.yaml @@ -55,9 +55,9 @@ ignore_errors: true vyos.vyos.vyos_config: lines: - - delete system name-server name-server 192.0.2.1 - - delete system name-server name-server 192.0.2.2 - - delete system name-server name-server 192.0.2.3 + - delete system name-server 192.0.2.1 + - delete system name-server 192.0.2.2 + - delete system name-server 192.0.2.3 match: none - debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" |