summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-03-22 15:42:53 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-22 05:02:38 +0000
commit3f518249b4cc80d0c739ab249687022cb1d84d30 (patch)
tree2bbfd7bca3563970a8191addab229f292256db9d
parent1da30d832cfd99849f1b400a1f257d5480ca8435 (diff)
downloadmongo-3f518249b4cc80d0c739ab249687022cb1d84d30.tar.gz
Import wiredtiger: ff2387a671b17424b2a0ad95e0d81137496b2aad from branch mongodb-5.0
ref: f6216f19aa..ff2387a671 for: 4.9.0 WT-7268 Coverity reports failures for test_harness code
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/component.h9
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/configuration.h16
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.h2
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/random_generator.h2
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.h5
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/test.h8
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/timestamp_manager.h18
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload_generator.h8
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload_tracking.h8
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload_validation.h13
-rwxr-xr-xsrc/third_party/wiredtiger/test/cppsuite/tests/poc.cxx3
12 files changed, 44 insertions, 50 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index ba494314b98..a4e38297e49 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-5.0",
- "commit": "f6216f19aaf7e66d1617331f69aebe335f0892fa"
+ "commit": "ff2387a671b17424b2a0ad95e0d81137496b2aad"
}
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/component.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/component.h
index 4d4e08164a6..ae8084db1b5 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/component.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/component.h
@@ -38,7 +38,7 @@ namespace test_harness {
*/
class component {
public:
- component(configuration *config) : _config(config) {}
+ component(configuration *config) : _enabled(true), _running(false), _config(config) {}
/*
* The load function should perform all tasks required to setup the component for the main phase
* of the test. An example operation performed in the load phase would be populating a database.
@@ -54,6 +54,12 @@ class component {
*/
virtual void run() = 0;
+ bool
+ is_enabled() const
+ {
+ return _enabled;
+ }
+
/*
* The finish phase is a cleanup phase. Created objects are destroyed here and any final testing
* requirements can be performed in this phase. An example could be the verification of the
@@ -66,6 +72,7 @@ class component {
}
protected:
+ bool _enabled;
volatile bool _running;
configuration *_config;
};
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/configuration.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/configuration.h
index 2e38dc4da52..b42cd91d3c8 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/configuration.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/configuration.h
@@ -41,22 +41,20 @@ class configuration {
int ret = wiredtiger_test_config_validate(
nullptr, nullptr, test_config_name.c_str(), config.c_str());
if (ret != 0)
- throw std::invalid_argument(
- "failed to validate given config, ensure test config exists");
- if (wiredtiger_config_parser_open(
- nullptr, config.c_str(), config.size(), &_config_parser) != 0)
- throw std::invalid_argument(
- "failed to create configuration parser for provided config");
+ testutil_die(EINVAL, "failed to validate given config, ensure test config exists");
+ ret =
+ wiredtiger_config_parser_open(nullptr, config.c_str(), config.size(), &_config_parser);
+ if (ret != 0)
+ testutil_die(EINVAL, "failed to create configuration parser for provided config");
}
configuration(const WT_CONFIG_ITEM &nested)
{
if (nested.type != WT_CONFIG_ITEM::WT_CONFIG_ITEM_STRUCT)
- throw std::invalid_argument("provided config item isn't a structure");
+ testutil_die(EINVAL, "provided config item isn't a structure");
int ret = wiredtiger_config_parser_open(nullptr, nested.str, nested.len, &_config_parser);
if (ret != 0)
- throw std::invalid_argument(
- "failed to create configuration parser for provided sub config");
+ testutil_die(EINVAL, "failed to create configuration parser for provided sub config");
}
~configuration()
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.h
index f3344ff4a30..9c025336150 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.h
@@ -48,7 +48,7 @@ class connection_manager {
public:
/* No copies of the singleton allowed. */
connection_manager(connection_manager const &) = delete;
- void operator=(connection_manager const &) = delete;
+ connection_manager &operator=(connection_manager const &) = delete;
static connection_manager &
instance()
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/random_generator.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/random_generator.h
index 455d4173b86..7df4d7da3fb 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/random_generator.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/random_generator.h
@@ -38,7 +38,7 @@ class random_generator {
public:
/* No copies of the singleton allowed. */
random_generator(random_generator const &) = delete;
- void operator=(random_generator const &) = delete;
+ random_generator &operator=(random_generator const &) = delete;
static random_generator &
instance()
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.h
index e1a4f3e4360..90ecd629fb8 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.h
@@ -117,7 +117,7 @@ class cache_limit_statistic : public statistic {
*/
class runtime_monitor : public component {
public:
- runtime_monitor(configuration *config) : component(config) {}
+ runtime_monitor(configuration *config) : component(config), _ops(1) {}
~runtime_monitor()
{
@@ -126,8 +126,9 @@ class runtime_monitor : public component {
_stats.clear();
}
- /* Delete copy constructor. */
+ /* Delete the copy constructor and the assignment operator. */
runtime_monitor(const runtime_monitor &) = delete;
+ runtime_monitor &operator=(const runtime_monitor &) = delete;
void
load()
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/test.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/test.h
index b2b106bb63d..0bd35e1d9ef 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/test.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/test.h
@@ -90,6 +90,10 @@ class test {
_components.clear();
}
+ /* Delete the copy constructor and the assignment operator. */
+ test(const test &) = delete;
+ test &operator=(const test &) = delete;
+
/*
* The primary run function that most tests will be able to utilize without much other code.
*/
@@ -97,7 +101,7 @@ class test {
run()
{
int64_t cache_size_mb = 100, duration_seconds = 0;
- bool enable_logging, enable_tracking = false, is_success = true;
+ bool enable_logging, is_success = true;
/* Build the database creation config string. */
std::string db_create_config = CONNECTION_CREATE;
@@ -129,7 +133,7 @@ class test {
_thread_manager->join();
/* Validation stage. */
- if (enable_tracking) {
+ if (_workload_tracking->is_enabled()) {
workload_validation wv;
is_success = wv.validate(_workload_tracking->get_operation_table_name(),
_workload_tracking->get_schema_table_name());
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/timestamp_manager.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/timestamp_manager.h
index a1cf1ad8d1d..81490ecc677 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/timestamp_manager.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/timestamp_manager.h
@@ -45,14 +45,11 @@ class timestamp_manager : public component {
public:
timestamp_manager(configuration *config)
: /* _periodic_update_s is hardcoded to 1 second for now. */
- component(config), _increment_ts(0U), _is_enabled(false), _latest_ts(0U), _oldest_lag(0),
- _oldest_ts(0U), _periodic_update_s(1), _stable_lag(0), _stable_ts(0U)
+ component(config), _increment_ts(0U), _latest_ts(0U), _oldest_lag(0), _oldest_ts(0U),
+ _periodic_update_s(1), _stable_lag(0), _stable_ts(0U)
{
}
- /* Delete the copy constructor. */
- timestamp_manager(const timestamp_manager &) = delete;
-
void
load()
{
@@ -61,7 +58,7 @@ class timestamp_manager : public component {
testutil_assert(_oldest_lag >= 0);
testutil_check(_config->get_int(STABLE_LAG, _stable_lag));
testutil_assert(_stable_lag >= 0);
- testutil_check(_config->get_bool(ENABLE_TIMESTAMP, _is_enabled));
+ testutil_check(_config->get_bool(ENABLE_TIMESTAMP, _enabled));
component::load();
}
@@ -72,7 +69,7 @@ class timestamp_manager : public component {
/* latest_ts_s represents the time component of the latest timestamp provided. */
wt_timestamp_t latest_ts_s;
- while (_is_enabled && _running) {
+ while (_enabled && _running) {
/* Timestamps are checked periodically. */
std::this_thread::sleep_for(std::chrono::seconds(_periodic_update_s));
latest_ts_s = (_latest_ts >> 32);
@@ -106,12 +103,6 @@ class timestamp_manager : public component {
}
}
- bool
- is_enabled() const
- {
- return _is_enabled;
- }
-
/*
* Get a unique commit timestamp. The first 32 bits represent the epoch time in seconds. The
* last 32 bits represent an increment for uniqueness.
@@ -148,7 +139,6 @@ class timestamp_manager : public component {
}
private:
- bool _is_enabled;
const wt_timestamp_t _periodic_update_s;
std::atomic<wt_timestamp_t> _increment_ts;
wt_timestamp_t _latest_ts, _oldest_ts, _stable_ts;
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_generator.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_generator.h
index 0b6cc1b2a84..23fbc25ddf9 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_generator.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_generator.h
@@ -54,8 +54,9 @@ class workload_generator : public component {
delete it;
}
- /* Delete the copy constructor. */
+ /* Delete the copy constructor and the assignment operator. */
workload_generator(const workload_generator &) = delete;
+ workload_generator &operator=(const workload_generator &) = delete;
/*
* Function that performs the following steps using the configuration that is defined by the
@@ -129,7 +130,6 @@ class workload_generator : public component {
void
run()
{
- WT_SESSION *session = nullptr;
int64_t duration_seconds, read_threads, min_operation_per_transaction,
max_operation_per_transaction, value_size;
@@ -204,7 +204,6 @@ class workload_generator : public component {
update_operation(thread_context &context, WT_SESSION *session)
{
WT_CURSOR *cursor;
- WT_DECL_RET;
wt_timestamp_t ts;
std::vector<WT_CURSOR *> cursors;
std::vector<std::string> collection_names;
@@ -246,7 +245,6 @@ class workload_generator : public component {
read_operation(thread_context &context, WT_SESSION *session)
{
WT_CURSOR *cursor;
- WT_DECL_RET;
std::vector<WT_CURSOR *> cursors;
testutil_assert(session != nullptr);
@@ -259,7 +257,7 @@ class workload_generator : public component {
while (context.is_running()) {
/* Walk each cursor. */
for (const auto &it : cursors) {
- if ((ret = it->next(it)) != 0)
+ if (it->next(it) != 0)
it->reset(it);
}
}
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_tracking.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_tracking.h
index e8c7d748e79..1233a4ee948 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_tracking.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_tracking.h
@@ -57,16 +57,13 @@ class workload_tracking : public component {
workload_tracking(configuration *_config, const std::string &operation_table_config,
const std::string &operation_table_name, const std::string &schema_table_config,
const std::string &schema_table_name)
- : component(_config), _cursor_operations(nullptr), _cursor_schema(nullptr), _enabled(false),
+ : component(_config), _cursor_operations(nullptr), _cursor_schema(nullptr),
_operation_table_config(operation_table_config),
_operation_table_name(operation_table_name), _schema_table_config(schema_table_config),
_schema_table_name(schema_table_name)
{
}
- /* Delete the copy constructor. */
- workload_tracking(const workload_tracking &) = delete;
-
const std::string &
get_schema_table_name() const
{
@@ -83,7 +80,7 @@ class workload_tracking : public component {
load()
{
WT_SESSION *session;
- /* Is tracking enabled? */
+
testutil_check(_config->get_bool(ENABLE_TRACKING, _enabled));
if (!_enabled)
return;
@@ -150,7 +147,6 @@ class workload_tracking : public component {
private:
WT_CURSOR *_cursor_operations;
WT_CURSOR *_cursor_schema;
- bool _enabled;
const std::string _operation_table_config;
const std::string _operation_table_name;
const std::string _schema_table_config;
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_validation.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_validation.h
index 21d25b0cece..4a3477e2dc2 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_validation.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload_validation.h
@@ -110,7 +110,7 @@ class workload_validation {
/* Clean the allocated memory. */
clean_memory(collections);
- return is_valid;
+ return (is_valid);
}
/* Clean the memory used to represent the collections after the test. */
@@ -165,7 +165,7 @@ class workload_validation {
}
}
- return created_collections;
+ return (created_collections);
}
/*
@@ -245,7 +245,8 @@ class workload_validation {
error_code = cursor->next(cursor);
}
- error_code = cursor->reset(cursor);
+ if (cursor->reset(cursor) != 0)
+ debug_info("Cursor could not be reset !", _trace_level, DEBUG_ERROR);
}
/*
@@ -257,7 +258,7 @@ class workload_validation {
WT_SESSION *session, std::map<std::string, std::map<int, std::string *> *> &collections)
{
- bool collection_exists, is_valid;
+ bool collection_exists, is_valid = true;
std::map<int, std::string *> *collection;
workload_validation wv;
std::string *value;
@@ -302,7 +303,7 @@ class workload_validation {
}
}
- return is_valid;
+ return (is_valid);
}
/* Check what is present on disk against what has been tracked. */
@@ -359,7 +360,7 @@ class workload_validation {
}
}
- return is_valid;
+ return (is_valid);
}
/*
diff --git a/src/third_party/wiredtiger/test/cppsuite/tests/poc.cxx b/src/third_party/wiredtiger/test/cppsuite/tests/poc.cxx
index 2873f95f37c..a1c6d0fb915 100755
--- a/src/third_party/wiredtiger/test/cppsuite/tests/poc.cxx
+++ b/src/third_party/wiredtiger/test/cppsuite/tests/poc.cxx
@@ -110,8 +110,7 @@ int
main(int argc, char *argv[])
{
std::string cfg, filename;
- int64_t trace_level = 0;
- int64_t error_code = 0;
+ int64_t trace_level = 0, error_code = 0;
/* Parse args
* -C : Configuration. Cannot be used with -f.