mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
fix(table-catalog): pass PyIceberg live smoke (#4637)
* fix(table-catalog): pass PyIceberg live smoke * fix(table-catalog): satisfy live smoke clippy --------- Co-authored-by: Henry Guo <marshawcoco@users.noreply.github.com>
This commit is contained in:
@@ -1185,6 +1185,15 @@ def run_view_probe(args: argparse.Namespace, deps: RuntimeDeps) -> None:
|
||||
raise
|
||||
|
||||
|
||||
def maintenance_job_id(job: object) -> str | None:
|
||||
if not isinstance(job, dict):
|
||||
return None
|
||||
value = job.get("job-id") or job.get("job_id")
|
||||
if not isinstance(value, str) or not value:
|
||||
return None
|
||||
return value
|
||||
|
||||
|
||||
def run_maintenance_probe(args: argparse.Namespace, deps: RuntimeDeps) -> None:
|
||||
config_path = table_endpoint_path(args, "/maintenance/config")
|
||||
scheduler_path = table_endpoint_path(args, "/maintenance/scheduler")
|
||||
@@ -1202,21 +1211,22 @@ def run_maintenance_probe(args: argparse.Namespace, deps: RuntimeDeps) -> None:
|
||||
{"retain-recent-metadata-files": 1, "delete": False},
|
||||
)
|
||||
job = report.get("job")
|
||||
if not isinstance(job, dict) or not job.get("job-id"):
|
||||
job_id = maintenance_job_id(job)
|
||||
if job_id is None:
|
||||
raise RuntimeError("maintenance metadata endpoint did not return a job id")
|
||||
audit_events = report.get("audit-events")
|
||||
if not isinstance(audit_events, list) or not audit_events:
|
||||
raise RuntimeError("maintenance metadata endpoint did not return audit events")
|
||||
if not any(isinstance(event, dict) and event.get("action") == "PLANNED" for event in audit_events):
|
||||
raise RuntimeError("maintenance metadata endpoint did not report a planning audit event")
|
||||
job_report = signed_rest_request(args, deps, "GET", table_endpoint_path(args, f"/maintenance/jobs/{job['job-id']}"))
|
||||
job_report = signed_rest_request(args, deps, "GET", table_endpoint_path(args, f"/maintenance/jobs/{job_id}"))
|
||||
if not isinstance(job_report.get("audit-events"), list):
|
||||
raise RuntimeError("maintenance job endpoint did not return audit events")
|
||||
quarantine = signed_rest_request(
|
||||
args,
|
||||
deps,
|
||||
"POST",
|
||||
table_endpoint_path(args, f"/maintenance/jobs/{job['job-id']}/quarantine"),
|
||||
table_endpoint_path(args, f"/maintenance/jobs/{job_id}/quarantine"),
|
||||
{"action": "INSPECT"},
|
||||
)
|
||||
if quarantine.get("action") != "INSPECT" or not isinstance(quarantine.get("report"), dict):
|
||||
|
||||
@@ -336,11 +336,11 @@ class PyIcebergSmokeConfigTest(unittest.TestCase):
|
||||
if (method, path) == ("GET", config_path):
|
||||
return {"version": 1}
|
||||
if (method, path) == ("POST", maintenance_path):
|
||||
return {"job": {"job-id": "job-1"}, "audit-events": [{"action": "PLANNED"}]}
|
||||
return {"job": {"job_id": "job-1"}, "audit-events": [{"action": "PLANNED"}]}
|
||||
if (method, path) == ("GET", job_path):
|
||||
return {"job": {"job-id": "job-1", "status": "SUCCESSFUL"}, "audit-events": [{"action": "PLANNED"}]}
|
||||
if (method, path) == ("POST", quarantine_path):
|
||||
return {"action": "INSPECT", "report": {"job": {"job-id": "job-1"}}}
|
||||
return {"action": "INSPECT", "report": {"job": {"job_id": "job-1"}}}
|
||||
if (method, path) == ("GET", scheduler_path):
|
||||
return {"status": "DISABLED", "audit_timeline": [{"job_id": "job-1", "audit-events": [{"action": "PLANNED"}]}]}
|
||||
if (method, path) == ("POST", scheduler_run_path):
|
||||
@@ -406,11 +406,11 @@ class PyIcebergSmokeConfigTest(unittest.TestCase):
|
||||
if (method, path) == ("GET", config_path):
|
||||
return {"version": 1}
|
||||
if (method, path) == ("POST", maintenance_path):
|
||||
return {"job": {"job-id": "job-1"}, "audit-events": [{"action": "PLANNED"}]}
|
||||
return {"job": {"job_id": "job-1"}, "audit-events": [{"action": "PLANNED"}]}
|
||||
if (method, path) == ("GET", pyiceberg_smoke.table_endpoint_path(args, "/maintenance/jobs/job-1")):
|
||||
return {"job": {"job-id": "job-1", "status": "SUCCESSFUL"}, "audit-events": [{"action": "PLANNED"}]}
|
||||
if (method, path) == ("POST", quarantine_path):
|
||||
return {"action": "INSPECT", "report": {"job": {"job-id": "job-1"}}}
|
||||
return {"action": "INSPECT", "report": {"job": {"job_id": "job-1"}}}
|
||||
if (method, path) == ("GET", scheduler_path):
|
||||
return {"status": "DISABLED", "audit_timeline": [{"job_id": "job-1", "audit-events": [{"action": "PLANNED"}]}]}
|
||||
if (method, path) == ("POST", scheduler_run_path):
|
||||
|
||||
Reference in New Issue
Block a user