Test-Kitchen & serverspec woes


#1

Hey ho!

I’m having a bit of trouble running serverspec … erm… specs in Test Kitchen 1.0.0.alpha.7.

This is an exerpt of the kind of error I’m seeing:

-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/opt/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /opt/busser/suites/serverspec/localhost/logstash_agent_spec.rb
FFF

Failures:

  1. Logstash Agent downloads the jar and install it
    Failure/Error: Unable to find matching line from backtrace
    NameError: undefined local variable or method `backend’ for #RSpec::Core::ExampleGroup::Nested_1:0x00000002e96068

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.6/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:237:in `instance_eval’

(…)

I have my specs in test/integration/default/serverspec/localhost (with a spec_helper.rb in its parent dir). All three specs fail with the same error.

The node conversion ran without problems, and I manually verified that it worked as expected, but the specs failed miserably.

Any ideas where should I look for the problem?

  • cassiano

#2

Whats your helper and spec files look like ? I have working / simple
example in my skeleton repo that should work

On Thu, Jun 20, 2013 at 11:58 AM, Cassiano Leal cassianoleal@gmail.comwrote:

Hey ho!

I’m having a bit of trouble running serverspec … erm… specs in Test
Kitchen 1.0.0.alpha.7.

This is an exerpt of the kind of error I’m seeing:

-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/opt/busser/suites/serverspec -S
/opt/chef/embedded/bin/rspec
/opt/busser/suites/serverspec/localhost/logstash_agent_spec.rb
FFF

Failures:

  1. Logstash Agent downloads the jar and install it
    Failure/Error: Unable to find matching line from backtrace
    NameError: undefined local variable or method `backend’ for
    #RSpec::Core::ExampleGroup::Nested_1:0x00000002e96068

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in
method_missing' # /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.6/lib/serverspec.rb:42:inblock (2 levels) in <top (required)>’
#
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:237:in
`instance_eval’
(…)

I have my specs in test/integration/default/serverspec/localhost (with a
spec_helper.rb in its parent dir). All three specs fail with the same error.

The node conversion ran without problems, and I manually verified that it
worked as expected, but the specs failed miserably.

Any ideas where should I look for the problem?

  • cassiano

#3

The spec_helper so far has only “require ‘serverspec’” in it.

localhost/logstash_agent_spec.rb has:

require ‘spec_helper’

describe ‘Logstash Agent’ do
it ‘downloads and installs the logstash jar’ do
jar = file '/opt/logstash/agent/lib/logstash-1.1.1-monolithic-es0.19.10.jar’
expect(jar).to be_file
expect(jar).to match_md5checksum '3eb8159a1566b3d21ec62b34c5984427’
end

A couple of other specs here

end

And that’s it, really.

  • cassiano

On Thursday, June 20, 2013 at 18:23, Jesse Nelson wrote:

Whats your helper and spec files look like ? I have working / simple example in my skeleton repo that should work https://github.com/spheromak/test_cook_skeleton/tree/master/test/integration/default/serverspec

On Thu, Jun 20, 2013 at 11:58 AM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

Hey ho!

I’m having a bit of trouble running serverspec … erm… specs in Test Kitchen 1.0.0.alpha.7.

This is an exerpt of the kind of error I’m seeing:

-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/opt/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /opt/busser/suites/serverspec/localhost/logstash_agent_spec.rb
FFF

Failures:

  1. Logstash Agent downloads the jar and install it
    Failure/Error: Unable to find matching line from backtrace
    NameError: undefined local variable or method `backend’ for #RSpec::Core::ExampleGroup::Nested_1:0x00000002e96068

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.6/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:237:in `instance_eval’

(…)

I have my specs in test/integration/default/serverspec/localhost (with a spec_helper.rb in its parent dir). All three specs fail with the same error.

The node conversion ran without problems, and I manually verified that it worked as expected, but the specs failed miserably.

Any ideas where should I look for the problem?

  • cassiano

#4

This is happening with all my serverspec tests.

This is where the problem occurs:

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.9/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

Which has:

RSpec.configure do |c|
c.include(Serverspec::Helper::Configuration)
c.include(Serverspec::Helper::RedHat, :os => :redhat)
c.include(Serverspec::Helper::Debian, :os => :debian)
c.include(Serverspec::Helper::Gentoo, :os => :gentoo)
c.include(Serverspec::Helper::Solaris, :os => :solaris)
c.include(Serverspec::Helper::Darwin, :os => :darwin)
c.add_setting :os, :default => nil
c.add_setting :host, :default => nil
c.add_setting :ssh, :default => nil
c.add_setting :sudo_password, :default => nil
Serverspec.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
c.before :each do
backend.set_example(example)
end
end

