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

Nightwatch bridge and/or other processes do not stop on errors when starting the test runner #60

Open
em0ney opened this issue Jul 7, 2015 · 8 comments

Comments

@em0ney
Copy link

em0ney commented Jul 7, 2015

Hi Abigail,

Firstly, thanks for building out this tool! Velocity is rubbish and I'm hoping starrynight is the test framework for me. The doc look good.

Just having a little trouble getting started. In the process of trying to get everything started, it seems that if I have a fatal error when starting starrynight, not all processes that it spawns die and on the subsequent connection, the port is taken.

$ starrynight run-tests --framework tinytest-ci                                                                              
This command should be run in the root of an application.
Running tiny tests on packages.  Check http://localhost:3000
multiFramework::options { _: [ 'node', '/usr/local/bin/starrynight', 'run-tests' ],
  framework: 'tinytest-ci' }
Detecting release version...
Spawning Meteor instance on port 3300 for Package Verification testing using TinyTest...
I20150707-12:27:23.543(10)? test-in-console listening
Detected a meteor instance on port 3300
Launching nightwatch bridge...
ERROR There was an error while starting the test runner:



Error: Failed to load external global file: External global file could not be located - using ./tests/nightwatch/globals.json.
    at Object.CliRunner.readExternalGlobals (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:130:13)
    at Object.CliRunner.initTestSettings (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:383:10)
    at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:363:10)
    at Object.CliRunner.init (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
    at module.exports.runner.runner [as runner] (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/index.js:512:19)
    at /usr/local/lib/node_modules/starrynight/node_modules/nightwatch/bin/runner.js:9:16
    at module.exports.cli.cli [as cli] (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/index.js:504:7)
    at Object.<anonymous> (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/bin/runner.js:8:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

Nightwatch exited with a code of 2

Then on the subsequent attempt

$ starrynight run-tests --framework tinytest-ci
This command should be run in the root of an application.
Running tiny tests on packages.  Check http://localhost:3000
multiFramework::options { _: [ 'node', '/usr/local/bin/starrynight', 'run-tests' ],
  framework: 'tinytest-ci' }
Detecting release version...
Spawning Meteor instance on port 3300 for Package Verification testing using TinyTest...
Can't listen on port 3300. Perhaps another Meteor is running?

Running two copies of Meteor in the same application directory
will not work. If something else is using port 3300, you can
specify an alternative port with --port <port>.
Package Verification Testing exited with code 254
Detected a meteor instance on port 3300
Launching nightwatch bridge...
ERROR There was an error while starting the test runner:



Error: Failed to load external global file: External global file could not be located - using ./tests/nightwatch/globals.json.
    at Object.CliRunner.readExternalGlobals (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:130:13)
    at Object.CliRunner.initTestSettings (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:383:10)
    at Object.CliRunner.parseTestSettings (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:363:10)
    at Object.CliRunner.init (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/runner/cli/clirunner.js:31:8)
    at module.exports.runner.runner [as runner] (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/index.js:512:19)
    at /usr/local/lib/node_modules/starrynight/node_modules/nightwatch/bin/runner.js:9:16
    at module.exports.cli.cli [as cli] (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/lib/index.js:504:7)
    at Object.<anonymous> (/usr/local/lib/node_modules/starrynight/node_modules/nightwatch/bin/runner.js:8:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

Nightwatch exited with a code of 2
$ ps -ef | grep meteor                                                                                                              
e         7734  1091  0 12:27 pts/19   00:00:03 /home/e/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node /home/e/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/main.js test-packages --once --driver-package test-in-console -p 3300
e         7756  7734  0 12:27 pts/19   00:00:01 /home/e/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 3301 --dbpath /tmp/meteor-test-runa8p3d5/.meteor/local/db --oplogSize 8 --replSet meteor
e         7814  7734  0 12:27 pts/19   00:00:00 /home/e/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node /tmp/meteor-test-runa8p3d5/.meteor/local/build/main.js
e         8357  3632  0 12:34 pts/19   00:00:00 grep meteor

Hopefully its just something crazy I have done wrong and there is no actual underlying bug.

Thanks,
Elliott

@awatson1978
Copy link
Owner

Hi Elliot,
Even when we're running the TinyTests, we're still going to be using Nightwatch, because it's all integrated. The global.json file is telling us that we don't have NightWatch setup correctly, and that its scaffold doesn't exist. So try running the following to set up the nightwatch environment:

starrynight scaffold --framework nightwatch
starrynight generate-autoconfig

Once that's all created, you'll be able able to run the TinyTest-CI framework, and the tinytest results will be picked up the Nightwatch runner.

Word of warning: this stuff is new, so you'll be reaching the edge of what the tool can do before long. But it's pretty open-ended what we can do at this point.

For instance: it seems like we need to check whether the /tests/nightwatch directory is created, and prompt the user to create it if it doesn't exist yet. Same with the .meteor/nightwatch.json file.

We're also working on an Atom package that's going to have a UI interface for running a bunch of StarryNight commands. That will give us an isomorphic environment and API between Client, Editor, and Test Harness.

Lastly, I've got a ton of documentation in the works. Take a look at http://starrynight-beta.meteor.com for an early look at the upcoming documentation.

@em0ney
Copy link
Author

em0ney commented Jul 9, 2015

Hi Abigail,

Thanks so much for the quick response.

Looks like that command has sorted me out with that original issue. Maybe there can be a 'getting started' section of the documentation with those two commands?

Now I am hitting a new issue though:

Running tiny tests on packages.  Check http://localhost:3000                                                                                       [10/404]
multiFramework::options undefined
Detecting release version...
Spawning Meteor instance on port 3300 for Package Verification testing using TinyTest...
I20150709-09:58:34.285(10)? test-in-console listening
/usr/local/lib/node_modules/starrynight/tool/frameworks/tinytest-on-server-console.js:44
      options.tinytests = true;
                        ^
TypeError: Cannot set property 'tinytests' of undefined
    at Socket.startTesting (/usr/local/lib/node_modules/starrynight/tool/frameworks/tinytest-on-server-console.js:44:25)
    at Socket.emit (events.js:129:20)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at Pipe.onread (net.js:538:20)

Then, the second time I run the same command:

$ starrynight run-tests --framework tinytest-ci
This command should be run in the root of an application.
Running tiny tests on packages.  Check http://localhost:3000
multiFramework::options { _: [ 'node', '/usr/local/bin/starrynight', 'run-tests' ],
  framework: 'tinytest-ci' }
Detecting release version...
Spawning Meteor instance on port 3300 for Package Verification testing using TinyTest...
Can't listen on port 3300. Perhaps another Meteor is running?

Running two copies of Meteor in the same application directory
will not work. If something else is using port 3300, you can
specify an alternative port with --port <port>.
Package Verification Testing exited with code 254
Detected a meteor instance on port 3300
Launching nightwatch bridge...
Starting selenium server... 
started - PID:  5492


No tests defined! using source folder: /home/e/dev/bigspendr/tests/nightwatch/walkthroughs ; using tags: tinytests

Nightwatch exited with a code of 1

I am defining my tiny-tests within my package right now using the Package.onTest() directive to specify dependencies and file load order etc (so that I can stub). When I run starrynight, is it loading my tests from individual packages? Or do these need to be moved somewhere else?

Awesome tool - if I get some more hours up my sleeve I'll try get involved and make some PRs.

Thanks for your help,
Elliott

@awatson1978
Copy link
Owner

Hi Elliot,
I've been spending this afternoon taking screenshots and writing tutorials. I'm going to make sure we get a walkthrough and tutorial written up and posted for both TinyTests and UnitTests. Hopefully within the next 24 hours.

Also, as I take the screenshots, I'm addressing more edge-cases, and flushing out bugs. So we're also going to bump versions within the next day or two, with lots of bug fixes.
Abigail

ps. I'm working on updating the scaffolds to have some default unittests and tinytests; and adding logic to detect that the necessary files are in place, and to prompt the user for action instead of throwing errors.

@em0ney
Copy link
Author

em0ney commented Jul 9, 2015

You're a legend! Thanks so much!!

@awatson1978
Copy link
Owner

Oi. I just finished making the screenshot/walkthrough of the tinytest-ci commands, and realized that tinyTestPickup.js wasn't being shipped with the StarryNight utility. That would make it awfully darn difficult for anybody to use the tinytest-ci integration, wouldn't it?

Okay, so 3.3.1 is now published on NPM, with an updated readme. It's got tons of bug fixes and streamlined functionality. Run a npm update starrynight to get the latest.
https://www.npmjs.com/package/starrynight

Also, I pushed online the screenshots of the new tutorials and examples. I still need to write text for them, but I think you may find the TinyTest Walkthrough to be useful as-is. Take a look at the preview site, if you wish:

http://starrynight-beta.meteor.com/examples/tinytests

@em0ney
Copy link
Author

em0ney commented Jul 13, 2015

Hey Abigail,

Great, thanks for that!

I worked through the example you have under http://starrynight-beta.meteor.com/examples/tinytests. Have it now running the tinytest pickup, but not always displaying test results. Also I forced two of my tests to fail and the generated report is only reporting one assertion and reporting it as passing.

Any idea what's happening?

screenshot of tests in browser

screenshot from 2015-07-13 10 33 51

command line output

e@m0ney:~/dev/project$ starrynight run-tests --framework tinytest-ci
This command should be run in the root of an application.
Running tiny tests on packages.  Check http://localhost:3000
Detecting release version...
Spawning Meteor instance on port 3300 for Package Verification testing using TinyTest...
Can't listen on port 3300. Perhaps another Meteor is running?

Running two copies of Meteor in the same application directory
will not work. If something else is using port 3300, you can
specify an alternative port with --port <port>.
Package Verification Testing exited with code 254
Detected a meteor instance on port 3300
Launching nightwatch bridge...
Found .meteor/nightwatch.json
Starting selenium server... 
started - PID:  9208
[Tiny Test Pickup] Test Suite
=============================

Running:  Test Getting Logs
✔ Testing if element <body> is present.
http://localhost:3300/packages/test-in-console.js?59d9cde1f0563b9d9cc5b99297a0997b32d3f499 75:17 S: tinytest - getAwsRegions method throws to future when ec2 callout returns error
http://localhost:3300/packages/test-in-console.js?59d9cde1f0563b9d9cc5b99297a0997b32d3f499 75:17 S: tinytest - getAwsRegions inserts new regions where those returned do not exist
http://localhost:3300/packages/test-in-console.js?59d9cde1f0563b9d9cc5b99297a0997b32d3f499 75:17 S: tinytest - getAwsRegions deletes regions who no longer exist
http://localhost:3300/packages/test-in-console.js?59d9cde1f0563b9d9cc5b99297a0997b32d3f499 75:17 S: tinytest - getAwsRegions updates regions with new endpoints no longer exist
OK. 1 assertions passed. (2.604s)

Finished!  Nightwatch ran all the tests!

generated report:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuites errors="0"
            failures="0"
            tests="1">

  <testsuite name="tinyTestPickup"
    errors="0" failures="0" hostname="" id="" package="tinyTestPickup" skipped="0"
    tests="1" time="2.604" timestamp="Mon, 13 Jul 2015 00:27:58 GMT">

    <testcase name="Test Getting Logs" time="2.604" assertions="1">


    </testcase>


  </testsuite>
</testsuites>

@awatson1978
Copy link
Owner

Hey! Yeah, we're about at the edge of development now.

SpaceJam had a bunch of similar problems, which is exactly why I ported all of its functionality over to StarryNight/Nightwatch... to hopefully be able to hack on things and figure out how to make it more consistent.

Obviously, part of the problem is that the console driver is writing to the console, and we have to do a pickup. TinyTest also writes a summary to a JSON object that sits in the browser console. It would be real nice to submit a pull request to MDG, and write all the results to the summary object. From a technical perspective, that would certainly be the easiest way to resolve the issue. But it also involves submitting a pull request (ug). If you want to try to put the pull request together, I'll certainly offer what assistance I can.

Other possibilities include adjusting timeouts; making sure there are no stale process in place; moving synchronous code into async callbacks for more reliable timing; and clarifying the spawn/exit code process. If you're interested on hacking on things, the relevant files are below:

https://github.com/awatson1978/starrynight/blob/develop/tool/frameworks/tinytest-on-server-console.js
https://github.com/awatson1978/starrynight/blob/develop/tool/frameworks/nightwatch.js

An 'npm install -g .' will compile and install a local version of starrynight.

@em0ney
Copy link
Author

em0ney commented Jul 13, 2015

Hey,

Yeah, I'd love to get involved. I'll get into it in my evenings here in
Sydney and will let you know when I have something you can look over and
contribute to.

Thanks for being super helpful - absolutely legendary response times and
quality information

On 13 July 2015 at 11:05, Abigail Watson notifications@github.com wrote:

Hey! Yeah, we're about at the edge of development now.

SpaceJam had a bunch of similar problems, which is exactly why I ported
all of its functionality over to StarryNight/Nightwatch... to hopefully be
able to hack on things and figure out how to make it more consistent.

Obviously, part of the problem is that the console driver is writing to
the console, and we have to do a pickup. TinyTest also writes a summary to
a JSON object that sits in the browser console. It would be real nice to
submit a pull request to MDG, and write all the results to the summary
object. From a technical perspective, that would certainly be the easiest
way to resolve the issue. But it also involves submitting a pull request
(ug). If you want to try to put the pull request together, I'll certainly
offer what assistance I can.

Other possibilities include adjusting timeouts; making sure there are no
stale process in place; moving synchronous code into async callbacks for
more reliable timing; and clarifying the spawn/exit code process. If you're
interested on hacking on things, the relevant files are below:

https://github.com/awatson1978/starrynight/blob/develop/tool/frameworks/tinytest-on-server-console.js

https://github.com/awatson1978/starrynight/blob/develop/tool/frameworks/nightwatch.js

An 'npm install -g .' will compile and install a local version of
starrynight.


Reply to this email directly or view it on GitHub
#60 (comment)
.

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

2 participants