Skip to content

Commit d82a870

Browse files
Roshan NikamRoshan Nikam
authored andcommitted
handled indirect flows for instrumenting raw logs
1 parent b6d9aa1 commit d82a870

File tree

9 files changed

+41
-33
lines changed

9 files changed

+41
-33
lines changed

bin/commands/generateDownloads.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = async function generateDownloads(args, rawArgs) {
2828
let errorCode = null;
2929
let buildId = args._[1];
3030

31-
await downloadBuildArtifacts(bsConfig, buildId, args);
31+
await downloadBuildArtifacts(bsConfig, buildId, args, rawArgs);
3232
utils.sendUsageReport(bsConfig, args, Constants.usageReportingConstants.GENERATE_DOWNLOADS, messageType, errorCode, null, rawArgs);
3333
}).catch(function (err) {
3434
logger.error(err);

bin/commands/generateReport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function generateReport(args, rawArgs) {
2929
let errorCode = null;
3030
let buildId = args._[1];
3131

32-
reportGenerator(bsConfig, buildId, args);
32+
reportGenerator(bsConfig, buildId, args, rawArgs);
3333
utils.sendUsageReport(bsConfig, args, 'generate-report called', messageType, errorCode, null, rawArgs);
3434
}).catch(function (err) {
3535
logger.error(err);

bin/commands/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ const fileHelpers = require("../helpers/fileHelpers"),
77
path = require('path');
88

99

10-
function get_path(args) {
10+
function get_path(args, rawArgs) {
1111
if (args._.length > 1 && args.p) {
1212
let filename = args._[1];
1313
if (filename !== path.basename(filename)) {
1414
let message = Constants.userMessages.CONFLICTING_INIT_ARGUMENTS;
1515
logger.error(message);
1616
// set cypress config filename
1717
utils.setCypressConfigFilename(args.bstack_config, args);
18-
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'conflicting_path_json_init');
18+
utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'conflicting_path_json_init', null, rawArgs);
1919
return;
2020
}
2121

@@ -37,7 +37,7 @@ function get_path(args) {
3737

3838
module.exports = function init(args, rawArgs) {
3939

40-
let path_to_json = get_path(args);
40+
let path_to_json = get_path(args, rawArgs);
4141
if (path_to_json === undefined) return;
4242

4343
// append .json if filename passed is not of json type

bin/commands/runs.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = function run(args, rawArgs) {
100100
utils.setParallels(bsConfig, args, specFiles.length);
101101

102102
// warn if specFiles cross our limit
103-
utils.warnSpecLimit(bsConfig, args, specFiles);
103+
utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
104104
markBlockEnd('preArchiveSteps');
105105
markBlockStart('checkAlreadyUploaded');
106106
return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
@@ -125,7 +125,7 @@ module.exports = function run(args, rawArgs) {
125125
// Create build
126126
//setup Local Testing
127127
markBlockStart('localSetup');
128-
let bs_local = await utils.setupLocalTesting(bsConfig, args);
128+
let bs_local = await utils.setupLocalTesting(bsConfig, args, rawArgs);
129129
markBlockEnd('localSetup');
130130
markBlockStart('createBuild');
131131
return build.createBuild(bsConfig, zip).then(function (data) {
@@ -161,21 +161,21 @@ module.exports = function run(args, rawArgs) {
161161

162162

163163
if (args.sync) {
164-
syncRunner.pollBuildStatus(bsConfig, data).then(async (exitCode) => {
164+
syncRunner.pollBuildStatus(bsConfig, data, rawArgs).then(async (exitCode) => {
165165

166166
// stop the Local instance
167-
await utils.stopLocalBinary(bsConfig, bs_local, args);
167+
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
168168

169169
// waiting for 5 secs for upload to complete (as a safety measure)
170170
await new Promise(resolve => setTimeout(resolve, 5000));
171171

172172
// download build artifacts
173173
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
174-
await downloadBuildArtifacts(bsConfig, data.build_id, args);
174+
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
175175
}
176176

177177
// Generate custom report!
178-
reportGenerator(bsConfig, data.build_id, args, function(){
178+
reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
179179
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
180180
utils.handleSyncExit(exitCode, data.dashboard_url);
181181
});
@@ -209,7 +209,7 @@ module.exports = function run(args, rawArgs) {
209209
// Build creation failed
210210
logger.error(err);
211211
// stop the Local instance
212-
await utils.stopLocalBinary(bsConfig, bs_local, args);
212+
await utils.stopLocalBinary(bsConfig, bs_local, args, rawArgs);
213213

214214
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'build_failed', null, rawArgs);
215215
process.exitCode = Constants.ERROR_EXIT_CODE;

bin/commands/stop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = function stop(args, rawArgs) {
2525

2626
let buildId = args._[1];
2727

28-
await utils.stopBrowserStackBuild(bsConfig, args, buildId);
28+
await utils.stopBrowserStackBuild(bsConfig, args, buildId, rawArgs);
2929

3030
}).catch(function (err) {
3131
logger.error(err);

bin/helpers/buildArtifacts.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const unzipFile = async (filePath, fileName) => {
134134
});
135135
}
136136

137-
const sendUpdatesToBstack = async (bsConfig, buildId, args, options) => {
137+
const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) => {
138138
let url = `${config.buildUrl}${buildId}/build_artifacts/status`;
139139

140140
let cypressJSON = utils.getCypressJSON(bsConfig);
@@ -159,11 +159,11 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options) => {
159159
try {
160160
await axios.post(url, data, options);
161161
} catch (err) {
162-
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update');
162+
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
163163
}
164164
}
165165

166-
exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
166+
exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
167167
BUILD_ARTIFACTS_FAIL_COUNT = 0;
168168
BUILD_ARTIFACTS_TOTAL_COUNT = 0;
169169

@@ -200,8 +200,8 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
200200
logger.info(message);
201201
}
202202

203-
await sendUpdatesToBstack(bsConfig, buildId, args, options);
204-
utils.sendUsageReport(bsConfig, args, message, messageType, null);
203+
await sendUpdatesToBstack(bsConfig, buildId, args, options, rawArgs);
204+
utils.sendUsageReport(bsConfig, args, message, messageType, null, null, rawArgs);
205205
} catch (err) {
206206
messageType = Constants.messageTypes.ERROR;
207207
errorCode = 'api_failed_build_artifacts';
@@ -214,7 +214,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args) => {
214214
logger.error('Downloading the build artifacts failed.');
215215
}
216216

217-
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode);
217+
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, null, rawArgs);
218218
process.exitCode = Constants.ERROR_EXIT_CODE;
219219
}
220220
};

bin/helpers/reporterHTML.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function buildSpecStats(specMeta) {
8989
return specStats;
9090
}
9191

92-
let reportGenerator = (bsConfig, buildId, args, cb) => {
92+
let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
9393
let options = {
9494
url: `${config.buildUrl}${buildId}/custom_report`,
9595
auth: {
@@ -115,7 +115,7 @@ let reportGenerator = (bsConfig, buildId, args, cb) => {
115115
logger.error('Generating the build report failed.');
116116
logger.error(message);
117117

118-
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode);
118+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
119119
return;
120120
} else {
121121
try {
@@ -167,7 +167,7 @@ let reportGenerator = (bsConfig, buildId, args, cb) => {
167167
await renderReportHTML(build);
168168
logger.info(message);
169169
}
170-
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode);
170+
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
171171
if (cb){
172172
cb();
173173
}

bin/helpers/sync/syncSpecsLogs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let setNoWrapParams = () => {
9090
}
9191
};
9292

93-
let printSpecsStatus = (bsConfig, buildDetails) => {
93+
let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
9494
setNoWrapParams();
9595
return new Promise((resolve, reject) => {
9696
options = getOptions(bsConfig.auth, buildDetails.build_id)
@@ -106,7 +106,7 @@ let printSpecsStatus = (bsConfig, buildDetails) => {
106106
},
107107
function(err, result) { // when loop ends
108108
if (err) {
109-
utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', err);
109+
utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', err, rawArgs);
110110
}
111111
logger.info(lineSeparator);
112112
specSummary.duration = endTime - startTime

bin/helpers/utils.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ exports.setParallels = (bsConfig, args, numOfSpecs) => {
164164
}
165165
};
166166

167-
exports.warnSpecLimit = (bsConfig, args, specFiles) => {
167+
exports.warnSpecLimit = (bsConfig, args, specFiles, rawArgs) => {
168168
let expectedCharLength = specFiles.join("").length + Constants.METADATA_CHAR_BUFFER_PER_SPEC * specFiles.length;
169169
let parallels = bsConfig.run_settings.parallels;
170170
let combinations = this.getBrowserCombinations(bsConfig).length;
@@ -177,7 +177,9 @@ exports.warnSpecLimit = (bsConfig, args, specFiles) => {
177177
args,
178178
Constants.userMessages.SPEC_LIMIT_WARNING,
179179
Constants.messageTypes.WARNING,
180-
null
180+
null,
181+
null,
182+
rawArgs
181183
);
182184
}
183185
}
@@ -595,7 +597,7 @@ exports.setLocalMode = (bsConfig, args) => {
595597
}
596598
};
597599

598-
exports.setupLocalTesting = (bsConfig, args) => {
600+
exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
599601
return new Promise(async (resolve, reject) => {
600602
if( bsConfig['connection_settings'] && bsConfig['connection_settings']['local'] && String(bsConfig['connection_settings']['local']) === "true" ){
601603
let localIdentifierRunning = await this.checkLocalIdentifierRunning(
@@ -618,7 +620,9 @@ exports.setupLocalTesting = (bsConfig, args) => {
618620
args,
619621
message,
620622
Constants.messageTypes.ERROR,
621-
errorCode
623+
errorCode,
624+
null,
625+
rawArgs
622626
);
623627
reject(Constants.userMessages.LOCAL_START_FAILED);
624628
}
@@ -632,7 +636,7 @@ exports.setupLocalTesting = (bsConfig, args) => {
632636
});
633637
};
634638

635-
exports.stopLocalBinary = (bsConfig, bs_local, args) => {
639+
exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
636640
return new Promise(async (resolve, reject) => {
637641
if(bsConfig['connection_settings'] && bsConfig['connection_settings']['local']){
638642
let localIdentifierRunning = await this.checkLocalIdentifierRunning(bsConfig,bsConfig["connection_settings"]["local_identifier"]);
@@ -644,7 +648,9 @@ exports.stopLocalBinary = (bsConfig, bs_local, args) => {
644648
args,
645649
message,
646650
Constants.messageTypes.ERROR,
647-
errorCode
651+
errorCode,
652+
null,
653+
rawArgs
648654
);
649655
}
650656
}
@@ -661,7 +667,9 @@ exports.stopLocalBinary = (bsConfig, bs_local, args) => {
661667
args,
662668
message,
663669
Constants.messageTypes.ERROR,
664-
errorCode
670+
errorCode,
671+
null,
672+
rawArgs
665673
);
666674
resolve(Constants.userMessages.LOCAL_STOP_FAILED);
667675
}
@@ -944,7 +952,7 @@ exports.setCLIMode = (bsConfig, args) => {
944952
}
945953
}
946954

947-
exports.stopBrowserStackBuild = async (bsConfig, args, buildId ) => {
955+
exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
948956
let url = config.buildStopUrl + buildId;
949957
let options = {
950958
url: url,
@@ -1004,7 +1012,7 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId ) => {
10041012
errorCode = 'api_failed_build_stop';
10051013
logger.info(message);
10061014
} finally {
1007-
this.sendUsageReport(bsConfig, args, message, messageType, errorCode);
1015+
this.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
10081016
}
10091017
}
10101018

0 commit comments

Comments
 (0)