diff --git a/pyproject.toml b/pyproject.toml index 046dd35..5258822 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "redisbench-admin" -version = "0.10.24" +version = "0.10.25" description = "Redis benchmark run helper. A wrapper around Redis and Redis Modules benchmark tools ( ftsb_redisearch, memtier_benchmark, redis-benchmark, aibench, etc... )." authors = ["filipecosta90 ","Redis Performance Group "] readme = "README.md" diff --git a/redisbench_admin/run_local/args.py b/redisbench_admin/run_local/args.py index 0a05c8b..1e809f4 100644 --- a/redisbench_admin/run_local/args.py +++ b/redisbench_admin/run_local/args.py @@ -8,13 +8,17 @@ from redisbench_admin.run.args import common_run_args from redisbench_admin.run.common import REDIS_BINARY -FLUSHALL_AT_START = bool(int(os.getenv("FLUSHALL_AT_START", "0"))) +FLUSHALL_AT_START = bool(int(os.getenv("FLUSHALL_AT_START", "1"))) IGNORE_KEYSPACE_ERRORS = bool(int(os.getenv("IGNORE_KEYSPACE_ERRORS", "0"))) +SKIP_REDIS_SPIN = bool(int(os.getenv("SKIP_REDIS_SPIN", "0"))) +REDIS_PORT = int(os.getenv("SKIP_REDIS_SPIN", "6379")) +REDIS_HOST = os.getenv("REDIS_HOST", "127.0.0.1") def create_run_local_arguments(parser): parser = common_run_args(parser) - parser.add_argument("--port", type=int, default=6379) + parser.add_argument("--port", type=int, default=REDIS_PORT) + parser.add_argument("--host", type=str, default=REDIS_HOST) parser.add_argument("--redis-binary", type=str, default=REDIS_BINARY) parser.add_argument( "--flushall_on_every_test_start", @@ -22,6 +26,12 @@ def create_run_local_arguments(parser): default=FLUSHALL_AT_START, help="At the start of every test send a FLUSHALL", ) + parser.add_argument( + "--skip-redis-spin", + type=bool, + default=SKIP_REDIS_SPIN, + help="Skip redis spin. consider redis alive at host:port", + ) parser.add_argument( "--ignore_keyspace_errors", type=bool, diff --git a/redisbench_admin/run_local/local_db.py b/redisbench_admin/run_local/local_db.py index 8d34d50..3a36c16 100644 --- a/redisbench_admin/run_local/local_db.py +++ b/redisbench_admin/run_local/local_db.py @@ -79,84 +79,86 @@ def local_db_spin( redis_processes, ) else: - # setup Redis - # copy the rdb to DB machine - redis_7 = args.redis_7 - logging.info( - "Using local temporary dir to spin up Redis Instance. Path: {}".format( - temporary_dir - ) - ) - if dbdir_folder is not None: - from distutils.dir_util import copy_tree - - copy_tree(dbdir_folder, temporary_dir) + if args.skip_redis_spin is False: + # setup Redis + # copy the rdb to DB machine + redis_7 = args.redis_7 logging.info( - "Copied entire content of {} into temporary path: {}".format( - dbdir_folder, temporary_dir + "Using local temporary dir to spin up Redis Instance. Path: {}".format( + temporary_dir ) ) - ( - _, - _, - redis_configuration_parameters, - dataset_load_timeout_secs, - modules_configuration_parameters_map, - ) = extract_redis_dbconfig_parameters(benchmark_config, "dbconfig") + if dbdir_folder is not None: + from distutils.dir_util import copy_tree - logging.info( - "Using a dataset load timeout of {} seconds.".format( - dataset_load_timeout_secs - ) - ) - - if setup_type == "oss-cluster": - cluster_api_enabled = True - shard_host = "127.0.0.1" - redis_processes, redis_conns = spin_up_local_redis_cluster( - binary, - temporary_dir, - shard_count, - shard_host, - args.port, - local_module_file, + copy_tree(dbdir_folder, temporary_dir) + logging.info( + "Copied entire content of {} into temporary path: {}".format( + dbdir_folder, temporary_dir + ) + ) + ( + _, + _, redis_configuration_parameters, dataset_load_timeout_secs, modules_configuration_parameters_map, - redis_7, - ) + ) = extract_redis_dbconfig_parameters(benchmark_config, "dbconfig") - status = setup_redis_cluster_from_conns( - redis_conns, shard_count, shard_host, args.port - ) - if status is False: - raise Exception("Redis cluster setup failed. Failing test.") - - if setup_type == "oss-standalone": - redis_processes = spin_up_local_redis( - binary, - args.port, - temporary_dir, - local_module_file, - redis_configuration_parameters, - dbdir_folder, - dataset_load_timeout_secs, - modules_configuration_parameters_map, - redis_7, + logging.info( + "Using a dataset load timeout of {} seconds.".format( + dataset_load_timeout_secs + ) ) - if setup_type == "oss-cluster": - for shardn, redis_process in enumerate(redis_processes): - logging.info( - "Checking if shard #{} process with pid={} is alive".format( - shardn + 1, redis_process.pid - ) + + if setup_type == "oss-cluster": + cluster_api_enabled = True + redis_processes, redis_conns = spin_up_local_redis_cluster( + binary, + temporary_dir, + shard_count, + args.host, + args.port, + local_module_file, + redis_configuration_parameters, + dataset_load_timeout_secs, + modules_configuration_parameters_map, + redis_7, + ) + + status = setup_redis_cluster_from_conns( + redis_conns, shard_count, args.host, args.port + ) + if status is False: + raise Exception("Redis cluster setup failed. Failing test.") + + if setup_type == "oss-standalone": + redis_processes = spin_up_local_redis( + binary, + args.port, + temporary_dir, + local_module_file, + redis_configuration_parameters, + dbdir_folder, + dataset_load_timeout_secs, + modules_configuration_parameters_map, + redis_7, ) - if is_process_alive(redis_process) is False: - raise Exception("Redis process is not alive. Failing test.") - cluster_init_steps(clusterconfig, redis_conns, local_module_file) + if setup_type == "oss-cluster": + for shardn, redis_process in enumerate(redis_processes): + logging.info( + "Checking if shard #{} process with pid={} is alive".format( + shardn + 1, redis_process.pid + ) + ) + if is_process_alive(redis_process) is False: + raise Exception("Redis process is not alive. Failing test.") + cluster_init_steps(clusterconfig, redis_conns, local_module_file) + else: + logging.info("Skipping DB spin step...") if setup_type == "oss-standalone": - r = redis.Redis(port=args.port) + r = redis.Redis(port=args.port, host=args.host) r.ping() r.client_setname("redisbench-admin-standalone") redis_conns.append(r) @@ -184,7 +186,7 @@ def local_db_spin( benchmark_config, full_benchmark_path, args.port, - "localhost", + args.host, local_benchmark_output_filename, False, benchmark_tool_workdir, diff --git a/redisbench_admin/run_local/run_local.py b/redisbench_admin/run_local/run_local.py index 2b30a81..b4e06a1 100644 --- a/redisbench_admin/run_local/run_local.py +++ b/redisbench_admin/run_local/run_local.py @@ -290,7 +290,7 @@ def run_local_command_logic(args, project_name, project_version): benchmark_config, full_benchmark_path, args.port, - "127.0.0.1", + args.host, local_benchmark_output_filename, False, benchmark_tool_workdir,