Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abao Tests Not Running #242

Open
NikhilPunwaney opened this issue May 22, 2018 · 28 comments
Open

Abao Tests Not Running #242

NikhilPunwaney opened this issue May 22, 2018 · 28 comments

Comments

@NikhilPunwaney
Copy link

My Abao tests are not running: upon running the test, I get the message: Found Hookfiles: tests/raml/test_machines_hooks.js

But none of the tests run as they did before.

Nothing has changed about the hookfiles or the RAML. Please advise what could have caused this issue

@plroebuck
Copy link
Collaborator

plroebuck commented May 23, 2018

Didn't provide enough information for me to help.

  1. Which version of Abao? (current release: v0.5.3)
  2. Node version?
  3. Platform?
  4. OS Version?
  5. API endpoint running? Verified URL using browser or curl?
  6. "None of the tests run as before" -- what does that mean? No tests run? All run but fail?
  7. What did you expect to happen?
  8. What actually did?

Not there with you. Screenshots always nice.

@jtodo
Copy link

jtodo commented May 24, 2018

I have a similar problem.

My environment is version v0.5.3, but the npm test fails.
It fails if version of underscore.js is 1.9.0, it does not seem to have failed in 1.8.3.

I’ll keep you posted.

@NikhilPunwaney
Copy link
Author

The Abao version is 0.5.0
The Node version is v9.4.0
Platform is
OS Version 10.12.6
API endpoint is running - verified using Postman

In the past, when I ran my command abao ../raml/api.raml --hookfiles=tests/raml/test_machines_hooks.js --server http://localhost:5000

Found Hookfiles: tests/raml/test_machines_hooks.js
GET /batches -> 200
✓ Validate response code and body
.
.

However now I get:

Found Hookfiles: tests/raml/test_machines_hooks.js

  1. "before all" hook
  2. "after all" hook

0 passing (6ms)
2 failing

  1. "before all" hook:
    TypeError: callback is not a function
    at /usr/local/lib/node_modules/abao/lib/hooks.coffee:76:16
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3888:9
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:473:16
    at replenish (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1006:25)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1016:9
    at eachOfLimit (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1041:24)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1046:16
    at parallel (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3879:5)
    at Object.series (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:4735:5)
    at Hooks.runBeforeAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:75:20)
    at Hooks.runBeforeAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:3:59)
    at Object.mocha.suite.beforeAll.
    .bind.hooks (/usr/local/lib/node_modules/abao/lib/test-runner.coffee:103:31)
    at executeBound (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:758:67)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:771:14)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:122:29)

  2. "after all" hook:
    TypeError: callback is not a function
    at /usr/local/lib/node_modules/abao/lib/hooks.coffee:82:16
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3888:9
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:473:16
    at replenish (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1006:25)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1016:9
    at eachOfLimit (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1041:24)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1046:16
    at parallel (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3879:5)
    at Object.series (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:4735:5)
    at Hooks.runAfterAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:81:20)
    at Hooks.runAfterAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:3:59)
    at Object.mocha.suite.afterAll.
    .bind.hooks (/usr/local/lib/node_modules/abao/lib/test-runner.coffee:108:31)
    at executeBound (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:758:67)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:771:14)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:122:29)

In another branch, I only get Found Hookfiles: tests/raml/test_machines_hooks.js but am not sure what may cause the rest to stop.

I would like to run it as it was before. Right now it either doesn't run at all or throws the error as above.

@plroebuck
Copy link
Collaborator

plroebuck commented May 25, 2018

@jtodo, you have the exact same error, or something else?

@NikhilPunwaney, BTW, shouldn't your hookfile be named "test_batches_hooks.js" (format: "test_<endpoint>_hooks.js")

Can either of you provide me with a copy of something I can test locally?
Would need hookfile, RAML, and copy of your endpoint code (abridged version would be fine).

@raj-bhagya
Copy link

raj-bhagya commented May 28, 2018