The backend.set_example line inside the before :each block is the one that breaks. That backend name is not defined anywhere previously, was it supposed to “just work” somehow? Or am I missing something in my tests?

Any help is appreciated, right now I’m clueless. :slight_smile:

  • cassiano

On Thursday, June 20, 2013 at 22:30, Cassiano Leal wrote:

The spec_helper so far has only “require ‘serverspec’” in it.

localhost/logstash_agent_spec.rb has:

require ‘spec_helper’

describe ‘Logstash Agent’ do
it ‘downloads and installs the logstash jar’ do
jar = file '/opt/logstash/agent/lib/logstash-1.1.1-monolithic-es0.19.10.jar’
expect(jar).to be_file
expect(jar).to match_md5checksum '3eb8159a1566b3d21ec62b34c5984427’
end

A couple of other specs here

end

And that’s it, really.

  • cassiano

On Thursday, June 20, 2013 at 18:23, Jesse Nelson wrote:

Whats your helper and spec files look like ? I have working / simple example in my skeleton repo that should work https://github.com/spheromak/test_cook_skeleton/tree/master/test/integration/default/serverspec

On Thu, Jun 20, 2013 at 11:58 AM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

Hey ho!

I’m having a bit of trouble running serverspec … erm… specs in Test Kitchen 1.0.0.alpha.7.

This is an exerpt of the kind of error I’m seeing:

-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/opt/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /opt/busser/suites/serverspec/localhost/logstash_agent_spec.rb
FFF

Failures:

  1. Logstash Agent downloads the jar and install it
    Failure/Error: Unable to find matching line from backtrace
    NameError: undefined local variable or method `backend’ for #RSpec::Core::ExampleGroup::Nested_1:0x00000002e96068

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.6/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:237:in `instance_eval’

(…)

I have my specs in test/integration/default/serverspec/localhost (with a spec_helper.rb in its parent dir). All three specs fail with the same error.

The node conversion ran without problems, and I manually verified that it worked as expected, but the specs failed miserably.

Any ideas where should I look for the problem?

  • cassiano

#5

It looks like requiring ‘pathname’ in the spec_helper fixes the problem. Any ideas as to why?

P.S.: Jesse: thanks for pointing to your skeleton cookbook, I got this requirement from there, I just don’t know why it’s required (and if it is, why it’s not already required by one of the higher level thingies, like serverspec itself) . :slight_smile:

  • cassiano

On Tuesday, June 25, 2013 at 15:45, Cassiano Leal wrote:

This is happening with all my serverspec tests.

This is where the problem occurs:

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.9/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

Which has:

RSpec.configure do |c|
c.include(Serverspec::Helper::Configuration)
c.include(Serverspec::Helper::RedHat, :os => :redhat)
c.include(Serverspec::Helper::Debian, :os => :debian)
c.include(Serverspec::Helper::Gentoo, :os => :gentoo)
c.include(Serverspec::Helper::Solaris, :os => :solaris)
c.include(Serverspec::Helper::Darwin, :os => :darwin)
c.add_setting :os, :default => nil
c.add_setting :host, :default => nil
c.add_setting :ssh, :default => nil
c.add_setting :sudo_password, :default => nil
Serverspec.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
c.before :each do
backend.set_example(example)
end
end

The backend.set_example line inside the before :each block is the one that breaks. That backend name is not defined anywhere previously, was it supposed to “just work” somehow? Or am I missing something in my tests?

Any help is appreciated, right now I’m clueless. :slight_smile:

  • cassiano

On Thursday, June 20, 2013 at 22:30, Cassiano Leal wrote:

The spec_helper so far has only “require ‘serverspec’” in it.

localhost/logstash_agent_spec.rb has:

require ‘spec_helper’

describe ‘Logstash Agent’ do
it ‘downloads and installs the logstash jar’ do
jar = file '/opt/logstash/agent/lib/logstash-1.1.1-monolithic-es0.19.10.jar’
expect(jar).to be_file
expect(jar).to match_md5checksum '3eb8159a1566b3d21ec62b34c5984427’
end

A couple of other specs here

end

And that’s it, really.

  • cassiano

On Thursday, June 20, 2013 at 18:23, Jesse Nelson wrote:

Whats your helper and spec files look like ? I have working / simple example in my skeleton repo that should work https://github.com/spheromak/test_cook_skeleton/tree/master/test/integration/default/serverspec

