github-actions[bot] commented on code in PR #29759:
URL: https://github.com/apache/doris/pull/29759#discussion_r1446927972


##########
be/test/olap/wal/wal_dirs_info_test.cpp:
##########
@@ -0,0 +1,132 @@
+// 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 "olap/wal/wal_dirs_info.h"
+
+#include <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+namespace doris {
+
+class WalDirsInfoTest : public testing::Test {
+public:
+    WalDirsInfoTest() = default;
+    ~WalDirsInfoTest() override = default;
+    void SetUp() override {

Review Comment:
   warning: method 'SetUp' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
       static void SetUp() override {
   ```
   



##########
be/src/olap/wal/wal_dirs_info.cpp:
##########
@@ -201,4 +213,18 @@ Status WalDirsInfo::get_wal_dir_available_size(const 
std::string& wal_dir,
     return Status::InternalError("can not find wal dir!");
 }
 
+Status WalDirsInfo::get_wal_dir_info(const std::string& wal_dir,

Review Comment:
   warning: method 'get_wal_dir_info' can be made static 
[readability-convert-member-functions-to-static]
   
   be/src/olap/wal/wal_dirs_info.h:76:
   ```diff
   -     Status get_wal_dir_info(const std::string& wal_dir, 
std::shared_ptr<WalDirInfo>& wal_dir_info);
   +     static Status get_wal_dir_info(const std::string& wal_dir, 
std::shared_ptr<WalDirInfo>& wal_dir_info);
   ```
   



##########
be/test/olap/wal/wal_dirs_info_test.cpp:
##########
@@ -0,0 +1,132 @@
+// 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 "olap/wal/wal_dirs_info.h"
+
+#include <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+namespace doris {
+
+class WalDirsInfoTest : public testing::Test {
+public:
+    WalDirsInfoTest() = default;
+    ~WalDirsInfoTest() override = default;
+    void SetUp() override {
+        // limit 1000 used 100 preallocated 200 available 700
+        Status st = wal_dirs_info.add(wal_dir_test_1, 0, 0, 0);
+        EXPECT_EQ(st, Status::OK());
+        // limit 1000 used 200 preallocated 300 available 500
+        st = wal_dirs_info.add(wal_dir_test_2, 0, 0, 0);
+        EXPECT_EQ(st, Status::OK());
+        // limit 1000 used 400 preallocated 500 available 100
+        st = wal_dirs_info.add(wal_dir_test_3, 0, 0, 0);
+        EXPECT_EQ(st, Status::OK());
+    }
+    void TearDown() override {}
+
+    void set_and_check_success(std::string wal_dir, size_t limit, size_t used,

Review Comment:
   warning: method 'set_and_check_success' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
       static void set_and_check_success(std::string wal_dir, size_t limit, 
size_t used,
   ```
   



##########
be/test/olap/wal/wal_dirs_info_test.cpp:
##########
@@ -0,0 +1,132 @@
+// 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 "olap/wal/wal_dirs_info.h"
+
+#include <gtest/gtest.h>
+
+#include <cstddef>
+#include <memory>
+
+namespace doris {
+
+class WalDirsInfoTest : public testing::Test {
+public:
+    WalDirsInfoTest() = default;
+    ~WalDirsInfoTest() override = default;
+    void SetUp() override {
+        // limit 1000 used 100 preallocated 200 available 700
+        Status st = wal_dirs_info.add(wal_dir_test_1, 0, 0, 0);
+        EXPECT_EQ(st, Status::OK());
+        // limit 1000 used 200 preallocated 300 available 500
+        st = wal_dirs_info.add(wal_dir_test_2, 0, 0, 0);
+        EXPECT_EQ(st, Status::OK());
+        // limit 1000 used 400 preallocated 500 available 100
+        st = wal_dirs_info.add(wal_dir_test_3, 0, 0, 0);
+        EXPECT_EQ(st, Status::OK());
+    }
+    void TearDown() override {}
+
+    void set_and_check_success(std::string wal_dir, size_t limit, size_t used,
+                               size_t pre_allocated) {
+        Status st = wal_dirs_info.update_wal_dir_limit(wal_dir, limit);
+        EXPECT_EQ(st, Status::OK());
+        std::shared_ptr<WalDirInfo> wal_dir_info;
+        st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+        EXPECT_NE(wal_dir_info, nullptr);
+        EXPECT_EQ(st, Status::OK());
+        EXPECT_EQ(wal_dir_info->get_limit(), limit);
+
+        st = wal_dirs_info.update_wal_dir_used(wal_dir, used);
+        EXPECT_EQ(st, Status::OK());
+        st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+        EXPECT_NE(wal_dir_info, nullptr);
+        EXPECT_EQ(st, Status::OK());
+        EXPECT_EQ(wal_dir_info->get_used(), used);
+
+        st = wal_dirs_info.update_wal_dir_pre_allocated(wal_dir, 
pre_allocated, 0);
+        EXPECT_EQ(st, Status::OK());
+        st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+        EXPECT_NE(wal_dir_info, nullptr);
+        EXPECT_EQ(st, Status::OK());
+        EXPECT_EQ(wal_dir_info->get_pre_allocated(), pre_allocated);
+
+        st = wal_dirs_info.update_wal_dir_pre_allocated(wal_dir, 0, 
pre_allocated);
+        EXPECT_EQ(st, Status::OK());
+        st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+        EXPECT_NE(wal_dir_info, nullptr);
+        EXPECT_EQ(st, Status::OK());
+        EXPECT_EQ(wal_dir_info->get_pre_allocated(), 0);
+
+        st = wal_dirs_info.update_wal_dir_pre_allocated(wal_dir, 
pre_allocated, 0);
+        EXPECT_EQ(st, Status::OK());
+        st = wal_dirs_info.get_wal_dir_info(wal_dir, wal_dir_info);
+        EXPECT_NE(wal_dir_info, nullptr);
+        EXPECT_EQ(st, Status::OK());
+        EXPECT_EQ(wal_dir_info->get_pre_allocated(), pre_allocated);
+
+        EXPECT_EQ(wal_dir_info->available(), limit - used - pre_allocated);
+    }
+
+    void set_and_check_fail(std::string wal_dir, size_t limit, size_t used, 
size_t pre_allocated) {

Review Comment:
   warning: method 'set_and_check_fail' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
       static void set_and_check_fail(std::string wal_dir, size_t limit, size_t 
used, size_t pre_allocated) {
   ```
   



-- 
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

Reply via email to