-
Notifications
You must be signed in to change notification settings - Fork 42
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
Cannot list inactive pools #12
Comments
Unable to reproduce with vagrant-2.2.4-2.fc30 both active and inactive are listed correctly now. Edit: I take it back, the bug is still there :-) |
This issue has been marked inactive and will be closed if no further activity occurs. |
I'd forgotten this issue. The fix appears to be a relatively simple one in changing to check if the pool is active before retrieving the number of volumes:
Question is, what's the impact? Right now it's not possible to list inactive pools without going directly to the client and checking if the pool that is of interest needs to be made active. It's possible that some code will be surprised by the code reporting additional pools that previously were hidden and such code might be surprised by getting a nil value for the I could add a guard where this only fixes this if some option is set so you only see active pools by default and those that want to list all must include a flag for the inactive ones to appear. Thoughts? |
The solution in the case of only listing inactive if requested instead of patching to include by default is as follows:
While I can test this by hand it might take me a little while to work out how to add shindo tests to ensure the correct behaviour. |
So based on the above change what I really need to test is that the functionality of fog-libvirt/lib/fog/libvirt/requests/compute/list_pools.rb Lines 19 to 46 in 783e7fa
client.lookup_storage_pool_by_name() and client.lookup_storage_pool_by_uuid() in functions find_pool_by_name and find_pool_by_uuid are processed as expected by pool_to_attributes .
However I'm not seeing how to mock the client part with shindo tests? I can certainly restructure the code so the function Any suggestions on how best to write a test for the above to ensure |
The proposed change via a filter argument looks good to me. Looking into tests is on my TODO, I haven't worked with Shindo yet. Maybe @geemus would have an advice how to approach testing in this case? |
Allow for an `:include_inactive` filter attribute to determine whether to include or exclude inactive pools and handle correctly setting the number of volumes in the case it is inactive. Current testing approach requires modifying the internal function in order to allow the Mock to call it to ensure it is exercised correctly. Fixes: fog#12
Thanks for that. Sidenote: I would love to have real tests as well, fixtures are nice but a real test against a libvirt session is a real test. We would not be able to run them on our CI however ability to run them locally would increase our confidence. That is just a wish, this is outside of your scope indeed. |
Agreed. I like having the mocks (partly to aide in CI/testing, partly because they are useful for end users when they are doing testing), but I always prefer to back them up with real tests that can be run to double-check stuff. |
This issue has been marked inactive and will be closed if no further activity occurs. |
Hoping to get back to this sometime next month, is that enough to stall the inactivity bot? |
Not sure but I removed the label so I think so? |
Yeah, I think comments will reset the timer. You can also use a |
This issue has been marked inactive and will be closed if no further activity occurs. |
Allow for an `:include_inactive` filter attribute to determine whether to include or exclude inactive pools and handle correctly setting the number of volumes in the case it is inactive. Current testing approach requires modifying the internal function in order to allow the Mock to call it to ensure it is exercised correctly. Fixes: fog#12
Allow for an `:include_inactive` filter attribute to determine whether to include or exclude inactive pools and handle correctly setting the number of volumes in the case it is inactive. Current testing approach requires modifying the internal function in order to allow the Mock to call it to ensure it is exercised correctly. Fixes: fog#12
Allow for an `:include_inactive` filter attribute to determine whether to include or exclude inactive pools and handle correctly setting the number of volumes in the case it is inactive. Current testing approach requires modifying the internal function in order to allow the Mock to call it to ensure it is exercised correctly. Fixes: fog#12
https://github.com/fog/fog-libvirt/blob/master/lib/fog/libvirt/requests/compute/list_pools.rb#L30 makes a call to get the num_of_volumes, however for inactive pools this will throw an exception in pool_to_attrbiutes that gets swallowed by either find_pool_by_name or find_pool_by_uuid.
I installed the gem, created a new pool in libvirt using virt-manager or virsh. Next I deactived the pool and ran the following code (similar to what vagrant-libvirt would do):
The result was be similar to:
Looking at the states supported by list_pools, it suggests it can handle inactive pools.
This caused vagrant-libvirt/vagrant-libvirt#536
The text was updated successfully, but these errors were encountered: