Browse Source

Fix multiple bugs in puppet-oslo

This patch aims to make puppet-oslo work:
  - fix oslo::versionedobjects spec
  - fix oslo::policy
  - drop mock dependency
  - add acceptance by msync

Co-Authored-By: Emilien Macchi <emilien@redhat.com>

Closes-Bug: #1492636
Change-Id: Icbb1df3498432d2a95342a14ce57b45b65a132c9
changes/67/271767/5
Xingchao 6 years ago
parent
commit
83062c3624
  1. 12
      .gitignore
  2. 5
      Gemfile
  3. 86
      Rakefile
  4. 4
      manifests/policy.pp
  5. 11
      spec/acceptance/nodesets/centos-70-x64.yml
  6. 10
      spec/acceptance/nodesets/default.yml
  7. 10
      spec/acceptance/nodesets/nodepool-centos7.yml
  8. 10
      spec/acceptance/nodesets/nodepool-trusty.yml
  9. 11
      spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
  10. 15
      spec/defines/oslo_versionedobjects_spec.rb
  11. 1
      spec/spec_helper.rb

12
.gitignore

@ -1,7 +1,11 @@
pkg/
Gemfile.lock
spec/fixtures/modules/*
spec/fixtures/manifests/site.pp
*.swp
pkg
vendor/
spec/fixtures/
.vagrant/
.bundle/
coverage/
.idea/
*.swp
*.iml
openstack/

5
Gemfile

@ -14,10 +14,7 @@ group :development, :test do
gem 'puppet-lint-variable_contains_upcase', :require => 'false'
gem 'puppet-lint-numericvariable', :require => 'false'
gem 'json', :require => 'false'
gem 'webmock', :require => 'false'
gem 'puppet-openstack_spec_helper',
:git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper',
:require => false
gem 'puppet-openstack_spec_helper', :require => 'false', :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper'
end
group :system_tests do

86
Rakefile

@ -1,85 +1 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'json'
modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
PuppetSyntax.exclude_paths ||= []
PuppetSyntax.exclude_paths << "spec/fixtures/**/*"
PuppetSyntax.exclude_paths << "pkg/**/*"
PuppetSyntax.exclude_paths << "vendor/**/*"
Rake::Task[:lint].clear
PuppetLint::RakeTask.new :lint do |config|
config.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"]
config.fail_on_warnings = true
config.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
config.disable_checks = ["80chars", "class_inherits_from_params_class", "only_variable_string"]
end
desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
Rake::Task[:spec_prep].clear
desc 'Create the fixtures directory'
task :spec_prep do
# Allow to test the module with custom dependencies
# like you could do with .fixtures file
if ENV['PUPPETFILE']
puppetfile = ENV['PUPPETFILE']
if ENV['GEM_HOME']
gem_home = ENV['GEM_HOME']
gem_bin_dir = "#{gem_home}" + '/bin/'
else
gem_bin_dir = ''
end
r10k = ['env']
r10k += ["PUPPETFILE=#{puppetfile}"]
r10k += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"]
r10k += ["#{gem_bin_dir}r10k"]
r10k += ['puppetfile', 'install', '-v']
sh(*r10k)
else
# otherwise, use official OpenStack Puppetfile
zuul_ref = ENV['ZUUL_REF']
zuul_branch = ENV['ZUUL_BRANCH']
zuul_url = ENV['ZUUL_URL']
repo = 'openstack/puppet-openstack-integration'
rm_rf(repo)
if File.exists?('/usr/zuul-env/bin/zuul-cloner')
zuul_clone_cmd = ['/usr/zuul-env/bin/zuul-cloner']
zuul_clone_cmd += ['--cache-dir', '/opt/git']
zuul_clone_cmd += ['--zuul-ref', "#{zuul_ref}"]
zuul_clone_cmd += ['--zuul-branch', "#{zuul_branch}"]
zuul_clone_cmd += ['--zuul-url', "#{zuul_url}"]
zuul_clone_cmd += ['git://git.openstack.org', "#{repo}"]
sh(*zuul_clone_cmd)
else
sh("git clone https://git.openstack.org/#{repo} #{repo}")
end
script = ['env']
script += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"]
script += ["ZUUL_REF=#{zuul_ref}"]
script += ["ZUUL_BRANCH=#{zuul_branch}"]
script += ["ZUUL_URL=#{zuul_url}"]
script += ['bash', "#{repo}/install_modules_unit.sh"]
sh(*script)
end
rm_rf("spec/fixtures/modules/#{modname}")
ln_s(Dir.pwd, "spec/fixtures/modules/#{modname}")
mkdir_p('spec/fixtures/manifests')
touch('spec/fixtures/manifests/site.pp')
end
Rake::Task[:spec_clean].clear
desc 'Clean up the fixtures directory'
task :spec_clean do
rm_rf('spec/fixtures/modules')
rm_rf('openstack')
if File.zero?('spec/fixtures/manifests/site.pp')
rm_f('spec/fixtures/manifests/site.pp')
end
end
require 'puppet-openstack_spec_helper/rake_tasks'

