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

Wifi connection success validation #445

Merged
merged 5 commits into from
Dec 4, 2015
Merged

Wifi connection success validation #445

merged 5 commits into from
Dec 4, 2015

Conversation

Frijol
Copy link
Member

@Frijol Frijol commented Nov 15, 2015

Working on #395

The current implementation is functional, but:

Other open questions:

  • I open a ubus listen, do I need to close that, or does it get closed when the connection is resolved?
  • How do I go about creating the appropriate tests for this?

@rwaldron comments appreciated. Thanks to @kevinmehall for the docs links.

@rwaldron
Copy link
Contributor

@Frijol run grunt, fix the lint nits and then re-commit any changes that jsbeautifier made, that should clear up some of the failures.

@rwaldron
Copy link
Contributor

Actually, looks like there are no lint nits. I think you can just do grunt and commit the changes

@rwaldron
Copy link
Contributor

An jscs errors will have to be fixed manually

// End the connection
return self.connection.end()
.then(resolve);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace lines 102-115 with the receive method:

self.receive(remoteProcess).then(function(data) {
  // do the check for ifup etc here, then just...
  // data is already a string
  return resolve();
}).catch(function(error) {
  logs.err('Error connecting:', error); // already a string 
   // this is sufficient, all connections will be closed by the process that called this operation
  return resolve();
});

@Frijol
Copy link
Member Author

Frijol commented Nov 24, 2015

fixed merge conflicts and delinted most of the way, but it stopped here:

Testing usb_connection.js........OK
Testing update.js.............OK
Testing wifi.js.....F..
>> Tessel.prototype.connectToNetwork - properCredentials
>> Error: 2 == 1
>> at /Users/kelseybreseman/Code/t2-cli/test/unit/wifi.js:195:14

>> Tessel.prototype.connectToNetwork - properCredentials
fix merge conflicts and delint
>> Error: 2 == 1
>> at /Users/kelseybreseman/Code/t2-cli/test/unit/wifi.js:196:14

Warning: 2/641 assertions failed (26437ms) Use --force to continue.

Aborted due to warnings.

@rwaldron I'm not that familiar with grunt, should I force? What does that do?

Also, need to test this with a tessel

@Frijol
Copy link
Member Author

Frijol commented Nov 24, 2015

also, will fix re your other note too.

// End the connection
return self.connection.end()
.then(resolve);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is missing: #445 (comment)

@rwaldron
Copy link
Contributor

So, the failures you're seeing are actual broken tests that you need to resolve:

Running "nodeunit:tests" (nodeunit) task
Testing access-point.js......OK
Testing bin-tessel-2.js..................OK
Testing constructor.js......OK
Testing controller.js..........................OK
Testing deploy.js.....................................OK
Testing discover.js...............OK
Testing erase.js..OK
Testing key.js....OK
Testing lan_connection.js...........OK
Testing menu.js..OK
Testing name.js........OK
Testing tessel.js...............OK
Testing provision.js.................OK
Testing update.js.............OK
Testing usb_connection.js........OK
Testing wifi.js.....F..
>> Tessel.prototype.connectToNetwork - properCredentials
>> Error: 2 == 1
>> at /Users/rwaldron/clonez/t2-cli/test/unit/wifi.js:195:14

>> Tessel.prototype.connectToNetwork - properCredentials
>> Error: 2 == 1
>> at /Users/rwaldron/clonez/t2-cli/test/unit/wifi.js:196:14

Warning: 2/641 assertions failed (36291ms) Use --force to continue.

I will take a look and see if I can help iron those out.

@@ -98,8 +98,43 @@ Tessel.prototype.connectToNetwork = function(opts) {
})
.then(function() {
// Then set the new credientials
logs.info('Credentials set!');
resolve();
return self.connection.exec(commands.commitWirelessCredentials());
Copy link
Contributor

Choose a reason for hiding this comment

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

This the source of the one of the test failures—commitWirelessCredentials has already been called by setWifiState just before this. If you remove the entire then, that test no longer fails.

Edit: I think it would be smarter to replace the call to setWifiState (above) with self.simpleExec(commands.turnOnWifi(enable)). Then this change stays as is.

@Frijol
Copy link
Member Author

Frijol commented Nov 25, 2015

fixed up based on your comments @rwaldron but I'm using a different computer than usual and getting problems so haven't tested on a T2 yet

@Frijol
Copy link
Member Author

Frijol commented Nov 26, 2015

tested on T2, didn't work as hoped, revised.

The takeaway: ubus is different from other commands we run on T2. It doesn't work to use a .receive, and the remote process has to be closed specifically.

Works great now (thanks for the help @johnnyman727).

Ready to merge!

@Frijol Frijol changed the title [WIP] Wifi connection success validation Wifi connection success validation Nov 26, 2015
@rwaldron
Copy link
Contributor

Ah, interesting—thanks for pointing that out. This patch also needs tests to prove the functionality—@johnnyman727 can you help @Frijol get started on those?

@johnnyman727
Copy link
Contributor

Sure thing. @Frijol what do you think of these tests: #473?

@HipsterBrown
Copy link
Contributor

@johnnyman727 I've started an update to this to work with #471 and the refactoring that happened with the wifi module. Your tests look great though, so I'm not sure the best course of action.

@johnnyman727
Copy link
Contributor

@HipsterBrown in theory, we could just merge this branch since it's been reviewed and has tests. The tests I added shouldn't break any of the tests that your branch introduces, right?

@HipsterBrown
Copy link
Contributor

@johnnyman727 Well my PR branch for #471 changes most of the connectToNetwork tests so there may be some gnarly conflicts. I'm working on integrating your tests into my working branch for this PR.

@johnnyman727
Copy link
Contributor

@HipsterBrown no worries if you have to throw theses tests away.

@HipsterBrown
Copy link
Contributor

@johnnyman727 Ok, well they really helped show how to mock those remote process events. 👍

@johnnyman727
Copy link
Contributor

👍 Glad they were helpful!

@rwaldron
Copy link
Contributor

rwaldron commented Dec 4, 2015

We're going to do tests in a follow up

rwaldron added a commit that referenced this pull request Dec 4, 2015
Wifi connection success validation
@rwaldron rwaldron merged commit 63952cb into master Dec 4, 2015
@Frijol Frijol deleted the kb-wifi branch December 8, 2015 18:12
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

Successfully merging this pull request may close these issues.

None yet

4 participants