Skip to content

Commit

Permalink
Long running script for all services
Browse files Browse the repository at this point in the history
  • Loading branch information
shosseinimotlagh committed May 28, 2024
1 parent 8e9e6a6 commit 772ed43
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 226 deletions.
6 changes: 5 additions & 1 deletion .jenkins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ RUN set -eux; \
COPY test_index_btree /usr/local/bin/test_index_btree
COPY test_meta_blk_mgr /usr/local/bin/test_meta_blk_mgr
COPY test_log_store /usr/local/bin/test_log_store
COPY btree_test.py /usr/local/bin/scripts/btree_test.py
COPY test_raft_repl_dev /usr/local/bin/test_raft_repl_dev
COPY test_solo_repl_dev /usr/local/bin/test_solo_repl_dev
COPY index_test.py /usr/local/bin/scripts/index_test.py
COPY log_meta_test.py /usr/local/bin/scripts/log_meta_test.py
COPY long_running.py /usr/local/bin/scripts/long_running.py


EXPOSE 5000
# ########## ####### ############
5 changes: 4 additions & 1 deletion .jenkins/jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ pipeline {
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_index_btree' -exec cp {} .jenkins/test_index_btree \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_meta_blk_mgr' -exec cp {} .jenkins/test_meta_blk_mgr \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_log_store' -exec cp {} .jenkins/test_log_store \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/scripts/btree_test.py' -exec install -Dm755 {} .jenkins/btree_test.py \\; "
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_raft_repl_dev' -exec cp {} .jenkins/test_raft_repl_dev \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_solo_repl_dev' -exec cp {} .jenkins/test_solo_repl_dev \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/scripts/index_test.py' -exec install -Dm755 {} .jenkins/index_test.py \\; "
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/scripts/log_meta_test.py' -exec install -Dm755 {} .jenkins/log_meta_test.py \\; "
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/scripts/long_running.py' -exec install -Dm755 {} .jenkins/long_running.py \\; "
}
post {
failure {
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "6.4.8"
version = "6.4.9"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_common/homestore_test_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ class HSTestHelper {
set_min_chunk_size(svc_params[HS_SERVICE::LOG].min_chunk_size);
}

if (need_format) {
if (need_format || init_device) {
LOGINFO("Formatting devices");
hsi->format_and_start({{HS_SERVICE::META, {.size_pct = svc_params[HS_SERVICE::META].size_pct}},
{HS_SERVICE::LOG,
{.size_pct = svc_params[HS_SERVICE::LOG].size_pct,
Expand Down
3 changes: 2 additions & 1 deletion src/tests/test_scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
file(COPY vol_test.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
file(COPY home_blk_flip.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
file(COPY home_blk_test.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
file(COPY btree_test.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
file(COPY index_test.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
file(COPY log_meta_test.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
file(COPY long_running.py DESTINATION ${CMAKE_BINARY_DIR}/bin/scripts)
#add_test(NAME TestVolRecovery COMMAND ${CMAKE_BINARY_DIR}/bin/scripts/vol_test.py --test_suits=recovery --dirpath=${CMAKE_BINARY_DIR}/bin/)
#SET_TESTS_PROPERTIES(TestVolRecovery PROPERTIES DEPENDS TestVol)

Expand Down
156 changes: 0 additions & 156 deletions src/tests/test_scripts/btree_test.py

This file was deleted.

102 changes: 102 additions & 0 deletions src/tests/test_scripts/index_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
## @file index_test.py
import subprocess
import sys
import getopt
import argparse


class TestFailedError(Exception):
pass


def run_test(options, type):
cmd_opts = f"--gtest_filter=BtreeConcurrentTest/{type}.ConcurrentAllOps --gtest_break_on_failure --cleanup_after_shutdown={options['cleanup_after_shutdown']} --init_device={options['init_device']} --preload_size={options['preload_size']} {options['log_mods']} --run_time={options['run_time']} --num_iters={options['num_iters']} --num_entries={options['num_entries']} --num_threads={options['threads']} --num_fibers={options['fibers']} {options['dev_list']} {options['op_list']}"
# print(f"Running test with options: {cmd_opts}")
try:
subprocess.check_call(f"{options['dirpath']}test_index_btree {cmd_opts}", stderr=subprocess.STDOUT, shell=True)
except subprocess.CalledProcessError as e:
print(f"Test failed: {e}")
raise TestFailedError(f"Test failed for type {type}")
print("Test completed")


def parse_arguments():
# Create the parser
parser = argparse.ArgumentParser(description='Parse command line options.')

# Add arguments with default values
parser.add_argument('--test_suits', help='Test suits to run', default='')
parser.add_argument('--dirpath', help='Directory path', default='bin/')
parser.add_argument('--op_list', help='List of operations', default='')
parser.add_argument('--log_mods', help='Log modules', default='')
parser.add_argument('--threads', help='Number of threads', type=int, default=2)
parser.add_argument('--fibers', help='Number of fibers', type=int, default=2)
parser.add_argument('--preload_size', help='Preload size', type=int, default=262144) # 256K
parser.add_argument('--num_entries', help='Number of entries', type=int, default=2097152) # 2M
parser.add_argument('--num_iters', help='Number of iterations', type=int, default=100000000)
parser.add_argument('--run_time', help='Run time in seconds', type=int, default=14400) # 4 hours
parser.add_argument('--dev_list', help='Device list', default='')
parser.add_argument('--cleanup_after_shutdown', help='Cleanup after shutdown', type=bool, default=False)
parser.add_argument('--init_device', help='Initialize device', type=bool, default=True)

# Parse the known arguments and ignore any unknown arguments
args, unknown = parser.parse_known_args()

if args.op_list:
args.op_list = ''.join([f' --operation_list={op}' for op in args.op_list.split()])
if args.dev_list:
args.dev_list = f' --device_list={args.dev_list}'

options = vars(args)

return options


def long_runnig_index(options, type=0):
print("Long running test started")
print(f"options: {options}")
run_test(options, type)
print("Long running test completed")


def long_running_clean_shutdown(options, type=0):
print("Long running clean shutdown started")
options['run_time'] = int(options['run_time']) // 10 # 20 minutes

try:
run_test(options, type)
options['init_device'] = False
print("Iteration 0 (aka init) completed successfully")
for i in range(1, 10):
run_test(options, type)
print("Iteration {} clean shutdown completed successfully".format(i))
except TestFailedError as e:
print(f"Test failed: {e}")
raise
print("Long running clean shutdown completed")


def main():
options = parse_arguments()
test_suite_name = options['test_suits']
try:
# Retrieve the function based on the name provided in options['test_suits']
test_suite_function = globals().get(test_suite_name)
if callable(test_suite_function):
print(f"Running {test_suite_name} with options: {options}")
test_suite_function(options)
else:
print(f"Test suite '{test_suite_name}' is not a callable function.")
except KeyError:
print(f"Test suite '{test_suite_name}' not found.")


def long_running(*args):
options = parse_arguments()
long_runnig_index(options)
long_running_clean_shutdown(options)


if __name__ == "__main__":
main()
Loading

0 comments on commit 772ed43

Please sign in to comment.