Hi @plroebuck
Here I attached the information you asked, sharing on behalf of @NikhilPunwaney . Please let me know if you need more details.
hook_endpoint_to_test.zip

@raj-bhagya
Copy link

raj-bhagya commented Jun 1, 2018

@plroebuck ,

Are you able to reproduce the issue? following details may help to reproduce the issue:
The Abao version is 0.5.0
The Node version is v9.4.0
Platform is OS Version 10.12.6
API endpoint is running - verified using Postman
Steps to run tests:

  1. Copy attached files into a folder
  2. Run following command in directory:
    abao api.raml --hookfiles=test_machines_hooks.js --server http://google.com
    hook_endpoint_to_test (1).zip

Console output:
[~/Downloads/hook_endpoint_to_test]$ abao api.raml --hookfiles=test_machines_hooks.js --server http://google.com
Found Hookfiles: test_machines_hooks.js

  1. "before all" hook
  2. "after all" hook

0 passing (10ms)
2 failing

  1. "before all" hook:
    TypeError: callback is not a function
    at /usr/local/lib/node_modules/abao/lib/hooks.coffee:76:16
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3888:9
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:473:16
    at replenish (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1006:25)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1016:9
    at eachOfLimit (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1041:24)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1046:16
    at parallel (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3879:5)
    at Object.series (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:4735:5)
    at Hooks.runBeforeAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:75:20)
    at Hooks.runBeforeAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:3:59)
    at Object.mocha.suite.beforeAll.
    .bind.hooks (/usr/local/lib/node_modules/abao/lib/test-runner.coffee:103:31)
    at executeBound (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:758:67)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:771:14)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:122:29)

  2. "after all" hook:
    TypeError: callback is not a function
    at /usr/local/lib/node_modules/abao/lib/hooks.coffee:82:16
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3888:9
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:473:16
    at replenish (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1006:25)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1016:9
    at eachOfLimit (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1041:24)
    at /usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:1046:16
    at parallel (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:3879:5)
    at Object.series (/usr/local/lib/node_modules/abao/node_modules/async/dist/async.js:4735:5)
    at Hooks.runAfterAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:81:20)
    at Hooks.runAfterAll (/usr/local/lib/node_modules/abao/lib/hooks.coffee:3:59)
    at Object.mocha.suite.afterAll.
    .bind.hooks (/usr/local/lib/node_modules/abao/lib/test-runner.coffee:108:31)
    at executeBound (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:758:67)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:771:14)
    at Context. (/usr/local/lib/node_modules/abao/node_modules/underscore/underscore.js:122:29)

plroebuck added a commit that referenced this issue Jun 2, 2018
Troubleshooting errors reported. See if problem caused by recent release.

#242
@plroebuck
Copy link
Collaborator

plroebuck commented Jun 2, 2018

@raj-bhagya, you sent a couple Python files but nothing that I could run myself. Unable to reproduce more than a portion of the required package, I can't do anything with what you provided.

Abao-0.6.0 now builds successfully with related patches to further lockdown dependencies.
Install the new version and retry the test on your side.

@raj-bhagya
Copy link

@plroebuck , Our services are developed on Flask web application framework written in Python.

@raj-bhagya
Copy link

raj-bhagya commented Jun 4, 2018

@plroebuck ,

I Installed latest development version Abao-0.6.0, but I'm encountering different error only with this version where as the previous version 0.5.0 is not throwing this error. I'm suspecting this could be because of node version compatibility, please suggest solution.

0.6.0 Installation output:
sudo npm install -g git+https://[email protected]/cybertk/abao.git#0.6.0
Password:
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/bin/abao -> /usr/local/lib/node_modules/abao/bin/abao

[/repos/simile → develop]$ npm --version
6.1.0
[
/repos/simile → develop]$ node -v
v10.2.1

