From 2fa3c313bb73ec2bb00c81c19af63ee176fbd7f0 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Thu, 25 Feb 2016 22:13:05 -0700 Subject: [PATCH] Fix osnailyfacter tests under puppet4 This change fixes osnailyfacter tests under puppet4 by fixing the scope declarations, fixing the lib load path and fixing the missing variable scope for the atop_retention template. Change-Id: Ie5cc5137c735748cdbc72bc82f30952b75ebeefc Closes-Bug: #1550132 --- .../spec/functions/format_allocation_pools__spec.rb | 6 +----- .../spec/functions/generate_bridge_mappings__spec.rb | 6 +----- .../spec/functions/generate_physnet_mtus__spec.rb | 6 +----- .../spec/functions/generate_physnet_vlan_ranges__spec.rb | 6 +----- .../osnailyfacter/spec/functions/get_ssl_property_spec.rb | 7 +++++++ deployment/puppet/osnailyfacter/spec/spec_helper.rb | 6 ++---- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/deployment/puppet/osnailyfacter/spec/functions/format_allocation_pools__spec.rb b/deployment/puppet/osnailyfacter/spec/functions/format_allocation_pools__spec.rb index d025592a88..f76d466561 100644 --- a/deployment/puppet/osnailyfacter/spec/functions/format_allocation_pools__spec.rb +++ b/deployment/puppet/osnailyfacter/spec/functions/format_allocation_pools__spec.rb @@ -5,11 +5,7 @@ describe 'function for formating allocation pools for neutron subnet resource' d def setup_scope @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - if Puppet.version =~ /^3\./ - @scope = Puppet::Parser::Scope.new(@compiler) - else - @scope = Puppet::Parser::Scope.new(:compiler => @compiler) - end + @scope = Puppet::Parser::Scope.new(@compiler) @topscope = @topscope @scope.parent = @topscope Puppet::Parser::Functions.function(:format_allocation_pools) diff --git a/deployment/puppet/osnailyfacter/spec/functions/generate_bridge_mappings__spec.rb b/deployment/puppet/osnailyfacter/spec/functions/generate_bridge_mappings__spec.rb index 666bfc510f..3321e4c08a 100644 --- a/deployment/puppet/osnailyfacter/spec/functions/generate_bridge_mappings__spec.rb +++ b/deployment/puppet/osnailyfacter/spec/functions/generate_bridge_mappings__spec.rb @@ -5,11 +5,7 @@ describe 'function for formating allocation pools for neutron subnet resource' d def setup_scope @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - if Puppet.version =~ /^3\./ - @scope = Puppet::Parser::Scope.new(@compiler) - else - @scope = Puppet::Parser::Scope.new(:compiler => @compiler) - end + @scope = Puppet::Parser::Scope.new(@compiler) @topscope = @topscope @scope.parent = @topscope Puppet::Parser::Functions.function(:generate_bridge_mappings) diff --git a/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_mtus__spec.rb b/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_mtus__spec.rb index 4302f8797e..d5f54a6a5a 100644 --- a/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_mtus__spec.rb +++ b/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_mtus__spec.rb @@ -5,11 +5,7 @@ describe 'function for formating allocation pools for neutron subnet resource' d def setup_scope @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - if Puppet.version =~ /^3\./ - @scope = Puppet::Parser::Scope.new(@compiler) - else - @scope = Puppet::Parser::Scope.new(:compiler => @compiler) - end + @scope = Puppet::Parser::Scope.new(@compiler) @topscope = @topscope @scope.parent = @topscope Puppet::Parser::Functions.function(:generate_physnet_mtus) diff --git a/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_vlan_ranges__spec.rb b/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_vlan_ranges__spec.rb index 457225840d..6aed4c370f 100644 --- a/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_vlan_ranges__spec.rb +++ b/deployment/puppet/osnailyfacter/spec/functions/generate_physnet_vlan_ranges__spec.rb @@ -5,11 +5,7 @@ describe 'function for formating allocation pools for neutron subnet resource' d def setup_scope @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production')) - if Puppet.version =~ /^3\./ - @scope = Puppet::Parser::Scope.new(@compiler) - else - @scope = Puppet::Parser::Scope.new(:compiler => @compiler) - end + @scope = Puppet::Parser::Scope.new(@compiler) @topscope = @topscope @scope.parent = @topscope Puppet::Parser::Functions.function(:generate_physnet_vlan_ranges) diff --git a/deployment/puppet/osnailyfacter/spec/functions/get_ssl_property_spec.rb b/deployment/puppet/osnailyfacter/spec/functions/get_ssl_property_spec.rb index 0e2a02d286..b6492309d9 100644 --- a/deployment/puppet/osnailyfacter/spec/functions/get_ssl_property_spec.rb +++ b/deployment/puppet/osnailyfacter/spec/functions/get_ssl_property_spec.rb @@ -2,6 +2,13 @@ require 'spec_helper' describe 'get_ssl_property' do + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } + + subject do + function_name = Puppet::Parser::Functions.function(:get_ssl_property) + scope.method(function_name) + end + let(:public_ssl_hash) do { 'horizon' => true, diff --git a/deployment/puppet/osnailyfacter/spec/spec_helper.rb b/deployment/puppet/osnailyfacter/spec/spec_helper.rb index edc5252dfc..0afeb2daaf 100644 --- a/deployment/puppet/osnailyfacter/spec/spec_helper.rb +++ b/deployment/puppet/osnailyfacter/spec/spec_helper.rb @@ -7,10 +7,8 @@ PROJECT_ROOT = File.expand_path('..', File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(PROJECT_ROOT, "lib")) # Add fixture lib dirs to LOAD_PATH. Work-around for PUP-3336 -if Puppet.version < '4.0.0' - Dir["#{fixture_path}/modules/*/lib"].entries.each do |lib_dir| - $LOAD_PATH << lib_dir - end +Dir["#{fixture_path}/modules/*/lib"].entries.each do |lib_dir| + $LOAD_PATH << lib_dir end RSpec.configure do |c|