gavinchou commented on code in PR #35670: URL: https://github.com/apache/doris/pull/35670#discussion_r1622704987
########## be/src/io/fs/azure_obj_storage_client.cpp: ########## Review Comment: How do we test each function implementation? ########## be/src/util/s3_util.cpp: ########## @@ -156,9 +159,9 @@ S3ClientFactory& S3ClientFactory::instance() { return ret; } -std::shared_ptr<Aws::S3::S3Client> S3ClientFactory::create(const S3ClientConf& s3_conf) { +std::shared_ptr<io::ObjStorageClient> S3ClientFactory::create(const S3ClientConf& s3_conf) { Review Comment: Naming S3ClientConf -> ObjClientConf ? ########## be/test/io/fs/azure_test.cpp: ########## @@ -0,0 +1,101 @@ +// 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. + +#include <aws/s3/S3Client.h> +#include <aws/s3/S3ServiceClientModel.h> +#include <aws/s3/model/CompleteMultipartUploadRequest.h> +#include <aws/s3/model/CompleteMultipartUploadResult.h> +#include <aws/s3/model/CompletedMultipartUpload.h> +#include <fmt/core.h> +#include <gtest/gtest.h> + +#include <azure/storage/blobs.hpp> +#include <azure/storage/blobs/blob_client.hpp> +#include <azure/storage/blobs/blob_container_client.hpp> +#include <azure/storage/common/storage_credential.hpp> +#include <cstdio> +#include <iostream> +#include <stdexcept> +#include <utility> + +#include "common/config.h" + +namespace doris { + +std::string GetConnectionString() { + const static std::string ConnectionString = ""; + + if (!ConnectionString.empty()) { + return ConnectionString; + } + const static std::string envConnectionString = std::getenv("AZURE_STORAGE_CONNECTION_STRING"); + if (!envConnectionString.empty()) { + return envConnectionString; + } + throw std::runtime_error("Cannot find connection string."); +} + +TEST(AzureTest, Write) { + // GTEST_SKIP() << "Skipping Azure test, because this test it to test the compile and linkage"; + using namespace Azure::Storage::Blobs; + + std::string accountName = config::test_s3_ak; + std::string accountKey = config::test_s3_sk; + + auto cred = + std::make_shared<Azure::Storage::StorageSharedKeyCredential>(accountName, accountKey); + + const std::string containerName = config::test_s3_bucket; + const std::string blobName = "sample-blob"; + const std::string blobContent = "Fuck Azure!"; Review Comment: Remove the F word ########## be/src/util/s3_util.cpp: ########## @@ -171,6 +174,25 @@ std::shared_ptr<Aws::S3::S3Client> S3ClientFactory::create(const S3ClientConf& s return it->second; } } + if (s3_conf.provider == "AZURE") { + return _create_azure_client(s3_conf); + } + return _create_s3_client(s3_conf); +} + +std::shared_ptr<io::ObjStorageClient> S3ClientFactory::_create_azure_client(const S3ClientConf& s3_conf) { + auto cred = + std::make_shared<Azure::Storage::StorageSharedKeyCredential>(s3_conf.ak, s3_conf.sk); + + const std::string containerName = s3_conf.bucket; + const std::string uri = + fmt::format("https://{}.blob.core.windows.net/{}", s3_conf.ak, containerName); Review Comment: Use existing BE config `http_scheme` ########## be/src/util/s3_util.cpp: ########## @@ -171,6 +174,25 @@ std::shared_ptr<Aws::S3::S3Client> S3ClientFactory::create(const S3ClientConf& s return it->second; } } + if (s3_conf.provider == "AZURE") { + return _create_azure_client(s3_conf); + } + return _create_s3_client(s3_conf); +} + +std::shared_ptr<io::ObjStorageClient> S3ClientFactory::_create_azure_client(const S3ClientConf& s3_conf) { + auto cred = + std::make_shared<Azure::Storage::StorageSharedKeyCredential>(s3_conf.ak, s3_conf.sk); + + const std::string containerName = s3_conf.bucket; Review Comment: `containerName` should be "lower_under_score", pls check other occurrences. -- 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...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org