morningman commented on code in PR #57004:
URL: https://github.com/apache/doris/pull/57004#discussion_r2444514750


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/S3ConnectivityTester.java:
##########
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.datasource.connectivity;
+
+import org.apache.doris.common.util.S3URI;
+import org.apache.doris.common.util.S3Util;
+import org.apache.doris.datasource.property.storage.S3Properties;
+
+import software.amazon.awssdk.services.s3.S3Client;
+
+import java.net.URI;
+
+public class S3ConnectivityTester extends 
AbstractS3CompatibleConnectivityTester {
+
+    public S3ConnectivityTester(S3Properties properties, String testLocation) {
+        super(properties, testLocation);
+    }
+
+    @Override
+    public String getTestType() {
+        return "S3";
+    }
+
+    @Override
+    protected void doTestFeConnection() throws Exception {
+        S3URI s3Uri = S3URI.create(testLocation,

Review Comment:
   I think we can move this to the parent class 
`AbstractS3CompatibleConnectivityTester`.
   And override it in subclass if needed(like minio need path style property)



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/connectivity/IcebergRestConnectivityTester.java:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.datasource.connectivity;
+
+import 
org.apache.doris.datasource.property.metastore.AbstractIcebergProperties;
+import org.apache.doris.datasource.property.metastore.IcebergRestProperties;
+
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.rest.RESTSessionCatalog;
+
+import java.util.Map;
+
+public class IcebergRestConnectivityTester extends 
AbstractIcebergConnectivityTester {
+    private static final String DEFAULT_BASE_LOCATION = 
"default-base-location";
+    private String warehouseLocation;
+
+    public IcebergRestConnectivityTester(AbstractIcebergProperties properties) 
{
+        super(properties);
+    }
+
+    @Override
+    public String getTestType() {
+        return "Iceberg REST";
+    }
+
+    @Override
+    public void testConnection() throws Exception {
+        Map<String, String> restProps = ((IcebergRestProperties) 
properties).getIcebergRestCatalogProperties();
+
+        try (RESTSessionCatalog catalog = new RESTSessionCatalog()) {
+            catalog.initialize("connectivity-test", restProps);
+
+            Map<String, String> mergedProps = catalog.properties();
+            String location = 
mergedProps.get(CatalogProperties.WAREHOUSE_LOCATION);
+            this.warehouseLocation = validateAndGetLocation(location);
+            if (this.warehouseLocation == null) {
+                location = mergedProps.get(DEFAULT_BASE_LOCATION);

Review Comment:
   where to get this property `default-base-location` ?
   we don't support this property at all



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java:
##########
@@ -258,6 +264,38 @@ public boolean ifNotSetFallbackToSimpleAuth() {
     // Will be called when creating catalog(not replaying).
     // Subclass can override this method to do some check when creating 
catalog.
     public void checkWhenCreating() throws DdlException {
+        boolean testConnection = Boolean.parseBoolean(
+                catalogProperty.getOrDefault(TEST_CONNECTION, 
String.valueOf(DEFAULT_TEST_CONNECTION)));
+
+        if (!testConnection) {
+            return;
+        }
+
+        MetaConnectivityTester metaTester = 
catalogProperty.getMetastoreProperties().createConnectivityTester();
+        try {
+            metaTester.testConnection();
+        } catch (Exception e) {
+            throw new DdlException(metaTester.getTestType() + " connectivity 
test failed: " + e.getMessage());
+        }
+
+        String testLocation = metaTester.getTestLocation();

Review Comment:
   There will be multi storage properties, but only one test location here.
   So you may use wrong storage property to test the location, which will throw 
exception.
   So maybe for multi storage properties, we can let test pass only if at least 
one storage test is passed



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to