Timeout issue with a dockerized phantomjs - node.js

I would like to do some test using nodejs and phantomjs inside a docker container.
All these tests work perfectly directly on a centos or debian server
npm run test
smart-tv-portal-tests#1.0.0 test /data/SmartTVPortal/tests
mocha test-*.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)
8 passing (1s)
but if I run the very same test within a docker container (based either on alpine/centos/ubuntu) it fails with timeout issue
docker run -ti --net=host --rm --volume /data/SmartTVPortal/:/srv --workdir /srv/tests arte/hbbtv bash
I get
bash-4.3# npm run test
smart-tv-portal-tests#1.0.0 test /srv/tests
mocha test-*.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
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. (/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)
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)
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. (/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)
3) should navigate interactive in the main carousel
5 passing (30s) 3 failing
1) test suite for
xxx
should validate carousel is loaded:
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
2) test suite for
xxx
should check last carousel element:
Error: Timeout of 7000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
3) test suite for
xxx
should navigate interactive in the main carousel:
Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; 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.
Problem is the same using casperjs
I've dug a little more)
The very part that 'timeout' within the docker container is
.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)

Sorry for the inconvenience, issue was linked to our tested applciation, I had to change the URL by adding some queryparam.
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.
I found the error using the snapshot feature.

Related

Nothing happens when I try to integrate Gitkraken with Gitlab

I am new to Gitkraken and want to integrate with Gitlab.
When I go to Preferences -> Integrations -> Gitlab and click the "Connect to Gitlab", nothing happens. I expected a browser window to open, prompting me for my Gitlab credentials.
Notes:
I have tried with Firefox and Google Chrome as my default browser
the Gitkraken error log is empty
the Gitkraken activity log contains:
Request OAuth token from GitLab: started.
Request OAuth token from GitLab: invalid token
Request OAuth token from GitLab: finished with errors.
Gitkraken outputs the following to stdout/stderr:
(node:70656) UnhandledPromiseRejectionWarning: Error: invalid token
at authenticateSaga (<embedded>:10:422633)
at authenticateSaga.next (<anonymous>)
at next (<embedded>:161:2671290)
at currCb (<embedded>:161:2671915)
at takeCb (<embedded>:161:2661241)
at Object.put (<embedded>:161:2659312)
at <embedded>:161:2675552
at WebSocket.connection.onmessage (<embedded>:10:421538)
at WebSocket.onMessage (/usr/share/gitkraken/resources/app.asar/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:310:20)
at WebSocket.EventEmitter.emit (domain.js:482:12)
at Receiver.receiverOnMessage (/usr/share/gitkraken/resources/app.asar/node_modules/ws/lib/websocket.js:834:20)
at Receiver.emit (events.js:310:20)
at Receiver.EventEmitter.emit (domain.js:482:12)
at Receiver.dataMessage (/usr/share/gitkraken/resources/app.asar/node_modules/ws/lib/receiver.js:437:14)
at Receiver.getData (/usr/share/gitkraken/resources/app.asar/node_modules/ws/lib/receiver.js:367:17)
(node:70656) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)
I am using Fedora 35 and have created a new SSH key in Gitkraken (but I assume it is not used until I have authenticated against Gitlab).
Am I doing something wrong?

Failed to launch the browser process [duplicate]

I have a puppeteer script I run to reboot my modem. It has worked for I guess about a year with no problem. 5 days ago it stopped working. I was looking into it and realized that I am getting errors I didn't used to get when running it and the script fails. The thing is I didn't change anything. As far as I can see, the HTML hasn't changed either yet it is failing. So I wonder if there is a bug in chromium or puppeteer or if it handles things differently somehow?
Here's a codepen with https://codepen.io/michaelbierman/pen/qQjdYR
HTML page
puppeteer script
errors
ERROR OUTPUT
Thursday 11/15/2018 11:14:04, Login...
Unhandled Rejection at: Promise (new page) Promise {
Error: No node found for selector: #id_username
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:771:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:971:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:49:13
at
at process._tickCallback (internal/process/next_tick.js:188:7) } reason: Error: No node found for selector: #id_username
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:771:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:971:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:49:13
at
at process._tickCallback (internal/process/next_tick.js:188:7)
/Users/bierman/Documents/Applications/bin/arris/arristest.js:29
browser.close();
^
ReferenceError: browser is not defined
at process.on (/Users/bierman/Documents/Applications/bin/arris/arristest.js:29:2)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
at process._tickCallback (internal/process/next_tick.js:189:7)
BigMac:bin michael$ /usr/local/bin/node /Users/bierman/Documents/Applications/bin/arris/arristest.js
Thursday 11/15/2018 11:20:29, Login...
Thursday 11/15/2018 11:20:36, Go to home...
Unhandled Rejection at: Promise (new page) Promise {
Error: No node found for selector: #alertExitButton
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:704:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:932:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:62:13
at
at process._tickCallback (internal/process/next_tick.js:188:7) } reason: Error: No node found for selector: #alertExitButton
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:704:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:932:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:62:13
at
at process._tickCallback (internal/process/next_tick.js:188:7)
/Users/bierman/Documents/Applications/bin/arris/arristest.js:29
browser.close();
^
ReferenceError: browser is not defined
at process.on (/Users/bierman/Documents/Applications/bin/arris/arristest.js:29:2)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
at process._tickCallback (internal/process/next_tick.js:189:7)
Try this:
npm uninstall chromium
npm uninstall puppeteer
npm i chromium#1
npm i puppeteer

