From 3a60ffbdbd58daaa964c4b62bfa92e991681090c Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Thu, 24 Sep 2020 09:46:22 -0500 Subject: [PATCH 1/2] (maint) Don't require config file for list --active Will fallback to printing ABS information, which is less than what you get if vmpooler_fallback is available --- lib/vmfloaty/utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 6deadb22674e8a1b0bee4a77b3547b161f78ce14 Mon Sep 17 00:00:00 2001 From: Samuel Beaulieu Date: Thu, 24 Sep 2020 10:00:15 -0500 Subject: [PATCH 2/2] Fix tests --- spec/vmfloaty/utils_spec.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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