mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Fix spec tests for ABS pretty print
ABS now returns the ABS job_id on the first line, then every vmpooler hostname indented. It queries them from vmpooler to get the metadata like lifetime etc
This commit is contained in:
parent
8546c1c4b6
commit
45f0ef031e
1 changed files with 29 additions and 3 deletions
|
|
@ -387,6 +387,7 @@ describe Utils do
|
||||||
|
|
||||||
let(:hostname) { '1597952189390' }
|
let(:hostname) { '1597952189390' }
|
||||||
let(:fqdn) { 'example-noun.delivery.puppetlabs.net' }
|
let(:fqdn) { 'example-noun.delivery.puppetlabs.net' }
|
||||||
|
let(:fqdn_hostname) {'example-noun'}
|
||||||
let(:template) { 'ubuntu-1604-x86_64' }
|
let(:template) { 'ubuntu-1604-x86_64' }
|
||||||
|
|
||||||
# This seems to be the miminal stub response from ABS for the current output
|
# This seems to be the miminal stub response from ABS for the current output
|
||||||
|
|
@ -410,17 +411,41 @@ describe Utils do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:default_output) { "- [JobID:#{hostname}] #{fqdn} (#{template}) <allocated>" }
|
# The vmpooler response contains metadata that is printed
|
||||||
|
let(:domain) { 'delivery.mycompany.net' }
|
||||||
|
let(:response_body_vmpooler) do
|
||||||
|
{
|
||||||
|
fqdn_hostname => {
|
||||||
|
'template' => 'redhat-7-x86_64',
|
||||||
|
'lifetime' => 48,
|
||||||
|
'running' => 7.67,
|
||||||
|
'state' => 'running',
|
||||||
|
'tags' => {
|
||||||
|
'user' => 'bob',
|
||||||
|
'role' => 'agent',
|
||||||
|
},
|
||||||
|
'ip' => '127.0.0.1',
|
||||||
|
'domain' => domain,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
allow(Utils).to receive(:get_vmpooler_service_config).and_return({
|
allow(Utils).to receive(:get_vmpooler_service_config).and_return({
|
||||||
'url' => 'http://vmpooler.example.com',
|
'url' => 'http://vmpooler.example.com',
|
||||||
'token' => 'krypto-knight'
|
'token' => 'krypto-knight'
|
||||||
})
|
})
|
||||||
|
allow(service).to receive(:query)
|
||||||
|
.with(anything, fqdn_hostname)
|
||||||
|
.and_return(response_body_vmpooler)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
|
||||||
|
let(:default_output_second_line) { " - example-noun.delivery.mycompany.net (redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)" }
|
||||||
|
|
||||||
it 'prints output with job id, host, and template' do
|
it 'prints output with job id, host, and template' do
|
||||||
expect(STDOUT).to receive(:puts).with(default_output)
|
expect(STDOUT).to receive(:puts).with(default_output_first_line)
|
||||||
|
expect(STDOUT).to receive(:puts).with(default_output_second_line)
|
||||||
|
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
@ -429,7 +454,8 @@ describe Utils do
|
||||||
let(:print_to_stderr) { true }
|
let(:print_to_stderr) { true }
|
||||||
|
|
||||||
it 'outputs to stderr instead of stdout' do
|
it 'outputs to stderr instead of stdout' do
|
||||||
expect(STDERR).to receive(:puts).with(default_output)
|
expect(STDERR).to receive(:puts).with(default_output_first_line)
|
||||||
|
expect(STDERR).to receive(:puts).with(default_output_second_line)
|
||||||
|
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue