Previously, all calls to the vSphere API assumed an instance variable called
`@connection`. This commit prepares the provider for a connection pooler:
- Removes all references to `@connection` where needed and funnels all calls to
get a vSphere connection through the newly renamed method `get_connection`.
For the moment, this still uses `@connection` behind the scenes but will make
it easier in the future to migrate to a connection pooler
- Removes all references and tests for the ensure_connected method as it's no
longer required
- All methods that explicitly need a connection object will have this as part of
the method parameters
- The connect_to_vsphere method has been changed so that instead of setting the
instance level `@connection` object it just returns the newly created connection.
This can then be easily consumed by a connection pooler later.
Previously, the vSphere Provider had two methods called
`find_least_used_compatible_host`: one in the base class and one in the vSphere
helper methods. This commit renames the vSphere helper methods and tests to
`find_least_used_vsphere_compatible_host` to stop the conflict.
Previously there were no spec tests to document the behaviour of the
vsphere_helper. This commit adds the behavioural spec tests in prepration of
the refactoring work as part of POOLER-70, the connection pooling work in
POOLER-52 and various bugs found in vsphere_helper while these spec tests were
being created.
This commit fixes minor rubocopy violations in eleven source files. Minor
violations are those that include formatting, single quotes, and recently added
classes.
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 all of the VM provisioning code was intertwined with the VM lifecycle
code e.g. The VSphere specific code is mixed with Redis code. This makes it
impossible to add aditional providers or disable VSphere integration. This
commit begins the process to refactor the VSphere code out of the lifecycle code
by introducing the concept of VM Providers. A Provider will contain the logic/
code to manage VMs i.e. create/destroy/inquire. Therefore the Pool Manager can
query a strict interface into one or more Providers. Initially only a VSphere
provider will be available.
This commit adds the base class for all providers and describes the API or
contract that the Pool Manager will use to manage VMs.
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.