Adding support for power metrics app

Change-Id: I493cf7b4f6874c040070108f409f419b59ecaa28
This commit is contained in:
Francischini de Souza, Gabriel
2025-05-28 15:19:53 -03:00
parent 2b0f4cbc68
commit 9c2636c605
5 changed files with 118 additions and 2 deletions

View File

@@ -2,5 +2,6 @@
base_application_path: "/usr/local/share/applications/helm/",
istio_app_name: "istio",
metric_server_app_name: "metrics-server",
oidc_app_name: "oidc-auth-apps"
oidc_app_name: "oidc-auth-apps",
power_metrics_app_name: "power-metrics"
}

View File

@@ -18,6 +18,7 @@ class AppConfig:
self.istio_app_name = app_dict["istio_app_name"]
self.metric_server_app_name = app_dict["metric_server_app_name"]
self.oidc_app_name = app_dict["oidc_app_name"]
self.power_metrics_app_name = app_dict["power_metrics_app_name"]
def get_base_application_path(self) -> str:
"""
@@ -58,3 +59,13 @@ class AppConfig:
"""
return self.oidc_app_name
def get_power_metrics_app_name(self) -> str:
"""
Getter for power metrics app name
Returns:
str: the power metrics app name path
"""
return self.power_metrics_app_name

View File

@@ -0,0 +1,101 @@
from config.configuration_manager import ConfigurationManager
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
from keywords.cloud_platform.system.application.system_application_list_keywords import SystemApplicationListKeywords
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.system_application_delete_keywords import SystemApplicationDeleteKeywords
from keywords.cloud_platform.system.application.system_application_upload_keywords import SystemApplicationUploadInput
from keywords.cloud_platform.system.application.system_application_remove_keywords import SystemApplicationRemoveInput
from keywords.cloud_platform.system.application.system_application_delete_keywords import SystemApplicationDeleteInput
from keywords.cloud_platform.system.application.object.system_application_status_enum import SystemApplicationStatusEnum
from keywords.cloud_platform.system.host.system_host_label_keywords import SystemHostLabelKeywords
from framework.validation.validation import validate_equals, validate_not_equals
def test_install_power_metrics():
"""
Install (Upload and Apply) Application Power Metrics
Raises:
Exception: If application Power Metrics failed to upload or apply
"""
# Setups app configs and lab connection
app_config = ConfigurationManager.get_app_config()
base_path = app_config.get_base_application_path()
power_metrics_name = app_config.get_power_metrics_app_name()
lab_connect_keywords = LabConnectionKeywords()
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
system_host_label_keywords = SystemHostLabelKeywords(ssh_connection)
lab_config = ConfigurationManager.get_lab_config()
nodes = lab_config.get_nodes()
for node in lab_config.get_nodes():
system_host_label_keywords.system_host_label_assign(node.get_name(), "power-metrics=enabled")
# Verifies if the app is present in the system
system_applications = SystemApplicationListKeywords(ssh_connection).get_system_application_list()
validate_equals(system_applications.is_in_application_list(power_metrics_name), False, f"The {power_metrics_name} application should not be already uploaded/applied on the system")
# Setups the upload input object
system_application_upload_input = SystemApplicationUploadInput()
system_application_upload_input.set_app_name(power_metrics_name)
system_application_upload_input.set_tar_file_path(f"{base_path}{power_metrics_name}*.tgz")
# Uploads the app file and verifies it
SystemApplicationUploadKeywords(ssh_connection).system_application_upload(system_application_upload_input)
system_applications = SystemApplicationListKeywords(ssh_connection).get_system_application_list()
power_metrics_app_status = system_applications.get_application(power_metrics_name).get_status()
validate_equals(power_metrics_app_status, "uploaded", f"{power_metrics_name} upload status validation")
# Applies the app to the active controller
system_application_apply_output = SystemApplicationApplyKeywords(ssh_connection).system_application_apply(power_metrics_name)
# Verifies the app was applied
system_application_object = system_application_apply_output.get_system_application_object()
validate_not_equals(system_application_object, None, f"System application object should not be None")
validate_equals(system_application_object.get_name(), power_metrics_name, f"Application name validation")
validate_equals(system_application_object.get_status(), SystemApplicationStatusEnum.APPLIED.value, f"Application status validation")
def test_uninstall_power_metrics():
"""
Uninstall (Remove and Delete) Application Power Metrics
Raises:
Exception: If application Power Metrics failed to remove or delete
"""
# Setups app configs and lab connection
app_config = ConfigurationManager.get_app_config()
power_metrics_name = app_config.get_power_metrics_app_name()
lab_connect_keywords = LabConnectionKeywords()
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
system_host_label_keywords = SystemHostLabelKeywords(ssh_connection)
lab_config = ConfigurationManager.get_lab_config()
for node in lab_config.get_nodes():
system_host_label_keywords.system_host_label_remove(node.get_name(), "power-metrics")
# Verifies if the app is not present in the system
system_applications = SystemApplicationListKeywords(ssh_connection).get_system_application_list()
validate_equals(system_applications.is_in_application_list(power_metrics_name), True, f"The {power_metrics_name} application should be uploaded/applied on the system")
# Removes the application
system_application_remove_input = SystemApplicationRemoveInput()
system_application_remove_input.set_app_name(power_metrics_name)
system_application_remove_input.set_force_removal(False)
system_application_output = SystemApplicationRemoveKeywords(ssh_connection).system_application_remove(system_application_remove_input)
validate_equals(system_application_output.get_system_application_object().get_status(), SystemApplicationStatusEnum.UPLOADED.value, f"Application removal status validation")
# Deletes the application
system_application_delete_input = SystemApplicationDeleteInput()
system_application_delete_input.set_app_name(power_metrics_name)
system_application_delete_input.set_force_deletion(False)
delete_msg = SystemApplicationDeleteKeywords(ssh_connection).get_system_application_delete(system_application_delete_input)
validate_equals(delete_msg, f"Application {power_metrics_name} deleted.\n", f"Application deletion message validation")

View File

@@ -17,6 +17,7 @@ def test_default_app_config():
assert default_config.get_istio_app_name() == "istio", "istio default app name was incorrect"
assert default_config.get_metric_server_app_name() == "metrics-server", "metric server default name was incorrect"
assert default_config.get_oidc_app_name() == "oidc-auth-apps", "oidc default app name was incorrect"
assert default_config.get_power_metrics_app_name() == "power-metrics", "power metrics default app name was incorrect"
def test_custom_app_config():
@@ -35,3 +36,4 @@ def test_custom_app_config():
assert custom_config.get_istio_app_name() == "istio_custom", "istio custom app name was incorrect"
assert custom_config.get_metric_server_app_name() == "metrics-server_custom", "metric server custom name was incorrect"
assert custom_config.get_oidc_app_name() == "oidc-auth-apps_custom", "oidc custom app name was incorrect"
assert custom_config.get_power_metrics_app_name() == "power-metrics_custom", "power metrics custom name was incorrect"

View File

@@ -2,5 +2,6 @@
base_application_path: "fake_path",
istio_app_name: "istio_custom",
metric_server_app_name: "metrics-server_custom",
oidc_app_name: "oidc-auth-apps_custom"
oidc_app_name: "oidc-auth-apps_custom",
power_metrics_app_name: "power-metrics_custom"
}