[英]Timeout issue with a dockerized phantomjs
I would like to do some test using nodejs and phantomjs inside a docker container. 我想在docker容器中使用nodejs和phantomjs做一些测试。 All these tests work perfectly directly on a centos or debian server 所有这些测试都可以直接在centos或debian服务器上完美运行
npm run test npm运行测试
smart-tv-portal-tests@1.0.0 test /data/SmartTVPortal/tests mocha test-*.js smart-tv-portal-tests@1.0.0测试/ data / SmartTVPortal / tests摩卡测试-*。js
test suite for xxx ✓ should respond 200 OR 304 for xxx (173ms) ✓ should assert that the reponse is application/json ✓ should be able to parse json ✓ should validate JSON integrity (videos.length === 6) ✓ should validate http status with phantomjs (160ms) ✓ should validate carousel is loaded (761ms) ✓ should check last carousel element ✓ should navigate interactive in the main carousel (121ms) xxx测试套件✓应该对xxx响应200或304(173ms)✓应该断言响应是application / json✓应该能够解析json✓应该验证JSON完整性(videos.length === 6)✓应该验证http phantomjs的状态(160ms)✓应该验证轮播是否已加载(761ms)✓应该检查最后一个轮播元素✓应该在主轮播中进行交互式导航(121ms)
8 passing (1s) 8次通过(1秒)
but if I run the very same test within a docker container (based either on alpine/centos/ubuntu) it fails with timeout issue 但是如果我在docker容器中运行相同的测试(基于alpine / centos / ubuntu),它将失败并出现超时问题
docker run -ti --net=host --rm --volume /data/SmartTVPortal/:/srv --workdir /srv/tests arte/hbbtv bash
I get 我懂了
bash-4.3# npm run test bash-4.3#npm运行测试
smart-tv-portal-tests@1.0.0 test /srv/tests mocha test-*.js smart-tv-portal-tests@1.0.0测试/ srv / tests摩卡测试-*。js
test suite for xxx ✓ should respond 200 OR 304 for xxx (2534ms) ✓ should assert that the reponse is application/json ✓ should be able to parse json ✓ should validate JSON integrity (videos.length === 6) ✓ should validate http status with phantomjs (89ms) 1) should validate carousel is loaded Unhandled rejection text evaluatePage xxx的测试套件✓应该为xxx响应200或304(2534ms)✓应该断言响应是application / json✓应该能够解析json✓应该验证JSON完整性(videos.length === 6)✓应该验证http phantomjs的状态(89ms)1)应该验证轮播是否已加载未处理的拒绝文本评估页面
global code evaluateJavaScript@[native code] evaluate@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61 at /srv/tests/node_modules/node-horseman/lib/actions.js:989:36 at tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.fromNode.Promise.fromCallback (/srv/tests/node_modules/bluebird/js/release/promise.js:179:30) at Horseman. 全局代码评价JavaScript @ [本机代码]评价@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61位于/ srv / tests / node_modules / node-horseman / lib /在tryCatcher上的actions.js:989:36(/srv/tests/node_modules/bluebird/js/release/util.js:16:23)在Function.Promise.fromNode.Promise.fromCallback(/ srv / tests / node_modules / bluebird /js/release/promise.js:179:30)。 (/srv/tests/node_modules/node-horseman/lib/actions.js:987:29) at Horseman.tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/srv/tests/node_modules/bluebird/js/release/promise.js:510:31) at Promise._settlePromise (/srv/tests/node_modules/bluebird/js/release/promise.js:567:18) at Promise._settlePromiseCtx (/srv/tests/node_modules/bluebird/js/release/promise.js:604:10) at Async._drainQueue (/srv/tests/node_modules/bluebird/js/release/async.js:143:12) at Async._drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:148:10) at Immediate.Async.drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:17:14) at runCallback (timers.js:574:20) at tryOnImmediate (timers.js:554:5) at processImmediate [as _immediateCallback] (timers.js:533:5) (/srv/tests/node_modules/node-horseman/lib/actions.js:987:29)在Horseman.tryCatcher(/srv/tests/node_modules/bluebird/js/release/util.js:16:23)在Promise ._settlePromiseFromHandler(/srv/tests/node_modules/bluebird/js/release/promise.js:510:31)在Promise._settlePromise(/srv/tests/node_modules/bluebird/js/release/promise.js:567:18)在Promise._settlePromiseCtx(/srv/tests/node_modules/bluebird/js/release/promise.js:604:10)在Async._drainQueue(/srv/tests/node_modules/bluebird/js/release/async.js:143: 12)在Instant.Async.drainQueues(/ srv / tests / node_modules / bluebird / js / release / async。)在Async._drainQueues(/srv/tests/node_modules/bluebird/js/release/async.js:148:10)处。 js:17:14)在runCallback(timers.js:574:20)在tryOnImmediate(timers.js:554:5)在processImmediate [as _immediateCallback](timers.js:533:5)
Unhandled rejection TimeoutError: timeout during .waitFor() after 15038 ms at Timeout.waitForCheck (/srv/tests/node_modules/node-horseman/lib/actions.js:1643:13) at Timeout.wrapper (timers.js:425:11) at tryOnTimeout (timers.js:232:11) at Timer.listOnTimeout (timers.js:202:5) 未处理的拒绝TimeoutError:在Timeout.wrapper(timers.js:425 :)在Timeout.waitForCheck(/srv/tests/node_modules/node-horseman/lib/actions.js:1643:13)在15038 ms之后在.waitFor()期间超时11)在Timer.listOnTimeout(timers.js:202:5)的tryOnTimeout(timers.js:232:11)
2) should check last carousel element Unhandled rejection text evaluatePage
global code evaluateJavaScript@[native code] evaluate@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61 at /srv/tests/node_modules/node-horseman/lib/actions.js:989:36 at tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.fromNode.Promise.fromCallback (/srv/tests/node_modules/bluebird/js/release/promise.js:179:30) at Horseman. 全局代码评价JavaScript @ [本机代码]评价@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61位于/ srv / tests / node_modules / node-horseman / lib /在tryCatcher上的actions.js:989:36(/srv/tests/node_modules/bluebird/js/release/util.js:16:23)在Function.Promise.fromNode.Promise.fromCallback(/ srv / tests / node_modules / bluebird /js/release/promise.js:179:30)。 (/srv/tests/node_modules/node-horseman/lib/actions.js:987:29) at Horseman.tryCatcher (/srv/tests/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/srv/tests/node_modules/bluebird/js/release/promise.js:510:31) at Promise._settlePromise (/srv/tests/node_modules/bluebird/js/release/promise.js:567:18) at Promise._settlePromiseCtx (/srv/tests/node_modules/bluebird/js/release/promise.js:604:10) at Async._drainQueue (/srv/tests/node_modules/bluebird/js/release/async.js:143:12) at Async._drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:148:10) at Immediate.Async.drainQueues (/srv/tests/node_modules/bluebird/js/release/async.js:17:14) at runCallback (timers.js:574:20) at tryOnImmediate (timers.js:554:5) at processImmediate [as _immediateCallback] (timers.js:533:5) (/srv/tests/node_modules/node-horseman/lib/actions.js:987:29)在Horseman.tryCatcher(/srv/tests/node_modules/bluebird/js/release/util.js:16:23)在Promise ._settlePromiseFromHandler(/srv/tests/node_modules/bluebird/js/release/promise.js:510:31)在Promise._settlePromise(/srv/tests/node_modules/bluebird/js/release/promise.js:567:18)在Promise._settlePromiseCtx(/srv/tests/node_modules/bluebird/js/release/promise.js:604:10)在Async._drainQueue(/srv/tests/node_modules/bluebird/js/release/async.js:143: 12)在Instant.Async.drainQueues(/ srv / tests / node_modules / bluebird / js / release / async。)在Async._drainQueues(/srv/tests/node_modules/bluebird/js/release/async.js:148:10)处。 js:17:14)在runCallback(timers.js:574:20)在tryOnImmediate(timers.js:554:5)在processImmediate [as _immediateCallback](timers.js:533:5)
3) should navigate interactive in the main carousel
5 passing (30s) 3 failing 5通过(30s)3失败
1) test suite for xxx should validate carousel is loaded: Error: Timeout of 10000ms exceeded. 1) xxx的测试套件应验证是否已装入轮播:错误:超时超过10000ms。 For async tests and hooks, ensure "done()" is called; 对于异步测试和挂钩,请确保调用了“ done()”; if returning a Promise, ensure it resolves. 如果返回承诺,请确保其解决。
2) test suite for xxx should check last carousel element: Error: Timeout of 7000ms exceeded. 2) xxx的测试套件应检查最后一个轮播元素:错误:超时超过7000ms。 For async tests and hooks, ensure "done()" is called; 对于异步测试和挂钩,请确保调用了“ done()”; if returning a Promise, ensure it resolves. 如果返回承诺,请确保其解决。
3) test suite for xxx should navigate interactive in the main carousel: Error: Timeout of 10000ms exceeded. 3) xxx的测试套件应在主轮播中进行交互式导航:错误:超时超过10000ms。 For async tests and hooks, ensure "done()" is called; 对于异步测试和挂钩,请确保调用了“ done()”; if returning a Promise, ensure it resolves. 如果返回承诺,请确保其解决。
The falling part of the test is 测试的下降部分是
it('should validate carousel is loaded', function(done) {
this.timeout(10000);
horseman
.open(WEBAPP_URL)
.waitFor(function() {
return document.querySelector('#loadingPanel').style.visibility === 'hidden';
}, true)
.waitFor(function() {
return document.querySelectorAll('.videosCarouselItem').length === 4;
}, true)
.then(function(res) {
done();
});
});
I guess the problem is coming from phantom not able to interpret jquery and so can't find the selector but the problem appears only within a docker container. 我猜问题出在幻影无法解释jquery,因此找不到选择器,但问题仅出现在docker容器中。
Problem is the same using casperjs 问题是使用casperjs一样
I've dug a little more) The very part that 'timeout' within the docker container is 我挖了更多)Docker容器中的'timeout'是
.waitForSelector('.videosCarouselItem')
.count('.videosCarouselItem')
and give me the error 给我错误
Unhandled rejection TimeoutError: timeout during .waitFor() after 15059 ms
at Timeout.waitForCheck (/srv/tests/node_modules/node-horseman/lib/actions.js:1643:13)
at Timeout.wrapper (timers.js:425:11)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
Outside docker it's OK, I get a 4 (that's correct) 在docker外部,没关系,我得到4(是正确的)
Sorry for the inconvenience, issue was linked to our tested applciation, I had to change the URL by adding some queryparam. 抱歉给您带来不便,问题与我们测试过的应用程序有关,我不得不通过添加一些queryparam来更改URL。 I don't why it was working with a browser inside windows, or phantomjs directly on a VM but not inside a docker but now it's OK. 我不知道为什么它可以在Windows内部使用浏览器,或者直接在VM上使用phantomjs,但不能在docker内部使用,但是现在可以了。
I found the error using the snapshot feature. 我使用快照功能发现了错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.