codeforequity-at / botium-bindings

The Selenium for Chatbots
http://www.botium.at
MIT License
108 stars 33 forks source link

Upgrade to 1.0.0 #39

Closed Naktibalda closed 6 years ago

Naktibalda commented 6 years ago

I have tried to upgrade my botkit project to use testmybot 1.0.0 But whenever I run tests they fail with timeout:

INFO: Ask FAQ question failed: Error: Queue.pop timeout after undefined
    at QueueTimeoutError (...\node_modules\botium-core\src\helpers\QueueTimeoutError.js:3:5)
    at timeoutRequest (...\node_modules\botium-core\src\helpers\Queue.js:46:18)
    at Timeout.timeoutCallback [as _onTimeout] (...\node_modules\async\dist\async.js:4922:13)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

Do I need to modify my testmybot.json file? It still contains

{
  "containermode": "local"
}

just like https://github.com/codeforequity-at/testmybot/blob/master/samples/botkit/jasmine/testmybot.json

My testmybot.spec.js contains this code:

var env = require('node-env-file');
env(__dirname + '/../.env');

const testmybot = require('testmybot');
const mochaHelper = testmybot.helper.mocha();
const botkitHelper = testmybot.helper.botkit();

const Botkit = require('botkit');
const bot = require('../build/bot').default;

const controller = Botkit.facebookbot({access_token: 'test', verify_token: 'test'});
bot(controller);

botkitHelper.wireWithBotkit(function() {
    controller.memory_store.users = {};
    return controller;
});

mochaHelper.setupMochaTestSuite(60000);

It worked before, the diff is:

-const botkitHelper = require('testmybot/helper/botkit');
-const mochaHelper = require('testmybot/helper/mocha');
+const testmybot = require('testmybot');
+const mochaHelper = testmybot.helper.mocha();
+const botkitHelper = testmybot.helper.botkit();
codeforequity-at commented 6 years ago

The contents of the testmybot.json file is ignored in this case, so this is not the problem.

What happens when you enable logging ("export DEBUG=*") before running it ?

Naktibalda commented 6 years ago

It looks like a very short timeout: (I removed some sensitive parts of output)

2018-01-03T15:06:21.404Z mocha:runnable timeout 60000
tmb.beforeEach
INFO: running testcase Ask FAQ question
DEBUG: Ask FAQ question: user says Where do you ship to?
2018-01-03T15:06:21.418Z watson-middleware:index Creating Conversation object with parameters: {
...
2018-01-03T15:06:21.419Z watson-middleware:utils User: me, Context: null
DEBUG: Ask FAQ question: wait for bot says (channel: null)
2018-01-03T15:06:21.422Z watson-middleware:utils Conversation Request: {
...
}
INFO: Ask FAQ question failed: Error: Queue.pop timeout after undefined
    at QueueTimeoutError (...\node_modules\botium-core\src\helpers\QueueTimeoutError.js:3:5)
    at timeoutRequest (...\node_modules\botium-core\src\helpers\Queue.js:46:18)
    at Timeout.timeoutCallback [as _onTimeout] (...\node_modules\async\dist\async.js:4922:13)
    at ontimeout (timers.js:386:14)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)
    1) Ask FAQ question
2018-01-03T15:06:21.430Z mocha:runnable timeout 60000

So it looks like timeout happens in less than 0.11s

codeforequity-at commented 6 years ago

thanks for the analysis, there is definitly something wrong with the timouts. I won't merge your commit now as I want to do some more analysis and solve this another way - there should be meaningful default timeout values in place.

codeforequity-at commented 6 years ago

by the way, I noticed that you are using IBM watson - there is a sample on how to connect to the watson conversation service with testmybot.

Naktibalda commented 6 years ago

I've seen watson in your pull request, but for me it is important to test botkit part too.

Would it be possible to make timeout configurable?

codeforequity-at commented 6 years ago

yes, will be configurable with a meaningful default ("undefined" is not meaningful ...)

codeforequity-at commented 6 years ago

The "wireWithBotkit" helper now has a second argument, the timeout to use (default: 5 seconds).

Naktibalda commented 6 years ago

Thanks, it works now.

Naktibalda commented 6 years ago

second argument of wireWithBotkit works too.