github-actions[bot] commented on code in PR #17586: URL: https://github.com/apache/doris/pull/17586#discussion_r1138974578
########## be/test/io/fs/file_system_test.cpp: ########## @@ -0,0 +1,643 @@ +// 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 <gtest/gtest.h> + +#include "io/fs/broker_file_system.h" +#include "io/fs/file_reader.h" +#include "io/fs/file_writer.h" +#include "io/fs/hdfs_file_system.h" +#include "io/fs/local_file_system.h" +#include "io/fs/s3_file_system.h" +#include "io/hdfs_builder.h" +#include "util/s3_uri.h" + +namespace doris { + +#ifndef CHECK_STATUS_OK +#define CHECK_STATUS_OK(stmt) \ + do { \ + Status _status_ = (stmt); \ + ASSERT_TRUE(_status_.ok()) << _status_; \ + } while (false) +#endif + +// set your own info +// s3 +static std::string ak = ""; +static std::string sk = ""; +static std::string endpoint = "http://cos.ap-beijing.myqcloud.com"; +static std::string region = "ap-beijing"; +static std::string s3_location = ""; + +// hdfs +static std::string fs_name = "hdfs://my_nameservice"; +static std::string username = "hadoop"; +static std::string nameservices = "my_nameservice"; +static std::string nn = "nn1,nn2"; +static std::string rpc1 = "172.21.0.1:4007"; +static std::string rpc2 = "172.21.0.2:4007"; +static std::string provider = + "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"; +static std::string hdfs_location = "/user/doris/"; + +// broker +static std::string broker_ip = "127.0.0.1"; +static int broker_port = 8008; +static std::string broker_location = "hdfs://my_nameservice/user/doris"; + +// commend out to enable specified test +#define TestHdfsFileSystem DISABLED_TestHdfsFileSystem +#define TestS3FileSystem DISABLED_TestS3FileSystem +#define TestBrokerFileSystem DISABLED_TestBrokerFileSystem + +class FileSystemTest : public testing::Test { +public: + virtual void SetUp() { Review Comment: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override] ```suggestion void SetUp() override { ``` ########## be/test/io/fs/file_system_test.cpp: ########## @@ -0,0 +1,643 @@ +// 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 <gtest/gtest.h> + +#include "io/fs/broker_file_system.h" +#include "io/fs/file_reader.h" +#include "io/fs/file_writer.h" +#include "io/fs/hdfs_file_system.h" +#include "io/fs/local_file_system.h" +#include "io/fs/s3_file_system.h" +#include "io/hdfs_builder.h" +#include "util/s3_uri.h" + +namespace doris { + +#ifndef CHECK_STATUS_OK +#define CHECK_STATUS_OK(stmt) \ + do { \ + Status _status_ = (stmt); \ + ASSERT_TRUE(_status_.ok()) << _status_; \ + } while (false) +#endif + +// set your own info +// s3 +static std::string ak = ""; +static std::string sk = ""; +static std::string endpoint = "http://cos.ap-beijing.myqcloud.com"; +static std::string region = "ap-beijing"; +static std::string s3_location = ""; + +// hdfs +static std::string fs_name = "hdfs://my_nameservice"; +static std::string username = "hadoop"; +static std::string nameservices = "my_nameservice"; +static std::string nn = "nn1,nn2"; +static std::string rpc1 = "172.21.0.1:4007"; +static std::string rpc2 = "172.21.0.2:4007"; +static std::string provider = + "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"; +static std::string hdfs_location = "/user/doris/"; + +// broker +static std::string broker_ip = "127.0.0.1"; +static int broker_port = 8008; +static std::string broker_location = "hdfs://my_nameservice/user/doris"; + +// commend out to enable specified test +#define TestHdfsFileSystem DISABLED_TestHdfsFileSystem +#define TestS3FileSystem DISABLED_TestS3FileSystem +#define TestBrokerFileSystem DISABLED_TestBrokerFileSystem + +class FileSystemTest : public testing::Test { +public: + virtual void SetUp() { + s3_prop.emplace("AWS_ACCESS_KEY", ak); + s3_prop.emplace("AWS_SECRET_KEY", sk); + s3_prop.emplace("AWS_ENDPOINT", endpoint); + s3_prop.emplace("AWS_REGION", region); + + hdfs_prop.emplace("fs.defaultFS", fs_name); + hdfs_prop.emplace("hadoop.username", username); + hdfs_prop.emplace("username", username); // for broker hdfs + hdfs_prop.emplace("dfs.nameservices", nameservices); + hdfs_prop.emplace("dfs.ha.namenodes.my_nameservice", nn); + hdfs_prop.emplace("dfs.namenode.rpc-address.my_nameservice.nn1", rpc1); + hdfs_prop.emplace("dfs.namenode.rpc-address.my_nameservice.nn2", rpc2); + hdfs_prop.emplace("dfs.client.failover.proxy.provider.my_nameservice", provider); + + broker_addr.__set_hostname(broker_ip); + broker_addr.__set_port(broker_port); + } + + virtual void TearDown() {} Review Comment: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override] ```suggestion void TearDown() override {} ``` ########## be/src/runtime/snapshot_loader.cpp: ########## @@ -628,4 +642,25 @@ Status SnapshotLoader::_report_every(int report_threshold, int* counter, int32_t return Status::OK(); } +Status SnapshotLoader::_list_with_checksum(const std::string& dir, + std::map<std::string, FileStat>* md5_files) { + bool exists = true; + std::vector<io::FileInfo> files; + RETURN_IF_ERROR(_remote_fs->list(dir, true, &files, &exists)); + for (auto& tmp_file : files) { + io::Path path(tmp_file.file_name); + std::string file_name = path.filename(); + size_t pos = file_name.find_last_of("."); Review Comment: warning: 'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character [performance-faster-string-find] ```suggestion size_t pos = file_name.find_last_of('.'); ``` ########## be/test/io/fs/file_system_test.cpp: ########## @@ -0,0 +1,643 @@ +// 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 <gtest/gtest.h> + +#include "io/fs/broker_file_system.h" +#include "io/fs/file_reader.h" +#include "io/fs/file_writer.h" +#include "io/fs/hdfs_file_system.h" +#include "io/fs/local_file_system.h" +#include "io/fs/s3_file_system.h" +#include "io/hdfs_builder.h" +#include "util/s3_uri.h" + +namespace doris { + +#ifndef CHECK_STATUS_OK +#define CHECK_STATUS_OK(stmt) \ + do { \ + Status _status_ = (stmt); \ + ASSERT_TRUE(_status_.ok()) << _status_; \ + } while (false) +#endif + +// set your own info +// s3 +static std::string ak = ""; +static std::string sk = ""; +static std::string endpoint = "http://cos.ap-beijing.myqcloud.com"; +static std::string region = "ap-beijing"; +static std::string s3_location = ""; + +// hdfs +static std::string fs_name = "hdfs://my_nameservice"; +static std::string username = "hadoop"; +static std::string nameservices = "my_nameservice"; +static std::string nn = "nn1,nn2"; +static std::string rpc1 = "172.21.0.1:4007"; +static std::string rpc2 = "172.21.0.2:4007"; +static std::string provider = + "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"; +static std::string hdfs_location = "/user/doris/"; + +// broker +static std::string broker_ip = "127.0.0.1"; +static int broker_port = 8008; +static std::string broker_location = "hdfs://my_nameservice/user/doris"; + +// commend out to enable specified test +#define TestHdfsFileSystem DISABLED_TestHdfsFileSystem +#define TestS3FileSystem DISABLED_TestS3FileSystem +#define TestBrokerFileSystem DISABLED_TestBrokerFileSystem + +class FileSystemTest : public testing::Test { +public: + virtual void SetUp() { + s3_prop.emplace("AWS_ACCESS_KEY", ak); + s3_prop.emplace("AWS_SECRET_KEY", sk); + s3_prop.emplace("AWS_ENDPOINT", endpoint); + s3_prop.emplace("AWS_REGION", region); + + hdfs_prop.emplace("fs.defaultFS", fs_name); + hdfs_prop.emplace("hadoop.username", username); + hdfs_prop.emplace("username", username); // for broker hdfs + hdfs_prop.emplace("dfs.nameservices", nameservices); + hdfs_prop.emplace("dfs.ha.namenodes.my_nameservice", nn); + hdfs_prop.emplace("dfs.namenode.rpc-address.my_nameservice.nn1", rpc1); + hdfs_prop.emplace("dfs.namenode.rpc-address.my_nameservice.nn2", rpc2); + hdfs_prop.emplace("dfs.client.failover.proxy.provider.my_nameservice", provider); + + broker_addr.__set_hostname(broker_ip); + broker_addr.__set_port(broker_port); + } + + virtual void TearDown() {} + +private: + std::map<std::string, std::string> s3_prop; + std::map<std::string, std::string> hdfs_prop; + TNetworkAddress broker_addr; +}; + +TEST_F(FileSystemTest, TestBrokerFileSystem) { + std::shared_ptr<io::BrokerFileSystem> fs; + CHECK_STATUS_OK(io::BrokerFileSystem::create(broker_addr, hdfs_prop, 0, &fs)); Review Comment: warning: 'broker_addr' is a private member of 'doris::FileSystemTest' [clang-diagnostic-error] ```cpp CHECK_STATUS_OK(io::BrokerFileSystem::create(broker_addr, hdfs_prop, 0, &fs)); ^ ``` **be/test/io/fs/file_system_test.cpp:93:** declared private here ```cpp TNetworkAddress broker_addr; ^ ``` ########## be/test/io/fs/file_system_test.cpp: ########## @@ -0,0 +1,643 @@ +// 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 <gtest/gtest.h> + +#include "io/fs/broker_file_system.h" +#include "io/fs/file_reader.h" +#include "io/fs/file_writer.h" +#include "io/fs/hdfs_file_system.h" +#include "io/fs/local_file_system.h" +#include "io/fs/s3_file_system.h" +#include "io/hdfs_builder.h" +#include "util/s3_uri.h" + +namespace doris { + +#ifndef CHECK_STATUS_OK +#define CHECK_STATUS_OK(stmt) \ + do { \ + Status _status_ = (stmt); \ + ASSERT_TRUE(_status_.ok()) << _status_; \ + } while (false) +#endif + +// set your own info +// s3 +static std::string ak = ""; +static std::string sk = ""; Review Comment: warning: redundant string initialization [readability-redundant-string-init] ```suggestion static std::string sk; ``` ########## be/test/io/fs/file_system_test.cpp: ########## @@ -0,0 +1,643 @@ +// 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 <gtest/gtest.h> + +#include "io/fs/broker_file_system.h" +#include "io/fs/file_reader.h" +#include "io/fs/file_writer.h" +#include "io/fs/hdfs_file_system.h" +#include "io/fs/local_file_system.h" +#include "io/fs/s3_file_system.h" +#include "io/hdfs_builder.h" +#include "util/s3_uri.h" + +namespace doris { + +#ifndef CHECK_STATUS_OK +#define CHECK_STATUS_OK(stmt) \ + do { \ + Status _status_ = (stmt); \ + ASSERT_TRUE(_status_.ok()) << _status_; \ + } while (false) +#endif + +// set your own info +// s3 +static std::string ak = ""; +static std::string sk = ""; +static std::string endpoint = "http://cos.ap-beijing.myqcloud.com"; +static std::string region = "ap-beijing"; +static std::string s3_location = ""; Review Comment: warning: redundant string initialization [readability-redundant-string-init] ```suggestion static std::string s3_location; ``` ########## be/test/olap/remote_rowset_gc_test.cpp: ########## @@ -53,8 +53,10 @@ class RemoteRowsetGcTest : public testing::Test { s3_conf.region = config::test_s3_region; Review Comment: warning: no member named 'test_s3_region' in namespace 'doris::config' [clang-diagnostic-error] ```cpp s3_conf.region = config::test_s3_region; ^ ``` -- 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]
