feat: complete transfer and eviction execution
This commit is contained in:
@@ -9,8 +9,6 @@ import sys
|
||||
import time
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
CONTROL = "http://127.0.0.1:18081/test/v1"
|
||||
@@ -103,30 +101,18 @@ def main() -> int:
|
||||
60,
|
||||
f"{args.cache_client}/{args.archive_client} route",
|
||||
)
|
||||
job_id = str(uuid.uuid4())
|
||||
now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
|
||||
definition = {
|
||||
"jobId": job_id,
|
||||
"idempotencyKey": str(uuid.uuid4()),
|
||||
"operation": (
|
||||
"JOB_OPERATION_ARCHIVE"
|
||||
if args.operation == "archive"
|
||||
else "JOB_OPERATION_UNARCHIVE"
|
||||
),
|
||||
"resourceId": {"infoHashV1Hex": INFO_HASH},
|
||||
"resourceDisplayName": "fixture.bin",
|
||||
"createdAt": now,
|
||||
"transfer": {
|
||||
"sourceClientId": args.source_client,
|
||||
"targetClientId": args.target_client,
|
||||
"routeId": route["route_id"],
|
||||
"requestedFiles": {"ranges": [{"first": 0, "last": 0}]},
|
||||
"transferDeltaFiles": {"ranges": [{"first": 0, "last": 0}]},
|
||||
"requestedLogicalBytes": str(LOGICAL_BYTES),
|
||||
"transferDeltaLogicalBytes": str(LOGICAL_BYTES),
|
||||
},
|
||||
}
|
||||
created = post_json(f"{CONTROL}/jobs", definition)
|
||||
preview = post_json(f"{CONTROL}/jobs/preview", {
|
||||
"operation": args.operation,
|
||||
"source_client_id": args.source_client,
|
||||
"target_client_id": args.target_client,
|
||||
"resource_id": {"info_hash_v1_hex": INFO_HASH},
|
||||
})
|
||||
definition = preview["definition"]
|
||||
job_id = definition["job_id"]
|
||||
created = post_json(f"{CONTROL}/jobs", {
|
||||
"preview_revision": preview["preview_revision"],
|
||||
"definition": definition,
|
||||
})
|
||||
if created["job_id"] != job_id:
|
||||
raise RuntimeError("control returned the wrong job")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user