Merge "hotfix k8s_dashboard and get pods kw"

This commit is contained in:
Zuul
2025-05-15 18:30:11 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 15 deletions

View File

@@ -186,9 +186,10 @@ class KubectlGetPodsKeywords(BaseKeyword):
if len(pods_in_incorrect_status) == 0:
return True
time.sleep(poll_interval)
pods_in_incorrect_status_names = [pod.get_name() for pod in pods_in_incorrect_status]
pods_in_incorrect_status_names = ", ".join(pods_in_incorrect_status_names)
raise KeywordException(f"Pods {pods_in_incorrect_status_names} in namespace {namespace} did not reach status {expected_status} within {timeout} seconds")
raise KeywordException(f"Pods {pod_names} in namespace {namespace} did not reach status {expected_status} within {timeout} seconds")
def wait_for_kubernetes_to_restart(self, timeout: int = 600, check_interval: int = 20) -> bool:
"""
Wait for the Kubernetes API to go down, then wait for the kube-apiserver pod to be Running.
@@ -224,16 +225,6 @@ class KubectlGetPodsKeywords(BaseKeyword):
polling_sleep_time=check_interval,
)
self.wait_for_pod_status(
pod_name="kube-apiserver-controller-0",
expected_status="Running",
namespace="kube-system",
timeout=timeout
)
self.wait_for_pod_status(pod_name="kube-apiserver-controller-0", expected_status="Running", namespace="kube-system", timeout=timeout)
return self.wait_for_pod_max_age(
pod_name="kube-apiserver-controller-0",
max_age=3,
namespace="kube-system",
timeout=timeout
)
return self.wait_for_pod_max_age(pod_name="kube-apiserver-controller-0", max_age=3, namespace="kube-system", timeout=timeout)

View File

@@ -217,6 +217,7 @@ def test_k8s_dashboard_access(request):
# Defines dashboard file name, source (local) and destination (remote) file paths.
# Opens an SSH session to active controller.
get_logger().log_test_case_step("Step 1: Transfer the dashboard files to the active controller")
ssh_connection = LabConnectionKeywords().get_active_controller_ssh()
def teardown_dashboard_directory():
@@ -228,6 +229,7 @@ def test_k8s_dashboard_access(request):
copy_k8s_files(request, ssh_connection)
# Step 2: Create Dashboard namespace
get_logger().log_test_case_step("Step 2: Create Dashboard namespace")
def teardown_dashboard_namespace():
# cleanup created dashboard namespace
@@ -253,6 +255,7 @@ def test_k8s_dashboard_access(request):
assert ns_list.is_namespace(namespace_name=namespace_name)
# Step 3: Create the necessary k8s dashboard resources
get_logger().log_test_case_step("Step 3: Create the necessary k8s dashboard resources")
test_namespace = "kubernetes-dashboard"
def teardown_secret():
@@ -264,6 +267,8 @@ def test_k8s_dashboard_access(request):
create_k8s_dashboard(namespace=test_namespace, con_ssh=ssh_connection)
# Step 4: Create the token for the dashboard
get_logger().log_test_case_step("Step 4: Create the token for the dashboard")
def teardown_svc_account():
serviceaccount = "admin-user"
get_logger().log_info(f"Removing serviceaccount {serviceaccount} in kube-system")
@@ -273,7 +278,7 @@ def test_k8s_dashboard_access(request):
token = get_k8s_token(request=request, con_ssh=ssh_connection)
# Step 5: Navigate to K8s dashboard login page
get_logger().log_test_case_step("Step 5: Navigate to K8s dashboard login page")
k8s_dashboard_url = OpenStackEndpointListKeywords(ssh_connection=ssh_connection).get_k8s_dashboard_url()
driver = WebDriverCore()
request.addfinalizer(lambda: driver.close())
@@ -282,9 +287,11 @@ def test_k8s_dashboard_access(request):
login_page.navigate_to_login_page(k8s_dashboard_url)
# Login to the dashboard using the token.
login_page.login_with_token(token)
get_logger().log_test_case_step("Step 6: Logout from dashboard")
# Step 6: Logout from dashboard
login_page.logout()
# Step 7: Login to the dashboard using kubeconfig file
get_logger().log_test_case_step("Step 7: Login to the dashboard using kubeconfig file")
kubeconfig_tmp_path = update_token_in_local_kubeconfig(token=token)
login_page.login_with_kubeconfig(kubeconfig_tmp_path)