fix(deploy): 校准跨节点图片验收请求

真实成功样本使用 2048x2048,验收脚本改用相同默认尺寸并允许环境覆盖。修正创建 API Key 响应中的 apiKey.id 读取,每次运行前清理本脚本遗留 Key,结束时删除新 Key。\n\n验证:bash -n、ShellCheck、node --check、git diff --check。
This commit is contained in:
2026-07-29 03:13:01 +08:00
parent 5d5284e068
commit a642f43cf2
2 changed files with 22 additions and 8 deletions
+12 -2
View File
@@ -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',