Skip to content

Commit

Permalink
Merge pull request #105 from puppetlabs/dont-require-vmfloaty.yml-list
Browse files Browse the repository at this point in the history
(maint) Don't require config file for list --active
  • Loading branch information
genebean authored Oct 9, 2020
2 parents 221f6c1 + 6deadb2 commit 3ce0222
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/vmfloaty/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def self.pretty_print_hosts(verbose, service, hostnames = [], print_to_stderr =

output_target.puts "- [JobID:#{host_data['request']['job']['id']}] <#{host_data['state']}>"
host_data['allocated_resources'].each do |allocated_resources, _i|
if allocated_resources['engine'] == "vmpooler"
if allocated_resources['engine'] == "vmpooler" && service.config["vmpooler_fallback"]
vmpooler_service = service.clone
vmpooler_service.silent = true
vmpooler_service.maybe_use_vmpooler
Expand Down
19 changes: 17 additions & 2 deletions spec/vmfloaty/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
require 'commander/command'
require_relative '../../lib/vmfloaty/utils'

# allow changing config in service for tests
class Service
attr_writer :config
end

describe Utils do
describe '#standardize_hostnames' do
before :each do
Expand Down Expand Up @@ -441,7 +446,7 @@
end

let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
let(:default_output_second_line) { " - #{fqdn} (#{template}, 7.67/48 hours, user: bob, role: agent)" }
let(:default_output_second_line) { " - #{fqdn} (#{template})" }

it 'prints output with job id, host, and template' do
expect(STDOUT).to receive(:puts).with(default_output_first_line)
Expand All @@ -450,6 +455,16 @@
subject
end

it 'prints more information when vmpooler_fallback is set output with job id, host, template, lifetime, user and role' do
fallback = {'vmpooler_fallback' => 'vmpooler'}
service.config.merge! fallback
default_output_second_line=" - #{fqdn} (#{template}, 7.67/48 hours, user: bob, role: agent)"
expect(STDOUT).to receive(:puts).with(default_output_first_line)
expect(STDOUT).to receive(:puts).with(default_output_second_line)

subject
end

context 'when print_to_stderr option is true' do
let(:print_to_stderr) { true }

Expand Down Expand Up @@ -529,7 +544,7 @@
end

let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
let(:default_output_second_line) { " - #{fqdn} (#{template}, 7.67/48 hours, user: bob, role: agent)" }
let(:default_output_second_line) { " - #{fqdn} (#{template})" }
let(:default_output_third_line) { " - #{fqdn_ns} (#{template_ns})" }

it 'prints output with job id, host, and template' do
Expand Down

0 comments on commit 3ce0222

Please sign in to comment.