On Thu, Jun 20, 2013 at 11:58 AM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

Hey ho!

I’m having a bit of trouble running serverspec … erm… specs in Test Kitchen 1.0.0.alpha.7.

This is an exerpt of the kind of error I’m seeing:

-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/opt/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /opt/busser/suites/serverspec/localhost/logstash_agent_spec.rb
FFF

Failures:

  1. Logstash Agent downloads the jar and install it
    Failure/Error: Unable to find matching line from backtrace
    NameError: undefined local variable or method `backend’ for #RSpec::Core::ExampleGroup::Nested_1:0x00000002e96068

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.6/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:237:in `instance_eval’

(…)

I have my specs in test/integration/default/serverspec/localhost (with a spec_helper.rb in its parent dir). All three specs fail with the same error.

The node conversion ran without problems, and I manually verified that it worked as expected, but the specs failed miserably.

Any ideas where should I look for the problem?

  • cassiano

#6

Nevermind, it was actually an include that was missing:

include Serverspec::Helper::Exec

Sorry for the noise.

  • cassiano

On Tuesday, June 25, 2013 at 15:56, Cassiano Leal wrote:

It looks like requiring ‘pathname’ in the spec_helper fixes the problem. Any ideas as to why?

P.S.: Jesse: thanks for pointing to your skeleton cookbook, I got this requirement from there, I just don’t know why it’s required (and if it is, why it’s not already required by one of the higher level thingies, like serverspec itself) . :slight_smile:

  • cassiano

On Tuesday, June 25, 2013 at 15:45, Cassiano Leal wrote:

This is happening with all my serverspec tests.

This is where the problem occurs:

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.9/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

Which has:

RSpec.configure do |c|
c.include(Serverspec::Helper::Configuration)
c.include(Serverspec::Helper::RedHat, :os => :redhat)
c.include(Serverspec::Helper::Debian, :os => :debian)
c.include(Serverspec::Helper::Gentoo, :os => :gentoo)
c.include(Serverspec::Helper::Solaris, :os => :solaris)
c.include(Serverspec::Helper::Darwin, :os => :darwin)
c.add_setting :os, :default => nil
c.add_setting :host, :default => nil
c.add_setting :ssh, :default => nil
c.add_setting :sudo_password, :default => nil
Serverspec.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
c.before :each do
backend.set_example(example)
end
end

The backend.set_example line inside the before :each block is the one that breaks. That backend name is not defined anywhere previously, was it supposed to “just work” somehow? Or am I missing something in my tests?

Any help is appreciated, right now I’m clueless. :slight_smile:

  • cassiano

On Thursday, June 20, 2013 at 22:30, Cassiano Leal wrote:

The spec_helper so far has only “require ‘serverspec’” in it.

localhost/logstash_agent_spec.rb has:

require ‘spec_helper’

describe ‘Logstash Agent’ do
it ‘downloads and installs the logstash jar’ do
jar = file '/opt/logstash/agent/lib/logstash-1.1.1-monolithic-es0.19.10.jar’
expect(jar).to be_file
expect(jar).to match_md5checksum '3eb8159a1566b3d21ec62b34c5984427’
end

A couple of other specs here

end

And that’s it, really.

  • cassiano

On Thursday, June 20, 2013 at 18:23, Jesse Nelson wrote:

Whats your helper and spec files look like ? I have working / simple example in my skeleton repo that should work https://github.com/spheromak/test_cook_skeleton/tree/master/test/integration/default/serverspec

On Thu, Jun 20, 2013 at 11:58 AM, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

Hey ho!

I’m having a bit of trouble running serverspec … erm… specs in Test Kitchen 1.0.0.alpha.7.

This is an exerpt of the kind of error I’m seeing:

-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/opt/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /opt/busser/suites/serverspec/localhost/logstash_agent_spec.rb
FFF

Failures:

  1. Logstash Agent downloads the jar and install it
    Failure/Error: Unable to find matching line from backtrace
    NameError: undefined local variable or method `backend’ for #RSpec::Core::ExampleGroup::Nested_1:0x00000002e96068

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/method_missing.rb:9:in `method_missing’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/serverspec-0.6.6/lib/serverspec.rb:42:in `block (2 levels) in <top (required)>’

    /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:237:in `instance_eval’

(…)

I have my specs in test/integration/default/serverspec/localhost (with a spec_helper.rb in its parent dir). All three specs fail with the same error.

The node conversion ran without problems, and I manually verified that it worked as expected, but the specs failed miserably.

Any ideas where should I look for the problem?

  • cassiano