Skip to content

Commit

Permalink
tests: fix keyfile parser existing tests
Browse files Browse the repository at this point in the history
Also add a couple of new tests.
  • Loading branch information
daniloegea committed Jun 22, 2023
1 parent a17cd75 commit 1f84145
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
31 changes: 31 additions & 0 deletions tests/generator/test_vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ def test_vlan_parent_match(self):
self.assert_nm(None)
self.assert_nm_udev(NM_UNMANAGED % 'lan' + NM_UNMANAGED_MAC % '11:22:33:44:55:66' + NM_UNMANAGED % 'vlan20')

def test_vlan_parent_must_exist(self):
out = self.generate('''network:
version: 2
renderer: networkd
vlans:
vlan20: {id: 20, link: lan}''', expect_fail=True)
self.assertIn('vlan20: interface \'lan\' is not defined', out)


class TestNetworkManager(TestBase):

Expand Down Expand Up @@ -300,3 +308,26 @@ def test_vlan_sriov(self):
ip6-privacy=0
'''})
self.assert_nm_udev(NM_MANAGED % 'en1' + NM_MANAGED % 'enblue' + NM_MANAGED % 'engreen')

def test_vlan_parent_is_allowed_to_be_missing_for_nm(self):
self.generate('''network:
version: 2
renderer: NetworkManager
vlans:
vlan20: {id: 20, link: lan}''')

self.assert_nm({'vlan20': '''[connection]
id=netplan-vlan20
type=vlan
interface-name=vlan20
[vlan]
id=20
parent=lan
[ipv4]
method=link-local
[ipv6]
method=ignore
'''})
15 changes: 5 additions & 10 deletions tests/parser/test_keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,6 @@ def test_keyfile_type_bridge(self):
def test_keyfile_type_bond(self):
self._template_keyfile_type('bonds', 'bond')

def test_keyfile_type_vlan(self):
self._template_keyfile_type('nm-devices', 'vlan', False)

def test_keyfile_type_tunnel(self):
self._template_keyfile_type('tunnels', 'ip-tunnel', False)

Expand Down Expand Up @@ -824,20 +821,18 @@ def test_keyfile_vlan(self):
'''.format(UUID))
self.assert_netplan({UUID: '''network:
version: 2
nm-devices:
vlans:
NM-{}:
renderer: NetworkManager
addresses:
- "1.2.3.4/24"
id: 1
link: "en1"
networkmanager:
uuid: "{}"
name: "netplan-enblue"
passthrough:
connection.type: "vlan"
connection.interface-name: "enblue"
vlan.id: "1"
vlan.parent: "en1"
ipv4.method: "manual"
ipv4.address1: "1.2.3.4/24"
ipv6.method: "ignore"
'''.format(UUID, UUID)})

def test_keyfile_bridge(self):
Expand Down

0 comments on commit 1f84145

Please sign in to comment.