Browse Source

Fix puppet-qdr testing

This change updates the puppet-qdr module to leverage the
puppet-openstack_spec_helper for unit testing and common dependency
management for spec tests. Additionally this change fixes the lint
issues with the module.

Change-Id: I62d6b60712e237a8b4daf654879a4f1912fb9ec6
changes/23/386223/3
Alex Schultz 5 years ago
parent
commit
75bb0b5c3e
  1. 51
      .gitignore
  2. 26
      Gemfile
  3. 18
      Rakefile
  4. 13
      manifests/init.pp
  5. 2
      manifests/install.pp
  6. 61
      metadata.json
  7. 11
      spec/acceptance/nodesets/centos-70-x64.yml
  8. 10
      spec/acceptance/nodesets/default.yml
  9. 10
      spec/acceptance/nodesets/nodepool-centos7.yml
  10. 10
      spec/acceptance/nodesets/nodepool-trusty.yml
  11. 10
      spec/acceptance/nodesets/nodepool-xenial.yml
  12. 11
      spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
  13. 5
      spec/shared_examples.rb
  14. 14
      spec/spec_helper.rb
  15. 1
      spec/spec_helper_acceptance.rb
  16. 4
      spec/unit/type/qdr_address_spec.rb

51
.gitignore

@ -1,40 +1,11 @@
## Emacs ##
*~
\#*\#
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/
## Specific to RubyMotion:
.dat*
.repl_history
build/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
pkg/
Gemfile.lock
vendor/
spec/fixtures/
.vagrant/
.bundle/
coverage/
.idea/
*.swp
*.iml
/openstack/

26
Gemfile

@ -1,7 +1,21 @@
source 'https://rubygems.org'
source ENV['GEM_SOURCE'] || "https://rubygems.org"
puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.8.2'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
group :development, :test, :system_tests do
gem 'puppet-openstack_spec_helper',
:git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper',
:require => false
end
if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
gem 'facter', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

18
Rakefile

@ -1,17 +1 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
desc "Validate manifests, templates, and ruby files"
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
require 'puppet-openstack_spec_helper/rake_tasks'

13
manifests/init.pp

@ -20,16 +20,17 @@
# (optional) Service host name
# Defaults to '127.0.0.1'
#
# [*listner_auth_peer*]
# (optional) Require the peer's identity to be authenticated.
# [*listener_auth_peer*]
# (optional)
# Defaults to 'no'
#
# [*listner_idle_timeout*]
# (optional) Idle timeout, in seconds, for connection through the listener
# [*listener_idle_timeout*]
# (optional)
# Defaults to '16'
#
# [*listener_max_frame_size*]
# (optional) Maximum frame size used for a message delivery over the connection
# (optional) Maximum frame size used for a message delivery over the
# connection
# Defaults to '16384'
#
# [*listener_port*]
@ -134,7 +135,7 @@ class qdr(
$enable_service = true,
$listener_addr = '127.0.0.1',
$listener_auth_peer = 'no',
$listener_idle_timout = '16',
$listener_idle_timeout = '16',
$listener_max_frame_size = '16384',
$listener_port = '5672',
$listener_require_encrypt = 'no',

2
manifests/install.pp

@ -10,7 +10,7 @@ class qdr::install inherits qdr {
$tools_package_list = $::qdr::params::tools_package_list
if $::osfamily == 'Debian' {
include apt
include ::apt
Class['apt::update'] -> Package<| provider == 'apt' |>

61
metadata.json

@ -1,14 +1,59 @@
{
"name": "ajssmith-qdr",
"name": "openstack-qdr",
"version": "0.1.0",
"author": "Andy Smith",
"summary": "This module manages qpid-dispatch-router service",
"author": "OpenStack Contributors",
"summary": "Puppet OpenStack Extras Module",
"license": "Apache-2.0",
"source": "https://github.com/ajssmith/puppet-qdr",
"project_page": "https://github.com/ajssmith/puppet-qdr",
"issues_url": "https://github.com/ajssmith/puppet-qdr/issues",
"source": "git://github.com/openstack/puppet-qdr.git",
"project_page": "https://launchpad.net/puppet-qdr",
"issues_url": "https://bugs.launchpad.net/puppet-qdr",
"requirements": [
{
"name": "pe",
"version_requirement": "3.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"7"
]
},
{
"operatingsystem": "Fedora",
"operatingsystemrelease": [
"20"
]
},
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6.5",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04"
]
}
],
"description": "Puppet module to add useful utilities for OpenStack deployments",
"dependencies": [
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
{
"name": "puppetlabs/apt",
"version_requirement": ">=1.8.0 <3.0.0"
},
{
"name": "puppetlabs/stdlib",
"version_requirement": ">=4.0.0 <5.0.0"
}
]
}

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

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

@ -0,0 +1,10 @@
HOSTS:
ubuntu-16.04-amd64:
roles:
- master
platform: ubuntu-16.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

5
spec/shared_examples.rb

@ -0,0 +1,5 @@
shared_examples_for "a Puppet::Error" do |description|
it "with message matching #{description.inspect}" do
expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
end
end

14
spec/spec_helper.rb

@ -1,10 +1,10 @@
require 'rspec-puppet/spec_helper'
require 'rspec-puppet'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
require 'puppetlabs_spec_helper/module_spec_helper'
require 'shared_examples'
require 'puppet-openstack_spec_helper/facts'
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
c.environmentpath = File.join(Dir.pwd, 'spec')
c.alias_it_should_behave_like_to :it_configures, 'configures'
c.alias_it_should_behave_like_to :it_raises, 'raises'
end
at_exit { RSpec::Puppet::Coverage.report! }

1
spec/spec_helper_acceptance.rb

@ -0,0 +1 @@
require 'puppet-openstack_spec_helper/beaker_spec_helper'

4
spec/unit/type/qdr_address_spec.rb

@ -2,12 +2,12 @@ require 'puppet'
require 'puppet/type/qdr_address'
describe 'Puppet::Type.type(:qdr_address)' do
before :each do
@qdr_address = Puppet::Type.type(:qdr_address).new(:prefix => 'unicast', :distribution => 'closest' )
@qdr_address = Puppet::Type.type(:qdr_address).new(:name => 'test', :prefix => 'unicast', :distribution => 'closest' )
end
it 'should not expect a prefix with a whitespace' do
expect {
Puppet::Type.type(:qdr_address).new(:prefix => 'multi cast')
Puppet::Type.type(:qdr_address).new(:name => 'test', :prefix => 'multi cast')
}.to raise_error(Puppet::Error, /Parameter prefix failed/)
end

Loading…
Cancel
Save