mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Adding delete and get active requests
This commit is contained in:
parent
7e27542670
commit
d963e357d3
9 changed files with 109 additions and 75 deletions
|
|
@ -36,25 +36,25 @@ describe ABS do
|
|||
end
|
||||
|
||||
it 'won\'t delete a job if not all vms are listed' do
|
||||
hosts = ["host1"]
|
||||
hosts = ['host1']
|
||||
allocated_resources = [
|
||||
{
|
||||
"hostname" => "host1"
|
||||
'hostname' => 'host1',
|
||||
},
|
||||
{
|
||||
"hostname" => "host2"
|
||||
}
|
||||
'hostname' => 'host2',
|
||||
},
|
||||
]
|
||||
expect(ABS.all_job_resources_accounted_for(allocated_resources, hosts)).to eq(false)
|
||||
|
||||
hosts = ["host1", "host2"]
|
||||
hosts = ['host1', 'host2']
|
||||
allocated_resources = [
|
||||
{
|
||||
"hostname" => "host1"
|
||||
'hostname' => 'host1',
|
||||
},
|
||||
{
|
||||
"hostname" => "host2"
|
||||
}
|
||||
'hostname' => 'host2',
|
||||
},
|
||||
]
|
||||
expect(ABS.all_job_resources_accounted_for(allocated_resources, hosts)).to eq(true)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ describe NonstandardPooler do
|
|||
@token_status_body_active = <<~BODY
|
||||
{
|
||||
"ok": true,
|
||||
"user": 'first.last',
|
||||
"user": "first.last",
|
||||
"created": "2017-09-18 01:25:41 +0000",
|
||||
"last_accessed": "2017-09-21 19:46:25 +0000",
|
||||
"reserved_hosts": ["sol10-9", "sol10-11"]
|
||||
|
|
@ -75,7 +75,7 @@ describe NonstandardPooler do
|
|||
@token_status_body_empty = <<~BODY
|
||||
{
|
||||
"ok": true,
|
||||
"user": 'first.last',
|
||||
"user": "first.last",
|
||||
"created": "2017-09-18 01:25:41 +0000",
|
||||
"last_accessed": "2017-09-21 19:46:25 +0000",
|
||||
"reserved_hosts": []
|
||||
|
|
@ -88,7 +88,7 @@ describe NonstandardPooler do
|
|||
.with(false, @nspooler_url, 'token-value')
|
||||
.and_return(JSON.parse(@token_status_body_active))
|
||||
|
||||
list = NonstandardPooler.list_active(false, @nspooler_url, 'token-value')
|
||||
list = NonstandardPooler.list_active(false, @nspooler_url, 'token-value', 'user')
|
||||
expect(list).to eql ['sol10-9', 'sol10-11']
|
||||
end
|
||||
end
|
||||
|
|
@ -125,7 +125,7 @@ describe NonstandardPooler do
|
|||
.to_return(:status => 401, :body => '{"ok":false,"reason": "token: token-value does not exist"}', :headers => {})
|
||||
|
||||
vm_hash = { 'solaris-11-sparc' => 1 }
|
||||
expect { NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last') }.to raise_error(AuthError)
|
||||
expect { NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {}) }.to raise_error(AuthError)
|
||||
end
|
||||
|
||||
it 'retrieves a single vm with a token' do
|
||||
|
|
@ -134,7 +134,7 @@ describe NonstandardPooler do
|
|||
.to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {})
|
||||
|
||||
vm_hash = { 'solaris-11-sparc' => 1 }
|
||||
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last')
|
||||
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {})
|
||||
expect(vm_req).to be_an_instance_of Hash
|
||||
expect(vm_req['ok']).to equal true
|
||||
expect(vm_req['solaris-11-sparc']['hostname']).to eq 'sol11-4.delivery.puppetlabs.net'
|
||||
|
|
@ -146,7 +146,7 @@ describe NonstandardPooler do
|
|||
.to_return(:status => 200, :body => @retrieve_response_body_many, :headers => {})
|
||||
|
||||
vm_hash = { 'aix-7.1-power' => 1, 'solaris-10-sparc' => 2 }
|
||||
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last')
|
||||
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {})
|
||||
expect(vm_req).to be_an_instance_of Hash
|
||||
expect(vm_req['ok']).to equal true
|
||||
expect(vm_req['solaris-10-sparc']['hostname']).to be_an_instance_of Array
|
||||
|
|
@ -246,7 +246,7 @@ describe NonstandardPooler do
|
|||
"sol10-11": {
|
||||
"fqdn": "sol10-11.delivery.puppetlabs.net",
|
||||
"os_triple": "solaris-10-sparc",
|
||||
"reserved_by_user": 'first.last',
|
||||
"reserved_by_user": "first.last",
|
||||
"reserved_for_reason": "testing",
|
||||
"hours_left_on_reservation": 29.12
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ describe Pooler do
|
|||
|
||||
vm_hash = {}
|
||||
vm_hash['debian-7-i386'] = 1
|
||||
expect { Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url) }.to raise_error(AuthError)
|
||||
expect { Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url, 'user', {}) }.to raise_error(AuthError)
|
||||
end
|
||||
|
||||
it 'retrieves a single vm with a token' do
|
||||
|
|
@ -63,7 +63,7 @@ describe Pooler do
|
|||
|
||||
vm_hash = {}
|
||||
vm_hash['debian-7-i386'] = 1
|
||||
vm_req = Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url)
|
||||
vm_req = Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url, 'user', {})
|
||||
expect(vm_req).to be_an_instance_of Hash
|
||||
expect(vm_req['ok']).to equal true
|
||||
expect(vm_req['debian-7-i386']['hostname']).to eq 'fq6qlpjlsskycq6'
|
||||
|
|
@ -77,7 +77,7 @@ describe Pooler do
|
|||
vm_hash = {}
|
||||
vm_hash['debian-7-i386'] = 2
|
||||
vm_hash['centos-7-x86_64'] = 1
|
||||
vm_req = Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url)
|
||||
vm_req = Pooler.retrieve(false, vm_hash, 'mytokenfile', @vmpooler_url, 'user', {})
|
||||
expect(vm_req).to be_an_instance_of Hash
|
||||
expect(vm_req['ok']).to equal true
|
||||
expect(vm_req['debian-7-i386']['hostname']).to be_an_instance_of Array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue