feat: add generic queue and subscription retirement
This commit is contained in:
@@ -83,7 +83,7 @@ def setup():
|
||||
'ORBIT_TEST_BACKEND_SUBNET': '10.253.240.0/24',
|
||||
'ORBIT_TEST_SERVICES_SUBNET': '10.253.241.0/24',
|
||||
'ORBIT_CONSOLE_QUEUE_ID': '', 'ORBIT_ARCHIVE_STORAGE_ID': secrets.token_hex(16),
|
||||
'ORBIT_BUILD_VERSION': 'v0.1.1-local', 'ORBIT_BUILD_REVISION': revision,
|
||||
'ORBIT_BUILD_VERSION': 'v0.1.2-local', 'ORBIT_BUILD_REVISION': revision,
|
||||
'ORBIT_BUILD_TIME': datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
|
||||
private_write(PRIVATE / 'admin.password', secrets.token_urlsafe(24) + '\n')
|
||||
values = settings()
|
||||
|
||||
@@ -151,6 +151,19 @@ call('/v1/subscriptions/' + subscription_id + ':configure', pause, headers=manag
|
||||
assert call('/v1/subscriptions/' + subscription_id, token=rotate['token'], session=False)['credential_id'] == op['credential_id']
|
||||
assert call('/console/scope')['entry']['namespace_id'] == original_scope['entry']['namespace_id']
|
||||
print('PASS: scoped task/schedule/workflow/subscription/retention/archive reads, subscription management/replay, SDK ownership, CSRF and cross-application isolation')
|
||||
# 通用退役管理:只操作本测试新建空资源,验证跨应用管理员范围和 CSRF。
|
||||
retire_queue = call('/v1/queues', {'name':'retire-'+uuid.uuid4().hex[:8], 'max_concurrency':1, 'rate_per_second':10}, token=rotate['token'], session=False, headers={'Idempotency-Key':uuid.uuid4().hex}, expected=201)['queue']
|
||||
retire_sub = call('/v1/subscriptions', {'name':'retire-'+uuid.uuid4().hex[:8], 'queue_id':retire_queue['id']}, token=rotate['token'], session=False, headers={'Idempotency-Key':uuid.uuid4().hex}, expected=201)['subscription']
|
||||
capacity_before = call('/console/applications/'+op['namespace_id'])['active_subscriptions']
|
||||
retire_body = {'expected_revision':retire_sub['revision'], 'reason':'completed isolated acceptance'}
|
||||
retire_headers = {**scope_headers,'Idempotency-Key':uuid.uuid4().hex}
|
||||
call('/v1/subscriptions/'+retire_sub['id']+':retire', retire_body, headers={**retire_headers,'Origin':'https://other.invalid'}, expected=403)
|
||||
assert call('/v1/subscriptions/'+retire_sub['id']+':retire', retire_body, headers=retire_headers)['subscription']['retired_at']
|
||||
assert call('/v1/subscriptions/'+retire_sub['id']+':retire', retire_body, headers=retire_headers)['deduplicated']
|
||||
assert call('/console/applications/'+op['namespace_id'])['active_subscriptions'] == capacity_before-1
|
||||
assert call('/v1/queues/'+retire_queue['id']+':retire', {'expected_revision':retire_queue['revision'],'reason':'completed isolated acceptance'}, headers={**scope_headers,'Idempotency-Key':uuid.uuid4().hex})['queue']['retired_at']
|
||||
assert call('/v1/queues/'+retire_queue['id'], headers=scope_headers)['retired_at']
|
||||
print('PASS: scoped resource retirement, CSRF, idempotency, historical reads and released subscription capacity')
|
||||
call('/console/auth/logout', {})
|
||||
call(token_path + 'reveal', {'expected_revision':'4'}, expected=401)
|
||||
call('/console/applications', expected=401)
|
||||
|
||||
@@ -84,6 +84,7 @@ if [ -z "$TASK_HTTP_PORT" ]; then printf '%s\n' 'Bootstrap HTTP server did not s
|
||||
(cd examples && ORBIT_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_CREDENTIALS_FILE="$TASK_TEST_DIR/sdk.credentials.json" "$TASK_GO" run ./task-query)
|
||||
ORBIT_MYSQL_DSN="$ORBIT_TEST_MYSQL_DSN" "$TASK_TEST_DIR/orbit-admin" bootstrap --application sdk-worker --namespace default --environment test --queue worker-examples --worker-access --schedule-access --event-access --output "$TASK_TEST_DIR/worker.credentials.json"
|
||||
(cd sdk/go && ORBIT_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_CREDENTIALS_FILE="$TASK_TEST_DIR/worker.credentials.json" "$TASK_TEST_DIR/orbit-exec-load" -requests 6 -concurrency 2 -workers 2 -capacity 2 -durations 0ms,100ms -run-timeout 30s)
|
||||
(cd sdk/go && ORBIT_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_CREDENTIALS_FILE="$TASK_TEST_DIR/worker.credentials.json" "$TASK_GO" run ./examples/resource-lifecycle)
|
||||
(cd sdk/go && ORBIT_TEST_WORKER_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_TEST_WORKER_CREDENTIALS_FILE="$TASK_TEST_DIR/worker.credentials.json" "$TASK_GO" test -race -count=1 -run 'IntegrationWorker(Connection|Runtime)' -v .)
|
||||
(cd sdk/go && ORBIT_TEST_WORKER_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_TEST_WORKER_CREDENTIALS_FILE="$TASK_TEST_DIR/worker.credentials.json" "$TASK_GO" test -race -count=1 -run '^TestIntegrationSchedule' -v .)
|
||||
(cd sdk/go && ORBIT_TEST_WORKER_URL="http://127.0.0.1:$TASK_HTTP_PORT" ORBIT_TEST_WORKER_CREDENTIALS_FILE="$TASK_TEST_DIR/worker.credentials.json" "$TASK_GO" test -race -count=1 -run '^TestIntegrationQueueResourcesSDK$' -v .)
|
||||
|
||||
Reference in New Issue
Block a user