Closed sgolodychenko closed 5 years ago
I think you are doing nothing wrong. I am surprised that the code you mentioned is reached, because obviously the capability "SIMPLEREST_CONTEXT_JSONPATH" is empty ? But the root of the problem seems to be, that the response from your HTTP service is not handled as JSON content by Botium - is it possible that the service is not returning a proper content type header ? Usually, the JSON parsing is done automatically.
"SIMPLEREST_CONTEXT_JSONPATH": "$.context" ..during debug steps has removed line :) Response from API is:
OK, everything looks correct, so most likely a bug in Botium. Can you run in debug mode ("export DEBUG=botium*") and attach the log output here (remove secrets please), I will try to find a generic solution (or just pull in your code changes from above).
Where i have to put debug settings? Using to run:
botium-cli run tap -C tests/test --config botium.rest.json
just use "--verbose" command line switch
`2018-12-19T09:16:10.225Z botium-cli Using Botium configuration file botium.rest.json 2018-12-19T09:16:10.228Z botium-cli-run command options: { _: [ 'run' ], help: false, h: false, version: false, V: false, C: [ 'tests/test' ], convos: [ 'tests/test' ], config: 'botium.rest.json', c: 'botium.rest.json', verbose: true, v: true, output: 'tap', testsuitename: 'Botium Test-Suite', n: 'Botium Test-Suite', expandutterances: false, timeout: 60, '$0': 'C:\Users\\AppData\Roaming\npm\node_modules\botium-cli\bin\botium-cli.js', filter: undefined, 'reporter-options': undefined } 2018-12-19T09:16:10.228Z botium-cli-run Mocha Reporter "tap", options: undefined 2018-12-19T09:16:10.229Z botium-BotDriver Loaded Botium configuration file ./botium.json 2018-12-19T09:16:10.229Z botium-BotDriver Loaded Botium configuration file botium.rest.json 2018-12-19T09:16:10.229Z botium-BotDriver Changed capability : CONFIG to : botium.rest.json using environment variables. 2018-12-19T09:16:10.229Z botium-BotDriver BuildCompiler: Capabilites: { PROJECTNAME: 'Chatbot', TEMPDIR: 'botiumwork', CLEANUPTEMPDIR: true, WAITFORBOTTIMEOUT: 10000, SIMULATE_WRITING_SPEED: false, DOCKERCOMPOSEPATH: 'docker-compose', DOCKERMACHINEPATH: 'docker-machine', DOCKERMACHINE: false, DOCKERIMAGE: 'node:boron', DOCKERUNIQUECONTAINERNAMES: false, DOCKERSYSLOGPORT_RANGE: '47100-47299', BOT_HEALTH_STATUS: 200, SLACK_PUBLISHPORT_RANGE: '46100-46299', FACEBOOK_PUBLISHPORT_RANGE: '46300-46499', FACEBOOK_SEND_DELIVERY_CONFIRMATION: true, BOTFRAMEWORK_PUBLISHPORT_RANGE: '46500-46699', BOTFRAMEWORK_WEBHOOK_PORT: 3978, BOTFRAMEWORK_WEBHOOK_PATH: 'api/messages', BOTFRAMEWORK_CHANNEL_ID: 'facebook', SIMPLEREST_METHOD: 'POST', WEBSPEECH_SERVER_PORT: 46050, WEBSPEECH_LANGUAGE: 'en-US', WEBSPEECH_CLOSEBROWSER: true, SCRIPTING_TXT_EOL: '\n', SCRIPTING_XLSX_STARTROW: 2, SCRIPTING_XLSX_STARTCOL: 1, SCRIPTING_NORMALIZE_TEXT: true, SCRIPTING_ENABLE_MEMORY: true, SCRIPTING_MATCHING_MODE: 'includeLowerCase', SCRIPTING_UTTEXPANSION_MODE: 'all', SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 1, SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION', ASSERTERS: [], CONTAINERMODE: 'simplerest', WATSON_USER: '', WATSON_PASSWORD: '', WATSON_WORKSPACE_ID: '', WATSON_USE_INTENT: true, SCRIPTING_FORMAT: 'xlsx', SCRIPTING_XLSX_SHEETNAMES: 'general_flow', SIMPLEREST_INIT_TEXT: 'hi', SIMPLEREST_URL: 'http://localhost:58812/api/ChatbotApi/Ask', SIMPLEREST_HEADERS_TEMPLATE: '{ "Content-Type": "application/json", "Referer": "http://localhost:58812/en" }', SIMPLEREST_RESPONSE_JSONPATH: '$.answer.0', SIMPLEREST_CONTEXT_JSONPATH: '$.context', SIMPLEREST_BODY_TEMPLATE: '{ "context": { {{#context.conversation_id}} "conversation_id": "{{context.conversation_id}}", {{/ context.conversation_id}} "system": { "initialized": "{{context.system.initialized}}", "dialog_stack": [ {{#context.system.dialog_stack}} { {{#dialog_node}} "dialog_node": "{{.}}" {{/dialog_node}} {{#state}}, "state": "{{.}}" {{/state}} } {{/context.system.dialog_stack}} ], "dialog_request_counter": "{{context.system.dialog_request_counter}}", "dialog_turn_counter" : "{{context.system.dialog_turn_counter}}" },"counter_repeats": "{{context.counter_repeats}}", "counter_repeats_max": "{{context.counter_repeats_max}}" {{#context.product}}, "product": "{{context.product}}"{{/ context.product}} {{# context.product_type}}, "product_type": "{{context.product_type}}" {{/ context.product_type}} {{#context.code}}, "code": "{{context.code}}" {{/ context.code}}, "next_dialog": "{{context.next_dialog}}" }, "question":"{{msg.messageText}}" }', SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'DATA', CONFIG: 'botium.rest.json' } 2018-12-19T09:16:10.416Z botium-ScriptingProvider Using matching mode: includeLowerCase 2018-12-19T09:16:10.417Z botium-asserterUtils Loaded Default asserter - { BUTTONS: ButtonsAsserter { context: { AddConvos: [Function: bound AddConvos], AddUtterances: [Function: bound AddUtterances], Match: [Function: bound Match], IsAsserterValid: [Function: bound IsAsserterValid], scriptingEvents: [Object] }, caps: { PROJECTNAME: 'Chatbot', TEMPDIR: 'botiumwork', CLEANUPTEMPDIR: true, WAITFORBOTTIMEOUT: 10000, SIMULATE_WRITING_SPEED: false, DOCKERCOMPOSEPATH: 'docker-compose', DOCKERMACHINEPATH: 'docker-machine', DOCKERMACHINE: false, DOCKERIMAGE: 'node:boron', DOCKERUNIQUECONTAINERNAMES: false, DOCKERSYSLOGPORT_RANGE: '47100-47299', BOT_HEALTH_STATUS: 200, SLACK_PUBLISHPORT_RANGE: '46100-46299', FACEBOOK_PUBLISHPORT_RANGE: '46300-46499', FACEBOOK_SEND_DELIVERY_CONFIRMATION: true, BOTFRAMEWORK_PUBLISHPORT_RANGE: '46500-46699', BOTFRAMEWORK_WEBHOOK_PORT: 3978, BOTFRAMEWORK_WEBHOOK_PATH: 'api/messages', BOTFRAMEWORK_CHANNEL_ID: 'facebook', SIMPLEREST_METHOD: 'POST', WEBSPEECH_SERVER_PORT: 46050, WEBSPEECH_LANGUAGE: 'en-US', WEBSPEECH_CLOSEBROWSER: true, SCRIPTING_TXT_EOL: '\n', SCRIPTING_XLSX_STARTROW: 2, SCRIPTING_XLSX_STARTCOL: 1, SCRIPTING_NORMALIZE_TEXT: true, SCRIPTING_ENABLE_MEMORY: true, SCRIPTING_MATCHING_MODE: 'includeLowerCase', SCRIPTING_UTTEXPANSION_MODE: 'all', SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 1, SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION', ASSERTERS: [], CONTAINERMODE: 'simplerest', WATSON_USER: '', WATSON_PASSWORD: '', WATSON_WORKSPACE_ID: '', WATSON_USE_INTENT: true, SCRIPTING_FORMAT: 'xlsx', SCRIPTING_XLSX_SHEETNAMES: 'general_flow', SIMPLEREST_INIT_TEXT: 'hi', SIMPLEREST_URL: 'http://localhost:58812/api/ChatbotApi/Ask', SIMPLEREST_HEADERS_TEMPLATE: '{ "Content-Type": "application/json", "Referer": "http://localhost:58812/en" }', SIMPLEREST_RESPONSE_JSONPATH: '$.answer.0', SIMPLEREST_CONTEXT_JSONPATH: '$.context', SIMPLEREST_BODY_TEMPLATE: '{ "context": { {{#context.conversation_id}} "conversation_id": "{{context.conversation_id}}", {{/ context.conversation_id}} "system": { "initialized": "{{context.system.initialized}}", "dialog_stack": [ {{#context.system.dialog_stack}} { {{#dialog_node}} "dialog_node": "{{.}}" {{/dialog_node}} {{#state}}, "state": "{{.}}" {{/state}} } {{/context.system.dialog_stack}} ], "dialog_request_counter": "{{context.system.dialog_request_counter}}", "dialog_turn_counter" : "{{context.system.dialog_turn_counter}}" },"counter_repeats": "{{context.counter_repeats}}", "counter_repeats_max": "{{context.counter_repeats_max}}" {{#context.product}}, "product": "{{context.product}}"{{/ context.product}} {{# context.product_type}}, "product_type": "{{context.product_type}}" {{/ context.product_type}} {{#context.code}}, "code": "{{context.code}}" {{/ context.code}}, "next_dialog": "{{context.next_dialog}}" }, "question":"{{msg.messageText}}" }', SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'DATA', CONFIG: 'botium.rest.json' } }, MEDIA: MediaAsserter { context: { AddConvos: [Function: bound AddConvos], AddUtterances: [Function: bound AddUtterances], Match: [Function: bound Match], IsAsserterValid: [Function: bound IsAsserterValid], scriptingEvents: [Object] }, caps: { PROJECTNAME: 'Chatbot', TEMPDIR: 'botiumwork', CLEANUPTEMPDIR: true, WAITFORBOTTIMEOUT: 10000, SIMULATE_WRITING_SPEED: false, DOCKERCOMPOSEPATH: 'docker-compose', DOCKERMACHINEPATH: 'docker-machine', DOCKERMACHINE: false, DOCKERIMAGE: 'node:boron', DOCKERUNIQUECONTAINERNAMES: false, DOCKERSYSLOGPORT_RANGE: '47100-47299', BOT_HEALTH_STATUS: 200, SLACK_PUBLISHPORT_RANGE: '46100-46299', FACEBOOK_PUBLISHPORT_RANGE: '46300-46499', FACEBOOK_SEND_DELIVERY_CONFIRMATION: true, BOTFRAMEWORK_PUBLISHPORT_RANGE: '46500-46699', BOTFRAMEWORK_WEBHOOK_PORT: 3978, BOTFRAMEWORK_WEBHOOK_PATH: 'api/messages', BOTFRAMEWORK_CHANNEL_ID: 'facebook', SIMPLEREST_METHOD: 'POST', WEBSPEECH_SERVER_PORT: 46050, WEBSPEECH_LANGUAGE: 'en-US', WEBSPEECH_CLOSEBROWSER: true, SCRIPTING_TXT_EOL: '\n', SCRIPTING_XLSX_STARTROW: 2, SCRIPTING_XLSX_STARTCOL: 1, SCRIPTING_NORMALIZE_TEXT: true, SCRIPTING_ENABLE_MEMORY: true, SCRIPTING_MATCHING_MODE: 'includeLowerCase', SCRIPTING_UTTEXPANSION_MODE: 'all', SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 1, SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION', ASSERTERS: [], CONTAINERMODE: 'simplerest', WATSON_USER: '', WATSON_PASSWORD: '', WATSON_WORKSPACE_ID: '', WATSON_USE_INTENT: true, SCRIPTING_FORMAT: 'xlsx', SCRIPTING_XLSX_SHEETNAMES: 'general_flow', SIMPLEREST_INIT_TEXT: 'hi', SIMPLEREST_URL: 'http://localhost:58812/api/ChatbotApi/Ask', SIMPLEREST_HEADERS_TEMPLATE: '{ "Content-Type": "application/json", "Referer": "http://localhost:58812/en" }', SIMPLEREST_RESPONSE_JSONPATH: '$.answer.0', SIMPLEREST_CONTEXT_JSONPATH: '$.context', SIMPLEREST_BODY_TEMPLATE: '{ "context": { {{#context.conversation_id}} "conversation_id": "{{context.conversation_id}}", {{/ context.conversation_id}} "system": { "initialized": "{{context.system.initialized}}", "dialog_stack": [ {{#context.system.dialog_stack}} { {{#dialog_node}} "dialog_node": "{{.}}" {{/dialog_node}} {{#state}}, "state": "{{.}}" {{/state}} } {{/context.system.dialog_stack}} ], "dialog_request_counter": "{{context.system.dialog_request_counter}}", "dialog_turn_counter" : "{{context.system.dialog_turn_counter}}" },"counter_repeats": "{{context.counter_repeats}}", "counter_repeats_max": "{{context.counter_repeats_max}}" {{#context.product}}, "product": "{{context.product}}"{{/ context.product}} {{# context.product_type}}, "product_type": "{{context.product_type}}" {{/ context.product_type}} {{#context.code}}, "code": "{{context.code}}" {{/ context.code}}, "next_dialog": "{{context.next_dialog}}" }, "question":"{{msg.messageText}}" }', SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'DATA', CONFIG: 'botium.rest.json' } } } 2018-12-19T09:16:10.422Z botium-ScriptingProvider ReadConvosFromDirectory(tests/test) found filenames: ~$hotline.xlsx,hotline.xlsx 2018-12-19T09:16:10.423Z botium-CompilerXlsx sheet names for SCRIPTING_TYPE_UTTERANCES: [ 'DATA' ] 2018-12-19T09:16:10.424Z botium-CompilerXlsx sheet names for SCRIPTING_TYPE_CONVO: [ 'general_flow' ] 2018-12-19T09:16:10.450Z botium-CompilerXlsx sheet names for SCRIPTING_TYPE_UTTERANCES: [ 'DATA' ] 2018-12-19T09:16:10.450Z botium-CompilerXlsx evaluating sheet name for SCRIPTING_TYPE_UTTERANCES: 'DATA', rowindex 2, colindex 0 2018-12-19T09:16:10.460Z botium-CompilerXlsx sheet names for SCRIPTING_TYPE_CONVO: [ 'general_flow' ] 2018-12-19T09:16:10.460Z botium-CompilerXlsx evaluating sheet name for SCRIPTING_TYPE_CONVO: 'general_flow', rowindex 2, colindex 0 2018-12-19T09:16:10.462Z botium-ScriptingProvider ReadConvosFromDirectory(tests/test) found convos: 1 general_flow-B2 ({ filename: 'hotline.xlsx' }): Cell B2: #bot - User | Cell B3: #bot - hi 2018-12-19T09:16:10.462Z botium-ScriptingProvider ReadConvosFromDirectory(tests/test) found utterances:
2018-12-19T09:16:10.462Z botium-cli-run ready reading convos (1), expanding convos ... 2018-12-19T09:16:10.462Z botium-ScriptingProvider ExpandConvos - Using utterances expansion mode: all 2018-12-19T09:16:10.462Z botium-cli-run ready expanding convos and utterances, number of test cases: (1). 2018-12-19T09:16:10.463Z botium-cli-run adding test case general_flow-B2 (from: { filename: 'hotline.xlsx' }) 2018-12-19T09:16:10.467Z botium-BotDriver Build - Capabilites: { PROJECTNAME: 'Chatbot', TEMPDIR: 'botiumwork', CLEANUPTEMPDIR: true, WAITFORBOTTIMEOUT: 10000, SIMULATE_WRITING_SPEED: false, DOCKERCOMPOSEPATH: 'docker-compose', DOCKERMACHINEPATH: 'docker-machine', DOCKERMACHINE: false, DOCKERIMAGE: 'node:boron', DOCKERUNIQUECONTAINERNAMES: false, DOCKERSYSLOGPORT_RANGE: '47100-47299', BOT_HEALTH_STATUS: 200, SLACK_PUBLISHPORT_RANGE: '46100-46299', FACEBOOK_PUBLISHPORT_RANGE: '46300-46499', FACEBOOK_SEND_DELIVERY_CONFIRMATION: true, BOTFRAMEWORK_PUBLISHPORT_RANGE: '46500-46699', BOTFRAMEWORK_WEBHOOK_PORT: 3978, BOTFRAMEWORK_WEBHOOK_PATH: 'api/messages', BOTFRAMEWORK_CHANNEL_ID: 'facebook', SIMPLEREST_METHOD: 'POST', WEBSPEECH_SERVER_PORT: 46050, WEBSPEECH_LANGUAGE: 'en-US', WEBSPEECH_CLOSEBROWSER: true, SCRIPTING_TXT_EOL: '\n', SCRIPTING_XLSX_STARTROW: 2, SCRIPTING_XLSX_STARTCOL: 1, SCRIPTING_NORMALIZE_TEXT: true, SCRIPTING_ENABLE_MEMORY: true, SCRIPTING_MATCHING_MODE: 'includeLowerCase', SCRIPTING_UTTEXPANSION_MODE: 'all', SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 1, SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION', ASSERTERS: [], CONTAINERMODE: 'simplerest', WATSON_USER: '', WATSON_PASSWORD: '', WATSON_WORKSPACE_ID: '', WATSON_USE_INTENT: true, SCRIPTING_FORMAT: 'xlsx', SCRIPTING_XLSX_SHEETNAMES: 'general_flow', SIMPLEREST_INIT_TEXT: 'hi', SIMPLEREST_URL: 'http://localhost:58812/api/ChatbotApi/Ask', SIMPLEREST_HEADERS_TEMPLATE: '{ "Content-Type": "application/json", "Referer": "http://localhost:58812/en" }', SIMPLEREST_RESPONSE_JSONPATH: '$.answer.0', SIMPLEREST_CONTEXT_JSONPATH: '$.context', SIMPLEREST_BODY_TEMPLATE: '{ "context": { {{#context.conversation_id}} "conversation_id": "{{context.conversation_id}}", {{/ context.conversation_id}} "system": { "initialized": "{{context.system.initialized}}", "dialog_stack": [ {{#context.system.dialog_stack}} { {{#dialog_node}} "dialog_node": "{{.}}" {{/dialog_node}} {{#state}}, "state": "{{.}}" {{/state}} } {{/context.system.dialog_stack}} ], "dialog_request_counter": "{{context.system.dialog_request_counter}}", "dialog_turn_counter" : "{{context.system.dialog_turn_counter}}" },"counter_repeats": "{{context.counter_repeats}}", "counter_repeats_max": "{{context.counter_repeats_max}}" {{#context.product}}, "product": "{{context.product}}"{{/ context.product}} {{# context.product_type}}, "product_type": "{{context.product_type}}" {{/ context.product_type}} {{#context.code}}, "code": "{{context.code}}" {{/ context.code}}, "next_dialog": "{{context.next_dialog}}" }, "question":"{{msg.messageText}}" }', SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'DATA', CONFIG: 'botium.rest.json' } 2018-12-19T09:16:10.467Z botium-BotDriver Build - Sources : { LOCALPATH: '.', GITPATH: 'git', GITBRANCH: 'master', GITDIR: '.' } 2018-12-19T09:16:10.467Z botium-BotDriver Build - Envs : { IS_BOTIUM_CONTAINER: true } 2018-12-19T09:16:10.507Z botium-SimpleRestContainer constructed requestOptions { "uri": "http://localhost:58812/api/ChatbotApi/Ask", "method": "POST", "json": true, "headers": { "Content-Type": "application/json", "Referer": "http://localhost:58812/en" }, "body": { "context": { "system": { "initialized": "", "dialog_stack": [], "dialog_request_counter": "", "dialog_turn_counter": "" }, "counter_repeats": "", "counter_repeats_max": "", "next_dialog": "" }, "question": "hi" } }
1..1
not ok 1 Botium Test-Suite "before each" hook
AssertionError [ERR_ASSERTION]: obj needs to be an object
at JSONPath.query (C:\Users\AppData\Roaming\npm\node_modules\botium-cli\node_modules\jsonpath\lib\index.js:91:10)
at Request.request [as _callback] (C:\Users\AppData\Roaming\npm\node_modules\botium-cli\node_modules\botium-core\src\containers\SimpleRestContainer.js:187:38)
at Request.self.callback (C:\Users\AppData\Roaming\npm\node_modules\botium-cli\node_modules\request\request.js:185:22)
at Request.
2018-12-19T09:16:11.172Z botium-BaseContainer Cleanup rimrafing temp dir D:\botiumwork\Chatbot-20181219-111610-UxAbp `
one more question - what version are you using ? (botium-cli --version)
nevermind, please take the latest botium-cli version, this should be fixed now.
Any Update here ?
Hello, tried changes from
"botium-cli": "0.0.40",
"botium-core": "^1.4.2"
and received "TranscriptError: Error: general_flow-A7/Cell B8: bot says nothing"
But once replaced line in SimpleRestContainer.json (line 165)
var body_parse = JSON.stringify(eval("(" + body + ")"))
body = JSON.parse(body_parse)
than works fine :)
@codeforequity-at , sorry for delayed response, does fix from previous message make sense? Could it be fixed in scope of this issue, or should I create new one? Thank you for your time.
We recently applied a fix to botium-core which will make your code changes obsolete (in fact, it solved the same problem as your code, just without using the evil "eval" call.
how can i track applied fix? how to know proper version? Thank you.
The fix is here: https://github.com/codeforequity-at/botium-core/blob/e222457a2f6681a013e7052717f26a26c09de242/src/containers/SimpleRestContainer.js#L163
check in your locale node_modules/botium-core - or remove the whole directory (and package-lock.json) and install again.
verified with version 1.4.3, still reproducible. for some reason context is not properly parsed and putted to next request. With fix, mentioned upper (just replaced line 165 with provided two lines) - works fine.
Hello, tried changes from
"botium-cli": "0.0.40",
"botium-core": "^1.4.2"
and received "TranscriptError: Error: general_flow-A7/Cell B8: bot says nothing"
But once replaced line in SimpleRestContainer.json (line 165)
var body_parse = JSON.stringify(eval("(" + body + ")"))
body = JSON.parse(body_parse)
than works fine :)
I cannot add the code you posted to Botium, because it is a huge huge huge security leak - it would basically allow your chatbot server to execute any Javascript code on your test automation server, and I am pretty sure you don't want that ... Can you please post the verbose output here - there should be a statement "got response body" somewhere, and this is where things start to get interesting - because it should actually fail with a very explicit error message if anything goes wrong here ("No valid JSON response", "Body not an object", ...).
Please find attached last verbose log output.log
I hope it will be helpful Thanks
Thanks it is somehow helpful. There is nothing wrong with your configuration, the JSON content and the JSON path settings are correct, I validated everything in detail. This means that I currently now idea why in your environment the context is not correctly evaluated.
What I can offer: if you could publish your localhost chatbot with ngrok and send me over the endpoint, I can use a debugger to reproduce and debug it.
We are trying to test with botium our custom API to Watson chatbot. For this we have used SIMPLEREST container mode. botium.json ` "botium": { "Capabilities": { "PROJECTNAME": "Chatbot", "CONTAINERMODE": "simplerest",
}` Receiving an error:
As a solution we add code to SimpleRestContainer.js Instead of code begin from line # 165
We began to use :
With this fix testing works for us.
Is this is an issue? or Should we use Simplerest in other way? How we could handle serialization of body?