Skip to content

Commit 1ee7301

Browse files
yiguoleiYour Name
authored andcommitted
[chore](beut) using uuid as dir name to make the test more stable (#62127)
1 parent 6df2128 commit 1ee7301

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

be/test/runtime/workload_group/workload_group_manager_test.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
#include <gen_cpp/Types_types.h>
2323
#include <glog/logging.h>
2424
#include <gtest/gtest.h>
25+
#include <unistd.h>
2526

27+
#include <chrono>
2628
#include <cmath>
27-
#include <cstdlib>
29+
#include <filesystem>
2830
#include <memory>
31+
#include <sstream>
2932

3033
#include "common/config.h"
3134
#include "common/status.h"
@@ -44,10 +47,22 @@ class WorkloadGroupManagerTest : public testing::Test {
4447
protected:
4548
void SetUp() override {
4649
_wg_manager = std::make_unique<WorkloadGroupMgr>();
47-
EXPECT_EQ(system("rm -rf ./wg_test_run && mkdir -p ./wg_test_run"), 0);
50+
// generate a unique test directory to avoid conflicts between parallel runs
51+
std::ostringstream _oss;
52+
_oss << "./wg_test_run_" << std::chrono::system_clock::now().time_since_epoch().count()
53+
<< "_" << getpid();
54+
_test_dir = _oss.str();
55+
56+
std::error_code ec;
57+
std::filesystem::remove_all(_test_dir, ec);
58+
if (ec) {
59+
FAIL() << "Failed to remove " << _test_dir << ": " << ec.message();
60+
}
61+
std::filesystem::create_directories(_test_dir, ec);
62+
ASSERT_FALSE(ec) << "Failed to create " << _test_dir << ": " << ec.message();
4863

4964
std::vector<doris::StorePath> paths;
50-
std::string path = std::filesystem::absolute("./wg_test_run").string();
65+
std::string path = std::filesystem::absolute(_test_dir).string();
5166
auto olap_res = doris::parse_conf_store_paths(path, &paths);
5267
EXPECT_TRUE(olap_res.ok()) << olap_res.to_string();
5368

@@ -76,7 +91,9 @@ class WorkloadGroupManagerTest : public testing::Test {
7691
ExecEnv::GetInstance()->_runtime_query_statistics_mgr->stop_report_thread();
7792
SAFE_DELETE(ExecEnv::GetInstance()->_runtime_query_statistics_mgr);
7893

79-
EXPECT_EQ(system("rm -rf ./wg_test_run"), 0);
94+
std::error_code ec;
95+
std::filesystem::remove_all(_test_dir, ec);
96+
EXPECT_FALSE(ec) << "Failed to remove " << _test_dir << ": " << ec.message();
8097
config::spill_in_paused_queue_timeout_ms = _spill_in_paused_queue_timeout_ms;
8198
doris::ExecEnv::GetInstance()->set_memtable_memory_limiter(nullptr);
8299
}
@@ -115,6 +132,7 @@ class WorkloadGroupManagerTest : public testing::Test {
115132
}
116133

117134
std::unique_ptr<WorkloadGroupMgr> _wg_manager;
135+
std::string _test_dir;
118136
const int64_t _spill_in_paused_queue_timeout_ms = config::spill_in_paused_queue_timeout_ms;
119137
};
120138

0 commit comments

Comments
 (0)