Skip to content

Commit 6c67180

Browse files
committed
feat: cycle through worker pool on retry
linting
1 parent 2407b4c commit 6c67180

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

run/test/specs/utils/open_app.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,21 @@ const openiOSApp = async (
292292
}> => {
293293
console.info('openiOSApp');
294294

295-
// Calculate the actual capabilities index for the current worker
296-
const actualCapabilitiesIndex =
297-
capabilitiesIndex + getDevicesPerTestCount() * parseInt(process.env.TEST_PARALLEL_INDEX || '0');
295+
const parallelIndex = parseInt(process.env.TEST_PARALLEL_INDEX || '0');
296+
const devicesPerWorker = getDevicesPerTestCount();
297+
298+
// Calculate base offset for this worker
299+
const workerBaseOffset = devicesPerWorker * parallelIndex;
300+
301+
// Add retry offset, but wrap within the worker's device pool only
302+
// This means when retrying, a alice/bob etc won't be the same device as before within a worker's pool
303+
const retryOffset = testInfo.retry || 0;
304+
const deviceIndexWithinWorker = (capabilitiesIndex + retryOffset) % devicesPerWorker;
305+
const actualCapabilitiesIndex = workerBaseOffset + deviceIndexWithinWorker;
306+
307+
console.info(
308+
`Worker ${parallelIndex}, Base Device ${capabilitiesIndex}, Retry ${retryOffset} -> Device ${actualCapabilitiesIndex}`
309+
);
298310

299311
const opts: XCUITestDriverOpts = {
300312
address: `http://localhost:${APPIUM_PORT}`,

0 commit comments

Comments
 (0)