testcases: Add Intel Device application tests
Add a new test case under `testcases/cloud_platform/apps_setup/intel_device_plugins_operator/` to automate the installation (upload and apply) of the Intel Device Plugin plugin. The test ensures the Node Feature Discovery (NFD) app is applied before proceeding with Intel Device Plugin installation, validates upload and apply states, Additionally, update: - `config/app/files/default.json5` to include Intel app name - `config/app/objects/app_config.py` to expose Intel app name. Change-Id: I05150f232aff622904514f862e04cf37243f2434 Signed-off-by: Caio Felipe Cruz <caio.soaresdacruz@windriver.com>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
oidc_app_name: "oidc-auth-apps",
|
||||
power_metrics_app_name: "power-metrics",
|
||||
power_manager_app_name: "kubernetes-power-manager",
|
||||
intel_device_plugins_app_name: "intel-device-plugins-operator",
|
||||
node_feature_discovery_app_name: "node-feature-discovery",
|
||||
node_interface_metrics_exporter_app_name: "node-interface-metrics-exporter",
|
||||
platform_integ_apps_app_name: "platform-integ-apps"
|
||||
|
||||
@@ -22,6 +22,7 @@ class AppConfig:
|
||||
self.oidc_app_name = app_dict["oidc_app_name"]
|
||||
self.power_metrics_app_name = app_dict["power_metrics_app_name"]
|
||||
self.power_manager_app_name = app_dict["power_manager_app_name"]
|
||||
self.intel_device_plugins_app_name = app_dict["intel_device_plugins_app_name"]
|
||||
self.node_feature_discovery_app_name = app_dict["node_feature_discovery_app_name"]
|
||||
self.node_interface_metrics_exporter_app_name = app_dict["node_interface_metrics_exporter_app_name"]
|
||||
self.platform_integ_apps_app_name = app_dict["platform_integ_apps_app_name"]
|
||||
@@ -86,6 +87,17 @@ class AppConfig:
|
||||
"""
|
||||
return self.power_manager_app_name
|
||||
|
||||
def get_intel_device_plugins_app_name(self) -> str:
|
||||
"""
|
||||
Getter for Intel Device Plugin app name
|
||||
|
||||
Returns:
|
||||
str: the intel device plugin app name
|
||||
|
||||
"""
|
||||
return self.intel_device_plugins_app_name
|
||||
|
||||
|
||||
def get_node_feature_discovery_app_name(self) -> str:
|
||||
"""
|
||||
Getter for node feature discovery app name
|
||||
|
||||
@@ -5,6 +5,8 @@ from keywords.cloud_platform.system.application.object.system_application_output
|
||||
from keywords.cloud_platform.system.application.object.system_application_remove_input import SystemApplicationRemoveInput
|
||||
from keywords.cloud_platform.system.application.object.system_application_status_enum import SystemApplicationStatusEnum
|
||||
from keywords.cloud_platform.system.application.system_application_list_keywords import SystemApplicationListKeywords
|
||||
from keywords.cloud_platform.system.application.system_application_delete_keywords import SystemApplicationDeleteInput
|
||||
from keywords.cloud_platform.system.application.system_application_delete_keywords import SystemApplicationDeleteKeywords
|
||||
|
||||
|
||||
class SystemApplicationRemoveKeywords(BaseKeyword):
|
||||
@@ -69,3 +71,18 @@ class SystemApplicationRemoveKeywords(BaseKeyword):
|
||||
|
||||
cmd = f'system application-remove {force_as_param} {system_application_remove_input.get_app_name()}'
|
||||
return cmd
|
||||
|
||||
def system_application_remove_and_delete_app(self, app_name: str, force_removal: bool = False, force_deletion: bool = False):
|
||||
|
||||
remove_input = SystemApplicationRemoveInput()
|
||||
remove_input.set_app_name(app_name)
|
||||
remove_input.set_force_removal(force_removal)
|
||||
|
||||
remove_output = self.system_application_remove(remove_input)
|
||||
|
||||
delete_input = SystemApplicationDeleteInput()
|
||||
delete_input.set_app_name(app_name)
|
||||
delete_input.set_force_deletion(force_deletion)
|
||||
delete_message = SystemApplicationDeleteKeywords(self.ssh_connection).get_system_application_delete(delete_input)
|
||||
|
||||
return delete_message
|
||||
|
||||
@@ -137,3 +137,26 @@ class SystemApplicationUploadKeywords(BaseKeyword):
|
||||
cmd = f'system application-upload {app_name_as_param} {app_version_as_param} {automatic_installation_as_param} {tar_file_path}'
|
||||
|
||||
return cmd
|
||||
|
||||
def system_application_upload_and_apply_app(self, app_name: str, tar_file_path: str):
|
||||
"""
|
||||
Upload and apply a system application.
|
||||
|
||||
Args:
|
||||
app_name (str): Application name
|
||||
base_path (str): Path where .tgz files are stored
|
||||
tar_file_path (str): Full path to the .tgz file
|
||||
|
||||
Returns:
|
||||
tuple: (upload_status, system_application_apply)
|
||||
"""
|
||||
|
||||
upload_input = SystemApplicationUploadInput()
|
||||
upload_input.set_app_name(app_name)
|
||||
upload_input.set_tar_file_path(f"{tar_file_path}")
|
||||
|
||||
self.system_application_upload(upload_input)
|
||||
|
||||
apply_output = SystemApplicationApplyKeywords(self.ssh_connection).system_application_apply(app_name)
|
||||
|
||||
return apply_output
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
from config.configuration_manager import ConfigurationManager
|
||||
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
|
||||
|
||||
from keywords.cloud_platform.system.application.system_application_upload_keywords import SystemApplicationUploadKeywords
|
||||
from keywords.cloud_platform.system.application.system_application_apply_keywords import SystemApplicationApplyKeywords
|
||||
from keywords.cloud_platform.system.application.system_application_remove_keywords import SystemApplicationRemoveKeywords
|
||||
|
||||
from keywords.cloud_platform.system.application.object.system_application_status_enum import SystemApplicationStatusEnum
|
||||
|
||||
from framework.validation.validation import validate_equals, validate_not_equals
|
||||
|
||||
from framework.logging.automation_logger import get_logger
|
||||
|
||||
|
||||
def test_install_intel_device_plugins():
|
||||
"""
|
||||
Install (Upload and Apply) Intel Device Plugins
|
||||
|
||||
Raises:
|
||||
Exception: If application Intel Device Plugins failed to upload or apply
|
||||
"""
|
||||
|
||||
# Setup app configs and lab connection
|
||||
app_config = ConfigurationManager.get_app_config()
|
||||
base_path = app_config.get_base_application_path()
|
||||
|
||||
nfd_name = app_config.get_node_feature_discovery_app_name()
|
||||
nfd_file_path = f"{base_path}{nfd_name}*.tgz"
|
||||
|
||||
intel_device_plugins_name = app_config.get_intel_device_plugins_app_name()
|
||||
intel_device_plugins_file_path = f"{base_path}{intel_device_plugins_name}*.tgz"
|
||||
|
||||
lab_connect_keywords = LabConnectionKeywords()
|
||||
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
|
||||
|
||||
get_logger().log_test_case_step('Install Node Feature Discovery first')
|
||||
# If NFD is not already installed, install it
|
||||
nfd_status = SystemApplicationApplyKeywords(ssh_connection).is_already_applied(nfd_name)
|
||||
if not nfd_status:
|
||||
get_logger().log_info('NFD not installed. Installing...')
|
||||
nfd_app_output = SystemApplicationUploadKeywords(ssh_connection).system_application_upload_and_apply_app(nfd_name, nfd_file_path)
|
||||
nfd_app_object = nfd_app_output.get_system_application_object()
|
||||
validate_equals(nfd_app_object.get_name(), nfd_name, f"{nfd_name} name validation")
|
||||
validate_equals(nfd_app_object.get_status(), SystemApplicationStatusEnum.APPLIED.value, f"{nfd_name} application status validation")
|
||||
else:
|
||||
validate_not_equals(nfd_status, None,
|
||||
"NFD application should be in applied state")
|
||||
|
||||
get_logger().log_test_case_step('Install Intel Device Plugins')
|
||||
# Verify the Intel Device Plugin app is not present in the system
|
||||
intel_device_plugins_status = SystemApplicationApplyKeywords(ssh_connection).is_already_applied(intel_device_plugins_name)
|
||||
if not intel_device_plugins_status:
|
||||
get_logger().log_info('Intel Device Plugins not installed. Installing...')
|
||||
intel_device_plugins_app_output = SystemApplicationUploadKeywords(ssh_connection).system_application_upload_and_apply_app(intel_device_plugins_name, intel_device_plugins_file_path)
|
||||
intel_device_plugins_app_object = intel_device_plugins_app_output.get_system_application_object()
|
||||
validate_equals(intel_device_plugins_app_object.get_name(), intel_device_plugins_name, f"{intel_device_plugins_name} name validation")
|
||||
validate_equals(intel_device_plugins_app_object.get_status(), SystemApplicationStatusEnum.APPLIED.value, f"{intel_device_plugins_name} application status validation")
|
||||
else:
|
||||
validate_not_equals(intel_device_plugins_status, None,
|
||||
" Intel Device Plugin application should be in applied state")
|
||||
|
||||
|
||||
def test_uninstall_intel_device_plugins():
|
||||
"""
|
||||
Uninstall (Remove and Delete) Application Intel Device Plugin
|
||||
|
||||
Raises:
|
||||
Exception: If application Intel Device Plugin failed to remove or delete
|
||||
"""
|
||||
# Setup app configs and lab connection
|
||||
app_config = ConfigurationManager.get_app_config()
|
||||
intel_device_plugins_name = app_config.get_intel_device_plugins_app_name()
|
||||
nfd_name = app_config.get_node_feature_discovery_app_name()
|
||||
lab_connect_keywords = LabConnectionKeywords()
|
||||
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
|
||||
|
||||
get_logger().log_test_case_step('Uninstall Intel Device Plugin first (since it depends on NFD)')
|
||||
# Verify if the Intel Device Plugin app already present in the system
|
||||
intel_device_plugins_status = SystemApplicationApplyKeywords(ssh_connection).is_already_applied(intel_device_plugins_name)
|
||||
if intel_device_plugins_status:
|
||||
get_logger().log_info('Intel Device Plugins installed. Removing...')
|
||||
remove_delete_output = SystemApplicationRemoveKeywords(ssh_connection).system_application_remove_and_delete_app(intel_device_plugins_name)
|
||||
validate_equals(remove_delete_output, f"Application {intel_device_plugins_name} deleted.\n",
|
||||
"Intel Device Plugin deletion validation")
|
||||
else:
|
||||
validate_not_equals(intel_device_plugins_status, None,
|
||||
"Intel Device Plugins application should be in applied state")
|
||||
|
||||
get_logger().log_test_case_step('Uninstall Node Feature Discovery')
|
||||
# Verify if the Intel Device Plugin app already present in the system
|
||||
nfd_status = SystemApplicationApplyKeywords(ssh_connection).is_already_applied(nfd_name)
|
||||
if nfd_status:
|
||||
get_logger().log_info('NFD installed. Removing...')
|
||||
remove_delete_output = SystemApplicationRemoveKeywords(ssh_connection).system_application_remove_and_delete_app(nfd_name)
|
||||
validate_equals(remove_delete_output, f"Application {nfd_name} deleted.\n",
|
||||
"NFD deletion validation")
|
||||
else:
|
||||
validate_not_equals(nfd_status, None,
|
||||
"NFD application should be in applied state")
|
||||
Reference in New Issue
Block a user