Error:
[~/repos/simile → develop]$ abao -v
path.js:39
throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
at assertPath (path.js:39:11)
at Object.basename (path.js:1299:5)
at parseArgs (/usr/local/lib/node_modules/abao/lib/cli.coffee:49:17)
at Object.main (/usr/local/lib/node_modules/abao/lib/cli.coffee:67:18)
at Object. (/usr/local/lib/node_modules/abao/bin/abao:15:27)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

@plroebuck
Copy link
Collaborator

plroebuck commented Jun 4, 2018

@raj-bhagya, I don't get an error on my side (displays usage) but to display the version type:

$ abao --version

@raj-bhagya
Copy link

raj-bhagya commented Jun 4, 2018

Same error with abao --version also, basically getting this error with any abao command option.

[~/repos/simile/simile_web_service → develop]$ abao --version
path.js:39
throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
at assertPath (path.js:39:11)
at Object.basename (path.js:1299:5)
at parseArgs (/usr/local/lib/node_modules/abao/lib/cli.coffee:49:17)
at Object.main (/usr/local/lib/node_modules/abao/lib/cli.coffee:67:18)
at Object. (/usr/local/lib/node_modules/abao/bin/abao:15:27)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

@plroebuck
Copy link
Collaborator

plroebuck commented Jun 4, 2018

Line numbers don't exactly match expected, but only place basename is used in CLI is here.

Original (line 35):

  prog = path.basename pkg.bin

For quick test, change that line to be:

  prog = 'abao'

What OS version for my reference?

@raj-bhagya
Copy link

I hardcoded value to prog = 'abao' in line 35, but still same issue.
macOS 10.13.2

@plroebuck
Copy link
Collaborator

plroebuck commented Jun 4, 2018

I'm running macOS-10.13.4 so OS-wise this code should have no problems.
I was running Node-8.11.1, but to test this I upgraded to current development version without any changes to abao-0.6.0 GitHub release.

$ node --version
v10.3.0
$ bin/abao --version
0.6.0

What is displayed for this command?

$ which abao

Should be impossible to get the same error if you replaced Line 35 above with the hardcoded value!

@raj-bhagya
Copy link

$ which abao
/usr/local/bin/abao

@plroebuck
Copy link
Collaborator

plroebuck commented Jun 4, 2018

Copy'n'paste the parseArgs function from "cli.coffee" here.

Also:

$ npm list --depth=0

@raj-bhagya
Copy link

parseArgs = (argv) ->
  'use strict'
  allOptions = _.assign {}, abaoOptions, mochaOptions
  mochaOptionNames = Object.keys mochaOptions
  prog = path.basename pkg.bin
  return yargs(argv)
    .usage("Usage:\n  #{prog} </path/to/raml> [OPTIONS]" +
      "\n\nExample:\n  #{prog} api.raml --server http://api.example.com")
    .options(allOptions)
    .group(mochaOptionNames, 'Options passed to Mocha:')
    .implies('template', 'generate-hooks')
    .check((argv) ->
      if argv.reporters == true
        showReporters()
        process.exit EXIT_SUCCESS

      # Ensure single positional argument present
      if argv._.length < 1
        throw new Error "#{prog}: must specify path to RAML file"
      else if argv._.length > 1
        throw new Error "#{prog}: accepts single positional command-line argument"

      return true
    )
    .wrap(80)
    .help('help', 'Show usage information and exit')
    .version('version', 'Show version number and exit', pkg.version)
    .epilog("Website:\n  #{pkg.homepage}")
    .argv

@plroebuck
Copy link
Collaborator

parseArgs = (argv) ->
  'use strict'
  allOptions = _.assign {}, abaoOptions, mochaOptions
  mochaOptionNames = Object.keys mochaOptions
  prog = path.basename pkg.bin        <--- Thought you changed this line
  return yargs(argv)
    .usage("Usage:\n  #{prog} </path/to/raml> [OPTIONS]" +
      "\n\nExample:\n  #{prog} api.raml --server http://api.example.com")
    .options(allOptions)
