(POOLER-81) Add time_remaining information (#276)

* (POOLER-81) Add time_remaining information

Before, the only time calculation displayed for a given VM was the
lifetime parameter. Added the time_remaining parameter which will
display time until the VM is destroyed in hours, minutes, seconds.

Additionally, updated the running parameter to display in a similar
fashion as time_remaining.

* Add spec testing for testing time_remaining stat
This commit is contained in:
Spencer McElmurry 2018-07-09 16:22:05 -07:00 committed by mattkirby
parent f27e2c1301
commit 1910cffaf7
2 changed files with 24 additions and 1 deletions

View file

@ -39,6 +39,26 @@ describe Vmpooler::API::V1 do
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)
end
describe 'GET /vm/:hostname' do
it 'returns correct information on a running vm' do
create_running_vm 'pool1', 'abcdefghijklmnop'
get "#{prefix}/vm/abcdefghijklmnop"
expect_json(ok = true, http = 200)
expected = {
ok: true,
abcdefghijklmnop: {
template: "pool1",
lifetime: 0,
running: "00h 00m ..s",
time_remaining: "00h ..m ..s",
state: "running",
ip: ""
}
}
expect(last_response.body).to match(JSON.pretty_generate(expected))
end
end
describe 'POST /vm' do
it 'returns a single VM' do
create_ready_vm 'pool1', 'abcdefghijklmnop'