|
7 | 7 | from utilities.constants import DscComponents |
8 | 8 | from tests.model_registry.constants import MR_INSTANCE_NAME |
9 | 9 | from kubernetes.dynamic.client import DynamicClient |
10 | | -from utilities.general import wait_for_pods_by_labels, wait_for_container_status |
11 | | - |
| 10 | +from utilities.general import wait_for_container_status |
| 11 | +from tests.model_registry.utils import wait_for_new_running_mr_pod |
12 | 12 |
|
13 | 13 | LOGGER = get_logger(name=__name__) |
14 | 14 |
|
@@ -36,30 +36,31 @@ def test_db_migration_negative( |
36 | 36 | admin_client: DynamicClient, |
37 | 37 | model_registry_db_instance_pod: Pod, |
38 | 38 | set_mr_db_dirty: int, |
| 39 | + model_registry_pod: Pod, |
39 | 40 | delete_mr_deployment: None, |
40 | 41 | ): |
41 | 42 | """ |
42 | 43 | RHOAIENG-27505: This test is to check the migration error when the database is dirty. |
43 | 44 | The test will: |
44 | 45 | 1. Set the dirty flag to 1 for the latest migration version |
45 | 46 | 2. Delete the model registry deployment |
46 | | - 3. Check the logs for the expected error |
| 47 | + 3. Wait for the old pods to be terminated |
| 48 | + 4. Check the logs for the expected error |
47 | 49 | """ |
48 | | - mr_pods = wait_for_pods_by_labels( |
| 50 | + LOGGER.info(f"Model registry pod: {model_registry_pod.name}") |
| 51 | + mr_pod = wait_for_new_running_mr_pod( |
49 | 52 | admin_client=admin_client, |
| 53 | + orig_pod_name=model_registry_pod.name, |
50 | 54 | namespace=py_config["model_registry_namespace"], |
51 | | - label_selector=f"app={MR_INSTANCE_NAME}", |
52 | | - expected_num_pods=1, |
| 55 | + instance_name=MR_INSTANCE_NAME, |
53 | 56 | ) |
54 | | - mr_pod = mr_pods[0] |
55 | | - LOGGER.info("Waiting for model registry pod to crash") |
| 57 | + LOGGER.info(f"Pod that should contains the container in CrashLoopBackOff state: {mr_pod.name}") |
56 | 58 | assert wait_for_container_status(mr_pod, "rest-container", Pod.Status.CRASH_LOOPBACK_OFF) |
57 | 59 |
|
58 | 60 | LOGGER.info("Checking the logs for the expected error") |
59 | | - |
60 | 61 | log_output = mr_pod.log(container="rest-container") |
61 | 62 | expected_error = ( |
62 | 63 | f"Error: {{{{ALERT}}}} error connecting to datastore: Dirty database version {set_mr_db_dirty}. " |
63 | 64 | "Fix and force version." |
64 | 65 | ) |
65 | | - assert expected_error in log_output, "Expected error message not found in logs!" |
| 66 | + assert expected_error in log_output, f"Expected error message not found in logs!\n{log_output}" |
0 commit comments