voxpupuli / onceover

Your gateway drug to automated infrastructure testing with Puppet
Apache License 2.0
142 stars 45 forks source link

[bug] ruby error if hiera.yaml is missing #7

Closed GeoffWilliams closed 8 years ago

GeoffWilliams commented 8 years ago

Overview

If hiera.yaml file is not where the control gem expects it, user gets a ruby error

Expected behaviour

one or more of the following:

User receives the following error when running bundle exec rake controlrepo_spec --trace (note that this system already has PR https://github.com/dylanratcliffe/controlrepo_gem/pull/6 applied so line numbers reflect this)

...
-1ov6m5s/modules/sudo
INFO     -> Updating module /private/var/folders/54/1svw01r93bz32rjjh2ytkgc40000gn/T/r10k20151117-25744-1ov6m5s/modules/r_profile
INFO     -> Updating module /private/var/folders/54/1svw01r93bz32rjjh2ytkgc40000gn/T/r10k20151117-25744-1ov6m5s/modules/bash_user_skel
rake aborted!
TypeError: no implicit conversion of nil into String
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `load_file'
/Users/geoff/github/controlrepo_gem/lib/controlrepo.rb:217:in `hiera_config'
/Users/geoff/github/controlrepo_gem/lib/controlrepo/rake_tasks.rb:116:in `block in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => controlrepo_spec => controlrepo_autotest_prep

Relevant code

controlrepo_gem/lib/controlrepo.rb:217

  def hiera_config
    YAML.load_file(hiera_config_file)
  end

Recommended fix

Get user to supply a special hiera.yaml just for testing. This can go in well-known (to controlrepo_gem) directory. At present I've done exactly this on my own repo in a directory called integration_test how does this sound

dylanratcliffe commented 8 years ago

I've fixed the error. I think we need people to supply their own hiera.yaml for testing purposes, maybe just document it better