From a642f43cf2f1f7b870341c06383053cedcdbe8ad Mon Sep 17 00:00:00 2001 From: wangbo Date: Wed, 29 Jul 2026 03:13:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E6=A0=A1=E5=87=86=E8=B7=A8?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=9B=BE=E7=89=87=E9=AA=8C=E6=94=B6=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 真实成功样本使用 2048x2048,验收脚本改用相同默认尺寸并允许环境覆盖。修正创建 API Key 响应中的 apiKey.id 读取,每次运行前清理本脚本遗留 Key,结束时删除新 Key。\n\n验证:bash -n、ShellCheck、node --check、git diff --check。 --- scripts/cluster/cross-node-file-e2e.mjs | 14 ++++++++++++-- scripts/cluster/run-cross-node-file-e2e.sh | 16 ++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/scripts/cluster/cross-node-file-e2e.mjs b/scripts/cluster/cross-node-file-e2e.mjs index 8a2b775..b6c4de5 100755 --- a/scripts/cluster/cross-node-file-e2e.mjs +++ b/scripts/cluster/cross-node-file-e2e.mjs @@ -55,7 +55,9 @@ const baseURL = process.env.AI_GATEWAY_E2E_BASE_URL || 'http://10.77.0.1:18089' const account = Buffer.from(process.env.E2E_ACCOUNT_B64 || '', 'base64').toString('utf8') const password = Buffer.from(process.env.E2E_PASSWORD_B64 || '', 'base64').toString('utf8') const model = process.env.AI_GATEWAY_E2E_IMAGE_MODEL || 'openai:gpt-image-1' +const imageSize = process.env.AI_GATEWAY_E2E_IMAGE_SIZE || '2048x2048' assert(account && password, 'E2E login credentials are unavailable') +assert(/^\d+x\d+$/.test(imageSize), 'E2E image size is invalid') async function request(path, { method = 'GET', token, body, form } = {}) { const headers = { Host: 'ai.51easyai.com' } @@ -95,6 +97,13 @@ const login = await request('/api/v1/auth/login', { const jwt = login.payload.accessToken assert(typeof jwt === 'string' && jwt.length > 20, 'login did not return an access token') +const existingKeys = await request('/api/v1/api-keys', { token: jwt }) +for (const item of existingKeys.payload.items || []) { + if (typeof item?.id === 'string' && item?.name?.startsWith('cluster-cross-node-')) { + await request(`/api/v1/api-keys/${item.id}`, { method: 'DELETE', token: jwt }) + } +} + const keyName = `cluster-cross-node-${Date.now()}` const keyResult = await request('/api/v1/api-keys', { method: 'POST', @@ -102,8 +111,9 @@ const keyResult = await request('/api/v1/api-keys', { body: { name: keyName }, }) const apiKey = keyResult.payload.secret -const apiKeyId = keyResult.payload.id || keyResult.payload.item?.id +const apiKeyId = keyResult.payload.apiKey?.id assert(typeof apiKey === 'string' && apiKey.startsWith('sk-gw-'), 'API key creation failed') +assert(typeof apiKeyId === 'string' && apiKeyId.length > 0, 'API key ID is unavailable') let result try { @@ -112,7 +122,7 @@ try { const form = new FormData() form.append('model', model) form.append('prompt', `Cross-node HA acceptance ${randomUUID()}: add a thin white border`) - form.append('size', '1024x1024') + form.append('size', imageSize) form.append('image', new Blob([fixture], { type: 'image/png' }), 'cluster-e2e.png') const accepted = await request('/api/v1/images/edits', { method: 'POST', diff --git a/scripts/cluster/run-cross-node-file-e2e.sh b/scripts/cluster/run-cross-node-file-e2e.sh index bfd1fed..e6591da 100755 --- a/scripts/cluster/run-cross-node-file-e2e.sh +++ b/scripts/cluster/run-cross-node-file-e2e.sh @@ -38,12 +38,16 @@ REMOTE credentials_file=$(mktemp "$cluster_root/.local-secrets/cluster/e2e.XXXXXX") trap 'rm -f -- "$credentials_file"; restore_workers' EXIT HUP INT TERM chmod 0600 "$credentials_file" -printf 'E2E_ACCOUNT_B64=%s\n' "$(printf '%s' "$AI_GATEWAY_ONLINE_ACCOUNT" | base64 | tr -d '\n')" \ - >"$credentials_file" -printf 'E2E_PASSWORD_B64=%s\n' "$(printf '%s' "$AI_GATEWAY_ONLINE_PASSWORD" | base64 | tr -d '\n')" \ - >>"$credentials_file" -printf 'AI_GATEWAY_E2E_IMAGE_MODEL=%s\n' "${AI_GATEWAY_E2E_IMAGE_MODEL:-openai:gpt-image-1}" \ - >>"$credentials_file" +{ + printf 'E2E_ACCOUNT_B64=%s\n' \ + "$(printf '%s' "$AI_GATEWAY_ONLINE_ACCOUNT" | base64 | tr -d '\n')" + printf 'E2E_PASSWORD_B64=%s\n' \ + "$(printf '%s' "$AI_GATEWAY_ONLINE_PASSWORD" | base64 | tr -d '\n')" + printf 'AI_GATEWAY_E2E_IMAGE_MODEL=%s\n' \ + "${AI_GATEWAY_E2E_IMAGE_MODEL:-openai:gpt-image-1}" + printf 'AI_GATEWAY_E2E_IMAGE_SIZE=%s\n' \ + "${AI_GATEWAY_E2E_IMAGE_SIZE:-2048x2048}" +} >"$credentials_file" cluster_scp "$credentials_file" "$CLUSTER_NINGBO_HOST:/root/easyai-cross-node-e2e.env" cluster_scp "$script_dir/cross-node-file-e2e.mjs" \ "$CLUSTER_NINGBO_HOST:/root/easyai-cross-node-file-e2e.mjs"