diff --git a/dist/test_data.py b/dist/test_data.py index a34f75d45..b5d5251ce 100644 --- a/dist/test_data.py +++ b/dist/test_data.py @@ -121,6 +121,11 @@ timestamp_manager = enable_config + [ The duration between the latest and stable timestamps''', min=0, max=1000000), ] +# +# Configuration that applies to the checkpoint_manager component. +# +checkpoint_manager = enable_config + throttle_config + # # Configuration that applies to the workload tracking component. # @@ -160,6 +165,9 @@ test_config = [ Config('workload_tracking','', r''' Configuration options for the workload tracker''', type='category', subconfig=workload_tracking), + Config('checkpoint_manager', '', r''' + Configuration options for the timestamp manager''', + type='category', subconfig=checkpoint_manager), # Non component top level configuration. Config('cache_size_mb', 0, r''' diff --git a/src/config/test_config.c b/src/config/test_config.c index 7843c8b54..5dd9877a7 100644 --- a/src/config/test_config.c +++ b/src/config/test_config.c @@ -2,6 +2,10 @@ #include "wt_internal.h" +static const WT_CONFIG_CHECK confchk_checkpoint_manager_subconfigs[] = { + {"enabled", "boolean", NULL, NULL, NULL, 0}, + {"rate_per_second", "int", NULL, "min=1,max=1000", NULL, 0}, {NULL, NULL, NULL, NULL, NULL, 0}}; + static const WT_CONFIG_CHECK confchk_stat_cache_size_subconfigs[] = { {"enabled", "boolean", NULL, NULL, NULL, 0}, {"limit", "string", NULL, NULL, NULL, 0}, {NULL, NULL, NULL, NULL, NULL, 0}}; @@ -45,6 +49,7 @@ static const WT_CONFIG_CHECK confchk_workload_tracking_subconfigs[] = { static const WT_CONFIG_CHECK confchk_example_test[] = { {"cache_size_mb", "int", NULL, "min=0,max=100000000000", NULL, 0}, + {"checkpoint_manager", "category", NULL, NULL, confchk_checkpoint_manager_subconfigs, 2}, {"duration_seconds", "int", NULL, "min=0,max=1000000", NULL, 0}, {"enable_logging", "boolean", NULL, NULL, NULL, 0}, {"runtime_monitor", "category", NULL, NULL, confchk_runtime_monitor_subconfigs, 2}, @@ -55,6 +60,7 @@ static const WT_CONFIG_CHECK confchk_example_test[] = { static const WT_CONFIG_CHECK confchk_poc_test[] = { {"cache_size_mb", "int", NULL, "min=0,max=100000000000", NULL, 0}, + {"checkpoint_manager", "category", NULL, NULL, confchk_checkpoint_manager_subconfigs, 2}, {"duration_seconds", "int", NULL, "min=0,max=1000000", NULL, 0}, {"enable_logging", "boolean", NULL, NULL, NULL, 0}, {"runtime_monitor", "category", NULL, NULL, confchk_runtime_monitor_subconfigs, 2}, @@ -65,7 +71,8 @@ static const WT_CONFIG_CHECK confchk_poc_test[] = { static const WT_CONFIG_ENTRY config_entries[] = { {"example_test", - "cache_size_mb=0,duration_seconds=0,enable_logging=true," + "cache_size_mb=0,checkpoint_manager=(enabled=false," + "rate_per_second=1),duration_seconds=0,enable_logging=true," "runtime_monitor=(rate_per_second=1," "stat_cache_size=(enabled=false,limit=))," "timestamp_manager=(enabled=false,oldest_lag=0,stable_lag=0)," @@ -74,9 +81,10 @@ static const WT_CONFIG_ENTRY config_entries[] = { "ops_per_transaction=(max=1,min=),read_threads=0," "update_config=(key_size=0,value_size=0),update_threads=0," "value_size=0),workload_tracking=(enabled=false)", - confchk_example_test, 7}, + confchk_example_test, 8}, {"poc_test", - "cache_size_mb=0,duration_seconds=0,enable_logging=true," + "cache_size_mb=0,checkpoint_manager=(enabled=false," + "rate_per_second=1),duration_seconds=0,enable_logging=true," "runtime_monitor=(rate_per_second=1," "stat_cache_size=(enabled=false,limit=))," "timestamp_manager=(enabled=false,oldest_lag=0,stable_lag=0)," @@ -85,7 +93,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { "ops_per_transaction=(max=1,min=),read_threads=0," "update_config=(key_size=0,value_size=0),update_threads=0," "value_size=0),workload_tracking=(enabled=false)", - confchk_poc_test, 7}, + confchk_poc_test, 8}, {NULL, NULL, NULL, 0}}; /* diff --git a/test/cppsuite/configs/config_example_test_default.txt b/test/cppsuite/configs/config_example_test_default.txt index 6cc427529..ab461b380 100644 --- a/test/cppsuite/configs/config_example_test_default.txt +++ b/test/cppsuite/configs/config_example_test_default.txt @@ -17,6 +17,10 @@ timestamp_manager= oldest_lag=1, stable_lag=1 ), +checkpoint_manager= +( + enabled=true, +), workload_generator= ( collection_count=2, diff --git a/test/cppsuite/configs/config_poc_test_default.txt b/test/cppsuite/configs/config_poc_test_default.txt index 1c8a865ca..73b79a7b2 100644 --- a/test/cppsuite/configs/config_poc_test_default.txt +++ b/test/cppsuite/configs/config_poc_test_default.txt @@ -13,6 +13,10 @@ runtime_monitor= limit=100 ) ), +checkpoint_manager= +( + enabled=true, +), timestamp_manager= ( enabled=true, diff --git a/test/cppsuite/test_harness/api_const.h b/test/cppsuite/test_harness/api_const.h index bccb3b9a6..9e95fd806 100644 --- a/test/cppsuite/test_harness/api_const.h +++ b/test/cppsuite/test_harness/api_const.h @@ -33,6 +33,7 @@ namespace test_harness { /* Component names. */ +static const char *CHECKPOINT_MANAGER = "checkpoint_manager"; static const char *RUNTIME_MONITOR = "runtime_monitor"; static const char *TIMESTAMP_MANAGER = "timestamp_manager"; static const char *WORKLOAD_GENERATOR = "workload_generator"; diff --git a/test/cppsuite/test_harness/checkpoint_manager.h b/test/cppsuite/test_harness/checkpoint_manager.h new file mode 100644 index 000000000..f26ae3573 --- /dev/null +++ b/test/cppsuite/test_harness/checkpoint_manager.h @@ -0,0 +1,78 @@ +/*- + * Public Domain 2014-present MongoDB, Inc. + * Public Domain 2008-2014 WiredTiger, Inc. + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef CHECKPOINT_MANAGER_H +#define CHECKPOINT_MANAGER_H + +#include + +#include "component.h" + +namespace test_harness { +/* + * The checkpoint monitor class generates checkpoints periodically. + */ +class checkpoint_manager : public component { + public: + checkpoint_manager(configuration *config) + : component(config), _session(nullptr), _periodic_update_s(1) + { + } + + void + load() + { + component::load(); + } + + void + run() + { + while (_enabled && _running) { + std::this_thread::sleep_for(std::chrono::seconds(_periodic_update_s)); + if (_session == nullptr) + testutil_die(DEBUG_ABORT, + "checkpoint_manager: session is null, did you forget to call set_session() ?"); + _session->checkpoint(_session, nullptr); + std::cout << "Checkpoint done !" << std::endl; + } + } + + void + set_session(WT_SESSION *session) + { + _session = session; + } + + private: + WT_SESSION *_session = nullptr; + const wt_timestamp_t _periodic_update_s; +}; +} // namespace test_harness + +#endif diff --git a/test/cppsuite/test_harness/test.h b/test/cppsuite/test_harness/test.h index 3f154a829..75f3f1fab 100644 --- a/test/cppsuite/test_harness/test.h +++ b/test/cppsuite/test_harness/test.h @@ -41,6 +41,7 @@ extern "C" { #include "api_const.h" #include "component.h" #include "configuration.h" +#include "checkpoint_manager.h" #include "connection_manager.h" #include "runtime_monitor.h" #include "timestamp_manager.h" @@ -59,6 +60,7 @@ class test : public database_operation { _workload_generator(nullptr), _workload_tracking(nullptr) { _config = new configuration(name, config); + _checkpoint_manager = new checkpoint_manager(_config->get_subconfig(CHECKPOINT_MANAGER)); _runtime_monitor = new runtime_monitor(_config->get_subconfig(RUNTIME_MONITOR)); _timestamp_manager = new timestamp_manager(_config->get_subconfig(TIMESTAMP_MANAGER)); _workload_tracking = new workload_tracking(_config->get_subconfig(WORKLOAD_TRACKING), @@ -71,20 +73,22 @@ class test : public database_operation { * Ordering is not important here, any dependencies between components should be resolved * internally by the components. */ - _components = { - _workload_tracking, _workload_generator, _timestamp_manager, _runtime_monitor}; + _components = {_workload_tracking, _workload_generator, _timestamp_manager, + _checkpoint_manager, _runtime_monitor}; } ~test() { delete _config; delete _runtime_monitor; + delete _checkpoint_manager; delete _timestamp_manager; delete _thread_manager; delete _workload_generator; delete _workload_tracking; _config = nullptr; _runtime_monitor = nullptr; + _checkpoint_manager = nullptr; _timestamp_manager = nullptr; _thread_manager = nullptr; _workload_generator = nullptr; @@ -118,6 +122,8 @@ class test : public database_operation { /* Set up the test environment. */ connection_manager::instance().create(db_create_config); + _checkpoint_manager->set_session(connection_manager::instance().create_session()); + /* Initiate the load stage of each component. */ for (const auto &it : _components) it->load(); @@ -181,6 +187,7 @@ class test : public database_operation { configuration *_config; runtime_monitor *_runtime_monitor; thread_manager *_thread_manager; + checkpoint_manager *_checkpoint_manager; timestamp_manager *_timestamp_manager; workload_generator *_workload_generator; workload_tracking *_workload_tracking;