Skip to content

Commit

Permalink
Enable all btree types (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
shosseinimotlagh authored Feb 7, 2024
1 parent e073fe2 commit 7ccd134
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -72,9 +72,10 @@ 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)
#TODO : Fix the test case and enable it
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)
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test_index_btree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
51 changes: 41 additions & 10 deletions src/tests/test_scripts/btree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
addln_opts += dev_list

btree_options = num_entries + num_iters + preload_size + fibers + threads + operations + addln_opts

class TestFailedError(Exception):
pass

def long_runnig_index():
print("normal test started with (%s)" % (btree_options+ " " + run_time))
Expand All @@ -82,19 +83,34 @@ 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 " +
try:
subprocess.check_call(dirpath + "test_index_btree " +
cmd_opts, stderr=subprocess.STDOUT, shell=True)
print("normal test completed")
except subprocess.CalledProcessError as e:
print("UT failed: {}".format(e))
raise TestFailedError("UT failed for type {}".format(type))

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 TestFailedError as e:
print("Test failed: {}".format(e))
raise

def crash_recovery_framework():
total_run_time = 30 * 3600
Expand All @@ -109,16 +125,31 @@ 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()
elapsed_time += end_time - start_time
function_normal(0, True, False) #cleanup after shutdown
print("crash recovery test completed")

def test_index_btree():
while True:
try:
#TODO enable for other types when fix is available for varlen node types.
#for type in range(4):
long_running_clean_shutdown(0)
except:
print("Test failed: {}".format(e))
break

# 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
Expand Down

0 comments on commit 7ccd134

Please sign in to comment.