Skip to content

Commit

Permalink
Fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed May 18, 2022
1 parent 350f337 commit f7c8d8a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 9 additions & 1 deletion dbms/src/Storages/Page/V2/PageFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,15 @@ size_t PageFile::Writer::write(DB::WriteBatch & wb, PageEntriesEdit & edit, cons
SCOPE_EXIT({ page_file.free(data_buf.begin(), data_buf.size()); });

auto write_buf = [&](WritableFilePtr & file, UInt64 offset, ByteBuffer buf, bool enable_failpoint) {
PageUtil::writeFile(file, offset, buf.begin(), buf.size(), write_limiter, background, enable_failpoint);
PageUtil::writeFile(
file,
offset,
buf.begin(),
buf.size(),
write_limiter,
background,
/*truncate_if_failed=*/true,
/*enable_failpoint=*/enable_failpoint);
if (sync_on_write)
PageUtil::syncFile(file);
};
Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Storages/Page/V2/tests/gtest_page_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace tests
{
static const std::string FileName = "page_util_test";

TEST(PageUtils_test, ReadWriteFile)
TEST(PageUtilsTest, ReadWriteFile)
{
::remove(FileName.c_str());

Expand All @@ -53,15 +53,15 @@ TEST(PageUtils_test, ReadWriteFile)
::remove(FileName.c_str());
}

TEST(PageUtils_test, FileNotExists)
TEST(PageUtilsTest, FileNotExists)
{
::remove(FileName.c_str());

int fd = PageUtil::openFile<true, false>(FileName);
ASSERT_EQ(fd, 0);
}

TEST(PageUtils_test, BigReadWriteFile)
TEST(PageUtilsTest, BigReadWriteFile)
{
::remove(FileName.c_str());

Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/Page/V3/BlobFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ void BlobFile::write(char * buffer, size_t offset, size_t size, const WriteLimit
});

#ifndef NDEBUG
PageUtil::writeFile(wrfile, offset, buffer, size, write_limiter, background, /*truncate_if_failed*/ false, /*enable_failpoint*/ true);
PageUtil::writeFile(wrfile, offset, buffer, size, write_limiter, background, /*truncate_if_failed=*/false, /*enable_failpoint=*/true);
#else
PageUtil::writeFile(wrfile, offset, buffer, size, write_limiter, background, /*truncate_if_failed*/ false, /*enable_failpoint*/ false);
PageUtil::writeFile(wrfile, offset, buffer, size, write_limiter, background, /*truncate_if_failed=*/false, /*enable_failpoint=*/false);
#endif
PageUtil::syncFile(wrfile);

Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Storages/Page/V3/LogFile/LogWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ void LogWriter::flush(const WriteLimiterPtr & write_limiter, const bool backgrou
write_buffer.buffer().begin(),
write_buffer.offset(),
write_limiter,
/*background*/ background,
/*truncate_if_failed*/ false,
/*enable_failpoint*/ false);
/*background=*/background,
/*truncate_if_failed=*/false,
/*enable_failpoint=*/false);
log_file->fsync();
written_bytes += write_buffer.offset();

Expand Down

0 comments on commit f7c8d8a

Please sign in to comment.