From 0c828d9d012afb581578068dee38d838137e6b60 Mon Sep 17 00:00:00 2001 From: Roman Belyakovsky Date: Wed, 8 Dec 2021 14:31:12 +0300 Subject: [PATCH] interfaces_file: unit tests improved (#3863) * interfaces_file: fixed unit tests and added README, added test cases for #3862 * typo fix for interfaces_file unit tests README.md Co-authored-by: Felix Fontein * typo fix for interfaces_file unit tests README.md Co-authored-by: Felix Fontein * typo fix for interfaces_file unit tests README.md Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../modules/system/interfaces_file/README.md | 21 ++++ .../address_family_add_aggi_up_twice | 12 ++ ...ss_family_add_aggi_up_twice.exceptions.txt | 17 +++ .../address_family_add_aggi_up_twice.json | 21 ++++ .../address_family_aggi_remove_dup | 12 ++ ...ress_family_aggi_remove_dup.exceptions.txt | 17 +++ .../address_family_aggi_remove_dup.json | 21 ++++ .../default_dhcp_add_aggi_up_twice | 6 + ...ault_dhcp_add_aggi_up_twice.exceptions.txt | 17 +++ .../default_dhcp_add_aggi_up_twice.json | 18 +++ .../default_dhcp_aggi_remove_dup | 6 + ...efault_dhcp_aggi_remove_dup.exceptions.txt | 17 +++ .../default_dhcp_aggi_remove_dup.json | 18 +++ .../servers.com_add_aggi_up_twice | 62 ++++++++++ ...rvers.com_add_aggi_up_twice.exceptions.txt | 0 .../servers.com_add_aggi_up_twice.json | 109 ++++++++++++++++++ .../golden_output/servers.com_aggi_remove_dup | 62 ++++++++++ ...servers.com_aggi_remove_dup.exceptions.txt | 0 .../servers.com_aggi_remove_dup.json | 109 ++++++++++++++++++ .../golden_output/up_down_dup.test_no_changes | 11 ++ .../up_down_dup.test_no_changes.json | 24 ++++ .../golden_output/up_down_dup_add_aggi_up | 11 ++ .../up_down_dup_add_aggi_up.exceptions.txt | 0 .../up_down_dup_add_aggi_up.json | 24 ++++ .../up_down_dup_add_aggi_up_twice | 11 ++ ..._down_dup_add_aggi_up_twice.exceptions.txt | 0 .../up_down_dup_add_aggi_up_twice.json | 24 ++++ .../up_down_dup_add_and_delete_aggi_up | 9 ++ ..._dup_add_and_delete_aggi_up.exceptions.txt | 0 .../up_down_dup_add_and_delete_aggi_up.json | 24 ++++ .../golden_output/up_down_dup_aggi_remove_dup | 10 ++ ...up_down_dup_aggi_remove_dup.exceptions.txt | 0 .../up_down_dup_aggi_remove_dup.json | 24 ++++ .../golden_output/up_down_dup_change_ipv4 | 11 ++ .../up_down_dup_change_ipv4.exceptions.txt | 9 ++ .../up_down_dup_change_ipv4.json | 24 ++++ .../up_down_dup_change_ipv4_post_up | 11 ++ ...own_dup_change_ipv4_post_up.exceptions.txt | 9 ++ .../up_down_dup_change_ipv4_post_up.json | 24 ++++ .../up_down_dup_change_ipv4_pre_up | 11 ++ ...down_dup_change_ipv4_pre_up.exceptions.txt | 9 ++ .../up_down_dup_change_ipv4_pre_up.json | 24 ++++ .../golden_output/up_down_dup_change_ipv6 | 11 ++ .../up_down_dup_change_ipv6.exceptions.txt | 9 ++ .../up_down_dup_change_ipv6.json | 24 ++++ .../up_down_dup_change_ipv6_post_up | 11 ++ ...own_dup_change_ipv6_post_up.exceptions.txt | 9 ++ .../up_down_dup_change_ipv6_post_up.json | 24 ++++ .../up_down_dup_change_ipv6_pre_up | 11 ++ ...down_dup_change_ipv6_pre_up.exceptions.txt | 9 ++ .../up_down_dup_change_ipv6_pre_up.json | 24 ++++ .../golden_output/up_down_dup_change_method | 11 ++ .../up_down_dup_change_method.exceptions.txt | 8 ++ .../up_down_dup_change_method.json | 24 ++++ .../fixtures/golden_output/up_down_dup_revert | 11 ++ .../up_down_dup_revert.exceptions.txt | 8 ++ .../golden_output/up_down_dup_revert.json | 24 ++++ .../up_down_dup_set_aggi_and_eth0_mtu | 11 ++ ...n_dup_set_aggi_and_eth0_mtu.exceptions.txt | 8 ++ .../up_down_dup_set_aggi_and_eth0_mtu.json | 24 ++++ .../golden_output/up_down_dup_set_aggi_slaves | 12 ++ ...up_down_dup_set_aggi_slaves.exceptions.txt | 0 .../up_down_dup_set_aggi_slaves.json | 24 ++++ .../fixtures/input/up_down_dup | 11 ++ .../interfaces_file/test_interfaces_file.py | 32 ++++- 65 files changed, 1187 insertions(+), 2 deletions(-) create mode 100644 tests/unit/plugins/modules/system/interfaces_file/README.md create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4 create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6 create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.exceptions.txt create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.json create mode 100644 tests/unit/plugins/modules/system/interfaces_file/fixtures/input/up_down_dup diff --git a/tests/unit/plugins/modules/system/interfaces_file/README.md b/tests/unit/plugins/modules/system/interfaces_file/README.md new file mode 100644 index 0000000000..a10c659db0 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/README.md @@ -0,0 +1,21 @@ +# interfaces_file unit tests + +## Tests structure + +- `input` directory contains interfaces configuration files +- `test_interfaces_file.py` runs each hardcoded test agains all configurations in `input` directory and compares results with golden outputs in `golden_output` + +## Running unit tests with docker + +1. Clone project to `ansible_collections/community/general` +2. Change directory to the project one `cd ansible_collections/community/general` +3. Run `ansible-test units --docker -v --python 3.6 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py` + +## Adding tests + +1. New configurations should added to `input` directory +2. New test cases should be defined in `test_interfaces_file.py`. Same for new test functions if needed +3. On first test run for a new combination of a test case and an interface configuration new set of golden files will be generated. In case of docker-based test approach that's going to fail due to RO mount option. The workaround is to run tests locally with Python 3 (3.7 in this example): + 1. Install required modules with `pip3.7 install pytest-xdist pytest-mock mock` + 3. Run tests with `ansible-test units --python 3.7 tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py` +4. Carefully verify newly created golden output files! diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice new file mode 100644 index 0000000000..bc4ecea78d --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice @@ -0,0 +1,12 @@ +# The loopback network interface +auto lo eth0 +iface lo inet loopback + +# The primary network interface +iface eth0 inet static + address 192.168.0.1 + post-up echo configuring ipv4 + +iface eth0 inet6 static + address fc00::1 + post-up echo configuring ipv6 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.exceptions.txt new file mode 100644 index 0000000000..a90dd1cafa --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.exceptions.txt @@ -0,0 +1,17 @@ +[0] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "present", + "value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" +} +===== +[1] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "present", + "value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.json new file mode 100644 index 0000000000..ee632bd542 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_add_aggi_up_twice.json @@ -0,0 +1,21 @@ +{ + "eth0": { + "address": "fc00::1", + "address_family": "inet6", + "down": [], + "method": "static", + "post-up": [ + "echo configuring ipv6" + ], + "pre-up": [], + "up": [] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup new file mode 100644 index 0000000000..bc4ecea78d --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup @@ -0,0 +1,12 @@ +# The loopback network interface +auto lo eth0 +iface lo inet loopback + +# The primary network interface +iface eth0 inet static + address 192.168.0.1 + post-up echo configuring ipv4 + +iface eth0 inet6 static + address fc00::1 + post-up echo configuring ipv6 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.exceptions.txt new file mode 100644 index 0000000000..7e1aa336c2 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.exceptions.txt @@ -0,0 +1,17 @@ +[0] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "absent", + "value": null +} +===== +[1] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "present", + "value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.json new file mode 100644 index 0000000000..ee632bd542 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/address_family_aggi_remove_dup.json @@ -0,0 +1,21 @@ +{ + "eth0": { + "address": "fc00::1", + "address_family": "inet6", + "down": [], + "method": "static", + "post-up": [ + "echo configuring ipv6" + ], + "pre-up": [], + "up": [] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice new file mode 100644 index 0000000000..bd4522ec09 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice @@ -0,0 +1,6 @@ +# The loopback network interface +auto lo eth0 +iface lo inet loopback + +# The primary network interface +iface eth0 inet dhcp diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.exceptions.txt new file mode 100644 index 0000000000..a90dd1cafa --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.exceptions.txt @@ -0,0 +1,17 @@ +[0] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "present", + "value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" +} +===== +[1] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "present", + "value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.json new file mode 100644 index 0000000000..bffc17a989 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_add_aggi_up_twice.json @@ -0,0 +1,18 @@ +{ + "eth0": { + "address_family": "inet", + "down": [], + "method": "dhcp", + "post-up": [], + "pre-up": [], + "up": [] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup new file mode 100644 index 0000000000..bd4522ec09 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup @@ -0,0 +1,6 @@ +# The loopback network interface +auto lo eth0 +iface lo inet loopback + +# The primary network interface +iface eth0 inet dhcp diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.exceptions.txt new file mode 100644 index 0000000000..7e1aa336c2 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.exceptions.txt @@ -0,0 +1,17 @@ +[0] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "absent", + "value": null +} +===== +[1] fail_json message: Error: interface aggi not found +options: +{ + "iface": "aggi", + "option": "up", + "state": "present", + "value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.json new file mode 100644 index 0000000000..bffc17a989 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/default_dhcp_aggi_remove_dup.json @@ -0,0 +1,18 @@ +{ + "eth0": { + "address_family": "inet", + "down": [], + "method": "dhcp", + "post-up": [], + "pre-up": [], + "up": [] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice new file mode 100644 index 0000000000..e86b25782b --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice @@ -0,0 +1,62 @@ + auto aggi + iface aggi inet static + hwaddress ether 22:44:77:88:D5:96 + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + slaves int1 int2 + bond_mode 4 + bond_miimon 100 + bond_downdelay 200 + bond_updelay 200 + bond_lacp_rate slow + bond_xmit_hash_policy layer3+4 + post-up /sbin/ethtool -K aggi tx off tso off + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + + auto agge + iface agge inet manual + + auto br0 + iface br0 inet static + bridge_ports agge + hwaddress ether 22:44:77:88:D5:98 + address 188.44.133.76 + netmask 255.255.255.248 + gateway 188.44.133.75 + slaves ext1 ext2 + bond_mode 4 + bond_miimon 100 + bond_downdelay 200 + bond_updelay 200 + bond_lacp_rate slow + bond_xmit_hash_policy layer3+4 + post-up /sbin/ethtool -K agge tx off tso off + + up route add -net 10.0.0.0/8 gw 10.44.15.117 dev aggi + up route add -net 192.168.0.0/16 gw 10.44.15.117 dev aggi + up route add -net 188.44.208.0/21 gw 10.44.15.117 dev aggi + + auto int1 + iface int1 inet manual + bond-master aggi + + auto int2 + iface int2 inet manual + bond-master aggi + + auto ext1 + iface ext1 inet manual + bond-master agge + + auto ext2 + iface ext2 inet manual + bond-master agge + + auto eth1 + iface eth1 inet manual + + auto lo + iface lo inet loopback + +source /etc/network/interfaces.d/*.cfg diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.json new file mode 100644 index 0000000000..9e97da32aa --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_add_aggi_up_twice.json @@ -0,0 +1,109 @@ +{ + "agge": { + "address_family": "inet", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "bond_downdelay": "200", + "bond_lacp_rate": "slow", + "bond_miimon": "100", + "bond_mode": "4", + "bond_updelay": "200", + "bond_xmit_hash_policy": "layer3+4", + "down": [], + "hwaddress": "ether 22:44:77:88:D5:96", + "method": "static", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [ + "/sbin/ethtool -K aggi tx off tso off" + ], + "pre-up": [], + "slaves": "int1 int2", + "up": [] + }, + "br0": { + "address": "188.44.133.76", + "address_family": "inet", + "bond_downdelay": "200", + "bond_lacp_rate": "slow", + "bond_miimon": "100", + "bond_mode": "4", + "bond_updelay": "200", + "bond_xmit_hash_policy": "layer3+4", + "bridge_ports": "agge", + "down": [], + "gateway": "188.44.133.75", + "hwaddress": "ether 22:44:77:88:D5:98", + "method": "static", + "netmask": "255.255.255.248", + "post-up": [ + "/sbin/ethtool -K agge tx off tso off" + ], + "pre-up": [], + "slaves": "ext1 ext2", + "up": [ + "route add -net 10.0.0.0/8 gw 10.44.15.117 dev aggi", + "route add -net 192.168.0.0/16 gw 10.44.15.117 dev aggi", + "route add -net 188.44.208.0/21 gw 10.44.15.117 dev aggi" + ] + }, + "eth1": { + "address_family": "inet", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "ext1": { + "address_family": "inet", + "bond-master": "agge", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "ext2": { + "address_family": "inet", + "bond-master": "agge", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "int1": { + "address_family": "inet", + "bond-master": "aggi", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "int2": { + "address_family": "inet", + "bond-master": "aggi", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup new file mode 100644 index 0000000000..e86b25782b --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup @@ -0,0 +1,62 @@ + auto aggi + iface aggi inet static + hwaddress ether 22:44:77:88:D5:96 + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + slaves int1 int2 + bond_mode 4 + bond_miimon 100 + bond_downdelay 200 + bond_updelay 200 + bond_lacp_rate slow + bond_xmit_hash_policy layer3+4 + post-up /sbin/ethtool -K aggi tx off tso off + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + + auto agge + iface agge inet manual + + auto br0 + iface br0 inet static + bridge_ports agge + hwaddress ether 22:44:77:88:D5:98 + address 188.44.133.76 + netmask 255.255.255.248 + gateway 188.44.133.75 + slaves ext1 ext2 + bond_mode 4 + bond_miimon 100 + bond_downdelay 200 + bond_updelay 200 + bond_lacp_rate slow + bond_xmit_hash_policy layer3+4 + post-up /sbin/ethtool -K agge tx off tso off + + up route add -net 10.0.0.0/8 gw 10.44.15.117 dev aggi + up route add -net 192.168.0.0/16 gw 10.44.15.117 dev aggi + up route add -net 188.44.208.0/21 gw 10.44.15.117 dev aggi + + auto int1 + iface int1 inet manual + bond-master aggi + + auto int2 + iface int2 inet manual + bond-master aggi + + auto ext1 + iface ext1 inet manual + bond-master agge + + auto ext2 + iface ext2 inet manual + bond-master agge + + auto eth1 + iface eth1 inet manual + + auto lo + iface lo inet loopback + +source /etc/network/interfaces.d/*.cfg diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.json new file mode 100644 index 0000000000..9e97da32aa --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/servers.com_aggi_remove_dup.json @@ -0,0 +1,109 @@ +{ + "agge": { + "address_family": "inet", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "bond_downdelay": "200", + "bond_lacp_rate": "slow", + "bond_miimon": "100", + "bond_mode": "4", + "bond_updelay": "200", + "bond_xmit_hash_policy": "layer3+4", + "down": [], + "hwaddress": "ether 22:44:77:88:D5:96", + "method": "static", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [ + "/sbin/ethtool -K aggi tx off tso off" + ], + "pre-up": [], + "slaves": "int1 int2", + "up": [] + }, + "br0": { + "address": "188.44.133.76", + "address_family": "inet", + "bond_downdelay": "200", + "bond_lacp_rate": "slow", + "bond_miimon": "100", + "bond_mode": "4", + "bond_updelay": "200", + "bond_xmit_hash_policy": "layer3+4", + "bridge_ports": "agge", + "down": [], + "gateway": "188.44.133.75", + "hwaddress": "ether 22:44:77:88:D5:98", + "method": "static", + "netmask": "255.255.255.248", + "post-up": [ + "/sbin/ethtool -K agge tx off tso off" + ], + "pre-up": [], + "slaves": "ext1 ext2", + "up": [ + "route add -net 10.0.0.0/8 gw 10.44.15.117 dev aggi", + "route add -net 192.168.0.0/16 gw 10.44.15.117 dev aggi", + "route add -net 188.44.208.0/21 gw 10.44.15.117 dev aggi" + ] + }, + "eth1": { + "address_family": "inet", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "ext1": { + "address_family": "inet", + "bond-master": "agge", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "ext2": { + "address_family": "inet", + "bond-master": "agge", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "int1": { + "address_family": "inet", + "bond-master": "aggi", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "int2": { + "address_family": "inet", + "bond-master": "aggi", + "down": [], + "method": "manual", + "post-up": [], + "pre-up": [], + "up": [] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup.test_no_changes.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_aggi_up_twice.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up new file mode 100644 index 0000000000..2b5ca74041 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up @@ -0,0 +1,9 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_add_and_delete_aggi_up.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup new file mode 100644 index 0000000000..326291ef26 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup @@ -0,0 +1,10 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_aggi_remove_dup.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4 b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4 new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4 @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.exceptions.txt new file mode 100644 index 0000000000..a1600d9a67 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.exceptions.txt @@ -0,0 +1,9 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "address_family": "inet", + "iface": "eth0", + "option": "address", + "state": "present", + "value": "192.168.0.42" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.exceptions.txt new file mode 100644 index 0000000000..e1e0152320 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.exceptions.txt @@ -0,0 +1,9 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "address_family": "inet", + "iface": "eth0", + "option": "post-up", + "state": "present", + "value": "XXXX_ipv4" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_post_up.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.exceptions.txt new file mode 100644 index 0000000000..9e510654c2 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.exceptions.txt @@ -0,0 +1,9 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "address_family": "inet", + "iface": "eth0", + "option": "pre-up", + "state": "present", + "value": "XXXX_ipv4" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv4_pre_up.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6 b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6 new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6 @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.exceptions.txt new file mode 100644 index 0000000000..04c2089186 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.exceptions.txt @@ -0,0 +1,9 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "address_family": "inet6", + "iface": "eth0", + "option": "address", + "state": "present", + "value": "fc00::42" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.exceptions.txt new file mode 100644 index 0000000000..48cb29b0aa --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.exceptions.txt @@ -0,0 +1,9 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "address_family": "inet6", + "iface": "eth0", + "option": "post-up", + "state": "present", + "value": "XXXX_ipv6" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_post_up.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.exceptions.txt new file mode 100644 index 0000000000..fbfed6be37 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.exceptions.txt @@ -0,0 +1,9 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "address_family": "inet6", + "iface": "eth0", + "option": "pre-up", + "state": "present", + "value": "XXXX_ipv6" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_ipv6_pre_up.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.exceptions.txt new file mode 100644 index 0000000000..050a983971 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.exceptions.txt @@ -0,0 +1,8 @@ +fail_json message: Error: interface eth1 not found +options: +{ + "iface": "eth1", + "option": "method", + "state": "present", + "value": "dhcp" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_change_method.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.exceptions.txt new file mode 100644 index 0000000000..fddf3b3b0a --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.exceptions.txt @@ -0,0 +1,8 @@ +fail_json message: Error: interface eth0 not found +options: +{ + "iface": "eth0", + "option": "mtu", + "state": "absent", + "value": "1350" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_revert.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu new file mode 100644 index 0000000000..6bc202e0c5 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1350 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.exceptions.txt new file mode 100644 index 0000000000..764c9cb016 --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.exceptions.txt @@ -0,0 +1,8 @@ +[1] fail_json message: Error: interface eth0 not found +options: +{ + "iface": "eth0", + "option": "mtu", + "state": "present", + "value": "1350" +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_and_eth0_mtu.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves new file mode 100644 index 0000000000..d044b9251a --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves @@ -0,0 +1,12 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + slaves int1 int3 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.exceptions.txt b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.exceptions.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.json b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.json new file mode 100644 index 0000000000..d21e3317ca --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/golden_output/up_down_dup_set_aggi_slaves.json @@ -0,0 +1,24 @@ +{ + "aggi": { + "address": "10.44.15.196", + "address_family": "inet", + "down": [], + "method": "dhcp", + "mtu": "1500", + "netmask": "255.255.255.248", + "post-up": [], + "pre-up": [], + "up": [ + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi", + "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi" + ] + }, + "lo": { + "address_family": "inet", + "down": [], + "method": "loopback", + "post-up": [], + "pre-up": [], + "up": [] + } +} \ No newline at end of file diff --git a/tests/unit/plugins/modules/system/interfaces_file/fixtures/input/up_down_dup b/tests/unit/plugins/modules/system/interfaces_file/fixtures/input/up_down_dup new file mode 100644 index 0000000000..fdf434eb4c --- /dev/null +++ b/tests/unit/plugins/modules/system/interfaces_file/fixtures/input/up_down_dup @@ -0,0 +1,11 @@ +# this file covers duplicates issue for up/down option, #3841 +auto lo +iface lo inet loopback + +auto aggi +iface aggi inet dhcp + address 10.44.15.196 + netmask 255.255.255.248 + mtu 1500 + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi + up route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi diff --git a/tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py b/tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py index 2008d62864..fd2ee9d7c9 100644 --- a/tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py +++ b/tests/unit/plugins/modules/system/interfaces_file/test_interfaces_file.py @@ -79,7 +79,7 @@ class TestInterfacesFileModule(unittest.TestCase): goldenstring = string if not os.path.isfile(testfilepath): f = io.open(testfilepath, 'wb') - f.write(string) + f.write(string.encode()) f.close() else: with open(testfilepath, 'r') as goldenfile: @@ -94,7 +94,7 @@ class TestInterfacesFileModule(unittest.TestCase): self.compareInterfacesLinesToFile(lines, testfile) self.compareInterfacesToFile(ifaces, testfile) - def test_add_up_aoption_to_aggi(self): + def test_add_up_option_to_aggi(self): testcases = { "add_aggi_up": [ { @@ -118,6 +118,34 @@ class TestInterfacesFileModule(unittest.TestCase): 'state': 'absent', }, ], + "add_aggi_up_twice": [ + { + 'iface': 'aggi', + 'option': 'up', + 'value': 'route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi', + 'state': 'present', + }, + { + 'iface': 'aggi', + 'option': 'up', + 'value': 'route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi', + 'state': 'present', + }, + ], + "aggi_remove_dup": [ + { + 'iface': 'aggi', + 'option': 'up', + 'value': None, + 'state': 'absent', + }, + { + 'iface': 'aggi', + 'option': 'up', + 'value': 'route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi', + 'state': 'present', + }, + ], "set_aggi_slaves": [ { 'iface': 'aggi',