wdio-docker-service
Advanced tools
Comparing version 1.1.8 to 1.2.0
@@ -1,2 +0,2 @@ | ||
172.17.0.1 - - [07/Mar/2018:05:09:40 +0000] "GET / HTTP/1.1" 200 174 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" "-" | ||
172.17.0.1 - - [07/Mar/2018:05:09:42 +0000] "GET / HTTP/1.1" 200 174 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/64.0.3282.186 Safari/537.36" "-" | ||
172.17.0.1 - - [29/Apr/2018:15:58:04 +0000] "GET / HTTP/1.1" 200 174 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" "-" | ||
172.17.0.1 - - [29/Apr/2018:15:58:07 +0000] "GET / HTTP/1.1" 200 174 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/66.0.3359.117 Safari/537.36" "-" |
@@ -52,3 +52,3 @@ 'use strict'; | ||
* @param {Object} [options] Docker run options | ||
* @param {String} [healthCheck] Url that verifies that service is running | ||
* @param {String|Object} [healthCheck] Url that verifies that service is running | ||
* @param {String} [command] docker command that follows image/tag name | ||
@@ -58,3 +58,3 @@ * @param {String} [args] docker args that follow image/tag name | ||
*/ | ||
constructor(image, { debug = false, options = {}, healthCheck, command, args } = {}, logger = console) { | ||
constructor(image, { debug = false, options = {}, healthCheck = {}, command, args } = {}, logger = console) { | ||
super(); | ||
@@ -75,2 +75,6 @@ | ||
if (typeof healthCheck === 'string') { | ||
this.healthCheck = { url: healthCheck }; | ||
} | ||
this.options = (0, _deepMerge2.default)({ | ||
@@ -154,3 +158,14 @@ cidfile: this.cidfile | ||
_reportWhenDockerIsRunning() { | ||
return new _bluebird2.default((resolve, reject) => { | ||
const { | ||
url, | ||
maxRetries = MAX_INSPECT_ATTEMPTS, | ||
inspectInterval = INSPECT_DOCKER_INTERVAL, | ||
startDelay = 0 | ||
} = this.healthCheck; | ||
if (url == undefined) { | ||
return _bluebird2.default.resolve(); | ||
} | ||
return _bluebird2.default.delay(startDelay).then(() => new _bluebird2.default((resolve, reject) => { | ||
let attempts = 0; | ||
@@ -160,29 +175,21 @@ let pollstatus = null; | ||
const poll = () => { | ||
if (this.healthCheck !== undefined) { | ||
(0, _ping2.default)(this.healthCheck).then(() => { | ||
resolve(); | ||
(0, _ping2.default)(url).then(() => { | ||
resolve(); | ||
clearTimeout(pollstatus); | ||
pollstatus = null; | ||
}).catch(err => { | ||
attempts++; | ||
if (attempts >= maxRetries) { | ||
clearTimeout(pollstatus); | ||
pollstatus = null; | ||
}).catch(err => { | ||
attempts++; | ||
if (attempts >= MAX_INSPECT_ATTEMPTS) { | ||
clearTimeout(pollstatus); | ||
pollstatus = null; | ||
reject(err); | ||
return; | ||
} | ||
reject(err); | ||
return; | ||
} | ||
pollstatus = setTimeout(poll, INSPECT_DOCKER_INTERVAL); | ||
}); | ||
return; | ||
} | ||
resolve(); | ||
clearTimeout(pollstatus); | ||
pollstatus = null; | ||
pollstatus = setTimeout(poll, inspectInterval); | ||
}); | ||
}; | ||
pollstatus = setTimeout(poll, INSPECT_DOCKER_INTERVAL); | ||
}); | ||
pollstatus = setTimeout(poll, inspectInterval); | ||
})); | ||
} | ||
@@ -189,0 +196,0 @@ |
{ | ||
"name": "wdio-docker-service", | ||
"version": "1.1.8", | ||
"version": "1.2.0", | ||
"description": "WebdriverIO service to start and stop docker container (for Selenium and more)", | ||
@@ -14,3 +14,3 @@ "repository": { | ||
"scripts": { | ||
"prepublish": "npm prune && npm run build", | ||
"prepare": "npm prune && npm run build", | ||
"build": "babel src --out-dir lib -s > /dev/null", | ||
@@ -38,17 +38,17 @@ "test": "eslint -c .eslintrc.json src/**/*.js && npm run test:unit && npm run test:integration", | ||
"coveralls": "^3.0.0", | ||
"eslint": "^4.15.0", | ||
"eslint": "^4.19.1", | ||
"gulp": "^3.9.1", | ||
"mocha": "^4.1.0", | ||
"nyc": "^11.4.1", | ||
"sinon": "^4.1.5", | ||
"wdio-mocha-framework": "^0.5.12", | ||
"wdio-selenium-standalone-service": "0.0.9", | ||
"wdio-spec-reporter": "^0.1.3", | ||
"webdriverio": "^4.10.1" | ||
"mocha": "^5.1.1", | ||
"nyc": "^11.7.1", | ||
"sinon": "^4.5.0", | ||
"wdio-mocha-framework": "^0.5.13", | ||
"wdio-selenium-standalone-service": "0.0.10", | ||
"wdio-spec-reporter": "^0.1.4", | ||
"webdriverio": "^4.12.0" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.5.1", | ||
"chalk": "^2.3.0", | ||
"chalk": "^2.4.1", | ||
"fs-extra": "^5.0.0", | ||
"node-fetch": "^1.7.3" | ||
"node-fetch": "^2.1.2" | ||
}, | ||
@@ -55,0 +55,0 @@ "contributors": [ |
@@ -76,10 +76,27 @@ WDIO Docker Service [![Maintainability](https://api.codeclimate.com/v1/badges/fa04188e6558671dbd9e/maintainability)](https://codeclimate.com/github/stsvilik/wdio-docker-service/maintainability) | ||
### dockerOptions.healthCheck | ||
Url to an app exposed by your container. Normally this is a localhost url. | ||
If healthCheck is not provided, Webdriver will start running tests immediately after Docker container is executed, which | ||
Configuration which checks your containers' readiness before initiating tests. Normally this would be a localhost url. | ||
If healthCheck is not configured, Webdriver will start running tests immediately after Docker container starts, which | ||
maybe too early considering that it takes time for web service to start inside a Docker container. | ||
Type: `String` | ||
Type: `String|Object` | ||
Example: `http://localhost:4444` | ||
Options for Object use: | ||
- *url* - url to an app running inside your container | ||
- *maxRetries* - number of retries until healthcheck fails. Default: 10 | ||
- *inspectInterval* - interval between each retry in ms. Default: 500 | ||
- *startDelay* - initial delay to begin healthcheck in ms. Default: 0 | ||
Example 1 (String): `healthCheck: 'http://localhost:4444'` | ||
Example 2 (Object): | ||
```javascript | ||
healthCheck: { | ||
url: 'http://localhost:4444', | ||
maxRetries: 3, | ||
inspectInterval: 1000, | ||
startDelay: 2000 | ||
} | ||
``` | ||
### dockerOptions.options | ||
@@ -86,0 +103,0 @@ Map of options used by `docker run` command. For more details on `run` command click [here](https://docs.docker.com/edge/engine/reference/commandline/run/). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204981
507
146
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedencoding@0.1.13(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedis-stream@1.1.0(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedsafer-buffer@2.1.2(transitive)
Updatedchalk@^2.4.1
Updatednode-fetch@^2.1.2