phanikumv commented on code in PR #24617:
URL: https://github.com/apache/airflow/pull/24617#discussion_r905948574


##########
airflow/providers/databricks/hooks/databricks.py:
##########
@@ -408,3 +410,18 @@ def get_repo_by_path(self, path: str) -> Optional[str]:
                 raise e
 
         return None
+
+    def test_connection(self):
+        """Test the Databricks connectivity from UI"""
+        status, message = False, ''
+        hook = DatabricksHook(databricks_conn_id=self.databricks_conn_id)
+        try:
+            result = 
hook._do_api_call(endpoint_info=LIST_ZONES_ENDPOINT).get('zones', [])
+            if result:

Review Comment:
   Below are the api responses , it will either return zones(because every 
valid databricks workspace is associated with a zone) or an exception. 
   
   For a working connection
   (base) phanikv@Phanis-MBP ~ % curl -X GET --header "Authorization: Bearer 
$DATABRICKS_TOKEN" \
   https://dbc-xxxxxxxxxxx.cloud.databricks.com/api/2.0/clusters/list-zones
   
{"zones":["us-east-2b","us-east-2c","us-east-2a"],"default_zone":"us-east-2b"}
   
   Let's say I enter a wrong host name
   (base) phanikv@Phanis-MBP ~ % curl -X GET --header "Authorization: Bearer 
$DATABRICKS_TOKEN" \
   https://dbc-xxxxxxxxxxx.cloud.databricks.com/api/2.0/clusters/list-zones 
   curl: (6) Could not resolve host: dbc-xxxxxxxxxxxcloud.databricks.com



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to