Skip to content

Commit

Permalink
Allowing to specify different host on local runner. Collecting extra…
Browse files Browse the repository at this point in the history
… server side metrics on local run. (#425)

* Enabled pushing timeseries data from local run

* Exposing memory metrics on local run

* Allowing to specify different host on local runner

* Bumping version from 0.10.24 to 0.10.25
  • Loading branch information
filipecosta90 authored Apr 24, 2024
1 parent de8031b commit 1ad4fdb
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 71 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <filipecosta.90@gmail.com>","Redis Performance Group <performance@redis.com>"]
readme = "README.md"
Expand Down
14 changes: 12 additions & 2 deletions redisbench_admin/run_local/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@
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",
type=bool,
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,
Expand Down
136 changes: 69 additions & 67 deletions redisbench_admin/run_local/local_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion redisbench_admin/run_local/run_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1ad4fdb

Please sign in to comment.