Skip to content

Commit

Permalink
Add long running log store tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanebay committed May 13, 2024
1 parent 74ca779 commit 6f1a673
Show file tree
Hide file tree
Showing 5 changed files with 652 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/logstore/log_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ std::shared_ptr< HomeLogStore > LogDev::create_new_log_store(bool append_mode) {
HS_REL_ASSERT((it == m_id_logstore_map.end()), "store_id {}-{} already exists", m_logdev_id, store_id);
m_id_logstore_map.insert(std::pair(store_id, logstore_info{.log_store = lstore, .append_mode = append_mode}));
}
LOGINFO("Created log store log_dev={} log_store={}", m_logdev_id, store_id);
HS_LOG(INFO, logstore, "Created log store log_dev={} log_store={}", m_logdev_id, store_id);
return lstore;
}

Expand Down
12 changes: 6 additions & 6 deletions src/lib/logstore/log_store_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ logdev_id_t LogStoreService::create_new_logdev() {
auto logdev = create_new_logdev_internal(logdev_id);
logdev->start(true /* format */);
COUNTER_INCREMENT(m_metrics, logdevs_count, 1);
LOGINFO("Created log_dev={}", logdev_id);
HS_LOG(INFO, logstore, "Created log_dev={}", logdev_id);
return logdev_id;
}

Expand All @@ -149,12 +149,12 @@ void LogStoreService::destroy_log_dev(logdev_id_t logdev_id) {

m_id_logdev_map.erase(it);
COUNTER_DECREMENT(m_metrics, logdevs_count, 1);
LOGINFO("Removed log_dev={}", logdev_id);
HS_LOG(INFO, logstore, "Removed log_dev={}", logdev_id);
}

void LogStoreService::delete_unopened_logdevs() {
for (auto logdev_id : m_unopened_logdev) {
LOGINFO("Deleting unopened log_dev={}", logdev_id);
HS_LOG(INFO, logstore, "Deleting unopened log_dev={}", logdev_id);
destroy_log_dev(logdev_id);
}
m_unopened_logdev.clear();
Expand All @@ -176,7 +176,7 @@ void LogStoreService::open_logdev(logdev_id_t logdev_id) {
auto logdev = std::make_shared< LogDev >(logdev_id, m_logdev_vdev.get());
m_id_logdev_map.emplace(logdev_id, logdev);
}
LOGDEBUGMOD(logstore, "Opened log_dev={}", logdev_id);
HS_LOG(INFO, logstore, "Opened log_dev={}", logdev_id);
}

std::vector< std::shared_ptr< LogDev > > LogStoreService::get_all_logdevs() {
Expand Down Expand Up @@ -204,7 +204,7 @@ void LogStoreService::logdev_super_blk_found(const sisl::byte_view& buf, void* m
folly::SharedMutexWritePriority::WriteHolder holder(m_logdev_map_mtx);
std::shared_ptr< LogDev > logdev;
auto id = sb->logdev_id;
LOGDEBUGMOD(logstore, "Log dev superblk found logdev={}", id);
HS_LOG(DEBUG, logstore, "Log dev superblk found logdev={}", id);
const auto it = m_id_logdev_map.find(id);
if (it == m_id_logdev_map.end()) {
LOGERROR("logdev={} found but not opened yet, it will be discarded after logstore is started", id);
Expand Down Expand Up @@ -233,7 +233,7 @@ void LogStoreService::rollback_super_blk_found(const sisl::byte_view& buf, void*
folly::SharedMutexWritePriority::WriteHolder holder(m_logdev_map_mtx);
std::shared_ptr< LogDev > logdev;
auto id = rollback_sb->logdev_id;
LOGDEBUGMOD(logstore, "Log dev rollback superblk found logdev={}", id);
HS_LOG(DEBUG, logstore, "Log dev rollback superblk found logdev={}", id);
const auto it = m_id_logdev_map.find(id);
if (it == m_id_logdev_map.end()) {
LOGERROR("logdev={} found but not opened yet, it will be discarded after logstore is started", id);
Expand Down
4 changes: 4 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ if (${io_tests})
target_sources(test_log_dev PRIVATE test_log_dev.cpp)
target_link_libraries(test_log_dev hs_logdev homestore ${COMMON_TEST_DEPS} )

add_executable(test_log_store_long_run)
target_sources(test_log_store_long_run PRIVATE test_log_store_long_run.cpp)
target_link_libraries(test_log_store_long_run hs_logdev homestore ${COMMON_TEST_DEPS})

set(TEST_METABLK_SOURCE_FILES test_meta_blk_mgr.cpp)
add_executable(test_meta_blk_mgr ${TEST_METABLK_SOURCE_FILES})
target_link_libraries(test_meta_blk_mgr homestore ${COMMON_TEST_DEPS} GTest::gmock)
Expand Down
1 change: 1 addition & 0 deletions src/tests/test_log_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ class SampleDB {
restart);

if (!restart) {
// Create one logdev for each logstore.
std::vector< logdev_id_t > logdev_id_vec;
for (uint32_t i{0}; i < n_log_stores; ++i) {
logdev_id_vec.push_back(logstore_service().create_new_logdev());
Expand Down
Loading

0 comments on commit 6f1a673

Please sign in to comment.