Merge "Add subcloud rehome test with mgmt network"
This commit is contained in:
@@ -39,7 +39,6 @@ class SystemAddrpoolListOutput:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, system_addrpool_list_output):
|
def __init__(self, system_addrpool_list_output):
|
||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
@@ -54,15 +53,15 @@ class SystemAddrpoolListOutput:
|
|||||||
if self.is_valid_output(value):
|
if self.is_valid_output(value):
|
||||||
self.system_addrpool.append(
|
self.system_addrpool.append(
|
||||||
SystemAddrpoolListObject(
|
SystemAddrpoolListObject(
|
||||||
value['uuid'],
|
value["uuid"],
|
||||||
value['name'],
|
value["name"],
|
||||||
value['network'],
|
value["network"],
|
||||||
value['order'],
|
value["order"],
|
||||||
value['ranges'],
|
value["ranges"],
|
||||||
value['floating_address'],
|
value["floating_address"],
|
||||||
value['controller0_address'],
|
value["controller0_address"],
|
||||||
value['controller1_address'],
|
value["controller1_address"],
|
||||||
value['gateway_address'],
|
value["gateway_address"],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -88,19 +87,27 @@ class SystemAddrpoolListOutput:
|
|||||||
raise KeywordException(f"No addrpool with name {name} was found.")
|
raise KeywordException(f"No addrpool with name {name} was found.")
|
||||||
return addrpools[0].get_floating_address()
|
return addrpools[0].get_floating_address()
|
||||||
|
|
||||||
|
def get_gateway_address_by_name(self, name: str) -> str:
|
||||||
|
"""
|
||||||
|
Gets the gateway address for the given name.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: the name of the desired addrpool
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The floating address of the addrpool with the specified name.
|
||||||
|
|
||||||
|
"""
|
||||||
|
addrpools = list(filter(lambda pool: name in pool.get_name(), self.system_addrpool))
|
||||||
|
if not addrpools:
|
||||||
|
raise KeywordException(f"No addrpool with name {name} was found.")
|
||||||
|
return addrpools[0].get_gateway_address()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_valid_output(value):
|
def is_valid_output(value):
|
||||||
required_keys = ['uuid', 'name', 'network', 'order', 'ranges', 'floating_address', 'controller0_address', 'controller1_address', 'gateway_address']
|
required_keys = ["uuid", "name", "network", "order", "ranges", "floating_address", "controller0_address", "controller1_address", "gateway_address"]
|
||||||
for key in required_keys:
|
for key in required_keys:
|
||||||
if key not in value:
|
if key not in value:
|
||||||
get_logger().log_error(f'{key} is not in the output value: {value}')
|
get_logger().log_error(f"{key} is not in the output value: {value}")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -40,4 +40,13 @@ class SystemAddrpoolListKeywords(BaseKeyword):
|
|||||||
Returns:
|
Returns:
|
||||||
The floating address for the name with management field.
|
The floating address for the name with management field.
|
||||||
"""
|
"""
|
||||||
return self.get_system_addrpool_list().get_floating_address_by_name("management")
|
return self.get_system_addrpool_list().get_floating_address_by_name("management")
|
||||||
|
|
||||||
|
def get_management_gateway_address(self) -> str:
|
||||||
|
"""
|
||||||
|
Retrieves the gateway address for the addrpool with name 'management'.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The gateway address for the name with management field.
|
||||||
|
"""
|
||||||
|
return self.get_system_addrpool_list().get_gateway_address_by_name("management")
|
@@ -0,0 +1,79 @@
|
|||||||
|
from pytest import fail, mark
|
||||||
|
|
||||||
|
from config.configuration_manager import ConfigurationManager
|
||||||
|
from framework.logging.automation_logger import get_logger
|
||||||
|
from framework.validation.validation import validate_equals, validate_not_equals
|
||||||
|
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_add_keywords import DcManagerSubcloudAddKeywords
|
||||||
|
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_delete_keywords import DcManagerSubcloudDeleteKeywords
|
||||||
|
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_list_keywords import DcManagerSubcloudListKeywords
|
||||||
|
from keywords.cloud_platform.dcmanager.dcmanager_subcloud_manager_keywords import DcManagerSubcloudManagerKeywords
|
||||||
|
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
|
||||||
|
from keywords.cloud_platform.system.addrpool.system_addrpool_list_keywords import SystemAddrpoolListKeywords
|
||||||
|
from keywords.cloud_platform.system.host.system_host_list_keywords import SystemHostListKeywords
|
||||||
|
from keywords.cloud_platform.system.host.system_host_route_keywords import SystemHostRouteKeywords
|
||||||
|
|
||||||
|
|
||||||
|
@mark.p2
|
||||||
|
@mark.lab_has_subcloud
|
||||||
|
@mark.lab_has_secondary_system_controller
|
||||||
|
def test_rehome_one_subcloud_mgmt_subcloud(request):
|
||||||
|
"""
|
||||||
|
Execute a subcloud rehome
|
||||||
|
|
||||||
|
Test Steps:
|
||||||
|
- Ensure both initial and target system controllers have the same date.
|
||||||
|
- Deploy a subcloud with mgmt network
|
||||||
|
- Unmanage the subcloud to be rehomed.
|
||||||
|
- Shutdown both initial controller and subcloud
|
||||||
|
- run dcmanager subcloud migration command.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
deployment_assets_config = ConfigurationManager.get_deployment_assets_config()
|
||||||
|
|
||||||
|
origin_system_controller_ssh = LabConnectionKeywords().get_active_controller_ssh()
|
||||||
|
destination_system_controller_ssh = LabConnectionKeywords().get_secondary_active_controller_ssh()
|
||||||
|
|
||||||
|
# Gets the lowest subcloud (the subcloud with the lowest id).
|
||||||
|
dcmanager_subcloud_list_keywords = DcManagerSubcloudListKeywords(origin_system_controller_ssh)
|
||||||
|
lowest_subcloud = dcmanager_subcloud_list_keywords.get_dcmanager_subcloud_list().get_healthy_subcloud_with_lowest_id()
|
||||||
|
subcloud_name = lowest_subcloud.get_name()
|
||||||
|
subcloud_ssh = LabConnectionKeywords().get_subcloud_ssh(subcloud_name)
|
||||||
|
|
||||||
|
subcloud_hostname = SystemHostListKeywords(subcloud_ssh).get_active_controller().get_host_name()
|
||||||
|
|
||||||
|
subcloud_bootstrap_values = deployment_assets_config.get_subcloud_deployment_assets(subcloud_name).get_bootstrap_file()
|
||||||
|
subcloud_install_values = deployment_assets_config.get_subcloud_deployment_assets(subcloud_name).get_install_file()
|
||||||
|
|
||||||
|
network_list = SystemHostRouteKeywords(subcloud_ssh).get_system_host_route_list_networks(subcloud_hostname)
|
||||||
|
subcloud_mgmt_gateway_address = SystemAddrpoolListKeywords(subcloud_ssh).get_management_gateway_address()
|
||||||
|
old_subcloud_oam_subnet = SystemAddrpoolListKeywords(subcloud_ssh).get_system_addrpool_list().get_floating_address_by_name("system-controller-oam-subnet")
|
||||||
|
old_subcloud_subnet = SystemAddrpoolListKeywords(subcloud_ssh).get_system_addrpool_list().get_floating_address_by_name("system-controller-subnet")
|
||||||
|
|
||||||
|
if not subcloud_mgmt_gateway_address:
|
||||||
|
fail("Subcloud has no management gateway address")
|
||||||
|
|
||||||
|
get_logger().log_info(f"Running rehome command on {destination_system_controller_ssh}")
|
||||||
|
DcManagerSubcloudAddKeywords(destination_system_controller_ssh).dcmanager_subcloud_add_migrate(subcloud_name, bootstrap_values=subcloud_bootstrap_values, install_values=subcloud_install_values)
|
||||||
|
DcManagerSubcloudListKeywords(destination_system_controller_ssh).validate_subcloud_status(subcloud_name=subcloud_name, status="rehoming")
|
||||||
|
DcManagerSubcloudListKeywords(destination_system_controller_ssh).validate_subcloud_status(subcloud_name=subcloud_name, status="complete")
|
||||||
|
|
||||||
|
new_subcloud_oam_subnet = SystemAddrpoolListKeywords(subcloud_ssh).get_system_addrpool_list().get_floating_address_by_name("system-controller-oam-subnet")
|
||||||
|
new_subcloud_subnet = SystemAddrpoolListKeywords(subcloud_ssh).get_system_addrpool_list().get_floating_address_by_name("system-controller-subnet")
|
||||||
|
|
||||||
|
validate_not_equals(old_subcloud_oam_subnet, new_subcloud_oam_subnet, "Validate subcloud system-controller-oam-subnet changed.")
|
||||||
|
validate_not_equals(old_subcloud_subnet, new_subcloud_subnet, "Validate subcloud system-controller-subnet changed.")
|
||||||
|
|
||||||
|
get_logger().log_info(f"Deleting subcloud from {origin_system_controller_ssh}")
|
||||||
|
DcManagerSubcloudManagerKeywords(origin_system_controller_ssh).get_dcmanager_subcloud_unmanage(subcloud_name=subcloud_name, timeout=30)
|
||||||
|
DcManagerSubcloudDeleteKeywords(origin_system_controller_ssh).dcmanager_subcloud_delete(subcloud_name=subcloud_name)
|
||||||
|
|
||||||
|
get_logger().log_info(f"Running rehome command on {origin_system_controller_ssh}")
|
||||||
|
DcManagerSubcloudAddKeywords(origin_system_controller_ssh).dcmanager_subcloud_add_migrate(subcloud_name, bootstrap_values=subcloud_bootstrap_values, install_values=subcloud_install_values)
|
||||||
|
dcmanager_subcloud_list_keywords.validate_subcloud_status(subcloud_name=subcloud_name, status="rehoming")
|
||||||
|
dcmanager_subcloud_list_keywords.validate_subcloud_status(subcloud_name=subcloud_name, status="complete")
|
||||||
|
|
||||||
|
get_logger().log_info(f"Deleting subcloud from {destination_system_controller_ssh}")
|
||||||
|
DcManagerSubcloudDeleteKeywords(destination_system_controller_ssh).dcmanager_subcloud_delete(subcloud_name=subcloud_name)
|
||||||
|
|
||||||
|
validate_equals(len(network_list), 1, "Validate system host route list only has one route.")
|
Reference in New Issue
Block a user