Skip to content

Commit 30d42bb

Browse files
Accept operations as args
Signed-off-by: Elena Kolevska <elena@kolevska.com>
1 parent 5a628f1 commit 30d42bb

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def cli():
7474
# Workload Configuration Parameters
7575
# ============================================================================
7676
@click.option('--workload-profile', type=click.Choice(WorkloadProfiles.list_profiles()), default=lambda: get_env_or_default('TEST_WORKLOAD_PROFILE', None), help='Pre-defined workload profile')
77-
@click.option('--operations', default=lambda: get_env_or_default('TEST_OPERATIONS', 'SET,GET'), help='Comma-separated list of Redis operations')
77+
@click.option('--operations', default=lambda: get_env_or_default('TEST_OPERATIONS', None), help='Comma-separated list of Redis operations')
7878
@click.option('--operation-weights', default=lambda: get_env_or_default('TEST_OPERATION_WEIGHTS', None), help='JSON string of operation weights (e.g., {"SET": 0.4, "GET": 0.6})')
7979
@click.option('--key-prefix', default=lambda: get_env_or_default('TEST_KEY_PREFIX', 'test_key'), help='Prefix for generated keys')
8080
@click.option('--key-range', type=int, default=lambda: get_env_or_default('TEST_KEY_RANGE', 10000, int), help='Range of key IDs to use')
@@ -308,10 +308,14 @@ def _build_config_from_args(kwargs) -> RunnerConfig:
308308
workload_config = WorkloadProfiles.get_profile(kwargs['workload_profile'])
309309

310310

311-
operations = [op.strip() for op in kwargs['operations'].split(',')]
311+
if kwargs['operations']:
312+
operations = [op.strip() for op in kwargs['operations'].split(',')]
313+
workload_config.options["operations"] = operations
314+
else:
315+
workload_config.options["operations"] = workload_config.get_option("operations")
312316

313317
# Build options dictionary
314-
workload_config.options["operations"] = operations or workload_config.get_option("operations")
318+
315319
workload_config.options["keyPrefix"] = kwargs['key_prefix'] or workload_config.get_option("keyPrefix")
316320

317321
if kwargs['key_range'] is not None:

workloads.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _get_default_operation(self) -> str:
116116
"""Get default operation based on workload type."""
117117
workload_type = self.config.type
118118
if workload_type == "high_throughput":
119-
return random.choice(["SET", "GET", "INCR"])
119+
return random.choice(["SET", "GET", "INCR", "DEL", "LPUSH", "LRANGE", "LTRIM"])
120120
elif workload_type == "list_operations":
121121
return random.choice(["LPUSH", "LRANGE", "LPOP"])
122122
elif workload_type == "pubsub_heavy":
@@ -236,6 +236,23 @@ def execute_operation(self) -> int:
236236
key = self._generate_key()
237237
pipe.incr(key)
238238

239+
elif operation == "DEL":
240+
key = self._generate_key()
241+
pipe.delete(key)
242+
243+
elif operation == "LPUSH":
244+
key = self._generate_key()
245+
value = self._generate_value()
246+
pipe.lpush(key, value)
247+
248+
elif operation == "LRANGE":
249+
key = self._generate_key()
250+
pipe.lrange(key, 0, 10)
251+
252+
elif operation == "LTRIM":
253+
key = self._generate_key()
254+
pipe.ltrim(key, 0, 10)
255+
239256
operations.append(operation)
240257

241258
# Execute pipeline

0 commit comments

Comments
 (0)