Skip to content

Commit

Permalink
add gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu committed Jul 15, 2022
1 parent d39d830 commit 35d1d99
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dbms/src/Storages/Page/V2/tests/gtest_page_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,38 @@ try
}
CATCH

TEST_F(PageStorage_test, RenewWriter)
try
{
constexpr size_t buf_sz = 100;
char c_buff[buf_sz];

{
WriteBatch wb;
memset(c_buff, 0xf, buf_sz);
auto buf = std::make_shared<ReadBufferFromMemory>(c_buff, sizeof(c_buff));
wb.putPage(1, 0, buf, buf_sz);
storage->write(std::move(wb));
}

{
PageStorage::ListPageFilesOption opt;
auto page_files = storage->listAllPageFiles(file_provider, storage->delegator, storage->log, opt);
ASSERT_EQ(page_files.size(), 1UL);
}

PageStorage::Config config;
config.file_roll_size = 10; // make it easy to renew a new page file for write
storage = reopenWithConfig(config);

{
PageStorage::ListPageFilesOption opt;
auto page_files = storage->listAllPageFiles(file_provider, storage->delegator, storage->log, opt);
ASSERT_EQ(page_files.size(), 2UL);
}
}
CATCH

/// Check if we can correctly do read / write after restore from disk.
TEST_F(PageStorage_test, WriteReadRestore)
try
Expand Down

0 comments on commit 35d1d99

Please sign in to comment.