@testim/testim-cli 3.196.0 → 3.197.0
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/README.md +1 -1
- package/cli/onExit.js +12 -1
- package/cli.js +5 -1
- package/commons/constants.js +0 -25
- package/commons/featureFlags.js +2 -0
- package/commons/socket/testResultService.js +4 -14
- package/commons/testimAnalytics.js +0 -1
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -94
- package/commons/testimServicesApi.js +9 -79
- package/executionQueue.js +7 -4
- package/npm-shrinkwrap.json +948 -512
- package/package.json +3 -1
- package/player/stepActions/baseJsStepAction.js +5 -1
- package/player/stepActions/pixelValidationStepAction.js +28 -0
- package/player/stepActions/salesforceAutoLoginStepAction.js +5 -3
- package/player/stepActions/stepActionRegistrar.js +3 -48
- package/player/utils/eyeSdkService.js +230 -0
- package/reports/consoleReporter.js +0 -20
- package/reports/reporter.js +0 -21
- package/runOptions.js +13 -89
- package/runner.js +3 -44
- package/runners/{strategies/LocalStrategy.js → ParallelWorkerManager.js} +59 -68
- package/runners/TestPlanRunner.js +286 -67
- package/runners/runnerUtils.js +73 -0
- package/services/analyticsService.js +94 -0
- package/services/gridService.js +24 -16
- package/services/gridService.test.js +21 -21
- package/testRunHandler.js +1 -1
- package/testRunStatus.js +13 -9
- package/utils.js +5 -5
- package/workers/BaseWorker.js +38 -39
- package/workers/BaseWorker.test.js +1 -1
- package/workers/WorkerExtensionSingleBrowser.js +6 -3
- package/commons/apkUploader/apkUploader.js +0 -46
- package/commons/apkUploader/apkUploaderFactory.js +0 -68
- package/commons/apkUploader/deviceFarmApkUploader.js +0 -41
- package/commons/apkUploader/saucelabsApkUploader.js +0 -36
- package/commons/apkUploader/testObjectApkUploader.js +0 -34
- package/player/mobile/mobileTestPlayer.js +0 -80
- package/player/mobile/mobileWebDriver.js +0 -155
- package/player/mobile/services/frameLocatorMock.js +0 -18
- package/player/mobile/services/mobilePortSelector.js +0 -22
- package/player/mobile/services/mobileTabService.js +0 -241
- package/player/mobile/utils/mobileScreenshotUtils.js +0 -46
- package/player/mobile/utils/mobileWindowUtils.js +0 -84
- package/player/stepActions/mobile/android/androidLocateStepAction.js +0 -122
- package/player/stepActions/mobile/android/androidLongClickStepAction.js +0 -12
- package/player/stepActions/mobile/android/androidScrollStepAction.js +0 -134
- package/player/stepActions/mobile/android/androidSpecialKeyStepAction.js +0 -22
- package/player/stepActions/mobile/android/androidSwipeStepAction.js +0 -32
- package/player/stepActions/mobile/androidGlobalActionStepAction.js +0 -12
- package/player/stepActions/mobile/androidTapStepAction.js +0 -19
- package/player/stepActions/mobile/androidTextChangeStepAction.js +0 -23
- package/player/stepActions/mobile/ios/iosLocateStepAction.js +0 -124
- package/player/stepActions/mobile/ios/iosScrollStepAction.js +0 -76
- package/runners/AnonymousTestPlanRunner.js +0 -106
- package/runners/BaseRunner.js +0 -42
- package/runners/BaseTestPlanRunner.js +0 -194
- package/runners/DeviceFarmRemoteRunner.js +0 -50
- package/runners/SchedulerRemoteRunner.js +0 -47
- package/runners/strategies/BaseStrategy.js +0 -86
- package/runners/strategies/DeviceFarmStrategy.js +0 -195
- package/runners/strategies/LocalDeviceFarmStrategy.js +0 -12
- package/runners/strategies/LocalTestStrategy.js +0 -14
- package/runners/strategies/Strategy.js +0 -17
- package/workers/WorkerAppium.js +0 -70
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const Promise = require('bluebird');
|
|
5
|
-
|
|
6
|
-
const _ = require('lodash');
|
|
7
|
-
|
|
8
|
-
const reporter = require('../reports/reporter');
|
|
9
|
-
const logger = require('../commons/logger').getLogger('suite-runner');
|
|
10
|
-
const utils = require('../utils.js');
|
|
11
|
-
const { ArgError } = require('../errors');
|
|
12
|
-
const perf = require('../commons/performance-logger');
|
|
13
|
-
|
|
14
|
-
const BaseTestPlanRunner = require('./BaseTestPlanRunner');
|
|
15
|
-
|
|
16
|
-
class AnonymousTestPlanRunner extends BaseTestPlanRunner {
|
|
17
|
-
runAnonymousTestPlan(options, branchToUse) {
|
|
18
|
-
logger.info('start to run anonymous', {
|
|
19
|
-
options: Object.assign({}, options, { token: undefined }),
|
|
20
|
-
branchToUse,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return this.prepareForTestResources(options)
|
|
24
|
-
.log('after prepareForTestResoutces')
|
|
25
|
-
.then(() => getSuite(options, branchToUse))
|
|
26
|
-
.log('after getSuite')
|
|
27
|
-
.then((suiteResult) => {
|
|
28
|
-
if (!suiteResult.tests[0] || suiteResult.tests[0].length === 0) {
|
|
29
|
-
if (options.rerunFailedByRunId) {
|
|
30
|
-
throw new ArgError('No failed tests found in the provided run');
|
|
31
|
-
}
|
|
32
|
-
if (options.passZeroTests) {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
throw new ArgError('No tests to run');
|
|
36
|
-
}
|
|
37
|
-
branchToUse = suiteResult.branch || branchToUse;
|
|
38
|
-
if (options.rerunFailedByRunId && !suiteResult.runName) {
|
|
39
|
-
if (!suiteResult.runExists) {
|
|
40
|
-
throw new ArgError('Invalid run ID - no such run.');
|
|
41
|
-
}
|
|
42
|
-
const isAnonymouslyNamedRun = suiteResult.runName === '';
|
|
43
|
-
if (isAnonymouslyNamedRun) {
|
|
44
|
-
suiteResult.runName = `rerun-${options.rerunFailedByRunId}`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const testPlanName = options.overrideExecutionName || suiteResult.runName || _.concat(options.label, options.name, options.suites).join(' ');
|
|
48
|
-
const isAnonymous = true;
|
|
49
|
-
perf.log('Right before validateConfig + runTestPlan Promise.map');
|
|
50
|
-
return Promise.map(suiteResult.tests, suiteTests => {
|
|
51
|
-
//override result id for remote run mode and run only the first test data
|
|
52
|
-
if (options.resultId) {
|
|
53
|
-
const firstTest = _.first(suiteTests);
|
|
54
|
-
firstTest.resultId = options.resultId;
|
|
55
|
-
suiteTests = [firstTest];
|
|
56
|
-
}
|
|
57
|
-
return this.validateConfig(options, suiteTests)
|
|
58
|
-
.log('right before runTestPlan')
|
|
59
|
-
.then(() => this.runTestPlan([], suiteTests, [], options, testPlanName, null, branchToUse, isAnonymous))
|
|
60
|
-
.log('right after runTestPlan')
|
|
61
|
-
.tap(async res => {
|
|
62
|
-
const isCodeMode = options.files.length > 0;
|
|
63
|
-
await reporter.onTestPlanFinished(res.results, testPlanName, this.startTime, res.executionId, isAnonymous, isCodeMode, res.childTestResults);
|
|
64
|
-
});
|
|
65
|
-
}).then(async results => { // array of results per execution
|
|
66
|
-
const flattenResults = _(results).flattenDeep().value();
|
|
67
|
-
perf.log('right before onAllTestPlansFinished');
|
|
68
|
-
await reporter.onAllTestPlansFinished(flattenResults);
|
|
69
|
-
perf.log('right after onAllTestPlansFinished');
|
|
70
|
-
return flattenResults.map(res => res.results).reduce((total, cur) => Object.assign(total, cur), {});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function getSuite(options, branchToUse) {
|
|
77
|
-
if (options.lightweightMode && options.lightweightMode.onlyTestIdsNoSuite && options.testId) {
|
|
78
|
-
return { tests: [options.testId.map(testId => ({ testId, testConfig: { }, resultId: utils.guid() }))] };
|
|
79
|
-
}
|
|
80
|
-
// local code test
|
|
81
|
-
if (options.files.length > 0) {
|
|
82
|
-
const { buildCodeTests } = require('./buildCodeTests');
|
|
83
|
-
let webpackConfig = {};
|
|
84
|
-
if (options.webpackConfig) {
|
|
85
|
-
const webpackConfigPath = path.join(process.cwd(), options.webpackConfig);
|
|
86
|
-
webpackConfig = require(webpackConfigPath);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return buildCodeTests(options.files, webpackConfig, { baseUrl: options.baseUrl });
|
|
90
|
-
}
|
|
91
|
-
// regular test
|
|
92
|
-
const servicesApi = require('../commons/testimServicesApi');
|
|
93
|
-
return await servicesApi.getSuiteTestList({
|
|
94
|
-
projectId: options.project,
|
|
95
|
-
labels: options.label,
|
|
96
|
-
testIds: options.testId,
|
|
97
|
-
testNames: options.name,
|
|
98
|
-
testConfigNames: options.testConfigNames,
|
|
99
|
-
suiteNames: options.suites,
|
|
100
|
-
suiteIds: options.suiteIds,
|
|
101
|
-
branch: branchToUse,
|
|
102
|
-
rerunFailedByRunId: options.rerunFailedByRunId,
|
|
103
|
-
testConfigIds: options.testConfigIds,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
module.exports = AnonymousTestPlanRunner;
|
package/runners/BaseRunner.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const Promise = require('bluebird');
|
|
2
|
-
const _ = require('lodash');
|
|
3
|
-
const utils = require('../utils');
|
|
4
|
-
const testimCustomToken = require('../commons/testimCustomToken');
|
|
5
|
-
const analytics = require('../commons/testimAnalytics');
|
|
6
|
-
const {ArgError} = require('../errors');
|
|
7
|
-
|
|
8
|
-
class BaseRunner {
|
|
9
|
-
constructor(strategy) {
|
|
10
|
-
this.strategy = strategy;
|
|
11
|
-
this.startTime = Date.now();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
analyticsExecsStart({ executionId, projectId, sessionType }) {
|
|
15
|
-
analytics.trackWithCIUser('batch-run-ci', {
|
|
16
|
-
executionId,
|
|
17
|
-
projectId,
|
|
18
|
-
sessionType,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
validateConfig(options, testList) {
|
|
23
|
-
let supportedBrowsers = options.mode === 'extension' ? [
|
|
24
|
-
'edge-chromium', 'chrome',
|
|
25
|
-
] : [
|
|
26
|
-
'ie11', 'firefox', 'chrome', 'edge', 'edge-chromium', 'safari', 'safari technology preview', 'browser', 'android', 'ios', 'iphone', 'ipad',
|
|
27
|
-
];
|
|
28
|
-
let diff = _.difference(utils.getUniqBrowsers(options, testList), supportedBrowsers);
|
|
29
|
-
|
|
30
|
-
if (diff.length > 0) {
|
|
31
|
-
analytics.trackWithCIUser('invalid-config-run', {
|
|
32
|
-
browser: diff.join(", "),
|
|
33
|
-
mode: 'runner'
|
|
34
|
-
});
|
|
35
|
-
return Promise.reject(new ArgError(`browser type <${diff}> is not supported in ${options.mode} mode.`));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return Promise.resolve(testList);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = BaseRunner;
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Promise = require('bluebird');
|
|
4
|
-
const _ = require('lodash');
|
|
5
|
-
const constants = require('../commons/constants');
|
|
6
|
-
|
|
7
|
-
const TESTIM_RUN_STATUS = constants.testRunStatus;
|
|
8
|
-
const { CLI_MODE } = constants;
|
|
9
|
-
const reporter = require('../reports/reporter');
|
|
10
|
-
const RealDataService = require('../commons/socket/realDataService');
|
|
11
|
-
const testimServicesApi = require('../commons/testimServicesApi');
|
|
12
|
-
const testimCustomToken = require('../commons/testimCustomToken');
|
|
13
|
-
const BaseRunner = require('./BaseRunner');
|
|
14
|
-
const TestRunStatus = require('../testRunStatus');
|
|
15
|
-
const config = require('../commons/config');
|
|
16
|
-
const utils = require('../utils');
|
|
17
|
-
const { StopRunOnError } = require('../errors');
|
|
18
|
-
const Logger = require('../commons/logger');
|
|
19
|
-
const perf = require('../commons/performance-logger');
|
|
20
|
-
|
|
21
|
-
const guid = utils.guid;
|
|
22
|
-
const _logger = Logger.getLogger('base-test-plan-runner');
|
|
23
|
-
const TDK_CHILD_RESULTS_TIMEOUT = 1000 * 60 * 5;
|
|
24
|
-
|
|
25
|
-
class BaseTestPlanRunner extends BaseRunner {
|
|
26
|
-
constructor(strategy) {
|
|
27
|
-
super(strategy);
|
|
28
|
-
this.runTestPlan = Promise.method(this.runTestPlan);
|
|
29
|
-
}
|
|
30
|
-
runTestAllPhases(beforeTests, tests, afterTests, branchToUse, tpOptions, executionId, testStatus) {
|
|
31
|
-
const executionResults = {};
|
|
32
|
-
const authData = testimCustomToken.getTokenV3UserData();
|
|
33
|
-
|
|
34
|
-
const runBeforeTests = (beforeTests, testStatus, executionId, tpOptions, branchToUse, authData) => {
|
|
35
|
-
const workerCount = 1;
|
|
36
|
-
const stopOnError = true;
|
|
37
|
-
return this.strategy.runTests(beforeTests, testStatus, executionId, tpOptions, branchToUse, authData, workerCount, stopOnError)
|
|
38
|
-
.then(beforeTestsResults => Object.assign(executionResults, beforeTestsResults));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const runTestPlanTests = (tests, testStatus, executionId, tpOptions, branchToUse, authData) => {
|
|
42
|
-
const workerCount = config.TESTIM_CONCURRENT_WORKER_COUNT || tpOptions.parallel;
|
|
43
|
-
const stopOnError = false;
|
|
44
|
-
perf.log('right before this.strategy.runTests');
|
|
45
|
-
return this.strategy.runTests(tests, testStatus, executionId, tpOptions, branchToUse, authData, workerCount, stopOnError)
|
|
46
|
-
.log('right after this.strategy.runTests')
|
|
47
|
-
.then(testsResults => Object.assign(executionResults, testsResults));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const runAfterTests = (afterTests, testStatus, executionId, tpOptions, branchToUse, authData) => {
|
|
51
|
-
const workerCount = 1;
|
|
52
|
-
const stopOnError = false;
|
|
53
|
-
return this.strategy.runTests(afterTests, testStatus, executionId, tpOptions, branchToUse, authData, workerCount, stopOnError)
|
|
54
|
-
.then(afterTestsResults => Object.assign(executionResults, afterTestsResults));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function catchBeforeTestsFailed(executionId) {
|
|
58
|
-
return testStatus.markAllQueuedTests(executionId, constants.runnerTestStatus.ABORTED, 'aborted', false);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const sessionType = utils.getSessionType(tpOptions);
|
|
62
|
-
this.analyticsExecsStart({ authData, executionId, projectId: tpOptions.project, sessionType });
|
|
63
|
-
perf.log('right before runBeforeTests');
|
|
64
|
-
return runBeforeTests(beforeTests, testStatus, executionId, tpOptions, branchToUse, authData)
|
|
65
|
-
.log('right before runTestPlanTests')
|
|
66
|
-
.then(() => runTestPlanTests(tests, testStatus, executionId, tpOptions, branchToUse, authData))
|
|
67
|
-
.log('right after runTestPlanTests')
|
|
68
|
-
.then(() => runAfterTests(afterTests, testStatus, executionId, tpOptions, branchToUse, authData))
|
|
69
|
-
.then(() => executionResults)
|
|
70
|
-
.catch(StopRunOnError, () => catchBeforeTestsFailed(executionId));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
prepareForTestResources(tpOptions) {
|
|
74
|
-
if (tpOptions.mode !== CLI_MODE.APPIUM && !(this.strategy.constructor.name === 'DeviceFarmStrategy')) {
|
|
75
|
-
return Promise.resolve();
|
|
76
|
-
}
|
|
77
|
-
const apkUploaderFactory = require('../commons/apkUploader/apkUploaderFactory');
|
|
78
|
-
return apkUploaderFactory.uploadApk(tpOptions);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async initRealDataService(projectId) {
|
|
82
|
-
const realDataService = new RealDataService();
|
|
83
|
-
await realDataService.init(projectId);
|
|
84
|
-
return realDataService;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async listenToTestCreatedInFile(realDataService, projectId, runId, testStatus) {
|
|
88
|
-
const childTestResults = {};
|
|
89
|
-
realDataService.joinToTestResultsByRunId(runId, projectId);
|
|
90
|
-
const promise = new Promise(resolve => {
|
|
91
|
-
realDataService.listenToTestResultsByRunId(runId, testResult => {
|
|
92
|
-
const resultId = testResult.id;
|
|
93
|
-
if (!testStatus.getTestResult(resultId)) {
|
|
94
|
-
const prevTestResult = childTestResults[resultId];
|
|
95
|
-
const mergedTestResult = _.merge({}, prevTestResult, testResult, { resultId });
|
|
96
|
-
childTestResults[resultId] = mergedTestResult;
|
|
97
|
-
if (!prevTestResult || prevTestResult.status !== testResult.status) {
|
|
98
|
-
const parentTestResult = testStatus.getTestResult(mergedTestResult.parentResultId) || { workerId: 1 };
|
|
99
|
-
const workerId = parentTestResult.workerId;
|
|
100
|
-
if ([TESTIM_RUN_STATUS.RUNNING].includes(testResult.status)) {
|
|
101
|
-
reporter.onTestStarted(mergedTestResult, workerId);
|
|
102
|
-
}
|
|
103
|
-
if ([TESTIM_RUN_STATUS.COMPLETED].includes(testResult.status)) {
|
|
104
|
-
mergedTestResult.duration = (mergedTestResult.endTime - mergedTestResult.startTime) || 0;
|
|
105
|
-
reporter.onTestFinished(mergedTestResult, workerId);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const allChildTestResultCompleted = !(Object.values(childTestResults)
|
|
111
|
-
.some(result => ['QUEUED', 'RUNNING'].includes(result.runnerStatus)));
|
|
112
|
-
|
|
113
|
-
const allParentTestResultCompleted = !(Object.values(testStatus.getAllTestResults())
|
|
114
|
-
.some(result => ['QUEUED', 'RUNNING'].includes(result.status)));
|
|
115
|
-
|
|
116
|
-
if (allChildTestResultCompleted && allParentTestResultCompleted) {
|
|
117
|
-
return resolve(Object.values(childTestResults));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (allParentTestResultCompleted && !allChildTestResultCompleted) {
|
|
121
|
-
// wait 10 sec to handle race condition when parent test result (file) finished before child test result
|
|
122
|
-
return Promise.delay(10000)
|
|
123
|
-
.then(() => {
|
|
124
|
-
if (promise.isPending()) {
|
|
125
|
-
// TODO(Benji) we are missing the child test results here.
|
|
126
|
-
// we are resolving here with partial data - we should consider fetching it
|
|
127
|
-
// from the server
|
|
128
|
-
resolve(childTestResults);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return undefined;
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
return await promise;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async runTestPlan(beforeTests, tests, afterTests, tpOptions, testPlanName, testPlanId, branch, isAnonymous) {
|
|
140
|
-
const executionId = guid();
|
|
141
|
-
const projectId = tpOptions.project;
|
|
142
|
-
Logger.setExecutionId(executionId);
|
|
143
|
-
beforeTests.forEach(test => { test.isBeforeTestPlan = true; });
|
|
144
|
-
afterTests.forEach(test => { test.isAfterTestPlan = true; });
|
|
145
|
-
const testStatus = new TestRunStatus(_.concat(beforeTests, tests, afterTests), tpOptions, testPlanId, branch);
|
|
146
|
-
|
|
147
|
-
const configs = _(_.concat(beforeTests, tests, afterTests)).map(test => (test.overrideTestConfig && test.overrideTestConfig.name) || '').uniq().filter(Boolean)
|
|
148
|
-
.value();
|
|
149
|
-
const configName = configs && configs.length === 1 ? configs[0] : null;
|
|
150
|
-
|
|
151
|
-
const isCodeMode = tpOptions.files.length > 0;
|
|
152
|
-
|
|
153
|
-
if (isCodeMode && tpOptions.mode === constants.CLI_MODE.SELENIUM) {
|
|
154
|
-
// in selenium mode we don't need to wait for the runner and clickim to sync, so we don't need to wait for reports.
|
|
155
|
-
testStatus.setAsyncReporting(true);
|
|
156
|
-
}
|
|
157
|
-
const testListInfoPromise = tpOptions.lightweightMode && tpOptions.lightweightMode.onlyTestIdsNoSuite ?
|
|
158
|
-
{ beforeTests, tests, afterTests } :
|
|
159
|
-
testStatus.executionStart(executionId, projectId, this.startTime, testPlanName);
|
|
160
|
-
let childTestResults;
|
|
161
|
-
if (isCodeMode) {
|
|
162
|
-
childTestResults = Promise.try(async () => {
|
|
163
|
-
const realDataService = await this.initRealDataService(projectId);
|
|
164
|
-
return this.listenToTestCreatedInFile(realDataService, projectId, executionId, testStatus);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
perf.log('before testListInfoPromise');
|
|
168
|
-
const testListInfo = await testListInfoPromise;
|
|
169
|
-
if (!(tpOptions.lightweightMode && tpOptions.lightweightMode.onlyTestIdsNoSuite)) {
|
|
170
|
-
reporter.onTestPlanStarted(testListInfo.beforeTests, testListInfo.tests, testListInfo.afterTests, testPlanName, executionId, isAnonymous, configName, isCodeMode);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
perf.log('before runTestAllPhases');
|
|
174
|
-
const results = await this.runTestAllPhases(testListInfo.beforeTests, testListInfo.tests, testListInfo.afterTests, branch, tpOptions, executionId, testStatus);
|
|
175
|
-
const childResults = await Promise.resolve(childTestResults)
|
|
176
|
-
.timeout(TDK_CHILD_RESULTS_TIMEOUT)
|
|
177
|
-
.catch(async () => {
|
|
178
|
-
_logger.warn('timed out waiting for child resutls on websocket. using REST fallback', { projectId, executionId });
|
|
179
|
-
const testResults = await testimServicesApi.getRealData(projectId, 'testResult', `runId=${executionId}&sort=runOrder`);
|
|
180
|
-
return _.chain((testResults && testResults.data && testResults.data.docs) || [])
|
|
181
|
-
.groupBy('parentResultId')
|
|
182
|
-
.omit('undefined')
|
|
183
|
-
.values()
|
|
184
|
-
.flatten()
|
|
185
|
-
.value();
|
|
186
|
-
});
|
|
187
|
-
perf.log('before executionEnd');
|
|
188
|
-
await testStatus.executionEnd(executionId);
|
|
189
|
-
perf.log('after executionEnd');
|
|
190
|
-
return { results, executionId, testPlanName, configName, childTestResults: childResults };
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
module.exports = BaseTestPlanRunner;
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
// 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, null, 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
|
-
|
|
50
|
-
module.exports = DeviceFarmRemoteRunner;
|
|
@@ -1,47 +0,0 @@
|
|
|
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 guid = require('../utils').guid;
|
|
10
|
-
const Logger = require('../commons/logger');
|
|
11
|
-
const logger = Logger.getLogger('remote-test-runner');
|
|
12
|
-
|
|
13
|
-
class SchedulerRemoteRunner extends BaseRunner {
|
|
14
|
-
runExecution(testList, testStatus, executionId, options, branchToUse) {
|
|
15
|
-
const sessionType = utils.getSessionType(options);
|
|
16
|
-
const projectId = options.project;
|
|
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(options, branchToUse) {
|
|
26
|
-
const executionId = options.executionId || guid();
|
|
27
|
-
const test = options.testObject;
|
|
28
|
-
Logger.setExecutionId(executionId);
|
|
29
|
-
|
|
30
|
-
logger.info("start to run test", {
|
|
31
|
-
executionId: executionId,
|
|
32
|
-
options: Object.assign({}, options, {token: undefined}),
|
|
33
|
-
branchToUse: branchToUse,
|
|
34
|
-
test: test
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const testArray = [test];
|
|
38
|
-
const testPlanName = options.overrideExecutionName || "remote run";
|
|
39
|
-
const testStatus = new TestRunStatus(testArray, options, null, branchToUse);
|
|
40
|
-
reporter.onTestPlanStarted([], testArray, [], testPlanName, executionId);
|
|
41
|
-
return this.runExecution(testArray, testStatus, executionId, options, branchToUse)
|
|
42
|
-
.tap(results => reporter.onTestPlanFinished(results, testPlanName, this.startTime, executionId))
|
|
43
|
-
.then(combinedTestResults => combinedTestResults);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = SchedulerRemoteRunner;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const analytics = require('../../commons/testimAnalytics');
|
|
4
|
-
const { isCi } = require('../../cli/isCiRun');
|
|
5
|
-
|
|
6
|
-
const calcSource = (source, user) => {
|
|
7
|
-
if (source !== 'cli' && source !== 'cli-local') {
|
|
8
|
-
return source;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (isCi && user) {
|
|
12
|
-
return 'ci-with-user';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (isCi) {
|
|
16
|
-
return 'ci';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (user) {
|
|
20
|
-
return 'cli-with-user';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return source;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function setLightweightAnalytics(properties, lightweightMode) {
|
|
27
|
-
if (lightweightMode && lightweightMode.type) {
|
|
28
|
-
properties[`${lightweightMode.type}Mode`] = true;
|
|
29
|
-
}
|
|
30
|
-
return properties;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class BaseStrategy {
|
|
34
|
-
analyticsTestStart({
|
|
35
|
-
executionId, projectId, testId, resultId, companyId, companyName, projectName, companyPlanType, sessionType, source, user, lightweightMode,
|
|
36
|
-
}) {
|
|
37
|
-
const properties = setLightweightAnalytics({
|
|
38
|
-
executionId,
|
|
39
|
-
projectId,
|
|
40
|
-
testId,
|
|
41
|
-
resultId,
|
|
42
|
-
companyId,
|
|
43
|
-
companyName,
|
|
44
|
-
projectName,
|
|
45
|
-
companyPlanType,
|
|
46
|
-
sessionType,
|
|
47
|
-
source: calcSource(source, user),
|
|
48
|
-
}, lightweightMode);
|
|
49
|
-
analytics.trackWithCIUser('test-run-ci', properties);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
analyticsTestEnd({
|
|
53
|
-
executionId, projectId, testId, resultId, result, companyId, companyName, projectName, companyPlanType, sessionType, source, user, lightweightMode,
|
|
54
|
-
logger,
|
|
55
|
-
}) {
|
|
56
|
-
try {
|
|
57
|
-
const properties = setLightweightAnalytics({
|
|
58
|
-
executionId,
|
|
59
|
-
projectId,
|
|
60
|
-
testId,
|
|
61
|
-
resultId,
|
|
62
|
-
companyId,
|
|
63
|
-
companyName,
|
|
64
|
-
projectName,
|
|
65
|
-
companyPlanType,
|
|
66
|
-
sessionType,
|
|
67
|
-
mockNetworkEnabled: result.wasMockNetworkActivated,
|
|
68
|
-
source: calcSource(source, user),
|
|
69
|
-
}, lightweightMode);
|
|
70
|
-
|
|
71
|
-
if (result.success) {
|
|
72
|
-
analytics.trackWithCIUser('test-run-ci-success', properties);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
analytics.trackWithCIUser('test-run-ci-fail', Object.assign({}, properties, { failureReason: result.failureReason }));
|
|
76
|
-
} catch (err) {
|
|
77
|
-
logger.error('failed to update test end analytics', { err });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
runTests(testList, testStatus, executionId, options, branchToUse, authData, workerCount, stopOnError) {
|
|
82
|
-
throw new Error('need to implement on child');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = BaseStrategy;
|