Commit graph

44 commits

Author SHA1 Message Date
Rick Sherman
b06de4bb8e (RE-7014) update statsd to use gauge for running/ready
Previously was using increment which was incorrect for that particular application.
2016-06-08 16:55:57 -05:00
Rick Sherman
c133bed945 (RE-7014) statsd nitpicks and additional rspec
Cleaned up some code review nitpicks and added pool_manager_spec for empty pool.
2016-06-08 16:55:52 -05:00
Rick Sherman
b983472088 (RE-7014) Add tracking of vm gets via statsd
Add the tracking of successful, failed, invalid, and empty pool vm gets.  It is possible we may want to tweak this, but have validated with spec tests and pcaps.

```
vmpooler-tmp-dev.ready.debian-7-x86_64:1|c
vmpooler-tmp-dev.running.debian-7-x86_64:1|c

vmpooler-tmp-dev.checkout.invalid:1|c
vmpooler-tmp-dev.checkout.success.debian-7-x86_64:1|c
vmpooler-tmp-dev.checkout.empty:1|c

vmpooler-tmp-dev.running.debian-7-x86_64:1|c

vmpooler-tmp-dev.clone.debian-7-x86_64:12.10|ms

vmpooler-tmp-dev.ready.debian-7-x86_64:1|c
```
2016-06-07 23:01:03 -05:00
Rick Sherman
8d75865a5c (RE-7014) Add support for statsd
They way we were using graphite was incorrect for the type of data we were sending it.  statsd is the appropriate mechanism for our needs.
statsd and graphite are mutually exclusive and configuring statsd will take precendence over Graphite.  Example of configuration in vmpooler.yaml.example
2016-06-02 16:24:03 -05:00
Rick Bradley
5aaab7c5c2 [QENG-3919] Make vmpooler checkouts be all or nothing (#153)
* (QENG-3919) spike for implementation of all-or-nothing checkout

* Fix two botched variable references

* Aggregate API helper methods

* Add specs for failed multi-vm allocation API endpoints

* (QENG-3919) Add tests for multiple vm requests

* (QENG-3919) Add (failing) specs for POST /vm/pool1+pool2 usages

This exposes the old (bad) behavior on this other code path. Will fix this up next.

* (QENG-3919) Bring query params version in line with JSON post version

Not clear to me why these had to be implemented so differently.

* (QENG-3919) extract common method from both methods of VM allocation

* (QENG-3919) Naming fix, cosmetic cleanups

I mean, I presume all these commits are going to get squashed away on merge anyway.

* (QENG-3919) Update API docs

We consider it a bug that the actual behavior was not this behavior, but the
documentation was also silent on this point.

* (QENG-3919) minor readability tweak in refactored method

* (QENG-3919) Clean up interim comments re: status codes

* (QENG-3919) Drop now-orphaned `checkout_vm` method

We kept this up-to-date while we were upgrading and refactoring, but, turns out,
this method is no longer called anywhere.  💀 🔥

* (QENG-3919) Return 503 status on failed allocation

Making sure we go back to the original functionality, which was:

 - status 200 when vms successfully allocated
 - status 404 when a pool name is unknown
 - status 404 when no pool name is specified
 - status 503 when vm allocation failed

* (QENG-3919) add net-ldap to Gemfile

Maybe we shouldn't foil-ball gems onto servers.

* (QENG-3919) Turns out, spush isn't a redis command

And hence we see once again the weakness of mockist tests.

* (QENG-3919) Pin the net-ldap gem to 0.11 for the jrubies, etc.

* (QENG-3919) Correct an old spelling error in spec descriptions

* (QENG-3919) Further tweak net-ldap version

* (QENG-3919) return_single_vm -> return_vm_to_ready_state

cc @shermdog
2016-05-27 12:49:57 -05:00
Scott Schneider
20fa7d20be Merge pull request #138 from sschneid/qeng_2807
(QENG-2807) Allow pool 'alias' names
2015-11-13 09:24:48 -08:00
Scott Schneider
1fcda86124 Spec tests for pool aliases, /vm/:template
This PR adds spec testing for pool 'alias' functionality introduced in
17b24d6, as well as the following previously non-existant tests:

- new tests for handling requests for a VM from a nonexistant pool
- new tests for the `POST /vm/:template` endpoint
2015-11-05 11:53:38 -08:00
Scott Schneider
d74c9ff512 Don't require username/password authentication for GET /token/:token route 2015-11-04 13:19:15 -08:00
Scott Schneider
e0356968df (QENG-2995) Display associated VMs in GET /token/:token endpoint 2015-11-04 12:35:35 -08:00
Colin
7b9b178861 (MAINT) Remove Ping Check on Running VMs
Prior to this commit, a running VM could fail a ping check and be
destroyed. This causes issues when network hiccups occur or the machine
is performing a reboot.

A VM that is in a ready state will now be destroyed when handed back or
it hits the lifetime TTL.
2015-10-02 13:03:48 -07:00
Scott Schneider
d1c8bcdbcc RSpec mocking for TCPSocket.new 2015-09-17 11:31:31 -07:00
Scott Schneider
906ae89987 Remove duplicate (nested) "ok" responses
As we approach an "official" v1.0.0 of the API I'd like to remove some old
nested "ok" responses.  These were left in as the Beaker vmpooler
hypervisor used them, but I long-ago patched that code and I think it's
time to deprecate these.
2015-08-21 13:58:07 -07:00
Scott Schneider
89ce70dba9 Track token use times
* rename the Redis token 'timestamp' var to 'created'
* update the Redis token 'last' var when token is successfully validataed
* expose the Redis token 'last' var in GET /token route
2015-08-20 19:54:59 -07:00
Scott Schneider
e4f2777889 Spec tests for GET /token 2015-08-20 18:50:55 -07:00
Scott Schneider
47deddcc46 Split API spec into /token and /token/:token 2015-08-20 18:50:55 -07:00
Scott Schneider
3c3172615b Merge pull request #120 from colinPL/main_less_redis
(MAINT) Reduce redis Calls in API
2015-08-03 09:42:16 -07:00
Scott Schneider
2d514f53bf Use expect_json helper method for determining JSON response status 2015-07-28 14:54:28 -07:00
Colin
acb95d34c8 (MAINT) Reduce redis Calls in API
The return values from most redis calls inform the caller of whether a
key or hash value exists. Several exists() calls can be removed in
favor of this approach.

Updated spec tests to account for a removal of exists() and ismember()
calls in API tests.
2015-07-28 14:47:01 -07:00
Scott Schneider
add88c7bba (QENG-1304) vmpooler should require an auth key for VM destruction 2015-07-28 12:03:14 -07:00
Scott Schneider
1689133b19 Require an auth token to use snapshots 2015-07-16 10:59:30 -07:00
Scott Schneider
fe65d5b11b Merge branch 'master' into host_snapshots 2015-07-16 10:42:16 -07:00
Scott Schneider
93acc8327b Host snapshot rspec tests 2015-07-16 10:35:44 -07:00
Scott Schneider
821ffd866a Log empty pools
Make a note in the logfile when a pool is detected to be empty.

Also:

- vmpooler__empty__<pool> Redis key to determine when to log
- lifetime/TTL checks moved to `_check_running_vm` method
  - no longer pay attention to VMware-based 'host.runtime.bootTime'

This PR implements a bunch of other stuff to account for rspec testing:

- Thread creation and looping in `check_pool`
- Everything else in `_check_pool`
2015-07-07 11:12:46 -07:00
Scott Schneider
6523062b62 Allow for only a [configurable] tag set 2015-06-30 12:54:46 -07:00
Scott Schneider
3aa8389749 Discard/skip empty tags 2015-06-30 11:20:13 -07:00
Scott Schneider
1f62379be8 Only filter regex matches
and a spec test for it.

Previously using the example shown in vmpooler.yaml.example was failing
to tag strings WITHOUT a '/' in them.
2015-06-02 19:12:30 -07:00
Scott Schneider
60819b9a7e Spec tests for tagfilter 2015-06-02 10:53:20 -07:00
Roger Ignazio
ae91077494 Merge pull request #104 from colinPL/qeng_2360
(QENG-2360) check_running_vm Spec Tests
2015-05-19 15:06:46 -07:00
Colin
dec95ba693 (QENG-2360) check_running_vm Spec Tests
Add spec tests for pool_manager#check_running_vm. In the process of
writing these tests, the method was broken in to smaller methods for
testability reasons.
2015-05-19 10:23:31 -07:00
Scott Schneider
c255494ddd Add spec tests for #get_tag_metrics method 2015-05-12 10:09:57 -07:00
Scott Schneider
7bddfdef1b Store token metadata in vmpooler__vm__ Redis hash 2015-04-30 19:29:18 -07:00
Scott Schneider
13df748cc6 Add basic auth token functionality
...and rspec tests, hooray!
2015-04-28 10:47:57 -07:00
Roger Ignazio
8cd49d215b Merge pull request #97 from sschneid/basic_auth
Add basic HTTP authentication and /token routes
2015-04-22 11:39:24 -07:00
Scott Schneider
bad1ce65a1 Spec tests for /token routes 2015-04-21 17:12:36 -07:00
Colin
bc5c3a889f (QENG-2208) Add more helper tests
Add tests for more Helper methods. This moves line coverage to 59%,
leaving only get_task_metrics remaining.
2015-04-15 14:00:13 -07:00
Colin
ab990e2081 (QENG-2208) Move Sinatra Helpers to own file
This moves the inline Helpers contained in V1.rb to their own file:
helpers.rb. In making this change, any API.settings call was removed
from the helper method itself and passed through from V1.

This also adds tests for hostname shortener and validate date string.
2015-04-15 12:44:12 -07:00
Scott Schneider
b9124b9a22 Fix rspec tests broken in f9de28236b 2015-04-10 10:28:52 -07:00
Scott Schneider
6224a20792 Add spec tests for dashboard redirect 2015-04-10 10:13:24 -07:00
Colin
6cd56f40ee Merge pull request #89 from sschneid/remove_janitor_expire_via_redis
Auto-expire Redis metadata key via Redis EXPIRE
2015-04-07 15:57:17 -07:00
Scott Schneider
4878799374 Merge pull request #88 from colinPL/qeng_1906_sinatra
(QENG-1906) Add specs for Dashboard and root API class
2015-04-07 11:15:14 -07:00
Scott Schneider
f9de28236b Auto-expire Redis metadata key via Redis EXPIRE
This commit also removed the unnecessary Vmpooler::Janitor lib
2015-04-07 11:01:37 -07:00
Colin
97879339b5 (QENG-1906) Add specs for Dashboard and root API class
Add spec tests for Sinatra powered Dashboard piece. This includes tests
for the homepage (/) and a nonexistent route.
2015-04-02 13:39:11 -07:00
Colin
e6ee6b1257 (QENG-1906) Break apart check_pending_vm and add spec tests
This commit breaks apart the method check_pending_vm in to three,
smaller methods that are easier to test. There are no functionality
changes or bug fixes.

This adds spec tests for the overall functionality that was
check_pending_vm.
2015-04-01 15:42:28 -07:00
Colin
d0275f5fba (QENG-1906) Add spec tests for Janitor
Add spec tests to verify Janitor deletes stale vms correctly. This
required a small refactor of Janitor to move the logic out of the for
loop.
2015-03-31 10:21:24 -07:00