You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2016/01/22 19:39:00 UTC
cordova-medic git commit: CB-10405 - Connectivity issue to Cordova
VM. This closes #72.
Repository: cordova-medic
Updated Branches:
refs/heads/master 9160c3d3e -> 8dc0c0764
CB-10405 - Connectivity issue to Cordova VM. This closes #72.
1. Added retry logic while checking if cordova vms are up.
2. Increased server response timeout from 3 seconds to 15 seconds
Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/8dc0c076
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/8dc0c076
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/8dc0c076
Branch: refs/heads/master
Commit: 8dc0c07640ac1324c20c2d4a386e906767d7ee50
Parents: 9160c3d
Author: Sarangan Rajamanickam <sa...@microsoft.com>
Authored: Wed Jan 20 17:21:19 2016 -0800
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Fri Jan 22 10:38:48 2016 -0800
----------------------------------------------------------------------
medic/medic-run.js | 49 +++++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/8dc0c076/medic/medic-run.js
----------------------------------------------------------------------
diff --git a/medic/medic-run.js b/medic/medic-run.js
index 20bb4bc..504935d 100644
--- a/medic/medic-run.js
+++ b/medic/medic-run.js
@@ -44,7 +44,9 @@ var MEDIC_BUILD_PREFIX = "medic-cli-build";
var DEFAULT_WINDOWS_VERSION = "store";
var WINDOWS_VERSION_CHOICES = ["store", "store80", "phone"];
var DEFAULT_TIMEOUT = 600; // in seconds
-var SERVER_RESPONSE_TIMEOUT = 3000; // in milliseconds
+var SERVER_RESPONSE_TIMEOUT = 15000; // in milliseconds
+var MAX_NUMBER_OF_TRIES = 3;
+var WAIT_TIME_TO_RETRY_CONNECTION = 15000; // in milliseconds
// helpers
function currentMillisecond() {
@@ -291,6 +293,29 @@ function failedBecauseNoDevice(output) {
return NO_DEVICE_PATTERN.test(output);
}
+function tryConnect(couchdbURI, pendingNumberOfTries, callback) {
+ util.medicLog("checking if " + couchdbURI + " is up.");
+
+ // check if results server is up
+ request({
+ uri: couchdbURI,
+ method: "GET",
+ timeout: SERVER_RESPONSE_TIMEOUT
+ }).on('response', function (response){
+ callback();
+ }).on('error', function (error){
+ if(pendingNumberOfTries > 1) {
+ util.medicLog("it's not up. Going to retry after " + WAIT_TIME_TO_RETRY_CONNECTION + " milliseconds");
+ setTimeout(function (){
+ tryConnect(couchdbURI, pendingNumberOfTries-1 , callback);
+ }, WAIT_TIME_TO_RETRY_CONNECTION);
+ } else {
+ util.fatal("it's not up even after " + MAX_NUMBER_OF_TRIES + " attempts to connect, so test run can't be monitored");
+ process.exit(1);
+ }
+ });
+}
+
// main
function main() {
@@ -324,23 +349,8 @@ function main() {
util.fatal("app " + appPath + " does not exist");
}
- util.medicLog("checking if " + couchdbURI + " is up");
-
- // check if results server is up
- request({
- uri: couchdbURI,
- method: "GET",
- timeout: SERVER_RESPONSE_TIMEOUT
- },
- function (error, response, body) {
-
- // bail if the results server is down
- if (error || response.statusCode !== 200) {
- util.fatal("it's not up, so test run can't be monitored");
- process.exit(1);
- } else {
- util.medicLog("it's up");
- }
+ tryConnect(couchdbURI, MAX_NUMBER_OF_TRIES, function (){
+ util.medicLog("it's up");
// modify the app to run autonomously
createMedicJson(appPath, buildId, couchdbURI);
@@ -414,8 +424,7 @@ function main() {
}
}
});
-
- }); // request(couchdbURI)
+ });
}
main();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org