(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
This commit is contained in:
Rick Bradley 2016-05-26 11:58:48 -05:00
parent 8943ff4935
commit c4cac5b0c5
2 changed files with 13 additions and 12 deletions

View file

@ -104,6 +104,7 @@ module Vmpooler
if failed if failed
vms.each do |(template, vm)| vms.each do |(template, vm)|
return_single_vm(template, vm) return_single_vm(template, vm)
status 503
end end
else else
vms.each do |(template, vm)| vms.each do |(template, vm)|

View file

@ -311,7 +311,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'returns any checked out vms to their pools when not all requested vms can be allocated' do it 'returns any checked out vms to their pools when not all requested vms can be allocated' do
@ -324,7 +324,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'fails when not all requested vms can be allocated, when requesting multiple instances from a pool' do it 'fails when not all requested vms can be allocated, when requesting multiple instances from a pool' do
@ -337,7 +337,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from a pool' do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from a pool' do
@ -350,7 +350,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'fails when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do it 'fails when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do
@ -363,7 +363,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do
@ -376,7 +376,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
context '(auth not configured)' do context '(auth not configured)' do
@ -577,7 +577,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'returns any checked out vms to their pools when not all requested vms can be allocated' do it 'returns any checked out vms to their pools when not all requested vms can be allocated' do
@ -590,7 +590,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'fails when not all requested vms can be allocated, when requesting multiple instances from a pool' do it 'fails when not all requested vms can be allocated, when requesting multiple instances from a pool' do
@ -603,7 +603,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from a pool' do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from a pool' do
@ -616,7 +616,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'fails when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do it 'fails when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do
@ -629,7 +629,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do
@ -642,7 +642,7 @@ describe Vmpooler::API::V1 do
expected = { ok: false } expected = { ok: false }
expect(last_response.body).to eq(JSON.pretty_generate(expected)) expect(last_response.body).to eq(JSON.pretty_generate(expected))
expect_json(ok = false, http = 200) expect_json(ok = false, http = 503)
end end
context '(auth not configured)' do context '(auth not configured)' do