fix(deploy): 校准跨节点图片验收请求
真实成功样本使用 2048x2048,验收脚本改用相同默认尺寸并允许环境覆盖。修正创建 API Key 响应中的 apiKey.id 读取,每次运行前清理本脚本遗留 Key,结束时删除新 Key。\n\n验证:bash -n、ShellCheck、node --check、git diff --check。
This commit is contained in:
@@ -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 account = Buffer.from(process.env.E2E_ACCOUNT_B64 || '', 'base64').toString('utf8')
|
||||||
const password = Buffer.from(process.env.E2E_PASSWORD_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 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(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 } = {}) {
|
async function request(path, { method = 'GET', token, body, form } = {}) {
|
||||||
const headers = { Host: 'ai.51easyai.com' }
|
const headers = { Host: 'ai.51easyai.com' }
|
||||||
@@ -95,6 +97,13 @@ const login = await request('/api/v1/auth/login', {
|
|||||||
const jwt = login.payload.accessToken
|
const jwt = login.payload.accessToken
|
||||||
assert(typeof jwt === 'string' && jwt.length > 20, 'login did not return an access token')
|
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 keyName = `cluster-cross-node-${Date.now()}`
|
||||||
const keyResult = await request('/api/v1/api-keys', {
|
const keyResult = await request('/api/v1/api-keys', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -102,8 +111,9 @@ const keyResult = await request('/api/v1/api-keys', {
|
|||||||
body: { name: keyName },
|
body: { name: keyName },
|
||||||
})
|
})
|
||||||
const apiKey = keyResult.payload.secret
|
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 apiKey === 'string' && apiKey.startsWith('sk-gw-'), 'API key creation failed')
|
||||||
|
assert(typeof apiKeyId === 'string' && apiKeyId.length > 0, 'API key ID is unavailable')
|
||||||
|
|
||||||
let result
|
let result
|
||||||
try {
|
try {
|
||||||
@@ -112,7 +122,7 @@ try {
|
|||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('model', model)
|
form.append('model', model)
|
||||||
form.append('prompt', `Cross-node HA acceptance ${randomUUID()}: add a thin white border`)
|
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')
|
form.append('image', new Blob([fixture], { type: 'image/png' }), 'cluster-e2e.png')
|
||||||
const accepted = await request('/api/v1/images/edits', {
|
const accepted = await request('/api/v1/images/edits', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -38,12 +38,16 @@ REMOTE
|
|||||||
credentials_file=$(mktemp "$cluster_root/.local-secrets/cluster/e2e.XXXXXX")
|
credentials_file=$(mktemp "$cluster_root/.local-secrets/cluster/e2e.XXXXXX")
|
||||||
trap 'rm -f -- "$credentials_file"; restore_workers' EXIT HUP INT TERM
|
trap 'rm -f -- "$credentials_file"; restore_workers' EXIT HUP INT TERM
|
||||||
chmod 0600 "$credentials_file"
|
chmod 0600 "$credentials_file"
|
||||||
printf 'E2E_ACCOUNT_B64=%s\n' "$(printf '%s' "$AI_GATEWAY_ONLINE_ACCOUNT" | base64 | tr -d '\n')" \
|
{
|
||||||
>"$credentials_file"
|
printf 'E2E_ACCOUNT_B64=%s\n' \
|
||||||
printf 'E2E_PASSWORD_B64=%s\n' "$(printf '%s' "$AI_GATEWAY_ONLINE_PASSWORD" | base64 | tr -d '\n')" \
|
"$(printf '%s' "$AI_GATEWAY_ONLINE_ACCOUNT" | base64 | tr -d '\n')"
|
||||||
>>"$credentials_file"
|
printf 'E2E_PASSWORD_B64=%s\n' \
|
||||||
printf 'AI_GATEWAY_E2E_IMAGE_MODEL=%s\n' "${AI_GATEWAY_E2E_IMAGE_MODEL:-openai:gpt-image-1}" \
|
"$(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}"
|
||||||
|
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 "$credentials_file" "$CLUSTER_NINGBO_HOST:/root/easyai-cross-node-e2e.env"
|
||||||
cluster_scp "$script_dir/cross-node-file-e2e.mjs" \
|
cluster_scp "$script_dir/cross-node-file-e2e.mjs" \
|
||||||
"$CLUSTER_NINGBO_HOST:/root/easyai-cross-node-file-e2e.mjs"
|
"$CLUSTER_NINGBO_HOST:/root/easyai-cross-node-file-e2e.mjs"
|
||||||
|
|||||||
Reference in New Issue
Block a user