Skip to content

Commit

Permalink
[branch-2.1](beut) fix BE UT (#36147)
Browse files Browse the repository at this point in the history
only for branch-2.1
  • Loading branch information
morningman authored Jun 12, 2024
1 parent c78c7f6 commit b75533e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions be/test/olap/segment_cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ static void set_up() {

doris::EngineOptions options;
options.store_paths = paths;
auto engine = std::make_unique<StorageEngine>(options);
engine_ref = engine.get();
Status s = engine->open();
engine_ref = new StorageEngine(options);
Status s = engine_ref->open();
ASSERT_TRUE(s.ok()) << s;
ASSERT_TRUE(s.ok()) << s;

Expand All @@ -95,6 +94,7 @@ static void set_up() {
static void tear_down() {
ExecEnv* exec_env = doris::ExecEnv::GetInstance();
exec_env->set_memtable_memory_limiter(nullptr);
delete engine_ref;
engine_ref = nullptr;
exec_env->set_storage_engine(nullptr);
EXPECT_EQ(system("rm -rf ./segment_cache_test"), 0);
Expand Down
8 changes: 3 additions & 5 deletions be/test/olap/single_compaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SingleCompactionTest : public ::testing::Test {
void SetUp() override {
const std::string dir_path = "ut_dir/single_compact_test";
_engine = new StorageEngine({});
_data_dir = new DataDir(*_engine, dir_path);
_data_dir = new DataDir(dir_path);
engine_ref = _engine;
}

Expand Down Expand Up @@ -80,8 +80,7 @@ class SingleCompactionTest : public ::testing::Test {
TEST_F(SingleCompactionTest, test_single) {
TabletSharedPtr tablet = create_tablet(10001);

SingleReplicaCompaction single_compaction(*engine_ref, tablet,
CompactionType::CUMULATIVE_COMPACTION);
SingleReplicaCompaction single_compaction(tablet, CompactionType::CUMULATIVE_COMPACTION);
auto st = tablet->init();
ASSERT_TRUE(st.ok()) << st;
// load 30 rowsets
Expand Down Expand Up @@ -119,8 +118,7 @@ TEST_F(SingleCompactionTest, test_single) {
TEST_F(SingleCompactionTest, test_unmatch) {
TabletSharedPtr tablet = create_tablet(10000);

SingleReplicaCompaction single_compaction(*engine_ref, tablet,
CompactionType::CUMULATIVE_COMPACTION);
SingleReplicaCompaction single_compaction(tablet, CompactionType::CUMULATIVE_COMPACTION);
auto st = tablet->init();
ASSERT_TRUE(st.ok()) << st;
// local rowset [4-6]
Expand Down
18 changes: 12 additions & 6 deletions be/test/vec/exec/delta_writer_v2_pool_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ TEST_F(DeltaWriterV2PoolTest, test_map) {
EXPECT_EQ(1, pool.size());
WriteRequest req;
RuntimeState state;
auto writer = map->get_or_create(
100, [&req, &state]() { return DeltaWriterV2::open(&req, {}, &state); });
auto writer2 = map->get_or_create(
101, [&req, &state]() { return DeltaWriterV2::open(&req, {}, &state); });
auto writer3 = map->get_or_create(
100, [&req, &state]() { return DeltaWriterV2::open(&req, {}, &state); });
auto writer = map->get_or_create(100, [&req, &state]() {
return std::make_unique<DeltaWriterV2>(
&req, std::vector<std::shared_ptr<LoadStreamStub>> {}, &state);
});
auto writer2 = map->get_or_create(101, [&req, &state]() {
return std::make_unique<DeltaWriterV2>(
&req, std::vector<std::shared_ptr<LoadStreamStub>> {}, &state);
});
auto writer3 = map->get_or_create(100, [&req, &state]() {
return std::make_unique<DeltaWriterV2>(
&req, std::vector<std::shared_ptr<LoadStreamStub>> {}, &state);
});
EXPECT_EQ(2, map->size());
EXPECT_EQ(writer, writer3);
EXPECT_NE(writer, writer2);
Expand Down
4 changes: 2 additions & 2 deletions be/test/vec/function/function_string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ TEST(function_string_test, function_lpad_test) {
{{std::string("hi"), 0, std::string("?")}, std::string("")},
{{std::string("hi"), -1, std::string("?")}, Null()},
{{std::string("h"), 1, std::string("")}, std::string("h")},
{{std::string("hi"), 5, std::string("")}, Null()},
{{std::string("hi"), 5, std::string("")}, std::string("")},
{{std::string("hi"), 5, std::string("ab")}, std::string("abahi")},
{{std::string("hi"), 5, std::string("呵呵")}, std::string("呵呵呵hi")},
{{std::string("呵呵"), 5, std::string("hi")}, std::string("hih呵呵")}};
Expand All @@ -304,7 +304,7 @@ TEST(function_string_test, function_rpad_test) {
{{std::string("hi"), 0, std::string("?")}, std::string("")},
{{std::string("hi"), -1, std::string("?")}, Null()},
{{std::string("h"), 1, std::string("")}, std::string("h")},
{{std::string("hi"), 5, std::string("")}, Null()},
{{std::string("hi"), 5, std::string("")}, std::string("")},
{{std::string("hi"), 5, std::string("ab")}, std::string("hiaba")},
{{std::string("hi"), 5, std::string("呵呵")}, std::string("hi呵呵呵")},
{{std::string("呵呵"), 5, std::string("hi")}, std::string("呵呵hih")}};
Expand Down

0 comments on commit b75533e

Please sign in to comment.