Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Don't require config file for list --active #105

Merged
merged 2 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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