(QENG-7604) Add support for Job IDs to ABS delete

This commit adds support for passing in a JobID when deleting with ABS.
This commit is contained in:
Brandon High 2020-01-17 15:12:22 -08:00
parent d6a69d08ac
commit 51a7eb809e
No known key found for this signature in database
GPG key ID: 270079C784FCAFDE
3 changed files with 40 additions and 3 deletions

View file

@ -65,14 +65,14 @@ describe ABS do
describe '#test_abs_status_queue_endpoint' do
before :each do
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
@active_requests_response = '
[
"{ \"state\":\"allocated\",\"last_processed\":\"2019-12-16 23:00:34 +0000\",\"allocated_resources\":[{\"hostname\":\"take-this.delivery.puppetlabs.net\",\"type\":\"win-2012r2-x86_64\",\"engine\":\"vmpooler\"}],\"audit_log\":{\"2019-12-13 16:45:29 +0000\":\"Allocated take-this.delivery.puppetlabs.net for job 1576255517241\"},\"request\":{\"resources\":{\"win-2012r2-x86_64\":1},\"job\":{\"id\":\"1576255517241\",\"tags\":{\"user\":\"test-user\"},\"user\":\"test-user\",\"time-received\":1576255519},\"priority\":1}}",
"null",
"{\"state\":\"allocated\",\"last_processed\":\"2019-12-16 23:00:34 +0000\",\"allocated_resources\":[{\"hostname\":\"not-this.delivery.puppetlabs.net\",\"type\":\"win-2012r2-x86_64\",\"engine\":\"vmpooler\"}],\"audit_log\":{\"2019-12-13 16:46:14 +0000\":\"Allocated not-this.delivery.puppetlabs.net for job 1576255565159\"},\"request\":{\"resources\":{\"win-2012r2-x86_64\":1},\"job\":{\"id\":\"1576255565159\",\"tags\":{\"user\":\"not-test-user\"},\"user\":\"not-test-user\",\"time-received\":1576255566},\"priority\":1}}"
]'
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength
@token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y'
@test_user = 'test-user'
end
@ -92,5 +92,35 @@ describe ABS do
)
end
end
describe '#test_abs_delete_jobid' do
before :each do
# rubocop:disable Layout/LineLength
@active_requests_response = '
[
"{ \"state\":\"allocated\", \"last_processed\":\"2020-01-17 22:29:13 +0000\", \"allocated_resources\":[{\"hostname\":\"craggy-chord.delivery.puppetlabs.net\", \"type\":\"centos-7-x86_64\", \"engine\":\"vmpooler\"}, {\"hostname\":\"visible-revival.delivery.puppetlabs.net\", \"type\":\"centos-7-x86_64\", \"engine\":\"vmpooler\"}], \"audit_log\":{\"2020-01-17 22:28:45 +0000\":\"Allocated craggy-chord.delivery.puppetlabs.net, visible-revival.delivery.puppetlabs.net for job 1579300120799\"}, \"request\":{\"resources\":{\"centos-7-x86_64\":2}, \"job\":{\"id\":\"1579300120799\", \"tags\":{\"user\":\"test-user\"}, \"user\":\"test-user\", \"time-received\":1579300120}, \"priority\":3}}"
]'
@return_request = { '{"job_id":"1579300120799","hosts":{"hostname":"craggy-chord.delivery.puppetlabs.net","type":"centos-7-x86_64","engine":"vmpooler"},{"hostname":"visible-revival.delivery.puppetlabs.net","type":"centos-7-x86_64","engine":"vmpooler"}}'=>true }
# rubocop:enable Layout/LineLength
@token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y'
@test_user = 'test-user'
# Job ID
@hosts = ['1579300120799']
end
it 'will delete the whole job' do
stub_request(:get, 'https://abs.example.com/status/queue')
.to_return(:status => 200, :body => @active_requests_response, :headers => {})
stub_request(:post, 'https://abs.example.com/return')
.with(:body => @return_request)
.to_return(:status => 200, :body => 'OK', :headers => {})
ret = ABS.delete(false, @abs_url, @hosts, @token, @test_user)
expect(ret).to include(
'craggy-chord.delivery.puppetlabs.net' => { 'ok'=>true }, 'visible-revival.delivery.puppetlabs.net' => { 'ok'=>true },
)
end
end
end
end