Skip to content

Commit ebd95db

Browse files
authored
Merge pull request #2 from rchougule/master
Custom error response code 502. Connectivity logs update. Ping commands at top for easy at-a-glance debugging.
2 parents 9e10f3c + c067ed7 commit ebd95db

File tree

9 files changed

+27
-22
lines changed

9 files changed

+27
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
TIMESTAMP_IN_UTC [#2::UNIQUE_IDENTIFIER] [Tool Request - Retries Left: 1] [INFO] POST http://<URL>/wd/hub/status, {"method":"POST","headers":{".......","Proxy-Authorization":"Basic AaBbCcDdEeFfGg==","X-Requests-Debugger":"2::UNIQUE_IDENTIFIER"},"host":"<EXTERNAL_PROXY_URL>","port":"3130","path":"http://<URL>/wd/hub/status","data":"{\"key\": \"value\"}"}
7878
TIMESTAMP_IN_UTC [#2::UNIQUE_IDENTIFIER] [Tool Request - Retries Left: 1] [ERROR] POST http://<URL>/wd/hub/status, {"errorMessage":"Error: getaddrinfo ENOTFOUND <EXTERNAL_PROXY_URL> <EXTERNAL_PROXY_URL>:3130"}
7979
TIMESTAMP_IN_UTC [#2::UNIQUE_IDENTIFIER] [Tool Request - Retries Left: 0] [ERROR] POST http://<URL>/wd/hub/status, {"errorMessage":"Error: getaddrinfo ENOTFOUND <EXTERNAL_PROXY_URL> <EXTERNAL_PROXY_URL>:3130"}
80-
TIMESTAMP_IN_UTC [#2::UNIQUE_IDENTIFIER] [Response End] [ERROR] POST http://<URL>/wd/hub/status, Status Code: 500, {"message":"Error: getaddrinfo ENOTFOUND <EXTERNAL_PROXY_URL> <EXTERNAL_PROXY_URL>:3130. Request Failed At Requests Debugger","error":"Request Failed At Requests Debugger"}
80+
TIMESTAMP_IN_UTC [#2::UNIQUE_IDENTIFIER] [Response End] [ERROR] POST http://<URL>/wd/hub/status, Status Code: 502, {"message":"Error: getaddrinfo ENOTFOUND <EXTERNAL_PROXY_URL> <EXTERNAL_PROXY_URL>:3130. Request Failed At Requests Debugger","error":"Request Failed At Requests Debugger"}
8181
- Tags & their meaning:
8282
- **TIMESTAMP_IN_UTC** : Timestamp of each event in UTC.
8383
- **#2** : This represents the `nth` request which the tool served from the time it was started.

config/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports.HUB_STATUS_URL = 'http://hub-cloud.browserstack.com/wd/hub/status
33
module.exports.RAILS_AUTOMATE = 'http://automate.browserstack.com';
44
module.exports.CONNECTIVITY_REQ_TIMEOUT = 30000;
55
module.exports.DEFAULT_PROXY_PORT = 3128;
6+
module.exports.CUSTOM_ERROR_RESPONSE_CODE = 502;
67
module.exports.MAX_RETRIES = 1;
78
module.exports.LOGS_FOLDER = 'RequestsDebuggerLogs';
89
module.exports.PORTS = {

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"bin": {
1717
"RequestsDebugger": "src/requestsDebugger.js"
1818
},
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/browserstack/requests-debugger.git"
22+
},
1923
"author": "",
2024
"license": "ISC",
2125
"devDependencies": {

src/connectivity.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,47 +71,47 @@ var ConnectivityChecker = {
7171
httpToHubWithoutProxy: function (callback) {
7272
var requestUrl = constants.HUB_STATUS_URL;
7373
var requestOptions = ConnectivityChecker.reqOpsWithoutProxy(requestUrl, 'http');
74-
fireRequest(requestOptions, 'http', 'HTTP Request To Hub Without Proxy', [200], function (response) {
74+
fireRequest(requestOptions, 'http', 'HTTP Request To ' + requestUrl + ' Without Proxy', [200], function (response) {
7575
callback(response);
7676
});
7777
},
7878

7979
httpToRailsWithoutProxy: function (callback) {
8080
var requestUrl = constants.RAILS_AUTOMATE;
8181
var requestOptions = ConnectivityChecker.reqOpsWithoutProxy(requestUrl, 'http');
82-
fireRequest(requestOptions, 'http', 'HTTP Request To Rails Without Proxy', [200, 301], function (response) {
82+
fireRequest(requestOptions, 'http', 'HTTP Request To ' + requestUrl + ' Without Proxy', [200, 301], function (response) {
8383
callback(response);
8484
});
8585
},
8686

8787
httpsToHubWithoutProxy: function (callback) {
8888
var requestUrl = constants.HUB_STATUS_URL;
8989
var requestOptions = ConnectivityChecker.reqOpsWithoutProxy(requestUrl, 'https');
90-
fireRequest(requestOptions, 'https', 'HTTPS Request To Hub Without Proxy', [200], function (response) {
90+
fireRequest(requestOptions, 'https', 'HTTPS Request To ' + requestUrl + ' Without Proxy', [200], function (response) {
9191
callback(response);
9292
});
9393
},
9494

9595
httpsToRailsWithoutProxy: function (callback) {
9696
var requestUrl = constants.RAILS_AUTOMATE;
9797
var requestOptions = ConnectivityChecker.reqOpsWithoutProxy(requestUrl, 'https');
98-
fireRequest(requestOptions, 'https', 'HTTPS Request to Rails Without Proxy', [301, 302], function (response) {
98+
fireRequest(requestOptions, 'https', 'HTTPS Request to ' + requestUrl + ' Without Proxy', [301, 302], function (response) {
9999
callback(response);
100100
});
101101
},
102102

103103
httpToHubWithProxy: function (callback) {
104104
var requestUrl = constants.HUB_STATUS_URL;
105105
var requestOptions = ConnectivityChecker.reqOpsWithProxy(requestUrl, 'http');
106-
fireRequest(requestOptions, 'http', 'HTTP Request To Hub With Proxy', [200], function (response) {
106+
fireRequest(requestOptions, 'http', 'HTTP Request To ' + requestUrl + ' With Proxy', [200], function (response) {
107107
callback(response);
108108
});
109109
},
110110

111111
httpToRailsWithProxy: function (callback) {
112112
var requestUrl = constants.RAILS_AUTOMATE;
113113
var requestOptions = ConnectivityChecker.reqOpsWithProxy(requestUrl, 'http');
114-
fireRequest(requestOptions, 'http', 'HTTP Request To Rails With Proxy', [301], function (response) {
114+
fireRequest(requestOptions, 'http', 'HTTP Request To ' + requestUrl + ' With Proxy', [301], function (response) {
115115
callback(response);
116116
});
117117
},

src/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ var RdHandler = {
9999
},
100100
state: 'error'
101101
},
102-
statusCode: 500
102+
statusCode: constants.CUSTOM_ERROR_RESPONSE_CODE
103103
};
104104
} else {
105105
return {
106106
data: {
107107
message: errorMessage,
108108
error: constants.STATIC_MESSAGES.REQ_FAILED_MSG
109109
},
110-
statusCode: 500
110+
statusCode: constants.CUSTOM_ERROR_RESPONSE_CODE
111111
};
112112
}
113113
},

src/stats/linuxStats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ LinuxStats.mem = function (callback) {
6161

6262
LinuxStats.network = function (callback) {
6363
var startTime = new Date();
64-
var commands = [constants.LINUX.TCP_LISTEN_ESTABLISHED, constants.COMMON.PING_HUB, constants.COMMON.PING_AUTOMATE];
64+
var commands = [constants.COMMON.PING_HUB, constants.COMMON.PING_AUTOMATE, constants.LINUX.TCP_LISTEN_ESTABLISHED];
6565
var finalOutput = "";
6666

6767
Utils.execMultiple(commands, function (results) {

src/stats/macStats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ MacStats.mem = function (callback) {
7171

7272
MacStats.network = function (callback) {
7373
var startTime = new Date();
74-
var commands = [constants.MAC.TCP_LISTEN_ESTABLISHED, constants.COMMON.PING_HUB, constants.COMMON.PING_AUTOMATE];
74+
var commands = [constants.COMMON.PING_HUB, constants.COMMON.PING_AUTOMATE, constants.MAC.TCP_LISTEN_ESTABLISHED];
7575
var finalOutput = "";
7676

7777
Utils.execMultiple(commands, function (results) {

src/stats/winStats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ WinStats.mem = function (callback) {
6666

6767
WinStats.network = function (callback) {
6868
var startTime = new Date();
69-
var commands = [constants.WIN.NETSTAT_TCP, constants.WIN.NETSTAT_ROUTING_TABLE, constants.WIN.IPCONFIG_ALL, constants.WIN.PING_HUB, constants.WIN.PING_AUTOMATE];
69+
var commands = [constants.WIN.PING_HUB, constants.WIN.PING_AUTOMATE, constants.WIN.NETSTAT_TCP, constants.WIN.NETSTAT_ROUTING_TABLE, constants.WIN.IPCONFIG_ALL];
7070
var finalOutput = "";
7171

7272
Utils.execMultiple(commands, function (results) {

test/connectivity.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,51 @@ describe('Connectivity Checker for BrowserStack Components', function () {
2020
data: '{"data":"value"}',
2121
statusCode: 200,
2222
errorMessage: null,
23-
description: 'HTTP Request To Hub Without Proxy',
23+
description: 'HTTP Request To ' + constants.HUB_STATUS_URL + ' Without Proxy',
2424
result: 'Passed'
2525
}, {
2626
data: '{"data":"value"}',
2727
statusCode: 301,
2828
errorMessage: null,
29-
description: 'HTTP Request To Rails Without Proxy',
29+
description: 'HTTP Request To ' + constants.RAILS_AUTOMATE + ' Without Proxy',
3030
result: 'Passed'
3131
}, {
3232
data: '{"data":"value"}',
3333
statusCode: 200,
3434
errorMessage: null,
35-
description: 'HTTPS Request To Hub Without Proxy',
35+
description: 'HTTPS Request To ' + constants.HUB_STATUS_URL + ' Without Proxy',
3636
result: 'Passed'
3737
}, {
3838
data: '{"data":"value"}',
3939
statusCode: 302,
4040
errorMessage: null,
41-
description: 'HTTPS Request to Rails Without Proxy',
41+
description: 'HTTPS Request to ' + constants.RAILS_AUTOMATE + ' Without Proxy',
4242
result: 'Passed'
4343
}];
4444

4545
var errorResult = [{
4646
data: [],
4747
statusCode: null,
4848
errorMessage: 'Error: something terrible',
49-
description: 'HTTP Request To Hub Without Proxy',
49+
description: 'HTTP Request To ' + constants.HUB_STATUS_URL + ' Without Proxy',
5050
result: 'Failed'
5151
}, {
5252
data: [],
5353
statusCode: null,
5454
errorMessage: 'Error: something terrible',
55-
description: 'HTTP Request To Rails Without Proxy',
55+
description: 'HTTP Request To ' + constants.RAILS_AUTOMATE + ' Without Proxy',
5656
result: 'Failed'
5757
}, {
5858
data: [],
5959
statusCode: null,
6060
errorMessage: 'Error: something terrible',
61-
description: 'HTTPS Request To Hub Without Proxy',
61+
description: 'HTTPS Request To ' + constants.HUB_STATUS_URL + ' Without Proxy',
6262
result: 'Failed'
6363
}, {
6464
data: [],
6565
statusCode: null,
6666
errorMessage: 'Error: something terrible',
67-
description: 'HTTPS Request to Rails Without Proxy',
67+
description: 'HTTPS Request to ' + constants.RAILS_AUTOMATE + ' Without Proxy',
6868
result: 'Failed'
6969
}];
7070

@@ -116,13 +116,13 @@ describe('Connectivity Checker for BrowserStack Components', function () {
116116
sinon.stub(Utils, 'beautifyObject');
117117
var resultWithProxy = resultWithoutProxy.concat([{
118118
data: '{"data":"value"}',
119-
description: "HTTP Request To Hub With Proxy",
119+
description: "HTTP Request To " + constants.HUB_STATUS_URL + " With Proxy",
120120
errorMessage: null,
121121
result: "Passed",
122122
statusCode: 200
123123
}, {
124124
data: '{"data":"value"}',
125-
description: "HTTP Request To Rails With Proxy",
125+
description: "HTTP Request To " + constants.RAILS_AUTOMATE + " With Proxy",
126126
errorMessage: null,
127127
result: "Passed",
128128
statusCode: 301

0 commit comments

Comments
 (0)