beaker test fails to resolve "agent" roles, works if role is master/database

99 views
Skip to first unread message

Manish Sapariya

unread,
Oct 28, 2014, 5:10:11 AM10/28/14
to puppet...@googlegroups.com
Hi,
I have the nodeset definition as follows..

---------- Some of the attributes removed for clarity ----------------------
HOSTS:
  kpointvm1.zencite.com:
    roles:
      - master
    hypervisor : vagrant
  kpointvm2.zencite.com:
    roles:
      - agent
    hypervisor : vagrant
----------------------

When I run the tests it fails with following stack trace

----------------------
/opt/manish/kpoint_beaker/spec/spec_helper_acceptance.rb:28:in `<top (required)>': undefined local variable or method `agent' for main:Object (NameError)
        from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /opt/manish/kpoint_beaker/spec/acceptance/001_basic_spec.rb:1:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/configuration.rb:1105:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/configuration.rb:1105:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:96:in `setup'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:84:in `run'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:69:in `run'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:37:in `invoke'
        from /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/exe/rspec:4:in `<main>'
/usr/local/rvm/rubies/ruby-1.9.3-p545/bin/ruby -I/usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-support-3.1.0/lib:/usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/lib /usr/local/rvm/gems/ruby-1.9.3-p545/gems/rspec-core-3.1.4/exe/rspec spec/acceptance --color failed
----------------------

Following is the on call ...

on agent, "mkdir -p /tmp/I-am-the-agent"


Surprisingly, if I change role to either master/dashboard/database it runs without
any problem.

I thought "agent" may be a reserved word, though documentation uses it,
I tried with other roles, but that fails too.

My environment is
----------------------
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-linux] (Running in RVM)
beaker (1.19.1)
----------------------

Any idea?

Thanks and Regards,
Manish

Kevin Imber

unread,
Oct 28, 2014, 2:27:07 PM10/28/14
to puppet...@googlegroups.com
Hi Manish,

I'm having some trouble reproducing the problem that you're seeing.  This is working for me with the tests given using generic beaker, although I'm using a different hypervisor at the moment.

Are you using beaker-rspec and the modules acceptance tests?

Thanks,
Kevin

Josh Partlow

unread,
Oct 29, 2014, 11:20:08 AM10/29/14
to puppet...@googlegroups.com


On Tuesday, October 28, 2014 2:10:11 AM UTC-7, Manish Sapariya wrote:
Hi Manish,

The error you are seeing is from Ruby.  There is no variable or method named 'agent' declared at this point.  I don't believe Beaker declares an 'agent' helper specifically.  It is assumed that agents are multiple, and there is instead an agents() method which returns an array.  Typically usage might be:

agents.each do |agent|
  on agent, "mkdir -p /tmp/I-am-the-agent"
end

hope this helps,
Josh Partlow

Manish Sapariya

unread,
Oct 30, 2014, 3:03:51 AM10/30/14
to puppet...@googlegroups.com
Josh,
Thanks for the clarification.

Now that I look closely at the Beaker wiki I see call as "on agents "do something"

For some reason I missed and assume that "on agent" should work.

I think confusion was from this sample from wiki
=============================================
manifest = "file { '#{target}': source => '#{source}', ensure => present }"
apply_manifest_on agent, manifest
=============================================
Do you think above call should also be to agents and not agent?

Thanks for the help.
Regards,
Manish

Manish Sapariya

unread,
Oct 30, 2014, 3:08:12 AM10/30/14
to puppet...@googlegroups.com
Yes kevin,
I am using acceptance tests using beaker-rspec.

beaker (1.19.1)
beaker-rspec (3.0.0)

By the way, now that Josh clarified I understand why agent did not work.

Thanks for sparing time though to look at the problem.
:-)

Regards,
Manish

Joshua Partlow

unread,
Oct 31, 2014, 2:35:52 PM10/31/14
to puppet...@googlegroups.com
On Thu, Oct 30, 2014 at 12:03 AM, Manish Sapariya <msap...@gmail.com> wrote:
Josh,
Thanks for the clarification.

Now that I look closely at the Beaker wiki I see call as "on agents "do something"

For some reason I missed and assume that "on agent" should work.

I think confusion was from this sample from wiki
=============================================
manifest = "file { '#{target}': source => '#{source}', ensure => present }"
apply_manifest_on agent, manifest
=============================================
Do you think above call should also be to agents and not agent?
In this case, the example is for a single host; I've changed those examples to use a generic 'host' variable instead of 'agent'.

thanks,
Josh 

--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/_mEAFTBtST4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/480234ed-18dd-4b38-b090-8c4541a458da%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Josh Partlow
jpar...@puppetlabs.com
Developer, Puppet Labs
Reply all
Reply to author
Forward
0 new messages