Mocha-allure-reporter not working with node js

I am facing issue when I run my tests with mocha-allure-reporter ,the tests are running successfully with mocha ,but mocha --reporter mocha-allure-reporter returns the following error
> notifications-api#1.0.0 test /app
> mocha --reporter mocha-allure-reporter
2016-11-15T06:13:26.762Z - info: Notification API up and running on port 4000
2016-11-15T06:13:26.773Z - error: Tue, 15 Nov 2016 06:13:26 GMT uncaughtException
2016-11-15T06:13:26.775Z - error: TypeError: test.currentRetry is not a function
at Runner.<anonymous> (/app/node_modules/mocha-allure-reporter/index.js:29:19)
at emitOne (events.js:77:13)
at Runner.emit (events.js:169:7)
at next (/app/node_modules/mocha/lib/runner.js:517:10)
at Runner.runTests (/app/node_modules/mocha/lib/runner.js:556:3)
at /app/node_modules/mocha/lib/runner.js:637:10
at next (/app/node_modules/mocha/lib/runner.js:283:14)
at Immediate._onImmediate (/app/node_modules/mocha/lib/runner.js:319:5)
at processImmediate [as _immediateCallback] (timers.js:383:17)
npm ERR! Test failed. See above for more details.
Can anyone help to fix this issue?
The issues can be resolved by updating your mocha to the latest version probably to v3 or above and allure reporter too. If the issue still persists regarding TypeError: test.currentRetry is not a function , please replace the line of code
if (!test.currentRetry()) {
with the following
if (typeof test.currentRetry !== "function" || !test.currentRetry()) {

Selenium mocha Tests

I was trying to put an implicit wait in selenium java script with mocha but i see the following error:
ReferenceError: timeUnit is not defined
Below is the code snippet i used:
driver.manage().timeouts().implicitlyWait(20, timeUnit.SECONDS);
and the stack trace I see is:
at Context.<anonymous> (C:\node_modules\Script\login_scenario.js:32:50)
at C:\node_modules\Script\node_modules\selenium-webdriver\testing\index.js:142:19
at new promise.Promise (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:355:5)
at controlFlowExecute (C:\node_modules\Script\node_modules\selenium-webdriver\testing\index.js:127:14)
at promise.ControlFlow.runInFrame_ (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20)
at promise.ControlFlow.runEventLoop_ (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:1755:8
at null.<anonymous> (C:\node_modules\Script\node_modules\selenium-webdriver\lib\webdriver\promise.js:2056:12)
at goog.async.run.processWorkQueue (C:\node_modules\Script\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
: Task: Automation of Shop Management Login scenario
at Context.ret (C:\node_modules\Script\node_modules\selenium-webdriver\testing\index.js:126:10)
at Test.Runnable.run (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:233:15)
at Runner.runTest (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:387:10)
at C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:470:12
at next (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:312:14)
at C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:322:7
at next (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:257:23)
at Immediate._onImmediate (C:\Users\kashyap\AppData\Roaming\npm\node_modules\mocha\lib\runner.js:289:5)
at processImmediate [as _immediateCallback] (timers.js:358:17)
implicitlyWait() in javascript selenium bindings accepts a single argument - a timeout in milliseconds:
driver.manage().timeouts().implicitlyWait(20000);
You are probably mixing it up with implicitlyWait() method from java selenium bindings, which allows you to specify the timeout unit alongside with the timeout itself.

Unable to get strong-remote example to work

I'm trying the example: https://github.com/strongloop/strong-remoting/blob/master/example/simple.js
When I invoke the curl, I get: curl: (52) Empty reply from server
and the node program exits with:
sm#valley:~/Documents/Projects/test/loopback.io/remoting$ node simple.js
/home/sm/Documents/Projects/test/loopback.io/node_modules/strong-remoting/node_modules/express/lib/router/index.js:603
return fn.apply(this, arguments);
^
TypeError: Cannot call method 'apply' of undefined
at Object. (/home/sm/Documents/Projects/test/loopback.io/node_modules/strong-remoting/node_modules/express/lib/router/index.js:603:15)
at Object.immediate._onImmediate (timers.js:348:16)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Any idea what I'm missing ?
You may want to also look at https://github.com/strongloop/loopback-example-remote. It's an example of the LB remote connector, which uses strong-remoting. Not sure if it fits your use case, but AFAIK it works.

Resources