i'm having issue serverspec. i'm trying test infrastructure deployed on cloud vm, cloudbees jenkins build server using ansible. created test each ansible role using serverspec. right i'm trying check if can run tests correctly, , connect vm.
the thing is, once run "rake spec" "don't know how build task 'spec:84'" error, isn't in code.
the whole log in here:
########## testing infrastructure ########## + cd openshift-testing/ + rake spec --trace ** invoke spec (first_time) ** invoke spec:all (first_time) rake aborted! don't know how build task 'spec:84' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task_manager.rb:62:in `[]' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:57:in `lookup_prerequisite' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:53:in `block in prerequisite_tasks' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:53:in `map' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:53:in `prerequisite_tasks' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain' /usr/share/ruby/monitor.rb:211:in `mon_synchronize' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:201:in `block in invoke_prerequisites' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `each' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain' /usr/share/ruby/monitor.rb:211:in `mon_synchronize' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `each' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `run' /home/jenkins/.gem/ruby/1.9.1/gems/rake-10.4.2/bin/rake:33:in `<top (required)>' /usr/local/bin/rake:23:in `load' /usr/local/bin/rake:23:in `<main>'
here rakefile:
1 require 'rake' 2 require 'rspec/core/rake_task' 3 4 hosts = %w( 5 84.39.33.93 6 ) 7 8 task :spec => 'spec:all' 9 10 namespace :spec 11 task :all => hosts.map {|h| 'spec:' + h.split('.')[0] } 12 hosts.each |host| 13 short_name = "sca-vm" 14 role = "common" 15 16 desc "run serverspec #{host}" 17 rspec::core::raketask.new(short_name) |t| 18 env['target_host'] = host 19 t.pattern = "spec/base,#{role}/*_spec.rb" 20 end 21 end 22 end ~
spec_helper.rb:
require 'serverspec' require 'net/ssh' set :backend, :ssh if env['ask_sudo_password'] begin require 'highline/import' rescue loaderror fail "highline not available. try installing it." end set :sudo_password, ask("enter sudo password: ") { |q| q.echo = false } else set :sudo_password, env['sudo_password'] end host = env['target_host'] options = net::ssh::config.for(host) options[:user] ||= etc.getlogin set :host, options[:host_name] || host set :ssh_options, options # disable sudo # set :disable_sudo, true # set environment variables # set :env, :lang => 'c', :lc_messages => 'c' # set path # set :path, '/sbin:/usr/local/sbin:$path'
finally, here's test_spec i'm using, verifies existence of plaint text file called now.txt:
require 'spec_helper' describe file('~/now.txt') { should be_file } end
i'm confused right now. guys please me understand what's going on?
the code snippet
hosts.map {|h| 'spec:' + h.split('.')[0] }
alone yields: ["spec:84"]. now, task spec:all depends on task. in loop starting with
hosts.each |host|
there's single task defined , it's called 'scm-va':
rspec::core::raketask.new(short_name) |t| # ... end
also note task defined every element of hosts (in example that's one, you've made hosts
array reason, assume).
try rake -t -a
on command line list tasks, one's without description, see tasks known rake.
in other words: code example declares spec:all depend on task (or tasks) that's not defined.
if change line to
rspec::core::raketask.new('spec:' + host.split('.')[0]) |t|
the code doesn't raise exception, i'm not sure fixes problem. maybe it's important 'scm-vm' in fact part of task name defined.
however if that's want, should refactor host.split('.')[0]
method of it's own.