Rehome test case
This commit introduces the test case for rehoming one subcloud. Test Plan: PASS: Deploy two DC systems, one with one subcloud and the other one with only the system controllers. Run the test case and verify that the subcloud is correctly migrated from one DC system to the other one and then migrated back to its original system controller. Change-Id: Ibd95d5abeb302a767f42a6177ef1d087442dc304 Signed-off-by: Gustavo Pereira <gustavo.lyrapereira@windriver.com>
This commit is contained in:
@@ -35,5 +35,6 @@
|
||||
"subclouds": {
|
||||
"subcloud1": "config/lab/files/template_subcloud1.json5",
|
||||
"subcloud2": "config/lab/files/template_subcloud2.json5"
|
||||
}
|
||||
},
|
||||
"secondary_system_controller": "config/lab/files/secondary_system_controller.json5",
|
||||
}
|
||||
39
config/lab/files/template_secondary_system_controller.json5
Normal file
39
config/lab/files/template_secondary_system_controller.json5
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"floating_ip": "10.2.3.125",
|
||||
"lab_name": "MyDCLab",
|
||||
"lab_type": "Standard",
|
||||
"admin_credentials": {
|
||||
"user_name": "fake_user",
|
||||
"password": "fake_password"
|
||||
},
|
||||
"bm_password": "",
|
||||
"use_jump_server": false,
|
||||
"horizon_url": "https://10.2.3.125:8443/",
|
||||
"lab_capabilities": [],
|
||||
"nodes": {
|
||||
"controller-0": {
|
||||
"ip": "10.2.3.126",
|
||||
"node_type": "Controller",
|
||||
"node_capabilities": []
|
||||
},
|
||||
"controller-1": {
|
||||
"ip": "10.2.3.127",
|
||||
"node_type": "Controller",
|
||||
"node_capabilities": []
|
||||
},
|
||||
"compute-0": {
|
||||
"ip": "10.2.3.128",
|
||||
"node_type": "Compute",
|
||||
"node_capabilities": []
|
||||
},
|
||||
"compute-1": {
|
||||
"ip": "10.2.3.129",
|
||||
"node_type": "Compute",
|
||||
"node_capabilities": []
|
||||
}
|
||||
},
|
||||
"subclouds": {
|
||||
"subcloud1": "config/lab/files/template_subcloud1.json5",
|
||||
"subcloud2": "config/lab/files/template_subcloud2.json5"
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,12 @@ class LabConfig:
|
||||
if "system_controller_name" in lab_dict:
|
||||
self.system_controller_name = lab_dict["system_controller_name"]
|
||||
|
||||
self.secondary_system_controller = None
|
||||
if "secondary_system_controller" in lab_dict:
|
||||
secondary_system_controller = lab_dict["secondary_system_controller"]
|
||||
secondary_lab_file = get_stx_resource_path(secondary_system_controller)
|
||||
self.secondary_system_controller = LabConfig(secondary_lab_file)
|
||||
|
||||
self.lab_config_file = config
|
||||
|
||||
def get_floating_ip(self) -> str:
|
||||
@@ -429,6 +435,24 @@ class LabConfig:
|
||||
"""
|
||||
self.system_controller_name = system_controller_name
|
||||
|
||||
def get_secondary_system_controller_config(self) -> object:
|
||||
"""
|
||||
Get the secondary system controller object.
|
||||
|
||||
Returns:
|
||||
object: Secondary dc configuration.
|
||||
"""
|
||||
return self.secondary_system_controller
|
||||
|
||||
def get_secondary_system_controller_name(self) -> str:
|
||||
"""
|
||||
Gets the secondary controller host name
|
||||
|
||||
Returns:
|
||||
str: Secondary lab name.
|
||||
"""
|
||||
return self.secondary_system_controller.get_lab_name()
|
||||
|
||||
def to_log_strings(self) -> List[str]:
|
||||
"""
|
||||
Convert lab configuration to a list of loggable strings.
|
||||
|
||||
@@ -47,3 +47,23 @@ class DcManagerSubcloudAddKeywords(BaseKeyword):
|
||||
# validate subcloud status until complete
|
||||
dc_manager_sc_list_kw = DcManagerSubcloudListKeywords(self.ssh_connection)
|
||||
dc_manager_sc_list_kw.validate_subcloud_status(subcloud_name, "complete")
|
||||
|
||||
def dcmanager_subcloud_add_migrate(self, subcloud_name: str, bootstrap_values: str, install_values: str):
|
||||
"""
|
||||
Runs 'dcmanager subcloud add --migrate' command.
|
||||
|
||||
Args:
|
||||
subcloud_name (str): Subcloud name.
|
||||
bootstrap_values (str): Bootstrap values file name.
|
||||
install_values (str): Install values file name.
|
||||
"""
|
||||
lab_config = ConfigurationManager.get_lab_config()
|
||||
subcloud_obj = lab_config.get_subcloud(subcloud_name)
|
||||
|
||||
subcloud_ip = subcloud_obj.get_floating_ip()
|
||||
subcloud_psswr = subcloud_obj.get_admin_credentials().get_password()
|
||||
|
||||
cmd = source_openrc(f"dcmanager subcloud add --migrate --bootstrap-address {subcloud_ip} " f"--bootstrap-values {bootstrap_values} --install-values {install_values}" f" --sysadmin-password {subcloud_psswr} --bmc-password {subcloud_psswr}")
|
||||
|
||||
self.ssh_connection.send(cmd)
|
||||
self.validate_success_return_code(self.ssh_connection)
|
||||
|
||||
@@ -145,3 +145,29 @@ class LabConnectionKeywords(BaseKeyword):
|
||||
)
|
||||
|
||||
return connection
|
||||
|
||||
def get_secondary_active_controller_ssh(self) -> SSHConnection:
|
||||
"""Gets an SSH connection to the secondary active controller node.
|
||||
|
||||
Returns:
|
||||
SSHConnection: the ssh for the secondary active controller
|
||||
"""
|
||||
lab_config = ConfigurationManager.get_lab_config()
|
||||
secondary_lab_config = lab_config.get_secondary_system_controller_config()
|
||||
|
||||
if not secondary_lab_config:
|
||||
raise ValueError(f"There is no {secondary_lab_config} defined in your config file.")
|
||||
|
||||
jump_host_config = None
|
||||
if lab_config.is_use_jump_server():
|
||||
jump_host_config = lab_config.get_jump_host_configuration()
|
||||
|
||||
connection = SSHConnectionManager.create_ssh_connection(
|
||||
secondary_lab_config.get_floating_ip(),
|
||||
secondary_lab_config.get_admin_credentials().get_user_name(),
|
||||
secondary_lab_config.get_admin_credentials().get_password(),
|
||||
ssh_port=secondary_lab_config.get_ssh_port(),
|
||||
jump_host=jump_host_config,
|
||||
)
|
||||
|
||||
return connection
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
from pytest import mark
|
||||
|
||||
from config.configuration_manager import ConfigurationManager
|
||||
from framework.logging.automation_logger import get_logger
|
||||
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
|
||||
|
||||
|
||||
@mark.p2
|
||||
@mark.lab_has_subcloud
|
||||
@mark.lab_has_secondary_system_controller
|
||||
def test_rehome_one_subcloud(request):
|
||||
"""
|
||||
Execute a subcloud rehome
|
||||
|
||||
Test Steps:
|
||||
- Ensure both initial and target system controllers have the same date.
|
||||
- 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_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()
|
||||
|
||||
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")
|
||||
|
||||
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)
|
||||
@@ -32,6 +32,7 @@ markers=
|
||||
lab_has_min_2_subclouds: mark tests that require at least 2 subcloud
|
||||
lab_has_compute: mark tests that require at least one compute node
|
||||
subcloud_lab_has_compute: mark tests that require at least one subcloud containing at least one compute node
|
||||
lab_has_secondary_system_controller: mark tests that require a secondary system controller
|
||||
#TODO: add 'lab_has_bmc_ipmi', 'lab_has_bmc_redfish', 'lab_has_bmc_dynamic', and 'lab_bmc_sensor'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user