@camunda/e2e-test-suite 0.0.501 → 0.0.503
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils/apiHelpers.js
CHANGED
|
@@ -303,29 +303,61 @@ async function createProcessInstance(processDefinitionKey, authToken, environmen
|
|
|
303
303
|
}
|
|
304
304
|
exports.createProcessInstance = createProcessInstance;
|
|
305
305
|
async function createClusterVariableInternal(authToken, environment, variableName, variableValue, variableType, clusterType) {
|
|
306
|
+
// Retry on transient ingress / upstream errors (502/503/504) and on
|
|
307
|
+
// network-layer exceptions, which we have observed during nightly runs
|
|
308
|
+
// when the orchestration cluster gateway is in the middle of a rollout.
|
|
309
|
+
// The actual "create" semantics are idempotent because HTTP 409 is
|
|
310
|
+
// already treated as success below.
|
|
311
|
+
const maxAttempts = 5;
|
|
312
|
+
const baseDelayMs = 2000;
|
|
313
|
+
let lastErrorMessage = '';
|
|
306
314
|
try {
|
|
307
315
|
apiRequestContext = await getApiRequestContext();
|
|
308
316
|
const url = buildZeebeApiUrl('/v2/cluster-variables/global', environment, clusterType);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
317
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
318
|
+
let status;
|
|
319
|
+
let bodyText = '';
|
|
320
|
+
try {
|
|
321
|
+
const response = await apiRequestContext.post(url, {
|
|
322
|
+
headers: {
|
|
323
|
+
Authorization: authToken,
|
|
324
|
+
},
|
|
325
|
+
data: {
|
|
326
|
+
name: variableName,
|
|
327
|
+
value: variableValue,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
status = response.status();
|
|
331
|
+
if (status === 200 || status === 201 || status === 204) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
// Handle "already exists" as a benign condition
|
|
335
|
+
if (status === 409) {
|
|
336
|
+
console.warn(`${variableType} cluster variable "${variableName}" already exists (HTTP 409).`);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
bodyText = await response.text();
|
|
340
|
+
lastErrorMessage = `HTTP ${status} - ${bodyText.slice(0, 200)}`;
|
|
341
|
+
// Retry on transient gateway / upstream errors.
|
|
342
|
+
if (status >= 502 && status <= 504 && attempt < maxAttempts) {
|
|
343
|
+
console.warn(`createClusterVariable "${variableName}" attempt ${attempt}/${maxAttempts} got HTTP ${status}; retrying...`);
|
|
344
|
+
await new Promise((r) => setTimeout(r, baseDelayMs * attempt));
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
catch (networkErr) {
|
|
349
|
+
// Network-layer error (e.g. ECONNRESET while the gateway is
|
|
350
|
+
// restarting). Retry a few times before giving up.
|
|
351
|
+
lastErrorMessage =
|
|
352
|
+
networkErr instanceof Error ? networkErr.message : String(networkErr);
|
|
353
|
+
if (attempt < maxAttempts) {
|
|
354
|
+
console.warn(`createClusterVariable "${variableName}" attempt ${attempt}/${maxAttempts} threw (${lastErrorMessage}); retrying...`);
|
|
355
|
+
await new Promise((r) => setTimeout(r, baseDelayMs * attempt));
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
throw new Error(`Failed to create ${variableType} cluster variable "${variableName}": ${lastErrorMessage}`);
|
|
326
360
|
}
|
|
327
|
-
const bodyText = await response.text();
|
|
328
|
-
throw new Error(`Failed to create ${variableType} cluster variable "${variableName}": HTTP ${status} - ${bodyText}`);
|
|
329
361
|
}
|
|
330
362
|
catch (error) {
|
|
331
363
|
if (error instanceof Error && error.message.includes('Failed to create')) {
|
|
@@ -23,7 +23,15 @@ const clickLocatorWithRetry = async (page, locator, options) => {
|
|
|
23
23
|
throw new Error('clickLocatorWithRetry: page is closed, aborting retries');
|
|
24
24
|
}
|
|
25
25
|
if (options?.preAction) {
|
|
26
|
-
|
|
26
|
+
try {
|
|
27
|
+
await options.preAction();
|
|
28
|
+
}
|
|
29
|
+
catch (preErr) {
|
|
30
|
+
if (isPageClosedError(preErr)) {
|
|
31
|
+
throw preErr;
|
|
32
|
+
}
|
|
33
|
+
console.warn(`clickLocatorWithRetry: preAction (attempt ${attempt}) threw and will be retried:`, preErr instanceof Error ? preErr.message : preErr);
|
|
34
|
+
}
|
|
27
35
|
}
|
|
28
36
|
await locator.waitFor({ state: 'visible', timeout: visibilityTimeout });
|
|
29
37
|
await locator.scrollIntoViewIfNeeded({ timeout: visibilityTimeout });
|
|
@@ -39,7 +47,18 @@ const clickLocatorWithRetry = async (page, locator, options) => {
|
|
|
39
47
|
}
|
|
40
48
|
console.log(`Attempt ${attempt} failed for ${locator}, retrying... Error: ${err}`);
|
|
41
49
|
if (options?.postAction) {
|
|
42
|
-
|
|
50
|
+
// Swallow transient errors from the recovery action (e.g.
|
|
51
|
+
// `page.reload()` throwing ERR_CONNECTION_REFUSED while the
|
|
52
|
+
// upstream is restarting). Retry the click on the next loop.
|
|
53
|
+
try {
|
|
54
|
+
await options.postAction();
|
|
55
|
+
}
|
|
56
|
+
catch (postErr) {
|
|
57
|
+
if (isPageClosedError(postErr)) {
|
|
58
|
+
throw postErr;
|
|
59
|
+
}
|
|
60
|
+
console.warn(`clickLocatorWithRetry: postAction (attempt ${attempt}) threw and will be retried:`, postErr instanceof Error ? postErr.message : postErr);
|
|
61
|
+
}
|
|
43
62
|
}
|
|
44
63
|
await page.waitForTimeout(retryDelayMs);
|
|
45
64
|
}
|
|
@@ -9,7 +9,12 @@ const expectLocatorWithRetry = async (page, item, options) => {
|
|
|
9
9
|
attempt++;
|
|
10
10
|
try {
|
|
11
11
|
if (options?.preAction) {
|
|
12
|
-
|
|
12
|
+
try {
|
|
13
|
+
await options.preAction();
|
|
14
|
+
}
|
|
15
|
+
catch (preErr) {
|
|
16
|
+
console.warn(`expectLocatorWithRetry: preAction (attempt ${attempt}) threw and will be retried:`, preErr instanceof Error ? preErr.message : preErr);
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
await page.waitForLoadState('domcontentloaded');
|
|
15
20
|
await item.waitFor({
|
|
@@ -21,7 +26,17 @@ const expectLocatorWithRetry = async (page, item, options) => {
|
|
|
21
26
|
catch (err) {
|
|
22
27
|
console.log(`Attempt ${attempt} failed for ${item}, retrying...`, err instanceof Error ? err.message : err);
|
|
23
28
|
if (options?.postAction) {
|
|
24
|
-
|
|
29
|
+
// Swallow transient errors from the recovery action (e.g.
|
|
30
|
+
// `page.reload()` throwing ERR_CONNECTION_REFUSED while the
|
|
31
|
+
// upstream is restarting). The next loop iteration will retry
|
|
32
|
+
// the visibility check itself, which is what we ultimately
|
|
33
|
+
// care about.
|
|
34
|
+
try {
|
|
35
|
+
await options.postAction();
|
|
36
|
+
}
|
|
37
|
+
catch (postErr) {
|
|
38
|
+
console.warn(`expectLocatorWithRetry: postAction (attempt ${attempt}) threw and will be retried:`, postErr instanceof Error ? postErr.message : postErr);
|
|
39
|
+
}
|
|
25
40
|
}
|
|
26
41
|
await page.waitForTimeout(500);
|
|
27
42
|
}
|