test: retry transient unauthenticated upload probe
This commit is contained in:
@@ -72,6 +72,20 @@ function expectedRejection(response) {
|
||||
return response?.http === 200 && response?.body && String(response.body.code) !== '200'
|
||||
}
|
||||
|
||||
export function isTransientGatewayFailure(response) {
|
||||
return response?.http === 0 || response?.http === 502 || response?.http === 503
|
||||
}
|
||||
|
||||
async function unauthenticatedMultipart(context, path, file) {
|
||||
let response = null
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
response = await multipart(context, path, file, '')
|
||||
if (!isTransientGatewayFailure(response) || attempt === 3) return response
|
||||
await new Promise((resolve) => setTimeout(resolve, attempt * 750))
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
function markerVisible(detail, marker) {
|
||||
const values = [
|
||||
detail?.publicRemark,
|
||||
@@ -435,7 +449,7 @@ export async function run(context) {
|
||||
}
|
||||
|
||||
const uploadPath = `/api/platform/v1/files/measurements/${encodeURIComponent(target.tenantId)}/${encodeURIComponent(target.inboundId)}`
|
||||
const noAuth = await multipart(context, uploadPath, image, '')
|
||||
const noAuth = await unauthenticatedMultipart(context, uploadPath, image)
|
||||
context.assert(MODULE, '未认证请求不能上传称重图片', noAuth,
|
||||
noAuth.http === 401 || noAuth.http === 403,
|
||||
`HTTP=${noAuth.http}, code=${noAuth.body?.code ?? 'none'}`, SCENARIO_OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user