Skip to content

Commit 06fde63

Browse files
authored
Merge pull request #264 from HRanjan-11/CYP-733
added retry for get build info
2 parents 39b9f99 + a368ecd commit 06fde63

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

commands/utils/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
SUPPORTED_CYPRESS_VERSIONS: ["5", "6"],
1414
WHITELISTED_ENV_VARS: ["CI_BUILD_ID", "PERCY_TOKEN", "QASE_REPORT", "QASE_RUN_ID", "QASE_RUN_NAME", "QASE_RUN_DESCRIPTION", "QASE_API_TOKEN", "QASE_API_BASE_URL", "QASE_ENVIRONMENT_ID", "QASE_SCREENSHOT_FOLDER", "QASE_SCREENSHOT_SENDING", "QASE_RUN_COMPLETE"],
1515
BUILD_END_STATES:
16-
"&status=running,queued,created,initiated,pqueued,error,lambda error,failed",
16+
"&status=running,queued,created,initiated,pqueued,error,lambda error,failed,completed,queue_timeout,idle_timeout,stopped,cancelled,passed,timeout,inactive",
1717
BUILD_ERROR_STATES: "&status=error,lambda error,failed",
1818
CYPRESS_ENV_FILE_PATH: "cypress.env.json",
1919
ENVS: ["stage", "beta", "prod", "preprod", "stage_new"],

commands/utils/poller/build_stats.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const constants = require("../constants");
22
const request = require("request");
33
const builds = require("./build");
44
//const poller=require("./poller.js")
5+
var get_build_info_count = 0;
56

67
function get_completed_build_info(lt_config, session_id, env) {
78
let options = {
@@ -66,6 +67,14 @@ function get_build_info(lt_config, session_id, env, update_status, callback) {
6667
error: 0,
6768
"lambda error": 0,
6869
failed: 0,
70+
completed: 0,
71+
queue_timeout : 0,
72+
idle_timeout : 0,
73+
stopped : 0,
74+
cancelled : 0,
75+
passed : 0,
76+
timeout : 0,
77+
inactive : 0,
6978
};
7079
let build_info = JSON.parse(body);
7180
if (build_info.Meta.result_set.count > 0) {
@@ -81,6 +90,27 @@ function get_build_info(lt_config, session_id, env, update_status, callback) {
8190
statsNew["pqueued"] ==
8291
0
8392
) {
93+
if (
94+
statsNew["error"] +
95+
statsNew["lambda error"] +
96+
statsNew["failed"] +
97+
statsNew["completed"] +
98+
statsNew["queue_timeout"] +
99+
statsNew["idle_timeout"] +
100+
statsNew["stopped"] +
101+
statsNew["cancelled"] +
102+
statsNew["passed"] +
103+
statsNew["timeout"] +
104+
statsNew["inactive"] ==
105+
0
106+
) {
107+
get_build_info_count = get_build_info_count + 1;
108+
if (get_build_info_count > 4) {
109+
update_status(false);
110+
return callback(null, JSON.parse(body));
111+
}
112+
return setTimeout(callback, 5000, null);
113+
}
84114
update_status(false);
85115
return callback(null, JSON.parse(body));
86116
}

commands/utils/poller/poller.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function poll_build(lt_config, session_id, env) {
2424
build_stats
2525
.get_completed_build_info(lt_config, session_id, env)
2626
.then(function (build_info) {
27+
if (!build_info || build_info.data == null) {
28+
console.log("Build info not found");
29+
resolve(1);
30+
return;
31+
}
2732
let stats = {};
2833
let status = [];
2934
for (i = 0; i < build_info["data"].length; i++) {

0 commit comments

Comments
 (0)