Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 1033402 - waitForSocket() before connecting to marionette. #115

Merged
merged 2 commits into from Aug 4, 2014
Merged

Bug 1033402 - waitForSocket() before connecting to marionette. #115

merged 2 commits into from Aug 4, 2014

Conversation

hfiguiere
Copy link
Contributor

No description provided.

// the logic is lifted from http://dxr.mozilla.org/mozilla-central/source/testing/marionette/client/marionette/marionette.py#562
var sockit = new sockittome.Sockit();
var start = Date.now();
var self = this;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer bind to self

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do that.

@lambdabaa
Copy link

Can we test this logic?

} catch(err) {
if (Date.now() - this._beginConnect >= this.connectionTimeout) {
callback(err);
var self = this;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is useless. Will remove.

@hfiguiere
Copy link
Contributor Author

Not sure there is an easy way to test, but I'll see.

@hfiguiere
Copy link
Contributor Author

@gaye do you know how we could test this on try? If it doesn't break the current tree.

@lambdabaa
Copy link

@hfiguiere I meant like writing a test that could be executed with the rest of the unit + integration suites. In order to test on try, you can probably publish an alpha version, require that in a fork of gaia-node-modules, and then submit a pr to gaia that changes the remote endpoint for gaia-node-modules and then set the gaia revision to your patch's sha.

var s = sockit.read(16).toString();
sockit.close();
if (s.indexOf(":") != -1) {
setTimeout(callback, 5000);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one come from the python stuff logic (see URL above). I'm wondering if it is really necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, removing this timeout.

@hfiguiere
Copy link
Contributor Author

Concerning the unit test, there is currently no unittest for tcp-sync. The tcp-sync is actually a simple test of the client with it. It should be enough and already test this one.

I more extensive unit test would be some work.

I run this patch with Gaia on Travis and Gaia-Try and all pass.

/**
* Utility to wait for the marionette socket to be ready.
*
* @method waitFor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: %s/waitFor/waitForSocket/

@lambdabaa
Copy link

I guess my hope was that you would make a very small, fake tcp server (which is not altogether too many lines of code in nodejs) and have it respond to new connections by waiting for a little bit and then writing back the string your code is looking for. You could use that to test the waitForSocket method and then, for the connect method, you could start trying to connect, then start your tcp server after a delay, and then make sure that the tcp server receives a connection and that connect resolves appropriately.

callback();
}.bind(this), 0);
callback();
}.bind(this), 0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: process.nextTick is more idiomatic then setTimeout(fn, 0) in node (I know this was here before)

@hfiguiere
Copy link
Contributor Author

While I agree that writing unit tests for these (and if we look at the current test we don't really unit test the driver, just the client using said driver - which means that we need more than just this to be tested), it is a bit like holding up a wanted feature that actually have been tested on our automation.....

I don't mind filing a bug for that and working on getting it addressed ASAP.

@hfiguiere
Copy link
Contributor Author

@gaye I also spoke to Mike Lee. It happens that this bug is blocking several critical bug that are needed for performance testing. We clearly understand the need to write the test, and are really willing to get them written in the close future, but we really need to get forward in running test-perf automation to collect more reliable dataset that would allow us to determine if we meet acceptation criteria for performance.

Also, @KevinGrandon would like to have this in, to really see if it will fix the intermittent failures in the Gaia integration tests.

I have run the whole test suite with this change and they all passed. Unless this break other thing, since I have addressed the nit above in my tree, I see nothing that really holds back.

If you have other concerns, please let us know, but getting a r+ is ultimately what we want to push it ASAP.

Thank you kindly.

@lambdabaa
Copy link

@gaye I also spoke to Mike Lee. It happens that this bug is blocking several critical bug that are needed for performance testing. We clearly understand the need to write the test, and are really willing to get them written in the close future, but we really need to get forward in running test-perf automation to collect more reliable dataset that would allow us to determine if we meet acceptation criteria for performance.

I really think writing tests for your business logic shouldn't be that hard. You could even use a less "realistic" mock if you're in a hurry.

I have run the whole test suite with this change and they all passed. Unless this break other thing, since I have addressed the nit above in my tree, I see nothing that really holds back.

That doesn't prove that the logic here is correct. It only proves that you didn't break anything...

@KevinGrandon
Copy link
Contributor

Replying cause I was pinged here. I believe this would solve the last blocker that was preventing us turning Gij on TBPL so I support this landing :) Tests are good, but if they're hard to write let's figure that out or do some knowledge sharing so it's easier in the future. I'd be happy with any of the three options:

1 - Figure out how to write a test for this.
2 - Land this and file a bug to write a test for it (test will probably never be written).
3 - Setup a peer programming session over Vidyo and get a test knocked out in an hour. We then have a test, this can land, and we are more knowledgeable for the future.

@hfiguiere
Copy link
Contributor Author

The test run better now. BUT, they still fail, without this change.

The error is
JavaScriptError: (17) TypeError: this.bluetooth is undefined

So....

@hfiguiere
Copy link
Contributor Author

The actual error message:

  scope
    sync waitFor
      1) "before each" hook

  ✖ 1 of NaN tests failed:

  1) scope "before each" hook:

  JavaScriptError: (17) TypeError: this.bluetooth is undefined
  Remote Stack:
  @app://system.gaiamobile.org/js/nfc_handover_manager.js, line 134
      at Error.MarionetteError (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/error.js:67:13)
      at Object.Client._handleCallback (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:476:19)
      at /home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:510:21
      at TcpSync.send (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/drivers/tcp-sync.js:153:10)
      at Object.send (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:457:36)
      at Object.Client._sendCommand (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:503:19)
      at Object._executeScript (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:1468:19)
      at Object.executeAsyncScript (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:1249:19)
      at Context.<anonymous> (/home/hub/source/mozilla/marionette-js-client/test/integration/helper.js:3:12)
      at Hook.Runnable.run (/home/hub/source/mozilla/marionette-js-client/node_modules/mocha/lib/runnable.js:196:15)
      at next (/home/hub/source/mozilla/marionette-js-client/node_modules/mocha/lib/runner.js:243:10)
      at /home/hub/source/mozilla/marionette-js-client/node_modules/mocha/lib/runner.js:249:7
      at done (/home/hub/source/mozilla/marionette-js-client/node_modules/mocha/lib/runnable.js:187:5)
      at /home/hub/source/mozilla/marionette-js-client/node_modules/mocha/lib/runnable.js:199:9
      at Object.executeHook (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:359:20)
      at Object.Client.runHook (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:377:7)
      at Object.runHook (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:730:14)
      at Object.Client._handleCallback (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:484:23)
      at newSession (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:546:21)
      at TcpSync.send (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/drivers/tcp-sync.js:153:10)
      at Object.send (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:457:36)
      at Object._newSession (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:549:19)
      at /home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:735:14
      at Object.<anonymous> (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:529:11)
      at Object.Client._handleCallback (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:484:23)
      at /home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:510:21
      at TcpSync.send (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/drivers/tcp-sync.js:153:10)
      at Object.send (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:457:36)
      at Object.Client._sendCommand (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:503:19)
      at Object._getActorId (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:526:19)
      at Object.startSession (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/client.js:733:19)
      at /home/hub/source/mozilla/marionette-js-client/node_modules/marionette-js-runner/lib/runtime/hostmanager.js:90:16
      at TcpSync.<anonymous> (/home/hub/source/mozilla/marionette-js-client/node_modules/marionette-client/lib/marionette/drivers/tcp-sync.js:112:7)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

@hfiguiere
Copy link
Contributor Author

@gaye there is now a test. It pass. Still the comment about failures above stick. Mine just pass before these.

Thank you kindly.

@@ -0,0 +1,32 @@
var net = require('net');
var debug = require('debug');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug is a function to which you're supposed to pass a topic for your logs... see https://github.com/visionmedia/debug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. right. done.

@lambdabaa
Copy link

JavaScriptError: (17) TypeError: this.bluetooth is undefined Remote Stack:

Hey @hub. Have you tried using a gaia profile to see if how that works out?

@lambdabaa
Copy link

@hfiguiere See https://github.com/mozilla-b2g/mozilla-profile-builder#usage for how to use gaia profile instead of the thing we download (which appears to crap out at the ftu).

@hfiguiere
Copy link
Contributor Author

I haven't tried the profile builder yet, but I just updated the PR with (most of) the feedback.

@lambdabaa
Copy link

@hfiguiere I think I'm still missing some bits here?

@hfiguiere
Copy link
Contributor Author

yes, the infamous refactor which will require a very thorough testing of the whole thing. More than just with this change. Working on it.

@lightsofapollo
Copy link
Contributor

Like I said on IRC r=me assuming we have tests passing... I gave hub permissions to push to the registry

@hfiguiere
Copy link
Contributor Author

hfiguiere added a commit that referenced this pull request Aug 4, 2014
Bug 1033402 - waitForSocket() before connecting to marionette. r=jlal
@hfiguiere hfiguiere merged commit be513c9 into mozilla-b2g:master Aug 4, 2014
@hfiguiere hfiguiere deleted the bug1033402 branch August 4, 2014 21:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants