Initial set of tests for cobbler module
This change includes an initial test setup for the cobbler module and ensures that running 'rake lint' will pass. Change-Id: I575483d8f36fcd236fd81ec012b16b44900b9960 Related-Bug: #1507751
This commit is contained in:
parent
790fa9354d
commit
d0b94c9572
7
deployment/puppet/cobbler/.fixtures.yml
Normal file
7
deployment/puppet/cobbler/.fixtures.yml
Normal file
@ -0,0 +1,7 @@
|
||||
fixtures:
|
||||
repositories:
|
||||
'stdlib': 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
|
||||
'openssl': 'https://review.fuel-infra.org/puppet-modules/puppet-openssl.git'
|
||||
'firewall': 'https://review.fuel-infra.org/puppet-modules/puppetlabs-firewall.git'
|
||||
symlinks:
|
||||
'cobbler': "#{source_dir}"
|
23
deployment/puppet/cobbler/Gemfile
Normal file
23
deployment/puppet/cobbler/Gemfile
Normal file
@ -0,0 +1,23 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => 'false'
|
||||
gem 'rspec-puppet', '~> 2.2.0', :require => 'false'
|
||||
gem 'metadata-json-lint', :require => 'false'
|
||||
# TODO(aschultz): fix linting and enable these
|
||||
#gem 'puppet-lint-param-docs', :require => 'false'
|
||||
#gem 'puppet-lint-absolute_classname-check', :require => 'false'
|
||||
#gem 'puppet-lint-absolute_template_path', :require => 'false'
|
||||
#gem 'puppet-lint-trailing_newline-check', :require => 'false'
|
||||
#gem 'puppet-lint-unquoted_string-check', :require => 'false'
|
||||
#gem 'puppet-lint-leading_zero-check', :require => 'false'
|
||||
#gem 'puppet-lint-variable_contains_upcase', :require => 'false'
|
||||
#gem 'puppet-lint-numericvariable', :require => 'false'
|
||||
gem 'json', :require => 'false'
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
33
deployment/puppet/cobbler/Rakefile
Normal file
33
deployment/puppet/cobbler/Rakefile
Normal file
@ -0,0 +1,33 @@
|
||||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
require 'puppet-syntax/tasks/puppet-syntax'
|
||||
|
||||
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 = false # TODO(aschultz): fix warnings
|
||||
config.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
|
||||
config.disable_checks = [
|
||||
"80chars",
|
||||
"class_inherits_from_params_class",
|
||||
"class_parameter_defaults",
|
||||
"only_variable_string",
|
||||
"autoloader_layout", # TODO(aschultz): this is from included defines in classes, should be fixed and this should be removed.
|
||||
"nested_classes_or_defines",
|
||||
"only_variable_string",
|
||||
"2sp_soft_tabs",
|
||||
"hard_tabs",
|
||||
"tailing_whitespace",
|
||||
"unquoted_file_mode",
|
||||
"double_quoted_strings",
|
||||
"arrow_alignment",
|
||||
"documentation",
|
||||
"leading_zero",
|
||||
|
||||
]
|
||||
end
|
@ -40,7 +40,7 @@ class cobbler::distro::centos63-x86_64(
|
||||
# CentOS-6.3-x86_64-minimal
|
||||
$iso_name = extension_basename($http_iso, "true")
|
||||
# CentOS-6.3-x86_64-minimal.iso
|
||||
$iso_basename = extension_basename($http_iso)
|
||||
$iso_basename = extension_basename($http_iso)
|
||||
# /var/www/cobbler/ks_mirror/CentOS-6.3-x86_64-minimal.iso
|
||||
$iso = "${ks_mirror}/${iso_basename}"
|
||||
# /var/www/cobbler/ks_mirror/CentOS-6.3-x86_64-minimal
|
||||
|
102
deployment/puppet/cobbler/spec/classes/cobbler_spec.rb
Normal file
102
deployment/puppet/cobbler/spec/classes/cobbler_spec.rb
Normal file
@ -0,0 +1,102 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cobbler' do
|
||||
|
||||
let(:default_params) { {
|
||||
:server => facts[:ipaddress],
|
||||
:production => 'prod',
|
||||
:domain_name => 'local',
|
||||
:name_server => facts[:ipaddress],
|
||||
:next_server => facts[:ipaddress],
|
||||
:dns_upstream => '8.8.8.8',
|
||||
:dns_domain => 'domain.tld',
|
||||
:dns_search => 'domain.tld',
|
||||
:dhcp_start_address => '10.0.0.201',
|
||||
:dhcp_end_address => '10.0.0.254',
|
||||
:dhcp_netmask => '255.255.255.0',
|
||||
:dhcp_gateway => facts[:ipaddress],
|
||||
:dhcp_interface => 'eth0',
|
||||
:cobbler_user => 'cobbler',
|
||||
:cobbler_password => 'cobbler',
|
||||
:pxetimeout => 0,
|
||||
:extra_admin_nets => {}
|
||||
} }
|
||||
|
||||
shared_examples_for 'cobbler configuration' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
|
||||
context 'with default params' do
|
||||
let :params do
|
||||
default_params.merge!({})
|
||||
end
|
||||
|
||||
it 'configures with the default params' do
|
||||
should contain_class('cobbler')
|
||||
should contain_class('cobbler::packages')
|
||||
should contain_class('cobbler::selinux')
|
||||
should contain_class('cobbler::iptables')
|
||||
should contain_class('cobbler::snippets')
|
||||
should contain_class('cobbler::server').with(
|
||||
:domain_name => params[:domain_name],
|
||||
:production => params[:production],
|
||||
:dns_upstream => params[:dns_upstream],
|
||||
:dns_domain => params[:dns_domain],
|
||||
:dns_search => params[:dns_search],
|
||||
:extra_admins_net => params[:extra_admins_nets])
|
||||
should contain_cobbler_digest_user(params[:cobbler_user]).with(
|
||||
:password => params[:cobbler_password])
|
||||
end
|
||||
end
|
||||
|
||||
context 'with production = docker' do
|
||||
let :params do
|
||||
default_params.merge!({
|
||||
:production => 'docker'
|
||||
})
|
||||
end
|
||||
|
||||
it 'configures with the default params' do
|
||||
should contain_class('cobbler')
|
||||
should contain_class('cobbler::packages')
|
||||
should contain_class('cobbler::selinux')
|
||||
should_not contain_class('cobbler::iptables')
|
||||
should contain_class('cobbler::snippets')
|
||||
should contain_class('cobbler::server').with(
|
||||
:domain_name => params[:domain_name],
|
||||
:production => params[:production],
|
||||
:dns_upstream => params[:dns_upstream],
|
||||
:dns_domain => params[:dns_domain],
|
||||
:dns_search => params[:dns_search],
|
||||
:extra_admins_net => params[:extra_admins_nets])
|
||||
should contain_cobbler_digest_user(params[:cobbler_user]).with(
|
||||
:password => params[:cobbler_password])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'cobbler configuration'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
@default_facts.merge({ :osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
})
|
||||
end
|
||||
|
||||
it_configures 'cobbler configuration'
|
||||
end
|
||||
|
||||
end
|
||||
|
5
deployment/puppet/cobbler/spec/shared_examples.rb
Normal file
5
deployment/puppet/cobbler/spec/shared_examples.rb
Normal file
@ -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
|
15
deployment/puppet/cobbler/spec/spec_helper.rb
Normal file
15
deployment/puppet/cobbler/spec/spec_helper.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'shared_examples'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
c.before :each do
|
||||
@default_facts = {
|
||||
:ipaddress => '10.0.0.1',
|
||||
:hostname => 'hostname.example.com',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
at_exit { RSpec::Puppet::Coverage.report! }
|
@ -3,7 +3,6 @@ anacron
|
||||
ceilometer
|
||||
cinder
|
||||
cluster
|
||||
cobbler
|
||||
common
|
||||
pacemaker
|
||||
docker
|
||||
|
Loading…
Reference in New Issue
Block a user