-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Test CPPsuite
-
Storage Engines
-
2
-
StorEng - Defined Pipeline
Background
Currently, we have asserts that make sure the number of collections is 1 in several tests.
testutil_assert(tc->collection_count == 1);
The tc is a thread_worker instance, and the member variable collection_count is initialized in its constructor, which is read from the config file.
collection_count(config->get_optional_int(COLLECTION_COUNT, 1))
A config file will have a workload_manager section which contains several sub configs, when we run cppsuite test, the framework will go through the workload_manager section, it first reads populate_config and populates seed data into db. Then it reads other operation configs and executes different test_operations.
workload_manager= ( populate_config= ( collection_count=1, key_count_per_collection=1000, key_size=5, ), read_config= ( thread_count=1 ), checkpoint_config= ( op_rate=20s, ) ),
Problem
When testutil_assert(tc->collection_count == 1), we actually want to check if the db has exactly one collection. However, tc->collection_count is to check if the collection_count defined in operation_config is 1, which is incorrect.
Suggested change
diff --git a/test/cppsuite/tests/api_instruction_count_benchmarks.cpp b/test/cppsuite/tests/api_instruction_count_benchmarks.cpp index ba3b48408..2a630ebde 100644 --- a/test/cppsuite/tests/api_instruction_count_benchmarks.cpp +++ b/test/cppsuite/tests/api_instruction_count_benchmarks.cpp @@ -58,7 +58,7 @@ public: custom_operation(thread_worker *tc) override final { /* The test expects no more than one collection. */ - testutil_assert(tc->collection_count == 1); + testutil_assert(tc->db.get_collection_count() == 1); /* Assert that we are running in memory. */ testutil_assert(_config->get_bool(IN_MEMORY)); diff --git a/test/cppsuite/tests/api_timing_benchmarks.cpp b/test/cppsuite/tests/api_timing_benchmarks.cpp index d96272a55..98645ada9 100644 --- a/test/cppsuite/tests/api_timing_benchmarks.cpp +++ b/test/cppsuite/tests/api_timing_benchmarks.cpp @@ -51,7 +51,7 @@ public: custom_operation(thread_worker *tc) override final { /* Assert there is only one collection. */ - testutil_assert(tc->collection_count == 1); + testutil_assert(tc->db.get_collection_count() == 1); /* Create the necessary timers. */ execution_timer begin_transaction_timer("begin_transaction", test::_args.test_name); diff --git a/test/cppsuite/tests/bounded_cursor_perf.cpp b/test/cppsuite/tests/bounded_cursor_perf.cpp index f6b6a129e..6a7c49a87 100644 --- a/test/cppsuite/tests/bounded_cursor_perf.cpp +++ b/test/cppsuite/tests/bounded_cursor_perf.cpp @@ -89,7 +89,7 @@ public: execution_timer compiled_config_timer("set_bounds_compiled", test::_args.test_name); /* Get the collection to work on. */ - testutil_assert(tc->collection_count == 1); + testutil_assert(tc->db.get_collection_count() == 1); collection &coll = tc->db.get_collection(0); /* Open the cursors. */
Acceptance Criteria
Assess if tc->db.get_collection_count() is what the tests actually want, and check if there are other places where tc->collection_count is misused with tc->db.get_collection_count(), and fix the code.