Skip to content

Commit 3e2709e

Browse files
authored
[fix](group commit)Fix wal manager ut (apache#48882)
pick pr:apache#48789
1 parent 3f6a701 commit 3e2709e

File tree

5 files changed

+360
-491
lines changed

5 files changed

+360
-491
lines changed

be/src/runtime/exec_env.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ class ExecEnv {
294294
void set_routine_load_task_executor(RoutineLoadTaskExecutor* r) {
295295
this->_routine_load_task_executor = r;
296296
}
297-
void set_wal_mgr(std::shared_ptr<WalManager> wm) { this->_wal_manager = wm; }
297+
void set_wal_mgr(std::shared_ptr<WalManager>&& wm);
298+
void clear_wal_mgr();
298299
void set_dummy_lru_cache(std::shared_ptr<DummyLRUCache> dummy_lru_cache) {
299300
this->_dummy_lru_cache = dummy_lru_cache;
300301
}

be/src/runtime/exec_env_init.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,15 @@ Status ExecEnv::_check_deploy_mode() {
643643
return Status::OK();
644644
}
645645

646+
#ifdef BE_TEST
647+
void ExecEnv::set_wal_mgr(std::shared_ptr<WalManager>&& wm) {
648+
this->_wal_manager = std::move(wm);
649+
}
650+
void ExecEnv::clear_wal_mgr() {
651+
this->_wal_manager.reset();
652+
}
653+
#endif
654+
646655
// TODO(zhiqiang): Need refactor all thread pool. Each thread pool must have a Stop method.
647656
// We need to stop all threads before releasing resource.
648657
void ExecEnv::destroy() {

be/test/http/stream_load_test.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ class StreamLoadTest : public testing::Test {
4545
StreamLoadTest() = default;
4646
virtual ~StreamLoadTest() = default;
4747
void SetUp() override {}
48-
void TearDown() override {}
48+
void TearDown() override {
49+
SAFE_STOP(ExecEnv::GetInstance()->_wal_manager);
50+
ExecEnv::GetInstance()->clear_wal_mgr();
51+
}
4952
};
5053

5154
void http_request_done_cb(struct evhttp_request* req, void* arg) {
@@ -58,7 +61,7 @@ TEST_F(StreamLoadTest, TestHeader) {
5861
static_cast<void>(wal_mgr->_wal_dirs_info->add("test_path_1", 1000, 0, 0));
5962
static_cast<void>(wal_mgr->_wal_dirs_info->add("test_path_2", 10000, 0, 0));
6063
static_cast<void>(wal_mgr->_wal_dirs_info->add("test_path_3", 100000, 0, 0));
61-
ExecEnv::GetInstance()->set_wal_mgr(wal_mgr);
64+
ExecEnv::GetInstance()->set_wal_mgr(std::move(wal_mgr));
6265
// 1. empty info
6366
{
6467
auto* evhttp_req = evhttp_request_new(nullptr, nullptr);

0 commit comments

Comments
 (0)