From 0332fb9fe5a4ef7bd1106654d0d30235cc9666b8 Mon Sep 17 00:00:00 2001 From: Pere Miquel Brull Date: Sun, 28 Jan 2024 19:25:15 +0100 Subject: [PATCH] #13934 - Update test connection no response error msg (#14897) * #13934 - Update test connection no response error msg * #13934 - Update test connection no response error msg --- .../automations/test_connection_automation.py | 44 +++++++++++++++++++ .../api/routes/run_automation.py | 1 + .../pipeline/airflow/AirflowRESTClient.java | 15 ++++--- .../sdk/PipelineServiceClient.java | 2 +- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/ingestion/tests/integration/automations/test_connection_automation.py b/ingestion/tests/integration/automations/test_connection_automation.py index 02926612d01..dad414d99a2 100644 --- a/ingestion/tests/integration/automations/test_connection_automation.py +++ b/ingestion/tests/integration/automations/test_connection_automation.py @@ -114,3 +114,47 @@ class TestConnectionAutomationTest(TestCase): entity_id=str(automation_workflow.id.__root__), hard_delete=True, ) + + def test_connection_workflow_ko(self): + """Test connection that will fail""" + wrong_service_connection = MysqlConnection( + username="openmetadata_user", + authType=BasicAuth(password="openmetadata_password"), + hostPort="localhost:8585", # There's something running there, but it's not MySQL + databaseSchema="openmetadata_db", + ) + + wrong_workflow_request = CreateWorkflowRequest( + name="test-connection-mysql-bad", + description="description", + workflowType=WorkflowType.TEST_CONNECTION, + request=TestServiceConnectionRequest( + serviceType=ServiceType.Database, + connectionType=MySQLType.Mysql.value, + connection=DatabaseConnection( + config=wrong_service_connection, + ), + ), + ) + + automation_workflow: Workflow = self.metadata.create_or_update( + data=wrong_workflow_request + ) + engine: Engine = get_connection(wrong_service_connection) + + test_connection_fn = get_test_connection_fn(wrong_service_connection) + test_connection_fn( + self.metadata, engine, wrong_service_connection, automation_workflow + ) + + final_workflow: Workflow = self.metadata.get_by_name( + entity=Workflow, fqn="test-connection-mysql-bad" + ) + + self.assertEqual(final_workflow.response.status, StatusType.Failed) + + self.metadata.delete( + entity=Workflow, + entity_id=str(automation_workflow.id.__root__), + hard_delete=True, + ) diff --git a/openmetadata-airflow-apis/openmetadata_managed_apis/api/routes/run_automation.py b/openmetadata-airflow-apis/openmetadata_managed_apis/api/routes/run_automation.py index ab79b75fbfa..f31b6a91546 100644 --- a/openmetadata-airflow-apis/openmetadata_managed_apis/api/routes/run_automation.py +++ b/openmetadata-airflow-apis/openmetadata_managed_apis/api/routes/run_automation.py @@ -61,6 +61,7 @@ def get_fn(blueprint: Blueprint) -> Callable: automation_workflow.openMetadataServerConnection.secretsManagerLoader, ) + # Should this be triggered async? execute(automation_workflow) return ApiResponse.success( diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/airflow/AirflowRESTClient.java b/openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/airflow/AirflowRESTClient.java index 66906b94acc..fedcc1a0124 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/airflow/AirflowRESTClient.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/airflow/AirflowRESTClient.java @@ -132,11 +132,11 @@ public class AirflowRESTClient extends PipelineServiceClient { } } catch (IOException | URISyntaxException e) { throw IngestionPipelineDeploymentException.byMessage( - ingestionPipeline.getName(), DEPLOYEMENT_ERROR, e.getMessage()); + ingestionPipeline.getName(), DEPLOYMENT_ERROR, e.getMessage()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw IngestionPipelineDeploymentException.byMessage( - ingestionPipeline.getName(), DEPLOYEMENT_ERROR, e.getMessage()); + ingestionPipeline.getName(), DEPLOYMENT_ERROR, e.getMessage()); } throw new PipelineServiceClientException( String.format( @@ -329,8 +329,13 @@ public class AirflowRESTClient extends PipelineServiceClient { return getResponse(200, response.body()); } } catch (IOException | URISyntaxException e) { + // We can end up here if the test connection is not sending back anything after the POST + // request + // due to the connection to the source service not being properly resolved. throw IngestionPipelineDeploymentException.byMessage( - workflow.getName(), TRIGGER_ERROR, e.getMessage()); + workflow.getName(), + TRIGGER_ERROR, + "No response from the test connection. Make sure your service is reachable and accepting connections"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw IngestionPipelineDeploymentException.byMessage( @@ -368,11 +373,11 @@ public class AirflowRESTClient extends PipelineServiceClient { } } catch (IOException | URISyntaxException e) { throw IngestionPipelineDeploymentException.byMessage( - workflowPayload, DEPLOYEMENT_ERROR, e.getMessage()); + workflowPayload, DEPLOYMENT_ERROR, e.getMessage()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw IngestionPipelineDeploymentException.byMessage( - workflowPayload, DEPLOYEMENT_ERROR, e.getMessage()); + workflowPayload, DEPLOYMENT_ERROR, e.getMessage()); } throw new PipelineServiceClientException( String.format( diff --git a/openmetadata-spec/src/main/java/org/openmetadata/sdk/PipelineServiceClient.java b/openmetadata-spec/src/main/java/org/openmetadata/sdk/PipelineServiceClient.java index cebb06f5b4c..1ed740a388c 100644 --- a/openmetadata-spec/src/main/java/org/openmetadata/sdk/PipelineServiceClient.java +++ b/openmetadata-spec/src/main/java/org/openmetadata/sdk/PipelineServiceClient.java @@ -78,7 +78,7 @@ public abstract class PipelineServiceClient { public static final String APP_TRIGGER = "run_application"; public static final String APP_VALIDATE = "validate_registration"; - public static final String DEPLOYEMENT_ERROR = "DEPLOYMENT_ERROR"; + public static final String DEPLOYMENT_ERROR = "DEPLOYMENT_ERROR"; public static final String TRIGGER_ERROR = "TRIGGER_ERROR"; public static final Map TYPE_TO_TASK = Map.of(