Previously the Pool Manager would use vSphere objects directly. This commit
- Modifies the pool_manager to use the VM provider methods instead
- Splits the destroy_vm function into two. One function spawns the thread
while the other actually does the work. This makes testing much easier.
Previously the Pool Manager would use vSphere objects directly. This commit
- Modifies the pool_manager to use the VM provider methods instead
- Splits the check_ready_vm function into two. One function spawns the thread
while the other actually does the work. This makes testing much easier.
Previously the Pool Manager would use vSphere objects directly. This commit
- Modifies the pool_manager to use the VM provider methods instead
- Modified to return true or false to indicate that the VM was failed
Previously the Pool Manager would use vSphere objects directly. This commit
- Modifies the pool_manager to use the VM provider methods instead
- Removes the open_socket method and tests as it is only required in the vSphere
VM provider
This commit creates a VM Provider test fixture for spec tests that merely uses
the Base Provider class with a name of mock_provider. This will then be used
by unit tests in further commits.
VM provisioning will be handled by VM Providers. This commit renames the use of
vsphere to provider where appropriate and changes the per-pool helper from
vsphere to providers to more accurately represent it's intended use.
Previously, the clone_vm method took various VSphere specific parameters e.g.
template folder. However in order make VMPooler less VSphere specific this
method should just take the pool configuration and then it can determine the
appropriate settings itself. This commit also moves the threading to a clone_vm
while the actual method which does the work is now _clone_vm as per all other
multithread worker methods in pool_manager. This commit also updates the spec
tests appropriately.
Previously in check_ready_vm, if the VM is powered off, the VM is moved in
redis however the function doesn't return there, and instead then checks if the
hostname is the same, and then if TCP socket 22 is open. This is unnecessary as
we already know the VM is turned off so of course the hostname is wrong and TCP
22 is unavailable. The same applies for the VM hostname.
This commit instead returns after it is found a VM is no longer ready. This
commit also amends the spec tests for the correct behaviour.
Add spec tests for check_snapshot_queue
Previously the check_snapshot_queue method would execute the loop indefinitely
as it did not have a terminating condition. This made it impossible to test.
This commit modifies the check_snapshot_queue method so that it can take a
maxloop and delay parameter so that it can be tested.
Add spec tests for check_disk_queue
Previously the check_disk_queue method would execute the loop indefinitely as it
did not have a terminating condition. This made it impossible to test. This
commit modifies the check_disk_queue method so that it can take a maxloop and
delay parameter so that it can be tested.
Add spec tests for check_pool
Previously the check_pool method would execute the loop indefinitely as it did not
have a terminating condition. This made it impossible to test. This commit
modifies the check_pool method so that it can take a maxloop and delay parameter
so that it can be tested.
Add spec tests for execute!
Previously the execute! method would execute the loop indefinitely as it did not
have a terminating condition. This made it impossible to test. This commit
modifies the execute! method so that it can take a maxloop and delay parameter
so that it can be tested.
This commit adds the following test helpers:
- MockFindFolder
Returns an mock result object from calling `Vmpooler::VsphereHelper.find_folder(foldername)`
- Use MockRedis instead of using method stubs
- MockLogger
Creates an object which looks like the VMPooler::Logger object but just
ignores all messages. This stops the proliferation of allow(logger).to ....
expectations in tests
- create_completed_vm
Creates the required redis information for a completed VM
- create_discovered_vm
Creates the required redis information for a newly discovered VM
- snapshot_revert_vm
Creates the required redis information to revert a snapshot for a VM
- disk_task_vm
Creates the required redis information to add a disk addition task to a VM
Previously all of the spec tests for VM Pooler were all together in the specs
directory. However some tests require a working local Redis server to operate
and other instead mock all external dependencies. This commit splits the test
files between unit and integration, where integration tests require a working
Redis instance, and unit tests do not. This commit also removes the root
`vmpooler` directory as it is not required. The tests rake test still operates
correctly.
This commit also adds the mock_redis library for testing for the pool_manager.