Fix fuel module tests
This change adds a Gemfile and updates the rspec tests for the fuel module so they actually work. Change-Id: Idb40cf3e7762c9460fc8ecbc700857829ef22627 Closes-Bug: #1608732
This commit is contained in:
parent
822a55230c
commit
794dd21bc5
|
@ -1,3 +1,15 @@
|
|||
fixtures:
|
||||
symlinks:
|
||||
fuel: "#{source_dir}"
|
||||
stdlib: "#{source_dir}/../stdlib"
|
||||
apache: "#{source_dir}/../apache"
|
||||
rabbitmq: "#{source_dir}/../rabbitmq"
|
||||
concat: "#{source_dir}/../concat"
|
||||
inifile: "#{source_dir}/../inifile"
|
||||
keystone: "#{source_dir}/../keystone"
|
||||
openstacklib: "#{source_dir}/../openstacklib"
|
||||
oslo: "#{source_dir}/../oslo"
|
||||
apt: "#{source_dir}/../apt"
|
||||
openssl: "#{source_dir}/../openssl"
|
||||
postgresql: "#{source_dir}/../postgresql"
|
||||
staging: "#{source_dir}/../staging"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'rake', :require => false
|
||||
gem 'rspec', '~>3.3', :require => false
|
||||
gem 'rspec-puppet', '~>2.1.0', :require => false
|
||||
gem 'rspec-puppet-facts', :require => false
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'puppet-lint', :require => false
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
||||
|
||||
# vim:ft=ruby
|
|
@ -3,10 +3,11 @@ require 'spec_helper'
|
|||
describe 'fuel::rabbitmq', :type => :class do
|
||||
context 'on supported platform' do
|
||||
let(:facts) {{
|
||||
:osfamily => 'Debian',
|
||||
:lsbdistid => 'Ubuntu',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:operatingsystemrelease => '14.04',
|
||||
:osfamily => 'RedHat',
|
||||
:lsbdistid => 'CentOS',
|
||||
:operatingsystem => 'CentOS',
|
||||
:operatingsystemrelease => '7.2',
|
||||
:operatingsystemmajrelease => '7',
|
||||
}}
|
||||
context 'with default parameters' do
|
||||
describe 'declares rabbitmq class' do
|
||||
|
|
|
@ -38,7 +38,7 @@ describe "fuel::keystone" do
|
|||
:priority => '05',
|
||||
:threads => 3,
|
||||
:vhost_custom_fragment => 'LimitRequestFieldSize 81900',
|
||||
:workers => 6,
|
||||
:workers => 1,
|
||||
:access_log_format => 'forwarded',
|
||||
)
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ describe "fuel::keystone" do
|
|||
|
||||
on_supported_os(supported_os: supported_os).each do |os, facts|
|
||||
context "on #{os}" do
|
||||
let(:facts) { facts }
|
||||
let(:facts) { facts.merge!(@default_facts) }
|
||||
it_configures "keystone configuration"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'fuel::nginx::services' do
|
||||
context 'when TLS enabled' do
|
||||
let :params do
|
||||
{
|
||||
:staticdir => '/var/www/static/',
|
||||
:logdumpdir => '/var/log/',
|
||||
:ssl_enabled => true,
|
||||
}
|
||||
end
|
||||
shared_examples_for "fuel nginx services" do
|
||||
context 'when TLS enabled' do
|
||||
let :params do
|
||||
{
|
||||
:staticdir => '/var/www/static/',
|
||||
:logdumpdir => '/var/log/',
|
||||
:ssl_enabled => true,
|
||||
}
|
||||
end
|
||||
|
||||
it 'should create new Diffie-Hellmann parameters file' do
|
||||
should contain_exec('create new dhparam file')
|
||||
it 'should create ssl file' do
|
||||
should contain_openssl__certificate__x509('nginx')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os(supported_os: supported_os).each do |os, facts|
|
||||
context "on #{os}" do
|
||||
let(:facts) { facts }
|
||||
it_configures "fuel nginx services"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'fuel::nginx' do
|
||||
it 'should contain X-Frame-Options SAMEORIGIN header' do
|
||||
should contain_file('/etc/nginx/nginx.conf').with_content(/^\s*add_header X-Frame-Options SAMEORIGIN;$/)
|
||||
shared_examples_for "fuel nginx" do
|
||||
it 'should contain X-Frame-Options SAMEORIGIN header' do
|
||||
should contain_file('/etc/nginx/nginx.conf').with_content(/^\s*add_header X-Frame-Options SAMEORIGIN;$/)
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os(supported_os: supported_os).each do |os, facts|
|
||||
context "on #{os}" do
|
||||
let(:facts) { facts }
|
||||
it_configures "fuel nginx"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
require 'spec_helper'
|
||||
require 'zlib'
|
||||
require 'ipaddr'
|
||||
|
||||
describe 'default' do
|
||||
admin_nets = [
|
||||
{"id"=>1,
|
||||
"node_group_name"=>nil,
|
||||
"node_group_id"=>nil,
|
||||
"cluster_name"=>nil,
|
||||
"cluster_id"=>nil,
|
||||
"cidr"=>"10.145.0.0/24",
|
||||
"gateway"=>"10.145.0.2",
|
||||
"ip_ranges"=>[["10.145.0.3", "10.145.0.250"]]},
|
||||
{"id"=>2,
|
||||
"node_group_name"=>"default2",
|
||||
"node_group_id"=>22,
|
||||
"cluster_name"=>"default2",
|
||||
"cluster_id"=>2,
|
||||
"cidr"=>"10.144.0.0/24",
|
||||
"gateway"=>"10.144.0.5",
|
||||
"ip_ranges"=>[["10.144.0.10", "10.144.0.254"]]},
|
||||
# Network with parameters shared with id=2
|
||||
{"id"=>3,
|
||||
"node_group_name"=>"default3",
|
||||
"node_group_id"=>23,
|
||||
"cluster_name"=>"default3",
|
||||
"cluster_id"=>3,
|
||||
"cidr"=>"10.144.0.0/24",
|
||||
"gateway"=>"10.144.0.5",
|
||||
"ip_ranges"=>[["10.144.0.10", "10.144.0.254"]]}
|
||||
]
|
||||
admin_network = {"interface"=>"eth0",
|
||||
"ipaddress"=>"10.145.0.2",
|
||||
"netmask"=>"255.255.255.0",
|
||||
"cidr"=>"10.20.0.0/24",
|
||||
"size"=>"256",
|
||||
"dhcp_pool_start"=>"10.145.0.3",
|
||||
"dhcp_pool_end"=>"10.145.0.254",
|
||||
"mac"=>"64:42:d3:10:64:68",
|
||||
"dhcp_gateway"=>"10.145.0.1"}
|
||||
|
||||
admin_nets.each do |net|
|
||||
net['ip_ranges'].each do |ip_range|
|
||||
netmask = IPAddr.new('255.255.255.255').mask(net['cidr'].split('/')[1]).to_s
|
||||
print_range = ip_range.join('_')
|
||||
resource_name = sprintf("range_%08x", Zlib::crc32("#{print_range}_#{net['cidr']}").to_i)
|
||||
it { should contain_file("/etc/dnsmasq.d/#{resource_name}.conf") \
|
||||
.with_content(/^dhcp-range=#{resource_name}.*#{netmask},120m\n|,boothost,#{admin_network['ipaddress']}\n/)
|
||||
}
|
||||
it { should contain_file("/etc/dnsmasq.d/#{resource_name}.conf") \
|
||||
.with_content(/^dhcp-match=set:ipxe,175$/)
|
||||
}
|
||||
it { should contain_file("/etc/dnsmasq.d/#{resource_name}.conf") \
|
||||
.with_content(/^dhcp-option-force=tag:ipxe,210,http:/)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,12 +1,25 @@
|
|||
require 'rspec-puppet'
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
|
||||
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
|
||||
require 'rspec-puppet-facts'
|
||||
include RspecPuppetFacts
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.module_path = File.join(fixture_path, 'modules')
|
||||
c.manifest_dir = File.join(fixture_path, 'manifests')
|
||||
c.mock_with(:mocha)
|
||||
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 = { :os_service_default => '<SERVICE DEFAULT>' }
|
||||
end
|
||||
end
|
||||
|
||||
# TODO(aschultz): remove these and switch rspec-puppet-facts to use
|
||||
# metadata.json values
|
||||
def supported_os
|
||||
[
|
||||
{ 'operatingsystem' => 'CentOS',
|
||||
'operatingsystemrelease' => [ '7.0' ] },
|
||||
{ 'operatingsystem' => 'Ubuntu',
|
||||
'operatingsystemrelease' => [ '14.04' ] }
|
||||
]
|
||||
end
|
||||
|
||||
def puppet_debug_override
|
||||
|
|
Loading…
Reference in New Issue