CCI-MOC / hil

Hardware Isolation Layer, formerly Hardware as a Service
Apache License 2.0
24 stars 54 forks source link

Update Switch Drivers to Handle Errors #963

Closed xuhang57 closed 6 years ago

xuhang57 commented 6 years ago

Since #929 introduces an approach of handling switch errors, this PR updates the existing switch drivers.

Relates to: https://github.com/CCI-MOC/hil/issues/948

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 1667


Changes Missing Coverage Covered Lines Changed/Added Lines %
hil/ext/switches/brocade.py 0 3 0.0%
<!-- Total: 0 3 0.0% -->
Files with Coverage Reduction New Missed Lines %
hil/ext/switches/brocade.py 1 0.0%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/ext/network_allocators/null.py 1 65.22%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/commands/db.py 2 100.0%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/client/extensions.py 3 60.0%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/client/user.py 10 38.46%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/client/network.py 11 37.93%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/client/project.py 11 40.74%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/deferred.py 13 22.41%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/client/switch.py 15 42.86%
/home/travis/virtualenv/python2.7_with_system_site_packages/lib/python2.7/site-packages/hil/migrations.py 20 92.31%
<!-- Total: 380 -->
Totals Coverage Status
Change from base Build 1641: -0.02%
Covered Lines: 2596
Relevant Lines: 6750

💛 - Coveralls
xuhang57 commented 6 years ago

hmm, I don't know whether I should add some test cases to test the lines I just added. Since we are not testing the coverage on actual drivers, which makes sense that I am adding a few lines that are not covered.

What do you guys think? If I do need to add the tests, any idea on what kind of tests I should have would be really helpful!

naved001 commented 6 years ago

If I do need to add the tests, any idea on what kind of tests I should have would be really helpful!

Just spitballing here:

But I don't know what are we testing here. The mechanism is already tested by tests/unit/deferred.py using the mock switch.

what do you think @zenhack

zenhack commented 6 years ago

I don't feel terribly strongly about adding tests for this. It might be nice to tweak the tests so we can run them against any driver instead of just mock, but that's a bigger change that I don't think it's worth holding this up over. @naved001 it might be good to run the deployment tests against the brocade switch if you've got the bandwidth for that.

I'm confused as to why coveralls is complaining; we marked the brocade driver as omit. it's also displaying paths in the virtualenv, which is weird. We've got some kind of configuration problem I think.

GitHub is telling me that I can still hit merge if I want to, so maybe we can just deal with coveralls config problem separately.

naved001 commented 6 years ago

@naved001 it might be good to run the deployment tests against the brocade switch if you've got the bandwidth for that.

Yeah I can do that, but to be honest it doesn't really change much, if an error is raised it will also log it as an error and the tests will fail since we have the fail on log warnings. I'll run it anyway.

GitHub is telling me that I can still hit merge if I want to, so maybe we can just deal with coveralls config problem separately.

Yeah, coveralls is optional right now (unlike Travis, which is required). So we can ignore it as per our convenience.

xuhang57 commented 6 years ago

But, yes, I am also very confused on why the coverage drops. I don't have a clue yet.

The thing is, you cannot drop the overage percentage when you have something that has already been 0.0%.

F = file

F1 (0.0%) + F2 + F3 + F4
-------------------------    = 38.4%
         Files
zenhack commented 6 years ago

@xuhang57, remember, you're making the uncovered file bigger, so that is going to drop the percentage of the overall code base. My question is more "why isn't coveralls ignoring this file?"

xuhang57 commented 6 years ago

@zenhack Make sense.

I am basically following this: http://coverage.readthedocs.io/en/coverage-4.2/source.html#source

Would be nice if there is a second person that can read this doc a bit and make sure it suits what we need.

Currently, coveralls basically set certain files to be 0.0% rather than ignoring them I believe.

naved001 commented 6 years ago

@zenhack Deployment tests passed with a caveat (unrelated to this PR):

for vlan_networks.py deployment tests if I specify a range of vlans in testsuite.cfg then the switch returns a range of vlans for which I have pushed a fixed in #958. The simple workaround was to specify non contiguous VLANs.

zenhack commented 6 years ago

LGTM. I'm going to merge, even though coveralls is unhappy (we've discussed the issue enough I think).