Skip to content

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

Conversation

Katana-Steel
Copy link
Contributor

@Katana-Steel Katana-Steel commented Jul 9, 2016

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

  • done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

def __init__(self):
stub = self.stub
Copy link
Member

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 :)

@Kami
Copy link
Member

Kami commented Jul 10, 2016

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 :().

@Katana-Steel
Copy link
Contributor Author

reviewed the suggestions and I did read up on Mock for testing
and updated the test code to mock essentially the entire libvirt module just to be safe ;)

Rene Kjellerup added 9 commits July 12, 2016 17:22
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
@Katana-Steel Katana-Steel force-pushed the libvirt/LibvirtNodeDriver_cleanup_and_tests branch from cc06e06 to 4eb18ed Compare July 13, 2016 00:22
@Katana-Steel
Copy link
Contributor Author

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
Copy link
Member

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 :)

@Kami
Copy link
Member

Kami commented Jul 13, 2016

@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).

@Kami
Copy link
Member

Kami commented Jul 13, 2016

Thanks for making those changes.

I will make the mock change and get the tests passing locally and then merge it into trunk.

@Kami
Copy link
Member

Kami commented Jul 13, 2016

I made those changes and merged it into trunk - 01c6db4 , d9fc1ed, a4bddfe

Thanks!

@asfgit asfgit closed this in 608b7ec Jul 13, 2016
@Kami
Copy link
Member

Kami commented Jul 13, 2016

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 libvirt library in all the virtual environments used by tox.

@Kami
Copy link
Member

Kami commented Jul 13, 2016

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 :/

https://travis-ci.org/apache/libcloud/jobs/144437976#L118

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.

2 participants