UNPKG

2.32 kBJavaScriptView Raw
1"use strict";
2
3const utils = require('../utils');
4const config = require('../commons/config');
5const testimCustomToken = require('../commons/testimCustomToken');
6const BaseRunner = require('./BaseRunner');
7const TestRunStatus = require('../testRunStatus');
8const reporter = require("../reports/reporter");
9const Logger = require('../commons/logger');
10const gridService = require('../services/gridService');
11const logger = Logger.getLogger('remote-test-runner');
12
13class DeviceFarmRemoteRunner extends BaseRunner {
14 runExecution(testList, testStatus, executionId, options, branchToUse) {
15 const projectId = options.project;
16 const sessionType = utils.getSessionType(options);
17 // report exec start analytics
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; //android or ios
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
50module.exports = DeviceFarmRemoteRunner;