summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/cppsuite/test_harness
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/test/cppsuite/test_harness')
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.cxx6
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.h6
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.cxx28
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.h3
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/util/logger.h4
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/util/scoped_types.h4
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.cxx3
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.h4
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.h1
-rw-r--r--src/third_party/wiredtiger/test/cppsuite/test_harness/workload/workload_tracking.cxx11
10 files changed, 53 insertions, 17 deletions
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.cxx b/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.cxx
index 6ff134c7c96..8a8b75b7b8f 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.cxx
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/connection_manager.cxx
@@ -80,6 +80,12 @@ connection_manager::create_session()
return (session);
}
+WT_CONNECTION *
+connection_manager::get_connection()
+{
+ return (_conn);
+}
+
/*
* set_timestamp calls into the connection API in a thread safe manner to set global timestamps.
*/
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 c6245160df1..a5d44903717 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
@@ -30,8 +30,12 @@
#define CONN_API_H
/* Following definitions are required in order to use printing format specifiers in C++. */
+#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
+#endif
#include <mutex>
@@ -60,6 +64,8 @@ class connection_manager {
void create(const std::string &config, const std::string &home = DEFAULT_DIR);
scoped_session create_session();
+ WT_CONNECTION *get_connection();
+
/*
* set_timestamp calls into the connection API in a thread safe manner to set global timestamps.
*/
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.cxx b/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.cxx
index ebb6520b465..0e454a4f4f0 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.cxx
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/runtime_monitor.cxx
@@ -36,16 +36,6 @@
namespace test_harness {
/* Static methods implementation. */
-static void
-get_stat(scoped_cursor &cursor, int stat_field, int64_t *valuep)
-{
- const char *desc, *pvalue;
- cursor->set_key(cursor.get(), stat_field);
- testutil_check(cursor->search(cursor.get()));
- testutil_check(cursor->get_value(cursor.get(), &desc, &pvalue, valuep));
- testutil_check(cursor->reset(cursor.get()));
-}
-
static std::string
collection_name_to_file_name(const std::string &collection_name)
{
@@ -100,9 +90,9 @@ cache_limit_statistic::check(scoped_cursor &cursor)
int64_t cache_bytes_image, cache_bytes_other, cache_bytes_max;
double use_percent;
/* Three statistics are required to compute cache use percentage. */
- get_stat(cursor, WT_STAT_CONN_CACHE_BYTES_IMAGE, &cache_bytes_image);
- get_stat(cursor, WT_STAT_CONN_CACHE_BYTES_OTHER, &cache_bytes_other);
- get_stat(cursor, WT_STAT_CONN_CACHE_BYTES_MAX, &cache_bytes_max);
+ runtime_monitor::get_stat(cursor, WT_STAT_CONN_CACHE_BYTES_IMAGE, &cache_bytes_image);
+ runtime_monitor::get_stat(cursor, WT_STAT_CONN_CACHE_BYTES_OTHER, &cache_bytes_other);
+ runtime_monitor::get_stat(cursor, WT_STAT_CONN_CACHE_BYTES_MAX, &cache_bytes_max);
/*
* Assert that we never exceed our configured limit for cache usage. Add 0.0 to avoid floating
* point conversion errors.
@@ -222,7 +212,7 @@ postrun_statistic_check::check_stat(scoped_cursor &cursor, const postrun_statist
int64_t stat_value;
testutil_assert(cursor.get() != nullptr);
- get_stat(cursor, stat.field, &stat_value);
+ runtime_monitor::get_stat(cursor, stat.field, &stat_value);
if (stat_value < stat.min_limit || stat_value > stat.max_limit) {
const std::string error_string = "runtime_monitor: Postrun stat \"" + stat.name +
"\" was outside of the specified limits. Min=" + std::to_string(stat.min_limit) +
@@ -236,6 +226,16 @@ postrun_statistic_check::check_stat(scoped_cursor &cursor, const postrun_statist
}
/* runtime_monitor class implementation */
+void
+runtime_monitor::get_stat(scoped_cursor &cursor, int stat_field, int64_t *valuep)
+{
+ const char *desc, *pvalue;
+ cursor->set_key(cursor.get(), stat_field);
+ testutil_check(cursor->search(cursor.get()));
+ testutil_check(cursor->get_value(cursor.get(), &desc, &pvalue, valuep));
+ testutil_check(cursor->reset(cursor.get()));
+}
+
runtime_monitor::runtime_monitor(configuration *config, database &database)
: component("runtime_monitor", config), _postrun_stats(config), _database(database)
{
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 e7e69302d1d..0f63585290d 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
@@ -116,6 +116,9 @@ class postrun_statistic_check {
*/
class runtime_monitor : public component {
public:
+ static void get_stat(scoped_cursor &, int, int64_t *);
+
+ public:
runtime_monitor(configuration *config, database &database);
~runtime_monitor();
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/util/logger.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/util/logger.h
index 8d67bfd7e27..2c35ef0d162 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/util/logger.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/util/logger.h
@@ -30,8 +30,12 @@
#define DEBUG_UTILS_H
/* Following definitions are required in order to use printing format specifiers in C++. */
+#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
+#endif
#include <chrono>
#include <iostream>
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/util/scoped_types.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/util/scoped_types.h
index 47b8592ede0..edb38e3e22c 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/util/scoped_types.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/util/scoped_types.h
@@ -30,8 +30,12 @@
#define SCOPED_TYPES_H
/* Following definitions are required in order to use printing format specifiers in C++. */
+#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
+#endif
extern "C" {
#include "test_util.h"
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.cxx b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.cxx
index c539fbc34fc..3973af7242c 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.cxx
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.cxx
@@ -44,10 +44,11 @@ random_generator::instance()
std::string
random_generator::generate_random_string(std::size_t length, characters_type type)
{
+ const std::string characters = get_characters(type);
std::string str;
while (str.size() < length)
- str += get_characters(type);
+ str += characters;
std::shuffle(str.begin(), str.end(), _generator);
return (str.substr(0, length));
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.h
index 31f44bbe98e..967d5566ce1 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/random_generator.h
@@ -30,8 +30,12 @@
#define RANDOM_GENERATOR_H
/* Following definitions are required in order to use printing format specifiers in C++. */
+#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
+#endif
+#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
+#endif
#include <random>
#include <string>
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.h b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.h
index 61e1b99f28a..28c1ee4265b 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.h
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/thread_context.h
@@ -159,6 +159,7 @@ class thread_context {
public:
scoped_session session;
scoped_cursor op_track_cursor;
+ scoped_cursor stat_cursor;
transaction_context transaction;
timestamp_manager *tsm;
workload_tracking *tracking;
diff --git a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/workload_tracking.cxx b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/workload_tracking.cxx
index 1211749ec28..e0e7738590d 100644
--- a/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/workload_tracking.cxx
+++ b/src/third_party/wiredtiger/test/cppsuite/test_harness/workload/workload_tracking.cxx
@@ -99,7 +99,8 @@ workload_tracking::do_work()
/* Take a copy of the oldest so that we sweep with a consistent timestamp. */
oldest_ts = _tsm.get_oldest_ts();
- while ((ret = _sweep_cursor->prev(_sweep_cursor.get())) == 0) {
+ /* We need to check if the component is still running to avoid unecessary iterations. */
+ while (_running && (ret = _sweep_cursor->prev(_sweep_cursor.get())) == 0) {
testutil_check(_sweep_cursor->get_key(_sweep_cursor.get(), &collection_id, &key, &ts));
testutil_check(_sweep_cursor->get_value(_sweep_cursor.get(), &op_type, &value));
/*
@@ -137,7 +138,13 @@ workload_tracking::do_work()
free(sweep_key);
- if (ret != WT_NOTFOUND)
+ /*
+ * If we get here and the test is still running, it means we must have reached the end of the
+ * table. We can also get here because the test is no longer running. In this case, the cursor
+ * can either be at the end of the table or still on a valid entry since we interrupted the
+ * work.
+ */
+ if (ret != 0 && ret != WT_NOTFOUND)
testutil_die(LOG_ERROR,
"Tracking table sweep failed: cursor->next() returned an unexpected error %d.", ret);