Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13934 - Update test connection no response error msg #14897

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,47 @@ def test_connection_workflow(self):
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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def run_automation() -> Response:
automation_workflow.openMetadataServerConnection.secretsManagerLoader,
)

# Should this be triggered async?
execute(automation_workflow)

return ApiResponse.success(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ public PipelineServiceClientResponse deployPipeline(
}
} 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(
Expand Down Expand Up @@ -329,8 +329,13 @@ public PipelineServiceClientResponse runAutomationsWorkflow(Workflow workflow) {
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(
Expand Down Expand Up @@ -368,11 +373,11 @@ private PipelineServiceClientResponse sendPost(String endpoint, Object request)
}
} 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> TYPE_TO_TASK =
Map.of(
Expand Down
Loading