mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
Remove abs eval from GET, rework spec tests to check each field.
This allows us to account for "flakiness" of the remaining return.
This commit is contained in:
parent
f95b878c8a
commit
d602057cf2
2 changed files with 11 additions and 15 deletions
|
|
@ -645,7 +645,7 @@ module Vmpooler
|
||||||
result[params[:hostname]]['state'] = 'destroyed'
|
result[params[:hostname]]['state'] = 'destroyed'
|
||||||
elsif rdata['checkout']
|
elsif rdata['checkout']
|
||||||
result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
||||||
result[params[:hostname]]['remaining'] = ((Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 - Time.now) / 60 / 60).round(2).abs
|
result[params[:hostname]]['remaining'] = ((Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60 - Time.now) / 60 / 60).round(2)
|
||||||
result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout'])
|
result[params[:hostname]]['start_time'] = Time.parse(rdata['checkout'])
|
||||||
result[params[:hostname]]['end_time'] = Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60
|
result[params[:hostname]]['end_time'] = Time.parse(rdata['checkout']) + rdata['lifetime'].to_i*60*60
|
||||||
result[params[:hostname]]['state'] = 'running'
|
result[params[:hostname]]['state'] = 'running'
|
||||||
|
|
|
||||||
|
|
@ -44,20 +44,16 @@ describe Vmpooler::API::V1 do
|
||||||
create_running_vm 'pool1', 'abcdefghijklmnop'
|
create_running_vm 'pool1', 'abcdefghijklmnop'
|
||||||
get "#{prefix}/vm/abcdefghijklmnop"
|
get "#{prefix}/vm/abcdefghijklmnop"
|
||||||
expect_json(ok = true, http = 200)
|
expect_json(ok = true, http = 200)
|
||||||
expected = {
|
response_body = (JSON.parse(last_response.body)["abcdefghijklmnop"])
|
||||||
ok: true,
|
|
||||||
abcdefghijklmnop: {
|
expect(response_body["template"]).to eq("pool1")
|
||||||
template: "pool1",
|
expect(response_body["lifetime"]).to eq(0)
|
||||||
lifetime: 0,
|
expect(response_body["running"]).to be >= 0
|
||||||
running: 0.0,
|
expect(response_body["remaining"]).to be <= 0
|
||||||
remaining: 0.0,
|
expect(response_body["start_time"]).to eq("#{current_time}")
|
||||||
start_time: "#{current_time}",
|
expect(response_body["end_time"]).to eq("#{current_time}")
|
||||||
end_time: "#{current_time}",
|
expect(response_body["state"]).to eq("running")
|
||||||
state: "running",
|
expect(response_body["ip"]).to eq("")
|
||||||
ip: ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expect(last_response.body).to match(JSON.pretty_generate(expected))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue