Created
October 16, 2014 06:00
-
-
Save hkumarmk/d40769d34db875743922 to your computer and use it in GitHub Desktop.
error on easy_host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It seems rspec is not getting functions from stdlib :(. I am getting the error saying puppet parser doesnt see function_ensure_resource. But If I use create_resources in the function easy_host, the below test works. | |
Here is my test code | |
require 'spec_helper' | |
require 'rspec-puppet' | |
describe 'easy_host' do | |
before :all do | |
Puppet::Parser::Functions.autoloader.loadall | |
Puppet::Parser::Functions.function(:ensure_resource) | |
end | |
context 'with more than one argument' do | |
it 'should only accept one argument' do | |
expect do | |
should run.with_params('FOO').and_return('bar') | |
end.to raise_error(ArgumentError, /Argument must be a hash/) | |
end | |
end | |
context 'with fqdn and hostnames' do | |
let :node do Puppet::Node.new('localhost') end | |
let :compiler do Puppet::Parser::Compiler.new(node) end | |
let :scope do Puppet::Parser::Scope.new(compiler) end | |
let :catalog do | |
Puppet[:code] = <<-EOS | |
easy_host({ 'node1.example.com' => '10.1.1.1'}) | |
EOS | |
Puppet::Parser::Compiler.compile(node) | |
end | |
it 'should contain the the host resources' do | |
Puppet::Util::Log.level = :debug | |
Puppet::Util::Log.newdestination(:console) | |
expect(catalog.resource(:host, 'node1.example.com').to_s).to eq('Host[node1.example.com]') | |
end | |
end | |
end | |
>>> Here is the output. It says it did not see ensure_resource function | |
Use '--' to separate paths from revisions, like this: | |
'git <command> [<revision>...] -- [<file>...]' | |
HEAD is now at 1dfcb60 Merge pull request #118 from apenney/3.0.1-release | |
/usr/bin/ruby1.9.1 -S rspec spec/classes/cassandra_spec.rb spec/classes/ceph/mon/mon_config_spec.rb spec/classes/ceph/mon_config_spec.rb spec/classes/ceph/mon_spec.rb spec/classes/ceph/osd_spec.rb spec/classes/ceph_spec.rb spec/classes/cinder_spec.rb spec/classes/consul_spec.rb spec/classes/db_spec.rb spec/classes/glance_spec.rb spec/classes/haproxy/contrail_spec.rb spec/classes/haproxy_openstack_spec.rb spec/classes/haproxy_spec.rb spec/classes/jiocloud_spec.rb spec/classes/keystone_spec.rb spec/classes/openstack_zeromq_spec.rb spec/classes/rabbitmq_spec.rb spec/classes/redis_spec.rb spec/classes/system/apt_spec.rb spec/classes/system/ntp_spec.rb spec/classes/system_spec.rb spec/classes/zookeeper_spec.rb spec/defines/db_instance_spec.rb spec/defines/haproxy_service_spec.rb spec/functions/dns_resolve_spec.rb spec/functions/easy_host_spec.rb --color | |
.......................................................Error: undefined method `function_ensure_resource' for Scope(Class[main]):Puppet::Parser::Scope at line 1 on node localhost | |
Wrapped exception: | |
undefined method `function_ensure_resource' for Scope(Class[main]):Puppet::Parser::Scope | |
F | |
Failures: | |
1) easy_host with fqdn and hostnames should contain the the host resources | |
Failure/Error: Puppet::Parser::Compiler.compile(node) | |
Puppet::Error: | |
undefined method `function_ensure_resource' for Scope(Class[main]):Puppet::Parser::Scope at line 1 on node localhost | |
# ./lib/puppet/parser/functions/easy_host.rb:29:in `block (2 levels) in <module:Functions>' | |
# ./lib/puppet/parser/functions/easy_host.rb:19:in `each' | |
# ./lib/puppet/parser/functions/easy_host.rb:19:in `block in <module:Functions>' | |
# /home/hkumar/.bundler/ruby/1.9.1/hiera-puppet-helper-80b597aec1a4/lib/hiera-puppet-helper/puppet.rb:16:in `compile' | |
# ./spec/functions/easy_host_spec.rb:26:in `block (3 levels) in <top (required)>' | |
# ./spec/functions/easy_host_spec.rb:31:in `block (3 levels) in <top (required)>' | |
Finished in 14.91 seconds | |
56 examples, 1 failure | |
Failed examples: | |
rspec ./spec/functions/easy_host_spec.rb:28 # easy_host with fqdn and hostnames should contain the the host resources | |
rake aborted! | |
/usr/bin/ruby1.9.1 -S rspec spec/classes/cassandra_spec.rb spec/classes/ceph/mon/mon_config_spec.rb spec/classes/ceph/mon_config_spec.rb spec/classes/ceph/mon_spec.rb spec/classes/ceph/osd_spec.rb spec/classes/ceph_spec.rb spec/classes/cinder_spec.rb spec/classes/consul_spec.rb spec/classes/db_spec.rb spec/classes/glance_spec.rb spec/classes/haproxy/contrail_spec.rb spec/classes/haproxy_openstack_spec.rb spec/classes/haproxy_spec.rb spec/classes/jiocloud_spec.rb spec/classes/keystone_spec.rb spec/classes/openstack_zeromq_spec.rb spec/classes/rabbitmq_spec.rb spec/classes/redis_spec.rb spec/classes/system/apt_spec.rb spec/classes/system/ntp_spec.rb spec/classes/system_spec.rb spec/classes/zookeeper_spec.rb spec/defines/db_instance_spec.rb spec/defines/haproxy_service_spec.rb spec/functions/dns_resolve_spec.rb spec/functions/easy_host_spec.rb --color failed | |
/var/lib/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/rake_task.rb:137:in `block (2 levels) in initialize' | |
/var/lib/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/rake_task.rb:127:in `block in initialize' | |
/var/lib/gems/1.9.1/gems/puppetlabs_spec_helper-0.7.0/lib/puppetlabs_spec_helper/rake_tasks.rb:167:in `block in <top (required)>' | |
Tasks: TOP => spec_standalone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment