Skip to content

Commit

Permalink
Add a test about keeping management address type when disabling
Browse files Browse the repository at this point in the history
Before it was forced to change into IPv4 and would break
IPv6 setups

Signed-off-by: Benjamin Reis <[email protected]>
  • Loading branch information
benjamreis committed Nov 22, 2024
1 parent d1fb97a commit 1c43424
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ def host_no_ipv6(host):
if is_ipv6(host.hostname_or_ip):
pytest.skip(f"This test requires an IPv4 XCP-ng")

@pytest.fixture(scope='session')
def host_ipv6(host):
if not is_ipv6(host.hostname_or_ip):
pytest.skip(f"This test requires an IPv6 XCP-ng")

@pytest.fixture(scope='session')
def local_sr_on_hostA1(hostA1):
""" A local SR on the pool's master. """
Expand Down
5 changes: 5 additions & 0 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from packaging import version

import lib.commands as commands
import lib.pif as pif

from lib.common import _param_add, _param_clear, _param_get, _param_remove, _param_set
from lib.common import safe_split, strip_suffix, to_xapi_bool, wait_for, wait_for_not
Expand Down Expand Up @@ -420,6 +421,10 @@ def reboot(self, verify=False):
def management_network(self):
return self.xe('network-list', {'bridge': self.inventory['MANAGEMENT_INTERFACE']}, minimal=True)

def management_pif(self):
uuid = self.xe('pif-list', {'management': True, 'host-uuid': self.uuid}, minimal=True)
return pif.PIF(uuid, self)

def disks(self):
""" List of SCSI disks, e.g ['sda', 'sdb', 'nvme0n1']. """
disks = self.ssh(['lsblk', '-nd', '-I', '8,259', '--output', 'NAME']).splitlines()
Expand Down
23 changes: 23 additions & 0 deletions tests/network/test_management_disable_address_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

# Requirements:
# - one XCP-ng host (--host) (>= 8.3 for IPv6 test)

def _test_management_disable_type(host, type):
management_pif = host.management_pif()
assert management_pif.param_get("primary-address-type").lower() == type

host.xe("host-management-disable")
assert management_pif.param_get("primary-address-type").lower() == type

host.xe("host-management-reconfigure", {"pif-uuid": management_pif.uuid})
assert management_pif.param_get("primary-address-type").lower() == type

class TestManagementDisableAddressType:
@pytest.mark.usefixtures("host_no_ipv6")
def test_management_disable_ipv4(self, host):
_test_management_disable_type(host, "ipv4")

@pytest.mark.usefixtures("host_ipv6")
def test_management_disable_ipv6(self, host):
_test_management_disable_type(host, "ipv6")

0 comments on commit 1c43424

Please sign in to comment.