diff --git a/lib/vmfloaty/utils.rb b/lib/vmfloaty/utils.rb index a569415..5a2775b 100644 --- a/lib/vmfloaty/utils.rb +++ b/lib/vmfloaty/utils.rb @@ -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 diff --git a/spec/vmfloaty/utils_spec.rb b/spec/vmfloaty/utils_spec.rb index e26e0f1..a90d3b1 100644 --- a/spec/vmfloaty/utils_spec.rb +++ b/spec/vmfloaty/utils_spec.rb @@ -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 @@ -441,7 +446,7 @@ end let(:default_output_first_line) { "- [JobID:#{hostname}] " } - 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) @@ -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 } @@ -529,7 +544,7 @@ end let(:default_output_first_line) { "- [JobID:#{hostname}] " } - 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