...

@raj-bhagya
Copy link

I changed that line and tried. Meantime time I tired to downgrade node version to 8.11.1 and reinstalled abao-0.6.0 (Just to see if there is compatibility problem), that's why it changed back to original state.
Sorry about the confusion. Here is the function code:

parseArgs = (argv) ->
  'use strict'
  allOptions = _.assign {}, abaoOptions, mochaOptions
  mochaOptionNames = Object.keys mochaOptions
  prog = 'abao'
  return yargs(argv)
    .usage("Usage:\n  #{prog} </path/to/raml> [OPTIONS]" +
      "\n\nExample:\n  #{prog} api.raml --server http://api.example.com")
    .options(allOptions)
    .group(mochaOptionNames, 'Options passed to Mocha:')
    .implies('template', 'generate-hooks')
    .check((argv) ->
      if argv.reporters == true
        showReporters()
        process.exit EXIT_SUCCESS

      # Ensure single positional argument present
      if argv._.length < 1
        throw new Error "#{prog}: must specify path to RAML file"
      else if argv._.length > 1
        throw new Error "#{prog}: accepts single positional command-line argument"

      return true
    )
    .wrap(80)
    .help('help', 'Show usage information and exit')
    .version('version', 'Show version number and exit', pkg.version)
    .epilog("Website:\n  #{pkg.homepage}")
    .argv

[~/repos/simile/simile_web_service/tests/raml → develop]$ npm list --depth=0

[email protected] /Users/ramesh/repos/simile
├── [email protected]
└── [email protected]

@plroebuck
Copy link
Collaborator

So I'm lost. If the code is changed, how are you still getting the same error referring to path.basename()?

@plroebuck
Copy link
Collaborator

plroebuck commented Jun 4, 2018

Need this from abao's perspective:

$ cd /usr/local/lib/node_modules/abao
$ npm list --depth=0

For me:

@raj-bhagya
Copy link

[/usr/local/lib/node_modules/abao]$ npm list --depth=0

[email protected] (git+https://[email protected]/cybertk/abao.git#20b9357daafb051d6f59db136f9b35b59a1eaa0e) /usr/local/lib/node_modules/abao
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Is there any other occurrence of basename? do I need to build anything after changing that line?

@plroebuck
Copy link
Collaborator

Rerun abao --version and post the current error message

@raj-bhagya
Copy link

$ abao --version

path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at assertPath (path.js:39:11)
    at Object.basename (path.js:1299:5)
    at parseArgs (/usr/local/lib/node_modules/abao/lib/cli.coffee:49:17)
    at Object.main (/usr/local/lib/node_modules/abao/lib/cli.coffee:67:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/abao/bin/abao:15:27)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

@raj-bhagya
Copy link

I got that fixed, there was a problem with my local setup. I was changing basename in one user's library not globally, changed it globally and working fine now. Sorry about that.

$ abao --version
0.6.0

Looks like raml tests are also running fine with "underscore": "1.8.3", I will confirm it soon. thanks!

plroebuck added a commit that referenced this issue Jun 4, 2018
…ge.json"

Field is treated differently after installation. Originally given as a string, the install converts
it to a map. Changed to use map with named field. Updated CLI to reference the named field.

Fixes #242
@plroebuck
Copy link
Collaborator

Found the TypeError problem you had above -- "npm" changes the "bin" field in "package.json" from string to a map when installed. Fix committed.

@raj-bhagya
Copy link

@plroebuck
Tests are running now with 0.6.0 version with above fix, thanks.
Just curious to know when is the Abao 0.6.0 expected to move to stable release?

@luis-carlos
Copy link

@plroebuck
Tests are running now with 0.6.0 version with above fix, thanks.
Just curious to know when is the Abao 0.6.0 expected to move to stable release?

@raj-bhagya: How can I install Abao 0.6.0?

I tried the following

image

but still got 0.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants