Commit graph

722 commits

Author SHA1 Message Date
Glenn Sarti
f433056734 (GH-185) Remove unnecessary checks in check_ready_vm
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.
2017-03-01 20:28:36 -08:00
Rob Braden
0754f86d8c Merge pull request #182 from glennsarti/ticket/master/POOLER-73-add-unit-tests
(POOLER-73) Update unit tests prior to refactoring
2017-03-01 17:54:38 -08:00
Rob Braden
dbd16ebc8c Merge pull request #187 from glennsarti/fix-rakefile-for-ruby
(maint) Only load rubocop rake tasks if gem is available
2017-02-28 15:12:46 -08:00
Glenn Sarti
f486129eab (maint) Only load rubocop rake tasks if gem is available
Previously in commit 145ecb443f Rakefile was modified to require the Rubocop
gem however, this gem is not available on jruby systems and would throw errors.
This commit modifies the Rakefile to first detect if the Gem is available and
optionally load the rubocop rake tasks.
2017-02-22 15:23:45 -08:00
Ryan McKern
145ecb443f Merge pull request #183 from glennsarti/add-rubocop
(maint) Add rubocop and allow failures in Travis CI
2017-02-21 16:10:17 -08:00
Glenn Sarti
e783e93784 (POOLER-73) Modify spec tests for _migrate_vm
Modify spec tests for _migrate_vm
2017-02-17 15:51:05 -08:00
Glenn Sarti
c69d61107f (POOLER-73) Modify spec tests for _revert_vm_snapshot
Modify spec tests for _revert_vm_snapshot
2017-02-17 15:51:05 -08:00
Glenn Sarti
b63822fa9f (POOLER-73) Modify spec tests for _create_vm_snapshot
Modify spec tests for _create_vm_snapshot
2017-02-17 15:51:05 -08:00
Glenn Sarti
0a6dffbd05 (POOLER-73) Add spec tests for _create_vm_disk
Add spec tests for _create_vm_disk
2017-02-17 15:51:05 -08:00
Glenn Sarti
3083186241 (POOLER-73) Add spec tests for _check_disk_queue
Add spec tests for _check_disk_queue
2017-02-17 15:51:05 -08:00
Glenn Sarti
25ad5d58f7 (POOLER-73) Add spec tests for _check_snapshot_queue
Add spec tests for _check_snapshot_queue
2017-02-17 15:51:05 -08:00
Glenn Sarti
6f127d32bc (POOLER-73) Add spec tests for check_snapshot_queue
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.
2017-02-17 15:51:05 -08:00
Glenn Sarti
4dd0c96a78 (POOLER-73) Add spec tests for check_disk_queue
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.
2017-02-17 15:51:04 -08:00
Glenn Sarti
47d597f68a (POOLER-73) Add spec tests for migrate_vm_and_record_timing
Add spec tests for migrate_vm_and_record_timing
2017-02-17 15:51:04 -08:00
Glenn Sarti
fb6be8e079 (POOLER-73) Add spec tests for remove_vmpooler_migration_vm
Add spec tests for remove_vmpooler_migration_vm
2017-02-17 15:51:04 -08:00
Glenn Sarti
a4c55d5bf4 (POOLER-73) Add spec tests for migration_limit
Add spec tests for migration_limit
2017-02-17 15:51:04 -08:00
Glenn Sarti
925071be79 (POOLER-73) Add spec tests for migrate_vm
Add spect tests for migrate_vm
2017-02-17 15:51:04 -08:00
Glenn Sarti
713e202d68 (POOLER-73) Add spec tests for revert_vm_snapshot
Add spec tests for revert_vm_snapshot
2017-02-17 15:51:04 -08:00
Glenn Sarti
e6be5bfb75 (POOLER-73) Add spec tests for create_vm_snapshot
Add spec tests for create_vm_snapshot
2017-02-17 15:51:04 -08:00
Glenn Sarti
6f79c438c7 (POOLER-73) Add spec tests for create_vm_disk
Add spec tests for create_vm_disk
2017-02-17 15:51:04 -08:00
Glenn Sarti
943d3025d1 (POOLER-73) Remove #_stats_running_ready tests
This commit removes the #_stats_running_ready tests as they are covered in the
_check_pool tests.
2017-02-17 15:51:04 -08:00
Glenn Sarti
15d4dfa64a (POOLER-73) Add spec tests for _check_pool
Add spec tests for _check_pool
2017-02-17 15:51:04 -08:00
Glenn Sarti
64d2d95ab3 (POOLER-73) Remove #move_running_to_completed tests
The tests for #move_running_to_completed are already tested in the
2017-02-17 15:51:03 -08:00
Glenn Sarti
daad5c7086 (POOLER-73) Add spec tests for check_pool
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.
2017-02-17 15:51:03 -08:00
Glenn Sarti
5e46ace584 (POOLER-73) Add spec tests for execute!
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.
2017-02-17 15:51:03 -08:00
Glenn Sarti
e342cfe56a (POOLER-73) Add spec tests for get_vm_host_info
Add spec tests for get_vm_host_info
2017-02-17 15:51:03 -08:00
Glenn Sarti
14c091383c (POOLER-73) Add spec tests for destroy_vm
Add spec tests for destroy_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
434ab546a2 (POOLER-73) Add spec tests for clone_vm
Add spec tests for clone_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
9d8b792c4a (POOLER-73) Add spec tests for move_vm_queue
Add spec tests for move_vm_queue
2017-02-17 15:51:03 -08:00
Glenn Sarti
cb4e1400aa (POOLER-73) Modify spec tests for _check_running_vm
Modify spec tests for _check_running_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
58175dec47 (POOLER-73) Add spec tests for check_running_vm
Add spec tests for check_running_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
2475f55103 (POOLER-73) Add spec tests for check_ready_vm
Add spec tests for check_ready_vm
2017-02-17 15:51:03 -08:00
Glenn Sarti
8ae6b29be3 (POOLER-73) Modify spec tests for move_pending_vm_to_ready
Modify spec tests for move_pending_vm_to_ready
2017-02-17 15:51:02 -08:00
Glenn Sarti
4b2ca49e02 (POOLER-73) Modify spec tests for fail_pending_vm
Modify spec tests for fail_pending_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
b5ec74bae9 (POOLER-73) Add spec tests for remove_nonexistent_vm
Add spec tests for remove_nonexistent_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
9fdb51eb00 (POOLER-73) Modify spec tests for _check_pending_vm
(POOLER-73) Modify spec tests for _check_pending_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
b72275b552 (POOLER-73) Add spec tests for open_socket
Add spec tests for open_socket
2017-02-17 15:51:02 -08:00
Glenn Sarti
af9ec66b78 (POOLER-73) Add spec tests for check_pending_vm
Add spec tests for check_pending_vm
2017-02-17 15:51:02 -08:00
Glenn Sarti
a9fc1bb8aa (POOLER-73) Update test helpers
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
2017-02-17 15:51:02 -08:00
Glenn Sarti
8bcf74872a (POOLER-73) Restructure tests to unit and integration directories
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.
2017-02-17 13:04:38 -08:00
Glenn Sarti
36310e381a (maint) Add rubocop checks to Travis
This commit adds rubocop checks to Travis for PR CI.  Any rubocop failures will
not fail the build yet.  Fixes for rubocop violations will happen in later
commits.
2017-02-10 13:33:36 -08:00
Glenn Sarti
85a2fa4f20 (maint) Add rubocop for testing
This commit adds the rubocop gem, a rubocop rake task and an initial rubocop
configuration file in prepartion for using rubocop in CI.

This commit also adds a rubocop todo file that exempts existing files from
violations.
2017-02-10 13:33:36 -08:00
Rob Braden
d67db2d380 Merge pull request #180 from glennsarti/ticket/maint/add-dummy-auth
(POOLER-71) Add dummy authentication provider
2017-02-09 16:44:26 -08:00
Ryan McKern
eb67ccad5a (POOLER-71) dummy auth only works in debug mode
If a user attempts to start vmpooler using dummy authentication
without setting the environment variable VMPOOLER_DEBUG, the vmpooler
will now refuse to start.
2017-02-09 16:27:10 -08:00
Glenn Sarti
2c74f4fa3a (POOLER-71) Add dummy authentication provider
Previously it was difficult to do local development as VMPooler requires an LDAP
service for authentication. This commit adds a dummy authentication provider.
The provider has passes authentication if the username and password are
different, and fails if the username and password are the same.  This commit
also updates the documentation in the config YML file.
2017-02-09 16:23:10 -08:00
Rick Sherman
71a5af9e88 Merge pull request #177 from glennsarti/ticket/maint/update-pooler-dev
(maint) Enhance VM Pooler developer experience
2017-02-09 14:38:39 -06:00
Glenn Sarti
8f294c055e (maint) Enable Ctrl-C to kill all threads in developer environment
Previously, if you ran the vpooler via ruby, pressing Ctrl-C would terminate the
Webserver however the PoolManager does not have a handler and would instead
just keep executing.  This commit adds a global Ctrl-C hook which terminates
both the api and manager threads.  This behaviour will only be enabled if the
`VMPOOLER_DEBUG` environment variable exists so that it does not affect VMPooler
when running in production environments.
2017-02-08 17:35:58 -08:00
Glenn Sarti
80c0742e80 (maint) Update Gemfile and gitignore
Previously, a bundle install would not pull in gems from Gemfile.local or
~/.gemfile which are common development workflows in Puppet.  This commit
modifies the Gemfile to pull in these additional gemfiles if they exist.  This
commit also adds common files and folders to gitignore which should not be
committed to this repository.
2017-02-08 17:35:58 -08:00
Michael Stahnke
1fa1909986 Merge pull request #178 from glennsarti/master
(maint) Remove Ruby 1.9.3 testing from Travis
2017-01-31 17:12:17 -06:00
Glenn Sarti
926eb47940 (maint) Remove Ruby 1.9.3 testing from Travis
Ruby 1.9.3 is end of life, and now longer bundles due to later Nokogiri 1.7.0.1
requiring Ruby 2.1 or above.  This commit removes ruby 1.9.3 from Travis
testing.
2017-01-24 14:59:14 -08:00