1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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 <felix@fontein.de>

* typo fix for interfaces_file unit tests README.md

Co-authored-by: Felix Fontein <felix@fontein.de>

* typo fix for interfaces_file unit tests README.md

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Roman Belyakovsky 2021-12-08 14:31:12 +03:00 committed by GitHub
parent 3dd5b0d343
commit 0c828d9d01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 1187 additions and 2 deletions

View file

@ -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!

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -0,0 +1,6 @@
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -0,0 +1,6 @@
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -0,0 +1,8 @@
fail_json message: Error: interface eth1 not found
options:
{
"iface": "eth1",
"option": "method",
"state": "present",
"value": "dhcp"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -0,0 +1,8 @@
fail_json message: Error: interface eth0 not found
options:
{
"iface": "eth0",
"option": "mtu",
"state": "absent",
"value": "1350"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -0,0 +1,8 @@
[1] fail_json message: Error: interface eth0 not found
options:
{
"iface": "eth0",
"option": "mtu",
"state": "present",
"value": "1350"
}

View file

@ -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": []
}
}

View file

@ -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

View file

@ -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": []
}
}

View file

@ -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

View file

@ -79,7 +79,7 @@ class TestInterfacesFileModule(unittest.TestCase):
goldenstring = string goldenstring = string
if not os.path.isfile(testfilepath): if not os.path.isfile(testfilepath):
f = io.open(testfilepath, 'wb') f = io.open(testfilepath, 'wb')
f.write(string) f.write(string.encode())
f.close() f.close()
else: else:
with open(testfilepath, 'r') as goldenfile: with open(testfilepath, 'r') as goldenfile:
@ -94,7 +94,7 @@ class TestInterfacesFileModule(unittest.TestCase):
self.compareInterfacesLinesToFile(lines, testfile) self.compareInterfacesLinesToFile(lines, testfile)
self.compareInterfacesToFile(ifaces, testfile) self.compareInterfacesToFile(ifaces, testfile)
def test_add_up_aoption_to_aggi(self): def test_add_up_option_to_aggi(self):
testcases = { testcases = {
"add_aggi_up": [ "add_aggi_up": [
{ {
@ -118,6 +118,34 @@ class TestInterfacesFileModule(unittest.TestCase):
'state': 'absent', '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": [ "set_aggi_slaves": [
{ {
'iface': 'aggi', 'iface': 'aggi',