Add more tests for method option change (#52228)

This commit is contained in:
Olivier Bourdon
2019-03-15 10:53:32 +01:00
committed by John R Barker
parent a65a137cdd
commit 668f014b3c
36 changed files with 186 additions and 23 deletions

View File

@@ -3,10 +3,10 @@ auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet manual
iface eth0 inet static
address 192.168.0.1
post-up echo configuring ipv4
iface eth0 inet6 manual
iface eth0 inet6 static
address fc00::1
post-up echo configuring ipv6

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

@@ -3,7 +3,7 @@
"address": "fc00::1",
"address_family": "inet6",
"down": [],
"method": "manual",
"method": "static",
"post-up": [
"echo configuring ipv6"
],

View File

@@ -3,4 +3,4 @@ auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet manual
iface eth0 inet dhcp

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

@@ -2,7 +2,7 @@
"eth0": {
"address_family": "inet",
"down": [],
"method": "manual",
"method": "dhcp",
"post-up": [],
"pre-up": [],
"up": []

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -53,6 +53,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet dhcp
auto lo
iface lo inet loopback

View File

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

View File

@@ -54,6 +54,14 @@
"route add -net 188.44.208.0/21 gw 10.44.15.117 dev aggi"
]
},
"eth1": {
"address_family": "inet",
"down": [],
"method": "dhcp",
"post-up": [],
"pre-up": [],
"up": []
},
"ext1": {
"address_family": "inet",
"bond-master": "agge",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -54,6 +54,14 @@
"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",

View File

@@ -52,6 +52,9 @@
iface ext2 inet manual
bond-master agge
auto eth1
iface eth1 inet manual
auto lo
iface lo inet loopback

View File

@@ -205,9 +205,9 @@ class TestInterfacesFileModule(unittest.TestCase):
testcases = {
"change_method": [
{
'iface': 'eth0',
'iface': 'eth1',
'option': 'method',
'value': 'manual',
'value': 'dhcp',
'state': 'present',
}
],
@@ -223,7 +223,15 @@ class TestInterfacesFileModule(unittest.TestCase):
options = options_list[0]
fail_json_iterations = []
try:
_, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'], options['option'], options['value'], options['state'])
changed, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'], options['option'],
options['value'], options['state'])
# When a changed is made try running it again for proper idempotency
if changed:
changed_again, lines = interfaces_file.setInterfaceOption(module, lines, options['iface'],
options['option'], options['value'], options['state'])
self.assertFalse(changed_again,
msg='Second request for change should return false for {0} running on {1}'.format(testname,
testfile))
except AnsibleFailJson as e:
fail_json_iterations.append("fail_json message: %s\noptions:\n%s" %
(str(e), json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))))