-
Notifications
You must be signed in to change notification settings - Fork 929
Libvirt/libvirt node driver cleanup and tests #838
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
Libvirt/libvirt node driver cleanup and tests #838
Conversation
def __init__(self): | ||
stub = self.stub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this code, but I believe you could also utilize Mock for that by specifying a class you want to mock for spec
argument - http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock.
This would mean less code to maintain and keep up to date :)
Thanks for this contribution. I've added some comments. It would be great if you could at least update the tests to follow the same approach as other driver test (sorry for not mentioning in your first tests PR, I missed it :(). |
reviewed the suggestions and I did read up on Mock for testing |
checking the uri string for +tcp before trying to do the SASL connection to the libvirtd service
if we get a connection with None, retrive the connection uri from libvirt.virConnection
the mock module is not in unittest2 so include it directly
cc06e06
to
4eb18ed
Compare
the have_libvirt check makes using the mock framework hard when libvirt isn't installed. I'll take any suggestions... I could go back to inherit and just use MagicMock for virConnection it seems bad to assume libvirt is installed for tests to pass. Or would that be an acceptable change? |
@@ -37,10 +38,12 @@ deps = -r{toxinidir}/requirements-tests.txt | |||
[testenv:py2.6-lxml] | |||
deps = -r{toxinidir}/requirements-tests.txt | |||
unittest2 | |||
mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mock is already specified in requirements-tests.txt so no need to also specify it here.
In any case, not a big deal, I will remove it while merging :)
@Katana-Steel Ideally we can make it work without requiring libvirt to be installed, at least for the basic unit tests. I'm fine with having additional integration tests which can require libvirt to be installed as long as those don't run by default if libvirt is not installed (we can use unittest.skipIf and skip if libvirt is not installed). |
Thanks for making those changes. I will make the mock change and get the tests passing locally and then merge it into trunk. |
Also - 6626808 Some time in the next couple of days when I get a chance I will look into running libvirt tests on Travis CI. For one, we need to make sure all the system level libvirt dependencies are installed on Travis and after that we need to install |
It looks like that Travis doesn't have libvirt system package whitelisted so sadly it doesn't look like we can get this easily to run on new Travis container based infrastructure :/ |
Extra tests for libvirt_driver and cleaner driver creation
Description
Code clean up and added more tests for the libvirt_driver module.
Cleaner driver creation with less console output when using SASL
authentication.
Status
Checklist (tick everything that applies)