github-actions[bot] commented on code in PR #24399:
URL: https://github.com/apache/doris/pull/24399#discussion_r1332621193
##########
be/test/http/http_client_test.cpp:
##########
@@ -177,4 +186,21 @@ TEST_F(HttpClientTest, post_failed) {
EXPECT_TRUE(boost::algorithm::contains(st.to_string(), not_found));
}
+TEST_F(HttpClientTest, not_found) {
+ HttpClient client;
Review Comment:
warning: variable 'client' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
HttpClient client = 0;
```
##########
be/test/olap/tablet_cooldown_test.cpp:
##########
@@ -339,15 +326,15 @@ static TDescriptorTable
create_descriptor_tablet_with_sequence_col() {
return desc_tbl_builder.desc_tbl();
}
-void createTablet(StorageEngine* engine, TabletSharedPtr* tablet, int64_t
replica_id,
- int32_t schema_hash, int64_t tablet_id, int64_t txn_id,
int64_t partition_id) {
+void createTablet(TabletSharedPtr* tablet, int64_t replica_id, int32_t
schema_hash,
+ int64_t tablet_id, int64_t txn_id, int64_t partition_id) {
// create tablet
std::unique_ptr<RuntimeProfile> profile;
profile = std::make_unique<RuntimeProfile>("CreateTablet");
TCreateTabletReq request;
create_tablet_request_with_sequence_col(tablet_id, schema_hash, &request);
request.__set_replica_id(replica_id);
- Status st = engine->create_tablet(request, profile.get());
+ Status st = k_engine->create_tablet(request, profile.get());
Review Comment:
warning: variable 'st' is not initialized [cppcoreguidelines-init-variables]
```suggestion
Status st = 0 = k_engine->create_tablet(request, profile.get());
```
##########
be/test/olap/txn_manager_test.cpp:
##########
@@ -185,19 +184,19 @@ class TxnManagerTest : public testing::Test {
};
TEST_F(TxnManagerTest, PrepareNewTxn) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
+ Status status =
Review Comment:
warning: variable 'status' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
Status status = 0 =
```
##########
be/test/olap/txn_manager_test.cpp:
##########
@@ -185,19 +184,19 @@ class TxnManagerTest : public testing::Test {
};
TEST_F(TxnManagerTest, PrepareNewTxn) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
+ Status status =
+ _txn_mgr->prepare_txn(partition_id, transaction_id, tablet_id,
_tablet_uid, load_id);
EXPECT_TRUE(status == Status::OK());
}
// 1. prepare txn
// 2. commit txn
// 3. should be success
TEST_F(TxnManagerTest, CommitTxnWithPrepare) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
- _txn_mgr->commit_txn(_meta, partition_id, transaction_id, tablet_id,
schema_hash, _tablet_uid,
- load_id, _rowset, false);
+ Status status =
Review Comment:
warning: variable 'status' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
Status status = 0 =
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
Review Comment:
warning: use '= default' to define a trivial destructor
[modernize-use-equals-default]
```suggestion
virtual ~BackendOptionsTest() = default;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
Review Comment:
warning: 'service/backend_options.h' file not found [clang-diagnostic-error]
```cpp
#include "service/backend_options.h"
^
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
Review Comment:
warning: use '= default' to define a trivial default constructor
[modernize-use-equals-default]
```suggestion
BackendOptionsTest() = default;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
Review Comment:
warning: variable 'localhost' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::string localhost = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("127.0.0.1", localhost.c_str());
+}
+
+// priority not loopback
+TEST_F(BackendOptionsTest, emptyCidr2) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("10.10.10.10", localhost.c_str());
+}
+
+// not choose ipv6
+TEST_F(BackendOptionsTest, emptyCidr3) {
+ std::vector<InetAddress> hosts;
Review Comment:
warning: variable 'hosts' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::vector<InetAddress> hosts = 0;
```
##########
be/test/olap/txn_manager_test.cpp:
##########
@@ -302,29 +298,27 @@ TEST_F(TxnManagerTest, PublishNotExistedTxn) {
auto not_exist_txn = transaction_id + 1000;
TabletPublishStatistics stats;
Status status = _txn_mgr->publish_txn(_meta, partition_id, not_exist_txn,
tablet_id,
- schema_hash, _tablet_uid,
new_version, &stats);
+ _tablet_uid, new_version, &stats);
EXPECT_EQ(status, Status::OK());
}
TEST_F(TxnManagerTest, DeletePreparedTxn) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
+ Status status =
Review Comment:
warning: variable 'status' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
Status status = 0 =
```
##########
be/test/runtime/load_stream_test.cpp:
##########
@@ -580,15 +582,14 @@ class LoadStreamMgrTest : public testing::Test {
doris::EngineOptions options;
options.store_paths = paths;
- Status s = doris::StorageEngine::open(options, &z_engine);
+ Status s = doris::StorageEngine::open(options, &k_engine);
Review Comment:
warning: variable 's' is not initialized [cppcoreguidelines-init-variables]
```suggestion
Status s = 0 = doris::StorageEngine::open(options, &k_engine);
```
##########
be/test/http/http_client_test.cpp:
##########
@@ -177,4 +186,21 @@ TEST_F(HttpClientTest, post_failed) {
EXPECT_TRUE(boost::algorithm::contains(st.to_string(), not_found));
}
+TEST_F(HttpClientTest, not_found) {
+ HttpClient client;
+ std::string url = hostname + "/not_found";
+ constexpr uint64_t kMaxTimeoutMs = 1000;
+
+ auto get_cb = [&url](HttpClient* client) {
+ std::string resp;
Review Comment:
warning: variable 'resp' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::string resp = 0;
```
##########
be/test/runtime/load_stream_test.cpp:
##########
@@ -604,35 +605,30 @@ class LoadStreamMgrTest : public testing::Test {
TCreateTabletReq request;
create_tablet_request(NORMAL_TABLET_ID + i, SCHEMA_HASH, &request);
auto profile = std::make_unique<RuntimeProfile>("test");
- Status res = z_engine->create_tablet(request, profile.get());
+ Status res = k_engine->create_tablet(request, profile.get());
Review Comment:
warning: variable 'res' is not initialized [cppcoreguidelines-init-variables]
```suggestion
Status res = 0 = k_engine->create_tablet(request, profile.get());
```
##########
be/test/runtime/user_function_cache_test.cpp:
##########
@@ -16,3 +16,31 @@
// under the License.
#include "runtime/user_function_cache.h"
Review Comment:
warning: 'runtime/user_function_cache.h' file not found
[clang-diagnostic-error]
```cpp
#include "runtime/user_function_cache.h"
^
```
##########
be/test/olap/txn_manager_test.cpp:
##########
@@ -210,49 +209,47 @@ TEST_F(TxnManagerTest, CommitTxnWithPrepare) {
// 2. should success
TEST_F(TxnManagerTest, CommitTxnWithNoPrepare) {
Status status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id,
- schema_hash, _tablet_uid, load_id,
_rowset, false);
+ _tablet_uid, load_id, _rowset, false);
EXPECT_TRUE(status == Status::OK());
}
// 1. commit twice with different rowset id
// 2. should failed
TEST_F(TxnManagerTest, CommitTxnTwiceWithDiffRowsetId) {
Status status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id,
- schema_hash, _tablet_uid, load_id,
_rowset, false);
+ _tablet_uid, load_id, _rowset, false);
EXPECT_TRUE(status == Status::OK());
- status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id, _rowset_diff_id,
false);
+ status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, _tablet_uid,
+ load_id, _rowset_diff_id, false);
EXPECT_TRUE(status != Status::OK());
}
// 1. commit twice with same rowset id
// 2. should success
TEST_F(TxnManagerTest, CommitTxnTwiceWithSameRowsetId) {
Status status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id,
- schema_hash, _tablet_uid, load_id,
_rowset, false);
+ _tablet_uid, load_id, _rowset, false);
EXPECT_TRUE(status == Status::OK());
- status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id, _rowset_same_id,
false);
+ status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, _tablet_uid,
+ load_id, _rowset_same_id, false);
EXPECT_TRUE(status == Status::OK());
}
// 1. prepare twice should be success
TEST_F(TxnManagerTest, PrepareNewTxnTwice) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
+ Status status =
Review Comment:
warning: variable 'status' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
Status status = 0 =
```
##########
be/test/olap/txn_manager_test.cpp:
##########
@@ -210,49 +209,47 @@ TEST_F(TxnManagerTest, CommitTxnWithPrepare) {
// 2. should success
TEST_F(TxnManagerTest, CommitTxnWithNoPrepare) {
Status status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id,
- schema_hash, _tablet_uid, load_id,
_rowset, false);
+ _tablet_uid, load_id, _rowset, false);
EXPECT_TRUE(status == Status::OK());
}
// 1. commit twice with different rowset id
// 2. should failed
TEST_F(TxnManagerTest, CommitTxnTwiceWithDiffRowsetId) {
Status status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id,
- schema_hash, _tablet_uid, load_id,
_rowset, false);
+ _tablet_uid, load_id, _rowset, false);
EXPECT_TRUE(status == Status::OK());
- status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id, _rowset_diff_id,
false);
+ status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, _tablet_uid,
+ load_id, _rowset_diff_id, false);
EXPECT_TRUE(status != Status::OK());
}
// 1. commit twice with same rowset id
// 2. should success
TEST_F(TxnManagerTest, CommitTxnTwiceWithSameRowsetId) {
Status status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id,
- schema_hash, _tablet_uid, load_id,
_rowset, false);
+ _tablet_uid, load_id, _rowset, false);
EXPECT_TRUE(status == Status::OK());
- status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id, _rowset_same_id,
false);
+ status = _txn_mgr->commit_txn(_meta, partition_id, transaction_id,
tablet_id, _tablet_uid,
+ load_id, _rowset_same_id, false);
EXPECT_TRUE(status == Status::OK());
}
// 1. prepare twice should be success
TEST_F(TxnManagerTest, PrepareNewTxnTwice) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
+ Status status =
+ _txn_mgr->prepare_txn(partition_id, transaction_id, tablet_id,
_tablet_uid, load_id);
EXPECT_TRUE(status == Status::OK());
- status = _txn_mgr->prepare_txn(partition_id, transaction_id, tablet_id,
schema_hash,
- _tablet_uid, load_id);
+ status = _txn_mgr->prepare_txn(partition_id, transaction_id, tablet_id,
_tablet_uid, load_id);
EXPECT_TRUE(status == Status::OK());
}
// 1. txn could be rollbacked if it is not committed
TEST_F(TxnManagerTest, RollbackNotCommittedTxn) {
- Status status = _txn_mgr->prepare_txn(partition_id, transaction_id,
tablet_id, schema_hash,
- _tablet_uid, load_id);
+ Status status =
Review Comment:
warning: variable 'status' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
Status status = 0 =
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("127.0.0.1", localhost.c_str());
+}
+
+// priority not loopback
+TEST_F(BackendOptionsTest, emptyCidr2) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
Review Comment:
warning: variable 'cidrs' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::vector<CIDR> cidrs = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
Review Comment:
warning: prefer using 'override' or (rarely) 'final' instead of 'virtual'
[modernize-use-override]
```suggestion
~BackendOptionsTest() override {}
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("127.0.0.1", localhost.c_str());
+}
+
+// priority not loopback
+TEST_F(BackendOptionsTest, emptyCidr2) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
Review Comment:
warning: variable 'localhost' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::string localhost = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("127.0.0.1", localhost.c_str());
+}
+
+// priority not loopback
+TEST_F(BackendOptionsTest, emptyCidr2) {
+ std::vector<InetAddress> hosts;
Review Comment:
warning: variable 'hosts' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::vector<InetAddress> hosts = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
Review Comment:
warning: variable 'hosts' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::vector<InetAddress> hosts = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
Review Comment:
warning: variable 'cidrs' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::vector<CIDR> cidrs = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("127.0.0.1", localhost.c_str());
+}
+
+// priority not loopback
+TEST_F(BackendOptionsTest, emptyCidr2) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("10.10.10.10", localhost.c_str());
+}
+
+// not choose ipv6
+TEST_F(BackendOptionsTest, emptyCidr3) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("fe80::5054:ff:fec9:dee0"), AF_INET6,
false);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
Review Comment:
warning: variable 'cidrs' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::vector<CIDR> cidrs = 0;
```
##########
be/test/util/quantile_state_test.cpp:
##########
@@ -23,10 +23,9 @@
#include "gtest/gtest_pred_impl.h"
namespace doris {
-using DoubleQuantileState = QuantileState<double>;
TEST(QuantileStateTest, merge) {
- DoubleQuantileState empty;
+ QuantileState empty;
Review Comment:
warning: variable 'empty' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
QuantileState empty = 0;
```
##########
be/test/util/backend_options_test.cpp:
##########
@@ -0,0 +1,78 @@
+// 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 "service/backend_options.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include "gtest/gtest_pred_impl.h"
+#include "util/cidr.h"
+
+namespace doris {
+
+class BackendOptionsTest : public testing::Test {
+public:
+ BackendOptionsTest() {}
+ virtual ~BackendOptionsTest() {}
+};
+
+// only loopback
+TEST_F(BackendOptionsTest, emptyCidr1) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("127.0.0.1", localhost.c_str());
+}
+
+// priority not loopback
+TEST_F(BackendOptionsTest, emptyCidr2) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
+ bool bind_ipv6 = false;
+ BackendOptions::analyze_localhost(localhost, bind_ipv6, &cidrs, &hosts);
+ EXPECT_STREQ("10.10.10.10", localhost.c_str());
+}
+
+// not choose ipv6
+TEST_F(BackendOptionsTest, emptyCidr3) {
+ std::vector<InetAddress> hosts;
+ hosts.emplace_back(std::string("127.0.0.1"), AF_INET, true);
+ hosts.emplace_back(std::string("fe80::5054:ff:fec9:dee0"), AF_INET6,
false);
+ hosts.emplace_back(std::string("10.10.10.10"), AF_INET, false);
+ hosts.emplace_back(std::string("10.10.10.11"), AF_INET, false);
+
+ std::vector<CIDR> cidrs;
+ BackendOptions::analyze_priority_cidrs("", &cidrs);
+ std::string localhost;
Review Comment:
warning: variable 'localhost' is not initialized
[cppcoreguidelines-init-variables]
```suggestion
std::string localhost = 0;
```
--
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]