4
manifests/policy.pp

@ -26,10 +26,10 @@
define oslo::policy(
$policy_file = $::os_service_default,
$policy_default_rule = $::os_service_default,
$policy_file = $::os_service_default,
$policy_dirs = $::os_service_default,
) {
create_resources($name, {'oslo_policy/policy_file' => { value => $policy_file }})
create_resources($name, {'oslo_policy/policy_default_rule' => { value => $policy_default_rule }})
create_resources($name, {'oslo_policy/policy_file' => { value => $policy_file }})
create_resources($name, {'oslo_policy/policy_dirs' => { value => $policy_dirs }})
}

11
spec/acceptance/nodesets/centos-70-x64.yml

@ -0,0 +1,11 @@
HOSTS:
centos-server-70-x64:
roles:
- master
platform: el-7-x86_64
box: puppetlabs/centos-7.0-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/centos-7.0-64-nocm
hypervisor: vagrant
CONFIG:
log_level: debug
type: foss

10
spec/acceptance/nodesets/default.yml

@ -0,0 +1,10 @@
HOSTS:
ubuntu-server-14.04-amd64:
roles:
- master
platform: ubuntu-14.04-amd64
box: puppetlabs/ubuntu-14.04-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
hypervisor: vagrant
CONFIG:
type: foss

10
spec/acceptance/nodesets/nodepool-centos7.yml

@ -0,0 +1,10 @@
HOSTS:
centos-70-x64:
roles:
- master
platform: el-7-x86_64
hypervisor: none
ip: 127.0.0.1
CONFIG:
type: foss
set_env: false

10
spec/acceptance/nodesets/nodepool-trusty.yml

@ -0,0 +1,10 @@
HOSTS:
ubuntu-14.04-amd64:
roles:
- master
platform: ubuntu-14.04-amd64
hypervisor: none
ip: 127.0.0.1
CONFIG:
type: foss
set_env: false

11
spec/acceptance/nodesets/ubuntu-server-1404-x64.yml

@ -0,0 +1,11 @@
HOSTS:
ubuntu-server-14.04-amd64:
roles:
- master
platform: ubuntu-14.04-amd64
box: puppetlabs/ubuntu-14.04-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
hypervisor: vagrant
CONFIG:
log_level: debug
type: foss

15
spec/defines/oslo_versionedobjects_spec.rb

@ -6,23 +6,22 @@ describe 'oslo::versionedobjects' do
shared_examples 'shared examples' do
context 'with only required parameters' do
let :params do
required_params
context 'with default parameters' do
it 'configure oslo_versionedobjects default params' do
is_expected.to contain_keystone_config('oslo_versionedobjects/fatal_exception_format_errors').with_value('<SERVICE DEFAULT>')
end
it { is_expected.to contain_keystone_config('oslo_versionedobjects/fatal_exception_format_errors').with_value('false') }
end
context 'with overridden parameters' do
let :params do
required_params.merge(
{ :fatal_exception_format_errors => true,
}
)
end
it { is_expected.to contain_keystone_config('oslo_versionedobjects/fatal_exception_format_errors').with_value('false') }
it 'configure oslo_versionedobjects with overriden values' do
is_expected.to contain_keystone_config('oslo_versionedobjects/fatal_exception_format_errors').with_value(true)
end
end
end

1
spec/spec_helper.rb

@ -1,6 +1,5 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'shared_examples'
require 'webmock/rspec'
require 'puppet-openstack_spec_helper/defaults'
require 'rspec-puppet-facts'

Loading…
Cancel
Save