browserstack-cypress-cli 1.31.9 → 1.32.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/bin/accessibility-automation/cypress/index.js +274 -276
- package/bin/accessibility-automation/helper.js +41 -27
- package/bin/accessibility-automation/plugin/index.js +2 -3
- package/bin/commands/generateReport.js +7 -8
- package/bin/commands/info.js +39 -38
- package/bin/commands/runs.js +9 -11
- package/bin/commands/stop.js +0 -1
- package/bin/helpers/atsHelper.js +48 -39
- package/bin/helpers/build.js +39 -31
- package/bin/helpers/buildArtifacts.js +91 -71
- package/bin/helpers/capabilityHelper.js +4 -0
- package/bin/helpers/checkUploaded.js +43 -33
- package/bin/helpers/downloadBuildStacktrace.js +23 -14
- package/bin/helpers/getInitialDetails.js +33 -22
- package/bin/helpers/helper.js +10 -2
- package/bin/helpers/reporterHTML.js +57 -39
- package/bin/helpers/sync/syncSpecsLogs.js +36 -23
- package/bin/helpers/usageReporting.js +52 -34
- package/bin/helpers/utils.js +96 -77
- package/bin/helpers/zipUpload.js +61 -85
- package/bin/testObservability/crashReporter/index.js +23 -14
- package/bin/testObservability/cypress/index.js +7 -7
- package/bin/testObservability/helper/helper.js +59 -43
- package/bin/testObservability/helper/requestQueueHandler.js +2 -2
- package/bin/testObservability/plugin/ipcServer.js +6 -6
- package/bin/testObservability/reporter/index.js +8 -10
- package/package.json +5 -4
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
const axios = require('axios').default;
|
|
2
|
+
|
|
1
3
|
const fs = require('fs'),
|
|
2
4
|
path = require('path'),
|
|
3
|
-
request = require('request'),
|
|
4
5
|
logger = require('./logger').winstonLogger,
|
|
5
6
|
utils = require("./utils"),
|
|
6
7
|
Constants = require('./constants'),
|
|
7
8
|
config = require("./config"),
|
|
8
9
|
decompress = require('decompress');
|
|
10
|
+
const { isTurboScaleSession } = require('../helpers/atsHelper');
|
|
11
|
+
|
|
12
|
+
const { setAxiosProxy } = require('./helper');
|
|
9
13
|
|
|
10
|
-
let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) => {
|
|
14
|
+
let reportGenerator = async (bsConfig, buildId, args, rawArgs, buildReportData, cb) => {
|
|
11
15
|
let options = {
|
|
12
16
|
url: `${config.buildUrl}${buildId}/custom_report`,
|
|
13
17
|
auth: {
|
|
@@ -19,34 +23,35 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) =>
|
|
|
19
23
|
},
|
|
20
24
|
};
|
|
21
25
|
|
|
26
|
+
if (isTurboScaleSession(bsConfig)) {
|
|
27
|
+
options.url = `${config.turboScaleBuildsUrl}/${buildId}/custom_report`;
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
logger.debug('Started fetching the build json and html reports.');
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let build;
|
|
29
|
-
|
|
30
|
-
if (err) {
|
|
31
|
-
message = err;
|
|
32
|
-
messageType = Constants.messageTypes.ERROR;
|
|
33
|
-
errorCode = 'api_failed_build_report';
|
|
32
|
+
let message = null;
|
|
33
|
+
let messageType = null;
|
|
34
|
+
let errorCode = null;
|
|
35
|
+
let build;
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
const axiosConfig = {
|
|
38
|
+
auth: {
|
|
39
|
+
username: options.auth.user,
|
|
40
|
+
password: options.auth.password
|
|
41
|
+
},
|
|
42
|
+
headers: options.headers
|
|
43
|
+
}
|
|
44
|
+
setAxiosProxy(axiosConfig);
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
build = null;
|
|
46
|
-
}
|
|
46
|
+
try {
|
|
47
|
+
const response = await axios.get(options.url, axiosConfig);
|
|
48
|
+
logger.debug('Received reports data from upstream.');
|
|
49
|
+
try {
|
|
50
|
+
build = response.data;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
build = null;
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
if (resp.statusCode == 299) {
|
|
54
|
+
if (response.status == 299) {
|
|
50
55
|
messageType = Constants.messageTypes.INFO;
|
|
51
56
|
errorCode = 'api_deprecated';
|
|
52
57
|
if (build) {
|
|
@@ -56,18 +61,18 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) =>
|
|
|
56
61
|
message = Constants.userMessages.API_DEPRECATED;
|
|
57
62
|
logger.info(message);
|
|
58
63
|
}
|
|
59
|
-
} else if (
|
|
64
|
+
} else if (response.status === 422) {
|
|
60
65
|
messageType = Constants.messageTypes.ERROR;
|
|
61
66
|
errorCode = 'api_failed_build_generate_report';
|
|
62
67
|
try {
|
|
63
|
-
response =
|
|
68
|
+
response = error.response.data;
|
|
64
69
|
message = response.message;
|
|
65
70
|
} catch (error) {
|
|
66
71
|
logger.error(`Error generating the report: ${error}`);
|
|
67
72
|
response = {message: message};
|
|
68
73
|
}
|
|
69
|
-
logger.error(utils.formatRequest(
|
|
70
|
-
} else if (
|
|
74
|
+
logger.error(utils.formatRequest(response.statusText, response, response.data));
|
|
75
|
+
} else if (response.status != 200) {
|
|
71
76
|
messageType = Constants.messageTypes.ERROR;
|
|
72
77
|
errorCode = 'api_failed_build_generate_report';
|
|
73
78
|
|
|
@@ -79,7 +84,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) =>
|
|
|
79
84
|
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
80
85
|
} else {
|
|
81
86
|
message = Constants.userMessages.BUILD_GENERATE_REPORT_FAILED.replace('<build-id>', buildId);
|
|
82
|
-
logger.error(utils.formatRequest(
|
|
87
|
+
logger.error(utils.formatRequest(error.response.statusText, error.response, error.response.data));
|
|
83
88
|
}
|
|
84
89
|
} else {
|
|
85
90
|
messageType = Constants.messageTypes.SUCCESS;
|
|
@@ -92,7 +97,16 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, buildReportData, cb) =>
|
|
|
92
97
|
if (cb){
|
|
93
98
|
cb();
|
|
94
99
|
}
|
|
95
|
-
})
|
|
100
|
+
} catch (error) {
|
|
101
|
+
message = error.response.statusText;
|
|
102
|
+
messageType = Constants.messageTypes.ERROR;
|
|
103
|
+
errorCode = 'api_failed_build_report';
|
|
104
|
+
|
|
105
|
+
logger.error('Generating the build report failed.');
|
|
106
|
+
logger.error(utils.formatRequest(error.response.statusText, error.response, error.response.data));
|
|
107
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
async function generateCypressBuildReport(report_data) {
|
|
@@ -111,15 +125,16 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
|
|
|
111
125
|
const writer = fs.createWriteStream(tmpFilePath);
|
|
112
126
|
logger.debug(`Fetching build reports zip.`)
|
|
113
127
|
return new Promise(async (resolve, reject) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
128
|
+
try {
|
|
129
|
+
const axiosConfig = {
|
|
130
|
+
responseType: 'stream',
|
|
131
|
+
};
|
|
132
|
+
setAxiosProxy(axiosConfig);
|
|
133
|
+
const response = await axios.get(reportJsonUrl, axiosConfig);
|
|
134
|
+
if(response.status === 200) {
|
|
120
135
|
//ensure that the user can call `then()` only when the file has
|
|
121
136
|
//been downloaded entirely.
|
|
122
|
-
response.pipe(writer);
|
|
137
|
+
response.data.pipe(writer);
|
|
123
138
|
let error = null;
|
|
124
139
|
writer.on('error', err => {
|
|
125
140
|
error = err;
|
|
@@ -144,7 +159,10 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
|
|
|
144
159
|
//'error' stream;
|
|
145
160
|
});
|
|
146
161
|
}
|
|
147
|
-
})
|
|
162
|
+
} catch (error) {
|
|
163
|
+
let message = `Received non 200 response while fetching reports, code: ${error.response.status}`;
|
|
164
|
+
reject(message);
|
|
165
|
+
}
|
|
148
166
|
});
|
|
149
167
|
}
|
|
150
168
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
const { default: axios } = require("axios");
|
|
4
|
+
|
|
5
|
+
const config = require("../config"),
|
|
4
6
|
utils = require("../utils"),
|
|
5
7
|
logger = require("../logger").syncCliLogger,
|
|
6
8
|
winstonLogger = require("../logger").winstonLogger,
|
|
@@ -9,6 +11,8 @@ const request = require("request"),
|
|
|
9
11
|
tableStream = require('table').createStream,
|
|
10
12
|
chalk = require('chalk');
|
|
11
13
|
|
|
14
|
+
const { setAxiosProxy } = require('../helper');
|
|
15
|
+
|
|
12
16
|
let whileLoop = true, whileTries = config.retries, options, timeout = 3000, n = 2, tableConfig, stream, endTime, startTime = Date.now(), buildStarted = false;
|
|
13
17
|
let specSummary = {
|
|
14
18
|
"buildError": null,
|
|
@@ -135,27 +139,23 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
|
|
|
135
139
|
});
|
|
136
140
|
};
|
|
137
141
|
|
|
138
|
-
let whileProcess = (whilstCallback) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
n = 2
|
|
149
|
-
return setTimeout(whilstCallback, timeout * n, null);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
142
|
+
let whileProcess = async (whilstCallback) => {
|
|
143
|
+
try {
|
|
144
|
+
const axiosConfig = {
|
|
145
|
+
auth: {
|
|
146
|
+
username: options.auth.user,
|
|
147
|
+
password: options.auth.password
|
|
148
|
+
},
|
|
149
|
+
headers: options.headers
|
|
150
|
+
};
|
|
151
|
+
setAxiosProxy(axiosConfig);
|
|
152
152
|
|
|
153
|
+
const response = await axios.post(options.url, {}, axiosConfig);
|
|
153
154
|
whileTries = config.retries; // reset to default after every successful request
|
|
154
|
-
|
|
155
|
-
switch (response.statusCode) {
|
|
155
|
+
switch (response.status) {
|
|
156
156
|
case 202: // get data here and print it
|
|
157
157
|
n = 2
|
|
158
|
-
showSpecsStatus(
|
|
158
|
+
showSpecsStatus(response.data, 202);
|
|
159
159
|
return setTimeout(whilstCallback, timeout * n, null);
|
|
160
160
|
case 204: // No data available, wait for some time and ask again
|
|
161
161
|
n = 1
|
|
@@ -163,14 +163,27 @@ let whileProcess = (whilstCallback) => {
|
|
|
163
163
|
case 200: // Build is completed.
|
|
164
164
|
whileLoop = false;
|
|
165
165
|
endTime = Date.now();
|
|
166
|
-
showSpecsStatus(
|
|
166
|
+
showSpecsStatus(response.data, 200);
|
|
167
167
|
return specSummary.exitCode == Constants.BUILD_FAILED_EXIT_CODE ?
|
|
168
168
|
whilstCallback({ status: 204, message: "No specs ran in the build"} ) : whilstCallback(null, body);
|
|
169
169
|
default:
|
|
170
170
|
whileLoop = false;
|
|
171
|
-
return whilstCallback({ status: response.
|
|
171
|
+
return whilstCallback({ status: response.status, message: response.data });
|
|
172
172
|
}
|
|
173
|
-
})
|
|
173
|
+
} catch (error) {
|
|
174
|
+
if (error) {
|
|
175
|
+
whileTries -= 1;
|
|
176
|
+
if (whileTries === 0) {
|
|
177
|
+
whileLoop = false;
|
|
178
|
+
endTime = Date.now();
|
|
179
|
+
specSummary.exitCode = config.networkErrorExitCode;
|
|
180
|
+
return whilstCallback({ status: 504, message: "Tries limit reached" }); //Gateway Timeout
|
|
181
|
+
} else {
|
|
182
|
+
n = 2
|
|
183
|
+
return setTimeout(whilstCallback, timeout * n, null);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
174
187
|
}
|
|
175
188
|
|
|
176
189
|
let getStackTraceUrl = () => {
|
|
@@ -178,7 +191,7 @@ let getStackTraceUrl = () => {
|
|
|
178
191
|
}
|
|
179
192
|
|
|
180
193
|
let showSpecsStatus = (data, statusCode) => {
|
|
181
|
-
let specData =
|
|
194
|
+
let specData = data;
|
|
182
195
|
specData["specData"].forEach(specDetails => {
|
|
183
196
|
if (specDetails.type === Constants.CYPRESS_CUSTOM_ERRORS_TO_PRINT_KEY) {
|
|
184
197
|
addCustomErrorToPrint(specDetails);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const cp = require("child_process"),
|
|
3
3
|
os = require("os"),
|
|
4
|
-
request = require("requestretry"),
|
|
5
4
|
fs = require('fs'),
|
|
6
5
|
path = require('path');
|
|
7
6
|
|
|
@@ -10,7 +9,11 @@ const config = require('./config'),
|
|
|
10
9
|
utils = require('./utils');
|
|
11
10
|
|
|
12
11
|
const { AUTH_REGEX, REDACTED_AUTH, REDACTED, CLI_ARGS_REGEX, RAW_ARGS_REGEX } = require("./constants");
|
|
13
|
-
const {
|
|
12
|
+
const { default: axios } = require("axios");
|
|
13
|
+
const axiosRetry = require("axios-retry");
|
|
14
|
+
const { isTurboScaleSession } = require("./atsHelper");
|
|
15
|
+
|
|
16
|
+
const { setAxiosProxy } = require('./helper');
|
|
14
17
|
|
|
15
18
|
function get_version(package_name) {
|
|
16
19
|
try {
|
|
@@ -217,31 +220,36 @@ function sendTurboscaleErrorLogs(args) {
|
|
|
217
220
|
password: bsConfig.auth.access_key,
|
|
218
221
|
},
|
|
219
222
|
url: `${config.turboScaleAPIUrl}/send-instrumentation`,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
maxAttempts: 10, // (default) try 3 times
|
|
223
|
+
data: turboscaleErrorPayload,
|
|
224
|
+
maxAttempts: 10,
|
|
223
225
|
retryDelay: 2000, // (default) wait for 2s before trying again
|
|
224
|
-
retrySrategy: request.RetryStrategies.HTTPOrNetworkError, // (default) retry on 5xx or network errors
|
|
225
226
|
};
|
|
226
227
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return;
|
|
228
|
+
axiosRetry(axios, {
|
|
229
|
+
retries: options.maxAttempts,
|
|
230
|
+
retryDelay: (retryCount) => options.retryDelay,
|
|
231
|
+
retryCondition: (error) => {
|
|
232
|
+
return axiosRetry.isRetryableError(error) // (default) retry on 5xx or network errors
|
|
233
233
|
}
|
|
234
|
-
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
fileLogger.info(`Sending ${JSON.stringify(turboscaleErrorPayload)} to ${config.turboScaleAPIUrl}/send-instrumentation`);
|
|
237
|
+
|
|
238
|
+
axios(options)
|
|
239
|
+
.then((res) => {
|
|
235
240
|
let response = {
|
|
236
|
-
attempts: res.
|
|
237
|
-
statusCode: res.
|
|
238
|
-
body:
|
|
241
|
+
attempts: res.config['axios-retry'].retryCount + 1,
|
|
242
|
+
statusCode: res.status,
|
|
243
|
+
body: res.data
|
|
239
244
|
};
|
|
240
245
|
fileLogger.info(`${JSON.stringify(response)}`);
|
|
246
|
+
})
|
|
247
|
+
.catch((error) => {
|
|
248
|
+
fileLogger.error(JSON.stringify(error));
|
|
241
249
|
});
|
|
242
250
|
}
|
|
243
251
|
|
|
244
|
-
function send(args) {
|
|
252
|
+
async function send(args) {
|
|
245
253
|
let bsConfig = JSON.parse(JSON.stringify(args.bstack_config));
|
|
246
254
|
|
|
247
255
|
if (isTurboScaleSession(bsConfig) && args.message_type === 'error') {
|
|
@@ -307,10 +315,6 @@ function send(args) {
|
|
|
307
315
|
},
|
|
308
316
|
};
|
|
309
317
|
|
|
310
|
-
if (isTurboScaleSession(bsConfig)) {
|
|
311
|
-
payload.event_type = 'hst_cypress_cli_stats';
|
|
312
|
-
}
|
|
313
|
-
|
|
314
318
|
const options = {
|
|
315
319
|
headers: {
|
|
316
320
|
"Content-Type": "text/json",
|
|
@@ -321,24 +325,38 @@ function send(args) {
|
|
|
321
325
|
json: true,
|
|
322
326
|
maxAttempts: 10, // (default) try 3 times
|
|
323
327
|
retryDelay: 2000, // (default) wait for 2s before trying again
|
|
324
|
-
retrySrategy: request.RetryStrategies.HTTPOrNetworkError, // (default) retry on 5xx or network errors
|
|
325
328
|
};
|
|
326
329
|
|
|
330
|
+
const axiosConfig = {
|
|
331
|
+
headers: options.headers,
|
|
332
|
+
};
|
|
333
|
+
setAxiosProxy(axiosConfig);
|
|
334
|
+
|
|
327
335
|
fileLogger.info(`Sending ${JSON.stringify(payload)} to ${config.usageReportingUrl}`);
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
336
|
+
axiosRetry(axios,
|
|
337
|
+
{
|
|
338
|
+
retries: 3,
|
|
339
|
+
retryDelay: 2000,
|
|
340
|
+
retryCondition: (error) => {
|
|
341
|
+
return utils.isNotUndefined(error.response) && (error.response.status === 503 || error.response.status === 500)
|
|
333
342
|
}
|
|
334
|
-
// write response file
|
|
335
|
-
let response = {
|
|
336
|
-
attempts: res.attempts,
|
|
337
|
-
statusCode: res.statusCode,
|
|
338
|
-
body: body
|
|
339
|
-
};
|
|
340
|
-
fileLogger.info(`${JSON.stringify(response)}`);
|
|
341
343
|
});
|
|
344
|
+
try {
|
|
345
|
+
const response = await axios.post(options.url, options.body, axiosConfig);
|
|
346
|
+
let result = {
|
|
347
|
+
statusText: response.statusText,
|
|
348
|
+
statusCode: response.status,
|
|
349
|
+
body: response.data
|
|
350
|
+
};
|
|
351
|
+
fileLogger.info(`${JSON.stringify(result)}`);
|
|
352
|
+
} catch (error) {
|
|
353
|
+
if (error.response) {
|
|
354
|
+
fileLogger.error(JSON.stringify(error.response.data));
|
|
355
|
+
} else {
|
|
356
|
+
fileLogger.error(`Error sending usage data: ${error.message}`);
|
|
357
|
+
}
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
342
360
|
}
|
|
343
361
|
|
|
344
362
|
module.exports = {
|
package/bin/helpers/utils.js
CHANGED
|
@@ -12,6 +12,7 @@ const { promisify } = require('util');
|
|
|
12
12
|
const readdir = promisify(fs.readdir);
|
|
13
13
|
const stat = promisify(fs.stat);
|
|
14
14
|
const TIMEZONE = require("../helpers/timezone.json");
|
|
15
|
+
const { setAxiosProxy } = require('./helper');
|
|
15
16
|
|
|
16
17
|
const usageReporting = require("./usageReporting"),
|
|
17
18
|
logger = require("./logger").winstonLogger,
|
|
@@ -25,7 +26,7 @@ const usageReporting = require("./usageReporting"),
|
|
|
25
26
|
o11yHelpers = require('../testObservability/helper/helper'),
|
|
26
27
|
{ OBSERVABILITY_ENV_VARS, TEST_OBSERVABILITY_REPORTER } = require('../testObservability/helper/constants');
|
|
27
28
|
|
|
28
|
-
const
|
|
29
|
+
const { default: axios } = require("axios");
|
|
29
30
|
|
|
30
31
|
exports.validateBstackJson = (bsConfigPath) => {
|
|
31
32
|
return new Promise(function (resolve, reject) {
|
|
@@ -491,6 +492,7 @@ exports.setNodeVersion = (bsConfig, args) => {
|
|
|
491
492
|
// specs can be passed via command line args as a string
|
|
492
493
|
// command line args takes precedence over config
|
|
493
494
|
exports.setUserSpecs = (bsConfig, args) => {
|
|
495
|
+
|
|
494
496
|
if(o11yHelpers.isBrowserstackInfra() && o11yHelpers.isTestObservabilitySession() && o11yHelpers.shouldReRunObservabilityTests()) {
|
|
495
497
|
bsConfig.run_settings.specs = process.env.BROWSERSTACK_RERUN_TESTS;
|
|
496
498
|
return;
|
|
@@ -591,7 +593,7 @@ exports.setSystemEnvs = (bsConfig) => {
|
|
|
591
593
|
OBSERVABILITY_ENV_VARS.forEach(key => {
|
|
592
594
|
envKeys[key] = process.env[key];
|
|
593
595
|
});
|
|
594
|
-
|
|
596
|
+
|
|
595
597
|
let gitConfigPath = o11yHelpers.findGitConfig(process.cwd());
|
|
596
598
|
if(!o11yHelpers.isBrowserstackInfra()) process.env.OBSERVABILITY_GIT_CONFIG_PATH_LOCAL = gitConfigPath;
|
|
597
599
|
if(gitConfigPath) {
|
|
@@ -1018,14 +1020,27 @@ exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
|
|
|
1018
1020
|
},
|
|
1019
1021
|
body: JSON.stringify({ localIdentifier: localIdentifier}),
|
|
1020
1022
|
};
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1023
|
+
|
|
1024
|
+
const axiosConfig = {
|
|
1025
|
+
auth: {
|
|
1026
|
+
username: options.auth.user,
|
|
1027
|
+
password: options.auth.password
|
|
1028
|
+
},
|
|
1029
|
+
headers: options.headers
|
|
1030
|
+
};
|
|
1031
|
+
setAxiosProxy(axiosConfig);
|
|
1032
|
+
|
|
1033
|
+
return new Promise (async function(resolve, reject) {
|
|
1034
|
+
try {
|
|
1035
|
+
const response = await axios.post(options.url, {
|
|
1036
|
+
localIdentifier: localIdentifier
|
|
1037
|
+
}, axiosConfig);
|
|
1038
|
+
resolve(response.data)
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
if(error.response) {
|
|
1041
|
+
reject(error.response.data.message);
|
|
1025
1042
|
}
|
|
1026
|
-
|
|
1027
|
-
resolve(response);
|
|
1028
|
-
});
|
|
1043
|
+
}
|
|
1029
1044
|
});
|
|
1030
1045
|
};
|
|
1031
1046
|
|
|
@@ -1475,6 +1490,7 @@ exports.splitStringByCharButIgnoreIfWithinARange = (str, splitChar, leftLimiter,
|
|
|
1475
1490
|
|
|
1476
1491
|
// blindly send other passed configs with run_settings and handle at backend
|
|
1477
1492
|
exports.setOtherConfigs = (bsConfig, args) => {
|
|
1493
|
+
|
|
1478
1494
|
if(o11yHelpers.isTestObservabilitySession() && process.env.BS_TESTOPS_JWT) {
|
|
1479
1495
|
bsConfig["run_settings"]["reporter"] = TEST_OBSERVABILITY_REPORTER;
|
|
1480
1496
|
return;
|
|
@@ -1537,7 +1553,7 @@ exports.setCLIMode = (bsConfig, args) => {
|
|
|
1537
1553
|
exports.formatRequest = (err, resp, body) => {
|
|
1538
1554
|
return {
|
|
1539
1555
|
err,
|
|
1540
|
-
status: resp ? resp.
|
|
1556
|
+
status: resp ? resp.status : null,
|
|
1541
1557
|
body: body ? util.format('%j', body) : null
|
|
1542
1558
|
}
|
|
1543
1559
|
}
|
|
@@ -1557,78 +1573,80 @@ exports.setDebugMode = (args) => {
|
|
|
1557
1573
|
|
|
1558
1574
|
exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs, buildReportData = null) => {
|
|
1559
1575
|
let that = this;
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1576
|
+
|
|
1577
|
+
let url = config.buildStopUrl + buildId;
|
|
1578
|
+
let options = {
|
|
1579
|
+
url: url,
|
|
1580
|
+
auth: {
|
|
1581
|
+
username: bsConfig["auth"]["username"],
|
|
1582
|
+
password: bsConfig["auth"]["access_key"],
|
|
1583
|
+
},
|
|
1584
|
+
headers: {
|
|
1585
|
+
'User-Agent': that.getUserAgent(),
|
|
1586
|
+
},
|
|
1587
|
+
};
|
|
1572
1588
|
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1589
|
+
const axiosConfig = {
|
|
1590
|
+
auth: options.auth,
|
|
1591
|
+
headers: options.headers
|
|
1592
|
+
};
|
|
1593
|
+
setAxiosProxy(axiosConfig);
|
|
1576
1594
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1595
|
+
if (Constants.turboScaleObj.enabled) {
|
|
1596
|
+
options.url = `${config.turboScaleBuildsUrl}/${buildId}/stop`;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
let message = null;
|
|
1600
|
+
let messageType = null;
|
|
1601
|
+
let errorCode = null;
|
|
1602
|
+
let build = null;
|
|
1603
|
+
|
|
1604
|
+
try {
|
|
1605
|
+
const response = await axios.post(options.url, {}, axiosConfig);
|
|
1606
|
+
|
|
1607
|
+
build = response.data;
|
|
1608
|
+
if (response.status == 299) {
|
|
1609
|
+
messageType = Constants.messageTypes.INFO;
|
|
1610
|
+
errorCode = 'api_deprecated';
|
|
1611
|
+
|
|
1612
|
+
if (build) {
|
|
1613
|
+
message = build.message;
|
|
1586
1614
|
logger.info(message);
|
|
1587
1615
|
} else {
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
if (resp.statusCode == 299) {
|
|
1591
|
-
messageType = Constants.messageTypes.INFO;
|
|
1592
|
-
errorCode = 'api_deprecated';
|
|
1593
|
-
|
|
1594
|
-
if (build) {
|
|
1595
|
-
message = build.message;
|
|
1596
|
-
logger.info(message);
|
|
1597
|
-
} else {
|
|
1598
|
-
message = Constants.userMessages.API_DEPRECATED;
|
|
1599
|
-
logger.info(message);
|
|
1600
|
-
}
|
|
1601
|
-
} else if (resp.statusCode != 200) {
|
|
1602
|
-
messageType = Constants.messageTypes.ERROR;
|
|
1603
|
-
errorCode = 'api_failed_build_stop';
|
|
1604
|
-
|
|
1605
|
-
if (build) {
|
|
1606
|
-
message = `${
|
|
1607
|
-
Constants.userMessages.BUILD_STOP_FAILED
|
|
1608
|
-
} with error: \n${JSON.stringify(build, null, 2)}`;
|
|
1609
|
-
logger.error(message);
|
|
1610
|
-
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
1611
|
-
} else {
|
|
1612
|
-
message = Constants.userMessages.BUILD_STOP_FAILED;
|
|
1613
|
-
logger.error(message);
|
|
1614
|
-
}
|
|
1615
|
-
} else {
|
|
1616
|
-
messageType = Constants.messageTypes.SUCCESS;
|
|
1617
|
-
message = `${JSON.stringify(build, null, 2)}`;
|
|
1618
|
-
logger.info(message);
|
|
1619
|
-
}
|
|
1620
|
-
} catch(err) {
|
|
1621
|
-
message = Constants.userMessages.BUILD_STOP_FAILED;
|
|
1622
|
-
messageType = Constants.messageTypes.ERROR;
|
|
1623
|
-
errorCode = 'api_failed_build_stop';
|
|
1624
|
-
logger.info(message);
|
|
1625
|
-
} finally {
|
|
1626
|
-
that.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
1627
|
-
}
|
|
1616
|
+
message = Constants.userMessages.API_DEPRECATED;
|
|
1617
|
+
logger.info(message);
|
|
1628
1618
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1619
|
+
} else if (response.status !== 200) {
|
|
1620
|
+
messageType = Constants.messageTypes.ERROR;
|
|
1621
|
+
errorCode = 'api_failed_build_stop';
|
|
1622
|
+
|
|
1623
|
+
if (build) {
|
|
1624
|
+
message = `${
|
|
1625
|
+
Constants.userMessages.BUILD_STOP_FAILED
|
|
1626
|
+
} with error: \n${JSON.stringify(build, null, 2)}`;
|
|
1627
|
+
logger.error(message);
|
|
1628
|
+
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
1629
|
+
} else {
|
|
1630
|
+
message = Constants.userMessages.BUILD_STOP_FAILED;
|
|
1631
|
+
logger.error(message);
|
|
1632
|
+
}
|
|
1633
|
+
} else {
|
|
1634
|
+
messageType = Constants.messageTypes.SUCCESS;
|
|
1635
|
+
message = `${JSON.stringify(build, null, 2)}`;
|
|
1636
|
+
logger.info(message);
|
|
1637
|
+
}
|
|
1638
|
+
} catch(err) {
|
|
1639
|
+
if(err.response) {
|
|
1640
|
+
message = `${
|
|
1641
|
+
Constants.userMessages.BUILD_STOP_FAILED
|
|
1642
|
+
} with error: ${err.response.data.message}`;
|
|
1643
|
+
messageType = Constants.messageTypes.ERROR;
|
|
1644
|
+
errorCode = 'api_failed_build_stop';
|
|
1645
|
+
logger.error(message);
|
|
1646
|
+
}
|
|
1647
|
+
} finally {
|
|
1648
|
+
that.sendUsageReport(bsConfig, args, message, messageType, errorCode, buildReportData, rawArgs);
|
|
1649
|
+
}
|
|
1632
1650
|
}
|
|
1633
1651
|
|
|
1634
1652
|
exports.setProcessHooks = (buildId, bsConfig, bsLocal, args, buildReportData) => {
|
|
@@ -1645,6 +1663,7 @@ exports.setProcessHooks = (buildId, bsConfig, bsLocal, args, buildReportData) =>
|
|
|
1645
1663
|
process.on('uncaughtException', processExitHandler.bind(this, bindData));
|
|
1646
1664
|
}
|
|
1647
1665
|
|
|
1666
|
+
|
|
1648
1667
|
exports.setO11yProcessHooks = (() => {
|
|
1649
1668
|
let bindData = {};
|
|
1650
1669
|
let handlerAdded = false;
|