diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index f7eef1e51..2a019a145 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -37,7 +37,7 @@ if (${build_nonio_tests}) add_executable(test_mem_btree ${TEST_MEMBTREE_SOURCE_FILES}) target_link_libraries(test_mem_btree ${COMMON_TEST_DEPS} GTest::gtest) add_test(NAME MemBtree COMMAND test_mem_btree) - set_tests_properties(MemBtree PROPERTIES TIMEOUT 600) + set_tests_properties(MemBtree PROPERTIES TIMEOUT 1200) add_executable(test_blk_read_tracker) target_sources(test_blk_read_tracker PRIVATE test_blk_read_tracker.cpp ../lib/blkdata_svc/blk_read_tracker.cpp ../lib/blkalloc/blk.cpp) @@ -72,9 +72,9 @@ if (${io_tests}) set(TEST_INDEXBTREE_SOURCE_FILES test_index_btree.cpp) add_executable(test_index_btree ${TEST_INDEXBTREE_SOURCE_FILES}) target_link_libraries(test_index_btree homestore ${COMMON_TEST_DEPS} GTest::gtest) - add_test(NAME IndexBtree COMMAND test_index_btree) + add_test(NAME IndexBtree COMMAND test_index_btree --gtest_filter=*/0.*) set_property(TEST IndexBtree PROPERTY ENVIRONMENT "ASAN_OPTIONS=detect_stack_use_after_return=true") - set_tests_properties(IndexBtree PROPERTIES TIMEOUT 600) + set_tests_properties(IndexBtree PROPERTIES TIMEOUT 1200) add_executable(test_data_service) target_sources(test_data_service PRIVATE test_data_service.cpp) diff --git a/src/tests/test_index_btree.cpp b/src/tests/test_index_btree.cpp index b298de358..afd9c7b48 100644 --- a/src/tests/test_index_btree.cpp +++ b/src/tests/test_index_btree.cpp @@ -123,7 +123,7 @@ struct BtreeTest : public BtreeTestHelper< TestType >, public ::testing::Test { } }; -using BtreeTypes = testing::Types< FixedLenBtree /*, VarKeySizeBtree, VarValueSizeBtree, VarObjSizeBtree */ >; +using BtreeTypes = testing::Types< FixedLenBtree, VarKeySizeBtree, VarValueSizeBtree, VarObjSizeBtree >; TYPED_TEST_SUITE(BtreeTest, BtreeTypes); @@ -501,7 +501,7 @@ struct BtreeConcurrentTest : public BtreeTestHelper< TestType >, public ::testin } private: - const std::string m_shadow_filename = "shadow_map.txt"; + const std::string m_shadow_filename = "/tmp/shadow_map.txt"; }; TYPED_TEST_SUITE(BtreeConcurrentTest, BtreeTypes); diff --git a/src/tests/test_scripts/btree_test.py b/src/tests/test_scripts/btree_test.py index b7db33259..7861906f6 100755 --- a/src/tests/test_scripts/btree_test.py +++ b/src/tests/test_scripts/btree_test.py @@ -82,19 +82,29 @@ def long_runnig_index(): subprocess.check_call(dirpath + "test_index_btree " + cmd_opts, stderr=subprocess.STDOUT, shell=True) print("Long running test completed") -def function_normal(runtime, cleanup_after_shutdown=False, init_device=False): - normal_options = "--gtest_filter=BtreeConcurrentTest/0.ConcurrentAllOps --gtest_break_on_failure " + btree_options + " " + log_mods + " --run_time " + str(runtime) +def function_normal(runtime, cleanup_after_shutdown=False, init_device=False, type=0): + normal_options = "--gtest_filter=BtreeConcurrentTest/" + str(type) +".ConcurrentAllOps --gtest_break_on_failure " + btree_options + " " + log_mods + " --run_time " + str(runtime) cmd_opts = normal_options + " --cleanup_after_shutdown=" + str(cleanup_after_shutdown) + " --init_device=" + str(init_device) print("normal test started with (%s)" % cmd_opts) subprocess.check_call(dirpath + "test_index_btree " + cmd_opts, stderr=subprocess.STDOUT, shell=True) - print("normal test completed") -def function_crash(runtime, cleanup_after_shutdown=False, init_device=False): - normal_options =" --gtest_filter=BtreeConcurrentTest/0.ConcurrentAllOps --gtest_break_on_failure " + btree_options + " "+log_mods +" --enable_crash" +def function_crash(runtime, cleanup_after_shutdown=False, init_device=False, type=0): + normal_options =" --gtest_filter=BtreeConcurrentTest/" + str(type) +".ConcurrentAllOps --gtest_break_on_failure " + btree_options + " "+log_mods +" --enable_crash" cmd_opts = normal_options +" --cleanup_after_shutdown=" + str(cleanup_after_shutdown) + " --init_device="+str(init_device) +" --run_time " + str(runtime) subprocess.check_call(dirpath + "test_index_btree " + cmd_opts, stderr=subprocess.STDOUT, shell=True) - print("crash test completed") + +def long_running_clean_shutdown(type=0): + normal_run_time = 1 * 3600 # 1 hour + try: + function_normal(normal_run_time, False, True, type) + for i in range(1,8): + function_normal(normal_run_time, False, False, type) + print("Iteration {} completed successfully".format(i)) + function_normal(0, True, False, type) # cleanup after shutdown + print("All iterations completed successfully for type {}".format(type)) + except subprocess.CalledProcessError as e: + print("Test failed: {}".format(e)) def crash_recovery_framework(): total_run_time = 30 * 3600 @@ -109,7 +119,7 @@ def crash_recovery_framework(): start_time = time.time() p = random.randint(0, 100) # some distribution if p < crash_execution_frequency: - function_crash(crash_run_time, False, False) + function_crash(crash_run_time, False, False) else: function_normal(min(normal_run_time, total_run_time - elapsed_time), False, False) end_time = time.time() @@ -117,8 +127,21 @@ def crash_recovery_framework(): function_normal(0, True, False) #cleanup after shutdown print("crash recovery test completed") +def test_index_btree(): + while True: + try: + for type in range(4): + long_running_clean_shutdown(type) + except subprocess.CalledProcessError as e: + print("Test failed: {}".format(e)) + + # wait for 1 minute before running again + time.sleep(60) + def nightly(): - long_runnig_index() + # long_runnig_index() + # long_running_clean_shutdown() + test_index_btree() # crash_recovery_framework() # The name of the method to be called is the var test_suits