
Adding first system test TC (deploy, scale and remove deployments). Adding new object for k8s get deployments. Updating existing k8s objects to support "namespace" parameter. Change-Id: Ifafa33638ab2949cac9d985b56ed90bebe2495a8 --- Signed-off-by: Vitor Vidal <vitor.vidaldenegreiros@windriver.com> --- Change-Id: I6c0cd323826f0c38db2289fb420d49bf432e1930
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from framework.logging.automation_logger import get_logger
|
|
from keywords.base_keyword import BaseKeyword
|
|
from keywords.k8s.k8s_command_wrapper import export_k8s_config
|
|
|
|
|
|
class KubectlDeleteDeploymentsKeywords(BaseKeyword):
|
|
|
|
def __init__(self, ssh_connection):
|
|
"""
|
|
Constructor
|
|
Args:
|
|
ssh_connection:
|
|
"""
|
|
self.ssh_connection = ssh_connection
|
|
|
|
def delete_deployment(self, deployment_name: str, namespace: str = None) -> str:
|
|
"""
|
|
Deletes the given deployment
|
|
Args:
|
|
deployment_name (): the deployment name
|
|
|
|
Returns: the output
|
|
|
|
"""
|
|
cmd = f"kubectl delete deployment {deployment_name}"
|
|
if namespace:
|
|
cmd = f"{cmd} -n {namespace}"
|
|
output = self.ssh_connection.send(export_k8s_config(cmd))
|
|
self.validate_success_return_code(self.ssh_connection)
|
|
|
|
return output
|
|
|
|
def cleanup_deployment(self, deployment_name: str) -> int:
|
|
"""
|
|
For use in cleanup as it doesn't automatically fail the test
|
|
Args:
|
|
deployment_name (): the deployment name
|
|
|
|
Returns: the return code
|
|
|
|
"""
|
|
self.ssh_connection.send(export_k8s_config(f"kubectl delete deployment {deployment_name}"))
|
|
rc = self.ssh_connection.get_return_code()
|
|
if rc != 0:
|
|
get_logger().log_error(f"Deployment {deployment_name} failed to delete")
|
|
return rc
|