GitHub user wilderrodrigues opened a pull request: https://github.com/apache/cloudstack/pull/233
Refactor/libvirt resource This PR contains the refactor of the LibvirtComputingResource. The motivation behind this effort is to increase maintainability and testability of the code. The LibvirtComputingResource went from 5.5k to 3.3k lines of code. The unit tests went from 300 to 5050 lines of code, covering 23.3% of the whole KVM plugin (instead of the previous 4%). All the code extracted from the LibvirtComputingResource has 64.8% coverage. This has already been rebased and built. I'm creating the PR now but will test it against a KVM hypervisor before it gets pushed towards the Master branch. Cheers, Wilder You can merge this pull request into a Git repository by running: $ git pull https://github.com/schubergphilis/cloudstack refactor/libvirt_resource Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cloudstack/pull/233.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #233 ---- commit 508f10527fc199a45900e456899893fb776e50da Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-22T09:35:57Z Refactoring the LibvirtComputingResource - Adding LibvirtStopCommandWrapper - LibvirtRequestWrapper - 1 unit tests Refactored the RequestWrapper to make it better. - Changes also applied to the CitrixRequestWrapper commit 7086d64387fd0fb6381e4dbb63d46361d619b948 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-22T12:53:28Z Refactoring the LibvirtComputingResource - Adding LibvirtGetVmStatsCommandWrapper - 3 unit tests Refactored the LibvirtConnectiobn by surrounding it with an wrapper. - Make it easier to cover the static/native calls - Added better coverage to StopCommand tests commit 51093afcf11ef37b3d54c5430b955e87e17d2be2 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-22T13:05:59Z Refactoring the LibvirtComputingResource - Adding LibvirtGetVmDiskStatsCommandWrapper - 1 unit test Added getConnection() to LibvirtConnectionWrapper commit 7a90c018fbba0419c55c245aa1cb3488472d2a62 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-22T14:06:43Z Refactoring the LibvirtComputingResource - Adding LibvirtRebootCommandWrapper and LibVirtRebootRouterCommandWrapper - 2 unit tests added - KVM hypervisor with 10.5% coverage commit 6e568125fc282a3d0984f59fa0755b087e29cf7f Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T08:30:13Z Refactoring the LibvirtComputingResource - Adding LibvirtGetHosStatsCommandWrapper - 1 unit test added - KVM hypervisor with 10.5% coverage Tests are a bit limited on this one becuause of the current implementation. Would clean it up later in a separate branch commit 54f68f519fc3baefe435f9b37f028ff2cca9106f Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T08:45:57Z Removing the CheckStateCommand form the IF statement on LibvirtComputingResource - It's not used and if so would cause an infinite loop. commit d730efb86681b2206b82cbacc828e77e1204367b Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T09:36:38Z Refactoring the LibvirtComputingResource - Adding LibvirtCheckHealthCommandWrapper and LibvirtPrepareForMigrationCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 10.8% coverage commit 28e55462f15bdd8699e97b668c4ffc01735a533d Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T11:31:58Z Refactoring the LibvirtComputingResource - Adding LibvirtMigrateCommandWrapper - 1 unit tests added - KVM hypervisor plugin with 10.9% coverage commit be1e5176156d9b7eb78e53c703b48d679ad52f56 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T11:57:13Z Refactoring the LibvirtComputingResource - Adding LibvirtPingTestCommandWrapper - 3 unit tests added - KVM hypervisor plugin with 11.2% coverage commit 4d216f1a6382c42cf94a947aa5432f4d18782811 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T12:24:53Z Refactoring the LibvirtComputingResource - Adding LibvirtAttachIsoCommandWrapper, LibvirtAttachIsoCommandWrapper and LibvirtAttachIsoCommandWrapper - 7 unit tests added - KVM hypervisor plugin with 11.5% coverage commit 40886b337c953378b93c03c899f801bb24e3aff6 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T12:44:13Z Refactoring the LibvirtComputingResource - Adding LibvirtAttachVolumeCommandWrapper - 3 unit tests added - KVM hypervisor plugin with 11.7% coverage commit 08a9523dcdd5b4d736c4ef29b9ea93daa2b6e400 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-23T12:46:09Z Fixing assertion on the tests that are execting exceptions commit 7319a12600a7823aef8167348ee66a74a43ede8b Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-24T09:49:00Z Refactoring the LibvirtComputingResource - Adding LibvirtCheckConsoleProxyLoadCommandWrapper, LibvirtConsoleProxyLoadCommandWrapper, LibvirtWatchConsoleProxyLoadCommandWrapperand CitrixConsoleProxyLoadCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 12% coverage Refactored the CommandWrapper interface in order to remove the esecuteProxyLoadScan, which is now implemented bu subclasses. commit f14c7c207494c1c01d73713f6a2c4ab5452d07e9 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-24T11:17:58Z Refactoring the LibvirtComputingResource - Adding LibvirtGetVncPortCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 12.1% coverage commit 6f757c6bf062d75c726f12dac49548dad9104cd0 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-29T13:24:18Z Refactoring the LibvirtComputingResource - Adding LibvirtModifySshKeysCommandWrapper - 1 unit test added - KVM hypervisor plugin with 12.3% coverage commit cb4670279f764e1747f6eaaf1e39b1516cce6a5d Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-29T14:05:44Z Refactoring the LibvirtComputingResource - Adding LibvirtCreateCommandWrapper and LibvirtMaintainCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 12.7% coverage commit 4472cade2f1c079d96ed738d32c0e046f76c832e Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-29T15:19:57Z Refactoring the LibvirtComputingResource - Adding LibvirtDestroyCommandWrapper - 2 unit tests added - KVM hypervisor plugin with 12.9% coverage commit 8268d353a2a5ffb032017687f7df82c4a6871812 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-30T12:53:17Z Refactoring the LibvirtComputingResource - Adding LibvirtPrimaryStorageDownloadCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 13.3% coverage commit 0d860af659da24b509910e5edbce95d58c6fe569 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-04-30T19:33:19Z Refactoring the LibvirtComputingResource - Adding LibvirtDeleteStoragePoolCommandWrapper, LibvirtGetStorageStatsCommandWrapper and LibvirtUpgradeSnapshotCommandWrapper - 7 unit tests added - KVM hypervisor plugin with 13.6% coverage commit 4887ce72544c3a9b9f507a916ec0c3a22e6b25f5 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-01T10:04:16Z Refactoring the LibvirtComputingResource - Adding LibvirtOvsDestroyBridgeCommandWrapper, LibvirtOvsSetupBridgeCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 13.9% coverage More tests added to cover LibvirtPrepareForMigrationCommandWrapper - Coverage of this wrapper broght from 37% to 90.6% - 4 new tests added commit 5499eecd33d93c88ed9c0b4828deb0d11ac0a66e Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-01T12:43:30Z Refactoring the LibvirtComputingResource - Adding 7 new command wrappers - 10 unit tests added - KVM hypervisor plugin with 14.8% coverage commit 6748a73b82bb7d1d45fdde1cbcc02f78b8f7b330 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-01T14:17:09Z Refactoring the LibvirtComputingResource - Adding 4 new command wrappers - 12 unit tests added - KVM hypervisor plugin with 15.5% coverage commit 3c8b217262e08053fd59329f7466b65b150a18c2 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-01T17:17:30Z Refactoring the LibvirtComputingResource - Adding LibvirtCheckOnHostCommandWrapper and LibvirtOvsCreateTunnelCommandWrapper - 4 unit tests added - KVM hypervisor plugin with 16.2% coverage commit ff7ae9ca0c9714dca684f3972eacae56254b76fd Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-02T07:37:59Z Refactoring the LibvirtComputingResource - Adding LibvirtCreateVolumeFromSnapshotCommandWrapper, LibvirtFenceCommandWrapper and LibvirtSecurityGroupRulesCommandWrapper - 6 unit tests added - KVM hypervisor plugin with 17.2% coverage commit 52d9f0c20624e74dd2852038cd3912e1756d11e3 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-05T08:39:50Z Refactoring the LibvirtComputingResource - Adding LibvirtNetworkUsageCommandWrapper, LibvirtPlugNicCommandWrapper and LibvirtUnPlugNicCommandWrapper - 9 unit tests added - KVM hypervisor plugin with 18.3% coverage commit bcf78d3b4304800d9a60db72742fb169c470093b Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-05T09:48:55Z Refactoring the LibvirtComputingResource - Adding LibvirtBackupSnapshotCommandWrapper, LibvirtCreatePrivateTemplateFromVolumeCommandWrapper and LibvirtManageSnapshotCommandWrapper - 3 unit tests added - KVM hypervisor plugin with 18.3% coverage Less tests added to those classes because the code is quite complex and way too long. The tests added are just covering the new flow, to make sure it works fine. I will come back to those classes later. commit b3913ca1fbd3b400961608a4434cd7619cf1606d Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-05T10:53:10Z Refactoring the LibvirtComputingResource - Adding LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper - 5 unit tests added - KVM hypervisor plugin with 19.5% coverage commit 885b9e45d767d9c1e97f9f89323733446b0815f0 Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-05T11:44:52Z Renaming LibvirtConnectionWrapper to LibvirtUtilitiesHelper - Gave it a better, more suggestive, name since I now added other methods to the class. - It makes easier to mock objects and get a better coverage of the classes commit 0b1b2b6d925ec919e5b467ce5da1fc91f60673cb Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-06T05:38:51Z Refactoring the LibvirtComputingResource - Adding LibvirtCopyVolumeCommandWrapper Refactoring the LibvirtUtilitiesHelper - Changing method name Did not add any test to this commit due to the refactor mentioned abot. Will proceed and add the tests i# Please enter the commit message for your changes. Lines starting commit 7fd43f33d35fc514cc480c0e15f934e58be2cfdc Author: wilderrodrigues <wrodrig...@schubergphilis.com> Date: 2015-05-06T06:48:24Z Refactoring the LibvirtComputingResource - 5 unit tests added - KVM hypervisor plugin with 20.1% coverage ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---