From 6a5617f7778e0cfbe66cdb4463cdc4cc6af6eb5b Mon Sep 17 00:00:00 2001 From: Anuchaithra Date: Fri, 25 Sep 2026 17:41:12 +0530 Subject: [PATCH] [closeloop] Lua prerequest cache invalidation and stale bytecode automations Signed-off-by: Anuchaithra --- ...aws_lua_prerequest_cache_invalidation.yaml | 17 + ...s_lua_prerequest_stale_bytecode_cache.yaml | 17 + rgw/v2/tests/aws/reusable.py | 164 ++++++- rgw/v2/tests/aws/test_lua_postauth_cache.py | 412 ++++++++++++------ .../tests/aws/test_lua_script_prerequest.py | 17 +- 5 files changed, 468 insertions(+), 159 deletions(-) create mode 100644 rgw/v2/tests/aws/configs/test_aws_lua_prerequest_cache_invalidation.yaml create mode 100644 rgw/v2/tests/aws/configs/test_aws_lua_prerequest_stale_bytecode_cache.yaml diff --git a/rgw/v2/tests/aws/configs/test_aws_lua_prerequest_cache_invalidation.yaml b/rgw/v2/tests/aws/configs/test_aws_lua_prerequest_cache_invalidation.yaml new file mode 100644 index 0000000000..ce5f621d10 --- /dev/null +++ b/rgw/v2/tests/aws/configs/test_aws_lua_prerequest_cache_invalidation.yaml @@ -0,0 +1,17 @@ +# Tracker: https://tracker.ceph.com/issues/80576 +# Fix: https://github.com/ceph/ceph/pull/71857 +# Script: test_lua_postauth_cache.py +# polarion_id: CEPH-83633021 +config: + user_count: 1 + bucket_count: 1 + objects_count: 1 + local_file_delete: true + objects_size_range: + min: 5K + max: 5K + user_remove: true + test_ops: + prerequest_cache_invalidation: true + lua_background_wait: 4 + delete_bucket: true diff --git a/rgw/v2/tests/aws/configs/test_aws_lua_prerequest_stale_bytecode_cache.yaml b/rgw/v2/tests/aws/configs/test_aws_lua_prerequest_stale_bytecode_cache.yaml new file mode 100644 index 0000000000..0330885eb0 --- /dev/null +++ b/rgw/v2/tests/aws/configs/test_aws_lua_prerequest_stale_bytecode_cache.yaml @@ -0,0 +1,17 @@ +# Tracker: https://tracker.ceph.com/issues/80532 +# Fix: https://github.com/ceph/ceph/pull/71873 +# Script: test_lua_postauth_cache.py +# polarion_id: CEPH-83633020 +config: + user_count: 1 + bucket_count: 1 + objects_count: 1 + local_file_delete: true + objects_size_range: + min: 5K + max: 5K + user_remove: true + test_ops: + prerequest_stale_bytecode_cache: true + lua_background_wait: 6 + delete_bucket: true diff --git a/rgw/v2/tests/aws/reusable.py b/rgw/v2/tests/aws/reusable.py index b2d274315d..ca63cef221 100644 --- a/rgw/v2/tests/aws/reusable.py +++ b/rgw/v2/tests/aws/reusable.py @@ -553,6 +553,36 @@ def put_object(aws_auth, bucket_name, object_name, end_point, body=None): raise AWSCommandExecError(message=str(e)) +def put_object_must_be_blocked( + aws_auth, + bucket_name, + object_name, + end_point, + body=None, + error_substrings=("403", "AccessDenied", "Forbidden", "Abort"), + fail_msg=None, +): + """ + put_object that must be rejected (e.g. by a prerequest Lua abort). + Raises TestExecError if the put succeeds or fails with an unexpected error. + """ + try: + put_object(aws_auth, bucket_name, object_name, end_point, body=body) + except AWSCommandExecError as e: + err = str(e) + if any(x in err for x in error_substrings): + log.info(f"put_object blocked as expected: {err}") + return + raise TestExecError(f"Unexpected put-object error: {err}") + raise TestExecError( + fail_msg + or ( + f"put_object {object_name} succeeded but should have been blocked " + "by the Lua prerequest script" + ) + ) + + def put_object_checksum( aws_auth, bucket_name, @@ -2162,6 +2192,127 @@ def get_all_rgw_hosts(): return rgw_hosts +def enable_rgw_debug_logging(level=20, settle_seconds=3): + """ + Enable log_to_file and set debug_rgw on all RGW services and daemons. + """ + log.info(f"Enabling log_to_file and debug_rgw={level}") + utils.exec_shell_cmd("ceph config set global log_to_file true") + out_ps = utils.exec_shell_cmd("ceph orch ps --daemon_type rgw -f json") + rgw_daemons = json.loads(out_ps) + services = set() + for daemon in rgw_daemons: + service_name = daemon.get("service_name") + if service_name: + services.add(service_name) + daemon_name = daemon.get("daemon_name") + if daemon_name: + utils.exec_shell_cmd( + f"ceph config set client.{daemon_name} debug_rgw {level}" + ) + for service_name in services: + utils.exec_shell_cmd(f"ceph config set client.{service_name} debug_rgw {level}") + log.info("log_to_file and debug_rgw set for all RGW services and daemons") + if settle_seconds: + time.sleep(settle_seconds) + + +def reset_rgw_debug_logging(): + """ + Remove debug_rgw override for all RGW services and daemons. + """ + log.info("Resetting debug_rgw to default level") + out_ps = utils.exec_shell_cmd("ceph orch ps --daemon_type rgw -f json") + rgw_daemons = json.loads(out_ps) + services = set() + for daemon in rgw_daemons: + service_name = daemon.get("service_name") + if service_name: + services.add(service_name) + daemon_name = daemon.get("daemon_name") + if daemon_name: + utils.exec_shell_cmd(f"ceph config rm client.{daemon_name} debug_rgw") + for service_name in services: + utils.exec_shell_cmd(f"ceph config rm client.{service_name} debug_rgw") + log.info("debug_rgw reset for all RGW daemons") + + +def grep_rgw_logs(pattern, ssh_con=None, haproxy=False, since_epoch=None): + """ + Grep RGW client logs for an ERE pattern (grep -iE). + + Returns list of matching lines. Remote host lines are prefixed with [host]. + If haproxy is False, try local/ssh_con first and fall back to all RGW hosts + when no matches are found. + """ + from datetime import datetime + + fsid = utils.get_cluster_fsid() + log_dir = f"/var/log/ceph/{fsid}" + lines = [] + + def _grep_on_node(node_ssh, host=None): + found = [] + if not check_log_directory_exists(log_dir, node_ssh): + return found + for log_file in get_rgw_log_files(log_dir, node_ssh, host): + cmd = f"sudo grep -iE '{pattern}' {log_file} 2>/dev/null || true" + try: + if node_ssh: + _stdin, stdout, _stderr = node_ssh.exec_command(cmd) + out = stdout.read().decode() + else: + out = utils.exec_shell_cmd(cmd) + if out is False or out is None: + out = "" + except Exception as e: + log.warning(f"Failed to grep {log_file} on {host}: {e}") + continue + if out and out.strip(): + for raw in out.strip().split("\n"): + if raw.strip(): + prefix = f"[{host}] " if host else "" + found.append(f"{prefix}{raw.strip()}") + return found + + search_all = haproxy + if not search_all: + lines = _grep_on_node(ssh_con) + if not lines: + log.info("No matching RGW log lines on local/ssh node; checking all hosts") + search_all = True + + if search_all: + lines = [] + for host in get_all_rgw_hosts(): + try: + node_ssh = utils.connect_remote(host) + lines.extend(_grep_on_node(node_ssh, host)) + except Exception as e: + log.warning(f"Failed to grep RGW logs on {host}: {e}") + + if since_epoch is not None: + cutoff = since_epoch - 1 + recent = [] + for line in lines: + raw = re.sub(r"^\[.*?\]\s+", "", line) + ts_match = re.match(r"^(\S+)\s", raw) + keep = True + if ts_match: + ts = ts_match.group(1) + if ts.endswith("+0000"): + ts = ts[:-5] + "+00:00" + try: + keep = datetime.fromisoformat(ts).timestamp() >= cutoff + except ValueError: + keep = True + if keep: + recent.append(line) + lines = recent + + return lines + + def check_rgw_debug_logs_and_reset( message_pattern=None, ssh_con=None, @@ -2308,19 +2459,8 @@ def check_rgw_debug_logs_and_reset( ) validation_error = None - log.info("Resetting debug_rgw to default level") try: - cmd_ps = "ceph orch ps --daemon_type rgw -f json" - out_ps = utils.exec_shell_cmd(cmd_ps) - rgw_daemons = json.loads(out_ps) - for daemon in rgw_daemons: - daemon_name = daemon.get("daemon_name") or daemon.get("service_name") - if daemon_name: - debug_cmd = f"ceph config rm client.{daemon_name} debug_rgw" - log.info(f"Resetting debug_rgw for {daemon_name}: {debug_cmd}") - utils.exec_shell_cmd(debug_cmd) - - log.info("debug_rgw reset to default for all RGW daemons") + reset_rgw_debug_logging() except Exception as e: raise TestExecError(f"Failed to reset debug_rgw: {e}") diff --git a/rgw/v2/tests/aws/test_lua_postauth_cache.py b/rgw/v2/tests/aws/test_lua_postauth_cache.py index 7ddd1ed011..d89111b23b 100644 --- a/rgw/v2/tests/aws/test_lua_postauth_cache.py +++ b/rgw/v2/tests/aws/test_lua_postauth_cache.py @@ -3,30 +3,25 @@ configs/test_aws_lua_postauth_cache.yaml - -postAuth is not a radosgw-admin script context. Valid upload contexts are -prerequest, postrequest, background, getdata, and putdata. This test uploads a -large padded policy script to prerequest (the closest CLI equivalent), then -compares RGW debug logs: - - - preRequest: bytecode cache miss on the first request, cache hit after - LuaBackground compiles (correct path). - - postRequest: negative-entry cache when no postrequest script is stored. - - postAuth (bug): read_script() is silent — no cache get / bytecode lines. - After the fix, read_script_or_bytecode() emits - "cache get: name=...script.postauth... hit" on subsequent requests, - matching postrequest. + configs/test_aws_lua_prerequest_stale_bytecode_cache.yaml + configs/test_aws_lua_prerequest_cache_invalidation.yaml + +Operation: + Lua bytecode cache scenarios via test_ops: + - lua_postauth_cache: postAuth vs prerequest bytecode cache behaviour + - prerequest_stale_bytecode_cache: script A warm-up, rm+put script B, verify + B runs (tracker #80532 / PR #71873) + - prerequest_cache_invalidation: upload blocking script, put_object must be + blocked immediately (tracker #80576 / PR #71857) """ import argparse -import json import logging import os import re import sys import time import traceback -from datetime import datetime sys.path.append(os.path.abspath(os.path.join(__file__, "../../../.."))) @@ -44,6 +39,41 @@ log = logging.getLogger(__name__) TEST_DATA_PATH = None +MARKER_A = "LUA_SCRIPT_A_COPYFROM" +MARKER_B = "LUA_SCRIPT_B_INTERRUPT" +BLOCK_MARKER = "LUA_BLOCK_PREREQUEST_CACHE_INVALIDATION" + +SCRIPT_A = f"""\ +-- prerequest script A ({MARKER_A}) +RGW.Log(20, "Lua INFO: {MARKER_A} running in prerequest") +RGW.Log(20, "Lua INFO: op was: " .. Request.RGWOp) +RGW.Log(20, "Lua INFO: context was: prerequest") +return 0 +""" + +SCRIPT_B = f"""\ +-- prerequest script B ({MARKER_B}) +RGW.Log(20, "Lua INFO: {MARKER_B} running in prerequest") +RGW.Log(20, "Lua INFO: op was: " .. Request.RGWOp) +RGW.Log(20, "Lua INFO: context was: prerequest") +Request.Response.HTTPStatusCode = 403 +Request.Response.Message = "Forbidden by prerequest Lua script B" +return RGW_ABORT_REQUEST +""" + +BLOCKING_SCRIPT = f"""\ +-- prerequest blocking script ({BLOCK_MARKER}) +RGW.Log(20, "Lua INFO: {BLOCK_MARKER} running in prerequest") +RGW.Log(20, "Lua INFO: op was: " .. Request.RGWOp) +RGW.Log(20, "Lua INFO: context was: prerequest") +if Request.RGWOp == "put_obj" then + Request.Response.HTTPStatusCode = 403 + Request.Response.Message = "Blocked by prerequest cache invalidation test script" + return RGW_ABORT_REQUEST +end +return 0 +""" + def test_exec(config, ssh_con): io_info_initialize = IOInfoInitialize() @@ -58,14 +88,236 @@ def test_exec(config, ssh_con): log.info(f"RGW endpoint: {endpoint}") lua_background_wait = int(config.test_ops.get("lua_background_wait", 10)) - measure_latency = config.test_ops.get("measure_latency", True) - latency_iterations = int(config.test_ops.get("latency_iterations", 20)) delete_bucket = config.test_ops.get("delete_bucket", True) user_info = resource_op.create_users(no_of_users_to_create=config.user_count) user = user_info[0] cli_aws = AWS(ssl=config.ssl) bucket_name = utils.gen_bucket_name_from_userid(user["user_id"], rand_no=0) + aws_auth.do_auth_aws(user) + + if config.test_ops.get("prerequest_cache_invalidation", False): + script_set = False + bucket_created = False + debug_set = False + objects = [] + try: + aws_reusable.enable_rgw_debug_logging(level=20) + debug_set = True + + try: + aws_reusable.remove_lua_script(context="prerequest") + except Exception as e: + log.info(f"No leftover prerequest script to remove: {e}") + + aws_reusable.create_bucket(cli_aws, bucket_name, endpoint) + bucket_created = True + + log.info(f"Upload blocking script ({BLOCK_MARKER}) to prerequest") + aws_reusable.set_lua_script( + context="prerequest", script_content=BLOCKING_SCRIPT + ) + script_set = True + stored = aws_reusable.get_lua_script(context="prerequest") + if BLOCK_MARKER not in stored: + raise TestExecError("blocking script was not stored in prerequest") + + blocked = os.path.join(TEST_DATA_PATH, "blocked.bin") + with open(blocked, "wb") as fh: + fh.write(b"should be blocked") + log.info("put_object immediately after upload — expect 403 (fixed path)") + aws_reusable.put_object_must_be_blocked( + cli_aws, + bucket_name, + "blocked.bin", + endpoint, + body=blocked, + fail_msg=( + "The put_object operation was not blocked by the Lua script " + "in the prerequest context (tracker #80576)." + ), + ) + + time.sleep(2) + lines = aws_reusable.grep_rgw_logs( + BLOCK_MARKER, + ssh_con=ssh_con, + haproxy=config.haproxy, + ) + log.info(f"Block-marker log lines found: {len(lines)}") + for ln in lines[-10:]: + log.info(ln) + if not lines: + raise TestExecError( + f"{BLOCK_MARKER} not found in RGW logs after blocked PUT. " + "Prerequest hook did not run the newly uploaded script." + ) + log.info(f"{BLOCK_MARKER} observed — script active after upload") + + log.info("Remove blocking script and wait for cache invalidation") + aws_reusable.remove_lua_script(context="prerequest") + script_set = False + time.sleep(lua_background_wait) + + unblocked = os.path.join(TEST_DATA_PATH, "unblocked.bin") + with open(unblocked, "wb") as fh: + fh.write(b"should pass") + log.info("put_object after script removal — expect success") + aws_reusable.put_object( + cli_aws, bucket_name, "unblocked.bin", endpoint, body=unblocked + ) + objects.append("unblocked.bin") + + if config.local_file_delete: + utils.exec_shell_cmd(f"rm -f {blocked} {unblocked}") + finally: + if script_set: + try: + aws_reusable.remove_lua_script(context="prerequest") + except Exception as e: + log.warning(f"Failed to remove prerequest script: {e}") + for key in objects: + try: + aws_reusable.delete_object(cli_aws, bucket_name, key, endpoint) + except Exception as e: + log.warning(f"delete_object {key}: {e}") + if bucket_created and delete_bucket: + try: + aws_reusable.delete_bucket(cli_aws, bucket_name, endpoint) + except Exception as e: + log.warning(f"Failed to delete bucket {bucket_name}: {e}") + if debug_set: + try: + aws_reusable.reset_rgw_debug_logging() + except Exception as e: + log.warning(f"Failed to reset debug_rgw: {e}") + if config.user_remove is True: + for u in user_info: + try: + s3_reusable.remove_user(u) + except Exception as e: + log.warning(f"Failed to remove user {u.get('user_id')}: {e}") + + crash_info = s3_reusable.check_for_crash() + if crash_info: + raise TestExecError("ceph daemon crash found!") + return + + if config.test_ops.get("prerequest_stale_bytecode_cache", False): + script_set = False + bucket_created = False + debug_set = False + objects = [] + try: + aws_reusable.enable_rgw_debug_logging(level=20) + debug_set = True + + aws_reusable.create_bucket(cli_aws, bucket_name, endpoint) + bucket_created = True + + log.info(f"Upload script A ({MARKER_A}) to prerequest") + aws_reusable.set_lua_script(context="prerequest", script_content=SCRIPT_A) + script_set = True + stored = aws_reusable.get_lua_script(context="prerequest") + if MARKER_A not in stored: + raise TestExecError("script A was not stored in prerequest") + + warmup = os.path.join(TEST_DATA_PATH, "warmup.bin") + with open(warmup, "wb") as fh: + fh.write(b"warmup") + log.info("Warm-up PUT to compile script A bytecode") + aws_reusable.put_object( + cli_aws, bucket_name, "warmup.bin", endpoint, body=warmup + ) + objects.append("warmup.bin") + log.info(f"Waiting {lua_background_wait}s for LuaBackground") + time.sleep(lua_background_wait) + + log.info("Remove script A and immediately upload script B (race window)") + aws_reusable.remove_lua_script(context="prerequest") + aws_reusable.set_lua_script(context="prerequest", script_content=SCRIPT_B) + stored_b = aws_reusable.get_lua_script(context="prerequest") + if MARKER_B not in stored_b: + raise TestExecError("script B was not stored in prerequest") + + time.sleep(1) + trigger = os.path.join(TEST_DATA_PATH, "trigger.bin") + with open(trigger, "wb") as fh: + fh.write(b"trigger") + log.info( + "Trigger PUT after script swap — expect 403 from script B (fixed path)" + ) + aws_reusable.put_object_must_be_blocked( + cli_aws, + bucket_name, + "trigger.bin", + endpoint, + body=trigger, + fail_msg=( + "Trigger PUT returned success — stale script A bytecode likely " + "still served (tracker #80532). Expected 403 from script B." + ), + ) + + time.sleep(2) + lines = aws_reusable.grep_rgw_logs( + f"{MARKER_A}|{MARKER_B}", + ssh_con=ssh_con, + haproxy=config.haproxy, + ) + log.info(f"Marker log lines found: {len(lines)}") + for ln in lines[-20:]: + log.info(ln) + if not any(MARKER_B in ln for ln in lines): + raise TestExecError( + f"{MARKER_B} not found in RGW logs after trigger PUT. " + "Script B did not run (possible stale bytecode cache)." + ) + log.info(f"{MARKER_B} observed — prerequest cache invalidated correctly") + + if config.local_file_delete: + utils.exec_shell_cmd(f"rm -f {warmup} {trigger}") + finally: + if script_set: + try: + aws_reusable.remove_lua_script(context="prerequest") + except Exception as e: + log.warning(f"Failed to remove prerequest script: {e}") + for key in objects: + try: + aws_reusable.delete_object(cli_aws, bucket_name, key, endpoint) + except Exception as e: + log.warning(f"delete_object {key}: {e}") + if bucket_created and delete_bucket: + try: + aws_reusable.delete_bucket(cli_aws, bucket_name, endpoint) + except Exception as e: + log.warning(f"Failed to delete bucket {bucket_name}: {e}") + if debug_set: + try: + aws_reusable.reset_rgw_debug_logging() + except Exception as e: + log.warning(f"Failed to reset debug_rgw: {e}") + if config.user_remove is True: + for u in user_info: + try: + s3_reusable.remove_user(u) + except Exception as e: + log.warning(f"Failed to remove user {u.get('user_id')}: {e}") + + crash_info = s3_reusable.check_for_crash() + if crash_info: + raise TestExecError("ceph daemon crash found!") + return + + if not config.test_ops.get("lua_postauth_cache", False): + raise TestExecError( + "Enable lua_postauth_cache, prerequest_stale_bytecode_cache, or " + "prerequest_cache_invalidation in test_ops" + ) + + measure_latency = config.test_ops.get("measure_latency", True) + latency_iterations = int(config.test_ops.get("latency_iterations", 20)) script_set = False bucket_created = False debug_set = False @@ -77,8 +329,6 @@ def test_exec(config, ssh_con): traces = {} try: - aws_auth.do_auth_aws(user) - # Lua 5.3/5.4 caps local variables per chunk at 200. # 199 local functions + local ok = 200 exactly. lua_lines = [ @@ -115,24 +365,8 @@ def test_exec(config, ssh_con): f"Generated Lua script is too small ({line_count} lines)" ) - log.info("Enabling log_to_file and debug_rgw=20") - utils.exec_shell_cmd("ceph config set global log_to_file true") - out_ps = utils.exec_shell_cmd("ceph orch ps --daemon_type rgw -f json") - rgw_daemons = json.loads(out_ps) - services = set() - for daemon in rgw_daemons: - service_name = daemon.get("service_name") - if service_name: - services.add(service_name) - daemon_name = daemon.get("daemon_name") - if daemon_name: - utils.exec_shell_cmd( - f"ceph config set client.{daemon_name} debug_rgw 20" - ) - for service_name in services: - utils.exec_shell_cmd(f"ceph config set client.{service_name} debug_rgw 20") + aws_reusable.enable_rgw_debug_logging(level=20) debug_set = True - time.sleep(3) log.info("Uploading script to prerequest") aws_reusable.set_lua_script(context="prerequest", script_content=lua_script) @@ -142,9 +376,6 @@ def test_exec(config, ssh_con): if "check_rule_0" not in retrieved or "local ok" not in retrieved: raise TestExecError("prerequest script was not stored correctly") - fsid = utils.get_cluster_fsid() - log_dir = f"/var/log/ceph/{fsid}" - for phase in ("cold", "warm", "followup"): if phase == "cold": log.info(f"First request (cold): create-bucket {bucket_name}") @@ -163,72 +394,12 @@ def test_exec(config, ssh_con): aws_reusable.list_objects(cli_aws, bucket_name, endpoint) time.sleep(2) - phase_lines = [] - search_all = config.haproxy - if not search_all: - if aws_reusable.check_log_directory_exists(log_dir, ssh_con): - rgw_log_files = aws_reusable.get_rgw_log_files(log_dir, ssh_con) - for log_file in rgw_log_files: - cmd = ( - f"sudo grep -iE '{log_grep}' {log_file} " - "2>/dev/null || true" - ) - if ssh_con: - _stdin, stdout, _stderr = ssh_con.exec_command(cmd) - out = stdout.read().decode() - else: - out = utils.exec_shell_cmd(cmd) - if out is False or out is None: - out = "" - if out and out.strip(): - for raw in out.strip().split("\n"): - if raw.strip(): - phase_lines.append(raw.strip()) - if not phase_lines: - log.info("No lua/cache lines on local node; checking all RGW hosts") - search_all = True - if search_all: - phase_lines = [] - for host in aws_reusable.get_all_rgw_hosts(): - try: - node_ssh = utils.connect_remote(host) - if not aws_reusable.check_log_directory_exists( - log_dir, node_ssh - ): - continue - rgw_log_files = aws_reusable.get_rgw_log_files( - log_dir, node_ssh, host - ) - for log_file in rgw_log_files: - cmd = ( - f"sudo grep -iE '{log_grep}' {log_file} " - "2>/dev/null || true" - ) - _stdin, stdout, _stderr = node_ssh.exec_command(cmd) - out = stdout.read().decode() - if out and out.strip(): - for raw in out.strip().split("\n"): - if raw.strip(): - phase_lines.append(f"[{host}] {raw.strip()}") - except Exception as e: - log.warning(f"Failed to grep RGW logs on {host}: {e}") - - cutoff = phase_start - 1 - recent = [] - for line in phase_lines: - raw = re.sub(r"^\[.*?\]\s+", "", line) - ts_match = re.match(r"^(\S+)\s", raw) - keep = True - if ts_match: - ts = ts_match.group(1) - if ts.endswith("+0000"): - ts = ts[:-5] + "+00:00" - try: - keep = datetime.fromisoformat(ts).timestamp() >= cutoff - except ValueError: - keep = True - if keep: - recent.append(line) + recent = aws_reusable.grep_rgw_logs( + log_grep, + ssh_con=ssh_con, + haproxy=config.haproxy, + since_epoch=phase_start, + ) traces[phase] = recent all_lua_lines.extend(recent) log.info(f"{phase} lua/cache trace: {len(recent)} matching line(s)") @@ -334,24 +505,7 @@ def test_exec(config, ssh_con): log.warning(f"Failed to delete bucket {bucket_name}: {e}") if debug_set: try: - log.info("Resetting debug_rgw to default") - out_ps = utils.exec_shell_cmd("ceph orch ps --daemon_type rgw -f json") - rgw_daemons = json.loads(out_ps) - services = set() - for daemon in rgw_daemons: - service_name = daemon.get("service_name") - if service_name: - services.add(service_name) - daemon_name = daemon.get("daemon_name") - if daemon_name: - utils.exec_shell_cmd( - f"ceph config rm client.{daemon_name} debug_rgw" - ) - for service_name in services: - utils.exec_shell_cmd( - f"ceph config rm client.{service_name} debug_rgw" - ) - log.info("debug_rgw reset for all RGW daemons") + aws_reusable.reset_rgw_debug_logging() except Exception as e: log.warning(f"Failed to reset debug_rgw: {e}") if config.user_remove is True: @@ -367,7 +521,7 @@ def test_exec(config, ssh_con): if __name__ == "__main__": - test_info = AddTestInfo("Lua postAuth bytecode cache test with awscli") + test_info = AddTestInfo("Lua bytecode cache tests with awscli") try: project_dir = os.path.abspath(os.path.join(__file__, "../../..")) @@ -377,12 +531,8 @@ def test_exec(config, ssh_con): if not os.path.exists(TEST_DATA_PATH): log.info("test data dir not exists, creating.. ") os.makedirs(TEST_DATA_PATH) - parser = argparse.ArgumentParser( - description="Lua postAuth bytecode cache test with awscli" - ) - parser.add_argument( - "-c", dest="config", help="Lua postAuth bytecode cache test with awscli" - ) + parser = argparse.ArgumentParser(description="Lua bytecode cache tests") + parser.add_argument("-c", dest="config", help="RGW Test yaml configuration") parser.add_argument( "-log_level", dest="log_level", @@ -402,7 +552,7 @@ def test_exec(config, ssh_con): configure_logging(f_name=log_f_name, set_level=args.log_level.upper()) config = resource_op.Config(yaml_file) config.read(ssh_con) - if config.mapped_sizes is None: + if config.mapped_sizes is None and config.objects_size_range is not None: config.mapped_sizes = utils.make_mapped_sizes(config) test_exec(config, ssh_con) test_info.success_status("test passed") diff --git a/rgw/v2/tests/aws/test_lua_script_prerequest.py b/rgw/v2/tests/aws/test_lua_script_prerequest.py index e33e2bef2a..5d30580977 100644 --- a/rgw/v2/tests/aws/test_lua_script_prerequest.py +++ b/rgw/v2/tests/aws/test_lua_script_prerequest.py @@ -264,22 +264,7 @@ def test_exec(config, ssh_con): log.info("Enabling RGW file logging and debug_rgw=20 for Lua RGWDebugLog") try: - utils.exec_shell_cmd("ceph config set global log_to_file true") - out_ps = utils.exec_shell_cmd("ceph orch ps --daemon_type rgw -f json") - rgw_daemons = json.loads(out_ps) - services = set() - for daemon in rgw_daemons: - service_name = daemon.get("service_name") - if service_name: - services.add(service_name) - daemon_name = daemon.get("daemon_name") - if daemon_name: - utils.exec_shell_cmd( - f"ceph config set client.{daemon_name} debug_rgw 20" - ) - for service_name in services: - utils.exec_shell_cmd(f"ceph config set client.{service_name} debug_rgw 20") - log.info("log_to_file and debug_rgw set for all RGW services and daemons") + aws_reusable.enable_rgw_debug_logging(level=20) except Exception as e: raise TestExecError(f"Failed to enable RGW Lua debug logging: {e}")