1 | "use strict";
|
2 |
|
3 | const utils = require('../utils');
|
4 | const config = require('../commons/config');
|
5 | const testimCustomToken = require('../commons/testimCustomToken');
|
6 | const BaseRunner = require('./BaseRunner');
|
7 | const TestRunStatus = require('../testRunStatus');
|
8 | const reporter = require("../reports/reporter");
|
9 | const Logger = require('../commons/logger');
|
10 | const gridService = require('../services/gridService');
|
11 | const logger = Logger.getLogger('remote-test-runner');
|
12 |
|
13 | class DeviceFarmRemoteRunner extends BaseRunner {
|
14 | runExecution(testList, testStatus, executionId, options, branchToUse) {
|
15 | const projectId = options.project;
|
16 | const sessionType = utils.getSessionType(options);
|
17 |
|
18 | const authData = testimCustomToken.getTokenV3UserData();
|
19 | this.analyticsExecsStart({authData, executionId, projectId, sessionType});
|
20 | const workerCount = config.TESTIM_CONCURRENT_WORKER_COUNT || options.parallel;
|
21 |
|
22 | return this.strategy.runTests(testList, testStatus, executionId, options, branchToUse, authData, workerCount);
|
23 | }
|
24 |
|
25 | runTest(executionId, testList, gridInfo, branchToUse, options) {
|
26 | Logger.setExecutionId(executionId);
|
27 |
|
28 | logger.info("start to remote runner", {
|
29 | executionId: executionId,
|
30 | options: Object.assign({}, options, {token: undefined}),
|
31 | branchToUse: branchToUse,
|
32 | });
|
33 |
|
34 | const testPlanName = "remote run";
|
35 | const testStatus = new TestRunStatus(testList, options, branchToUse);
|
36 | reporter.onTestPlanStarted([], testList, [], testPlanName, executionId);
|
37 |
|
38 | const workerId = 1;
|
39 | const browserType = options.projectData.type;
|
40 | const {gridId, slotId} = gridInfo;
|
41 | gridService.addItemToGridCache(workerId, gridId, slotId, browserType);
|
42 | options.disableWindowAnimation = options.remoteRunObject.echoedOptions.disableWindowAnimation
|
43 | options.baseUrl = options.remoteRunObject.echoedOptions.baseUrl
|
44 | return this.runExecution(testList, testStatus, executionId, options, branchToUse)
|
45 | .tap(results => reporter.onTestPlanFinished(results, testPlanName, this.startTime, executionId))
|
46 | .then(combinedTestResults => combinedTestResults);
|
47 | }
|
48 | }
|
49 |
|
50 | module.exports = DeviceFarmRemoteRunner;
|