Merge "Noop tests update"
This commit is contained in:
commit
05a1faa729
1
deployment/puppet/osnailyfacter/modular/master
Symbolic link
1
deployment/puppet/osnailyfacter/modular/master
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../nailgun/examples
|
1
tests/noop/astute.yaml/.gitignore
vendored
1
tests/noop/astute.yaml/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
globals_yaml_for_*yaml
|
|
0
tests/noop/astute.yaml/facts/.gitkeep
Normal file
0
tests/noop/astute.yaml/facts/.gitkeep
Normal file
1
tests/noop/astute.yaml/facts/master-astute-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-astute-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-cobbler-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-cobbler-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-dhcp-default-range.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-dhcp-default-range.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-hiera-for-container.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-hiera-for-container.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-host-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-host-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-host-upgrade.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-host-upgrade.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-keystone-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-keystone-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-nailgun-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-nailgun-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-nginx-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-nginx-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-ostf-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-ostf-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-postgres-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-postgres-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-puppetsync-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-puppetsync-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-rabbitmq-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-rabbitmq-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
1
tests/noop/astute.yaml/facts/master-rsyslog-only.yaml
Symbolic link
1
tests/noop/astute.yaml/facts/master-rsyslog-only.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
master.facts.yaml
|
3
tests/noop/astute.yaml/facts/master.facts.yaml
Normal file
3
tests/noop/astute.yaml/facts/master.facts.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# these facts are needed for old-style manifests with $::fuel_settings
|
||||||
|
astute_settings_yaml: "\"HOSTNAME\": \"nailgun\"\n\"DNS_DOMAIN\": \"test.domain.local\"\n\"DNS_SEARCH\": \"test.domain.local\"\n\"DNS_UPSTREAM\": \"10.109.0.1\"\n\"NTP1\": \"0.fuel.pool.ntp.org\"\n\"NTP2\": \"1.fuel.pool.ntp.org\"\n\"NTP3\": \"2.fuel.pool.ntp.org\"\n\"ADMIN_NETWORK\":\n \"interface\": \"eth0\"\n \"ipaddress\": \"10.109.0.2\"\n \"netmask\": \"255.255.255.0\"\n \"cidr\": \"10.20.0.0/24\"\n \"size\": \"256\"\n \"dhcp_gateway\": \"10.109.0.1\"\n \"dhcp_pool_start\": \"10.109.0.3\"\n \"dhcp_pool_end\": \"10.109.0.254\"\n \"mac\": \"64:60:46:2e:5d:37\"\n\"FUEL_ACCESS\":\n \"user\": \"admin\"\n \"password\": \"admin\"\n\"BOOTSTRAP\":\n \"MIRROR_DISTRO\": \"http://archive.ubuntu.com/ubuntu\"\n \"MIRROR_MOS\": \"http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0\"\n \"HTTP_PROXY\": \"\"\n \"EXTRA_APT_REPOS\": \"\"\n \"flavor\": \"centos\"\n\"PRODUCTION\": \"docker\"\n\"postgres\":\n \"keystone_dbname\": \"keystone\"\n \"nailgun_user\": \"nailgun\"\n \"keystone_user\": \"keystone\"\n \"nailgun_password\": \"CYoU6RS6\"\n \"ostf_user\": \"ostf\"\n \"nailgun_dbname\": \"nailgun\"\n \"keystone_password\": \"cpppakUb\"\n \"ostf_dbname\": \"ostf\"\n \"ostf_password\": \"TwfzylM7\"\n\"cobbler\":\n \"password\": \"0mMXE4t8\"\n \"user\": \"cobbler\"\n\"astute\":\n \"password\": \"SwLCUx2H\"\n \"user\": \"naily\"\n\"keystone\":\n \"nailgun_user\": \"nailgun\"\n \"monitord_user\": \"monitord\"\n \"nailgun_password\": \"MtC5S2TN\"\n \"monitord_password\": \"9IR0gsgd\"\n \"ostf_user\": \"ostf\"\n \"admin_token\": \"ZoyxrMO6\"\n \"ostf_password\": \"7evzsSBv\"\n\"mcollective\":\n \"password\": \"PPMi1XT2\"\n \"user\": \"mcollective\"\n"
|
||||||
|
fuel_release: "8.0"
|
1
tests/noop/astute.yaml/globals/.gitignore
vendored
Normal file
1
tests/noop/astute.yaml/globals/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.yaml
|
76
tests/noop/astute.yaml/master.yaml
Normal file
76
tests/noop/astute.yaml/master.yaml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# fqdn is needed for tests internals
|
||||||
|
fqdn: "fuel.domain.tld"
|
||||||
|
role: "master"
|
||||||
|
|
||||||
|
# run only these tasks with the master node manifest
|
||||||
|
test_tasks:
|
||||||
|
- master/astute-only
|
||||||
|
- master/cobbler-only
|
||||||
|
- master/dhcp-default-range
|
||||||
|
- master/hiera-for-container
|
||||||
|
- master/host-only
|
||||||
|
- master/host-upgrade
|
||||||
|
- master/keystone-only
|
||||||
|
- master/nailgun-only
|
||||||
|
- master/nginx-only
|
||||||
|
- master/ostf-only
|
||||||
|
- master/postgres-only
|
||||||
|
- master/puppetsync-only
|
||||||
|
- master/rabbitmq-only
|
||||||
|
- master/rsyslog-only
|
||||||
|
|
||||||
|
# Full astute.yaml for new-style manifests that load it via Hiera
|
||||||
|
"HOSTNAME": "nailgun"
|
||||||
|
"DNS_DOMAIN": "test.domain.local"
|
||||||
|
"DNS_SEARCH": "test.domain.local"
|
||||||
|
"DNS_UPSTREAM": "10.109.0.1"
|
||||||
|
"NTP1": "0.fuel.pool.ntp.org"
|
||||||
|
"NTP2": "1.fuel.pool.ntp.org"
|
||||||
|
"NTP3": "2.fuel.pool.ntp.org"
|
||||||
|
"ADMIN_NETWORK":
|
||||||
|
"interface": "eth0"
|
||||||
|
"ipaddress": "10.109.0.2"
|
||||||
|
"netmask": "255.255.255.0"
|
||||||
|
"cidr": "10.20.0.0/24"
|
||||||
|
"size": "256"
|
||||||
|
"dhcp_gateway": "10.109.0.1"
|
||||||
|
"dhcp_pool_start": "10.109.0.3"
|
||||||
|
"dhcp_pool_end": "10.109.0.254"
|
||||||
|
"mac": "64:60:46:2e:5d:37"
|
||||||
|
"FUEL_ACCESS":
|
||||||
|
"user": "admin"
|
||||||
|
"password": "admin"
|
||||||
|
"BOOTSTRAP":
|
||||||
|
"MIRROR_DISTRO": "http://archive.ubuntu.com/ubuntu"
|
||||||
|
"MIRROR_MOS": "http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0"
|
||||||
|
"HTTP_PROXY": ""
|
||||||
|
"EXTRA_APT_REPOS": ""
|
||||||
|
"flavor": "centos"
|
||||||
|
"PRODUCTION": "docker"
|
||||||
|
"postgres":
|
||||||
|
"keystone_dbname": "keystone"
|
||||||
|
"nailgun_user": "nailgun"
|
||||||
|
"keystone_user": "keystone"
|
||||||
|
"nailgun_password": "CYoU6RS6"
|
||||||
|
"ostf_user": "ostf"
|
||||||
|
"nailgun_dbname": "nailgun"
|
||||||
|
"keystone_password": "cpppakUb"
|
||||||
|
"ostf_dbname": "ostf"
|
||||||
|
"ostf_password": "TwfzylM7"
|
||||||
|
"cobbler":
|
||||||
|
"password": "0mMXE4t8"
|
||||||
|
"user": "cobbler"
|
||||||
|
"astute":
|
||||||
|
"password": "SwLCUx2H"
|
||||||
|
"user": "naily"
|
||||||
|
"keystone":
|
||||||
|
"nailgun_user": "nailgun"
|
||||||
|
"monitord_user": "monitord"
|
||||||
|
"nailgun_password": "MtC5S2TN"
|
||||||
|
"monitord_password": "9IR0gsgd"
|
||||||
|
"ostf_user": "ostf"
|
||||||
|
"admin_token": "ZoyxrMO6"
|
||||||
|
"ostf_password": "7evzsSBv"
|
||||||
|
"mcollective":
|
||||||
|
"password": "PPMi1XT2"
|
||||||
|
"user": "mcollective"
|
0
tests/noop/astute.yaml/override/.gitkeep
Normal file
0
tests/noop/astute.yaml/override/.gitkeep
Normal file
@ -10,6 +10,8 @@ describe manifest do
|
|||||||
it 'should save the globals yaml file' do
|
it 'should save the globals yaml file' do
|
||||||
globals_yaml_content = Noop.resource_parameter_value self, 'file', '/etc/hiera/globals.yaml', 'content'
|
globals_yaml_content = Noop.resource_parameter_value self, 'file', '/etc/hiera/globals.yaml', 'content'
|
||||||
globals_yaml_path = Noop.globals_yaml_path
|
globals_yaml_path = Noop.globals_yaml_path
|
||||||
|
globals_yaml_folder = Noop.hiera_globals_folder_path
|
||||||
|
Dir.mkdir globals_yaml_folder unless File.directory? globals_yaml_folder
|
||||||
raise 'Could not get globals file content!' unless globals_yaml_content
|
raise 'Could not get globals file content!' unless globals_yaml_content
|
||||||
File.open(globals_yaml_path, 'w') { |file| file.write globals_yaml_content }
|
File.open(globals_yaml_path, 'w') { |file| file.write globals_yaml_content }
|
||||||
puts "Globals yaml saved to: '#{globals_yaml_path}'" if ENV['SPEC_PUPPET_DEBUG']
|
puts "Globals yaml saved to: '#{globals_yaml_path}'" if ENV['SPEC_PUPPET_DEBUG']
|
||||||
|
8
tests/noop/spec/hosts/master/astute-only_spec.rb
Normal file
8
tests/noop/spec/hosts/master/astute-only_spec.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/astute-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
||||||
|
|
7
tests/noop/spec/hosts/master/cobbler-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/cobbler-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/cobbler-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/dhcp-default-range_spec.rb
Normal file
7
tests/noop/spec/hosts/master/dhcp-default-range_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/dhcp-default-range.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/hiera-for-container_spec.rb
Normal file
7
tests/noop/spec/hosts/master/hiera-for-container_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/hiera-for-container.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/host-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/host-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/host-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/host-upgrade_spec.rb
Normal file
7
tests/noop/spec/hosts/master/host-upgrade_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/host-upgrade.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/keystone-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/keystone-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/keystone-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
16
tests/noop/spec/hosts/master/nailgun-only_spec.rb
Normal file
16
tests/noop/spec/hosts/master/nailgun-only_spec.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/nailgun-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
Noop.puppet_function_load :file
|
||||||
|
MockFunction.new(:file) do |function|
|
||||||
|
allow(function).to receive(:call).with(['/root/.ssh/id_rsa.pub']).and_return('key')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test_centos manifest
|
||||||
|
end
|
||||||
|
|
7
tests/noop/spec/hosts/master/nginx-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/nginx-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/nginx-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/ostf-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/ostf-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/ostf-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/postgres-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/postgres-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/postgres-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/puppetsync-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/puppetsync-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/puppetsync-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/rabbitmq-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/rabbitmq-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/rabbitmq-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
7
tests/noop/spec/hosts/master/rsyslog-only_spec.rb
Normal file
7
tests/noop/spec/hosts/master/rsyslog-only_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
require 'shared-examples'
|
||||||
|
manifest = 'master/rsyslog-only.pp'
|
||||||
|
|
||||||
|
describe manifest do
|
||||||
|
test_centos manifest
|
||||||
|
end
|
@ -3,11 +3,10 @@ require 'shared-examples'
|
|||||||
manifest = 'murano/db.pp'
|
manifest = 'murano/db.pp'
|
||||||
|
|
||||||
describe manifest do
|
describe manifest do
|
||||||
murano_hash = Noop.hiera('murano')
|
|
||||||
|
|
||||||
if murano_hash['enabled']
|
|
||||||
shared_examples 'catalog' do
|
shared_examples 'catalog' do
|
||||||
it 'should install proper mysql-client' do
|
murano_enabled = Noop.hiera_structure('murano/enabled', false)
|
||||||
|
|
||||||
|
it 'should install proper mysql-client', :if => murano_enabled do
|
||||||
if facts[:osfamily] == 'RedHat'
|
if facts[:osfamily] == 'RedHat'
|
||||||
pkg_name = 'MySQL-client-wsrep'
|
pkg_name = 'MySQL-client-wsrep'
|
||||||
elsif facts[:osfamily] == 'Debian'
|
elsif facts[:osfamily] == 'Debian'
|
||||||
@ -18,7 +17,6 @@ describe manifest do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
test_ubuntu_and_centos manifest
|
test_ubuntu_and_centos manifest
|
||||||
end
|
end
|
||||||
|
@ -3,11 +3,10 @@ require 'shared-examples'
|
|||||||
manifest = 'sahara/db.pp'
|
manifest = 'sahara/db.pp'
|
||||||
|
|
||||||
describe manifest do
|
describe manifest do
|
||||||
sahara_hash = Noop.hiera('sahara')
|
|
||||||
|
|
||||||
if sahara_hash['enabled']
|
|
||||||
shared_examples 'catalog' do
|
shared_examples 'catalog' do
|
||||||
it 'should install proper mysql-client' do
|
sahara_enabled = Noop.hiera_structure('sahara/enabled', false)
|
||||||
|
|
||||||
|
it 'should install proper mysql-client', :if => sahara_enabled do
|
||||||
if facts[:osfamily] == 'RedHat'
|
if facts[:osfamily] == 'RedHat'
|
||||||
pkg_name = 'MySQL-client-wsrep'
|
pkg_name = 'MySQL-client-wsrep'
|
||||||
elsif facts[:osfamily] == 'Debian'
|
elsif facts[:osfamily] == 'Debian'
|
||||||
@ -18,7 +17,6 @@ describe manifest do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
test_ubuntu_and_centos manifest
|
test_ubuntu_and_centos manifest
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ class Noop
|
|||||||
# escapes single quote characters and wrap into them
|
# escapes single quote characters and wrap into them
|
||||||
"'#{value.gsub "'", '\\\\\''}'"
|
"'#{value.gsub "'", '\\\\\''}'"
|
||||||
end
|
end
|
||||||
else value.inspect
|
else value.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,19 +5,38 @@ class Noop
|
|||||||
puts msg if ENV['SPEC_PUPPET_DEBUG']
|
puts msg if ENV['SPEC_PUPPET_DEBUG']
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_report(context)
|
def hiera_data_yaml_files
|
||||||
<<-eos
|
hiera_config.fetch(:hierarchy, []).map do |element|
|
||||||
=============================================
|
File.join hiera_data_path, "#{element}.yaml"
|
||||||
OS: #{current_os context}
|
end
|
||||||
YAML: #{astute_yaml_base}
|
end
|
||||||
Spec: #{current_spec context}
|
|
||||||
Manifest: #{manifest_path}
|
def status_report_template
|
||||||
Node: #{fqdn}
|
<<-'eos'
|
||||||
Role: #{role}
|
<%= '=' * 80 %>
|
||||||
=============================================
|
Node: <%= fqdn or '?' %>
|
||||||
|
OS: <%= current_os context %>
|
||||||
|
Role: <%= role or '?' %>
|
||||||
|
|
||||||
|
YAML: <%= astute_yaml_path %>
|
||||||
|
Spec: <%= current_spec context %>
|
||||||
|
Manifest: <%= manifest_path %>
|
||||||
|
<% if ENV['SPEC_CATALOG_CHECK'] -%>
|
||||||
|
Catalog: <%= catalog_dump_file_path context %>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
Hiera:
|
||||||
|
<% hiera_data_yaml_files.each do |element| -%>
|
||||||
|
* <%= element %>
|
||||||
|
<% end -%>
|
||||||
|
<%= '=' * 80 %>
|
||||||
eos
|
eos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def status_report(context)
|
||||||
|
ERB.new(status_report_template, nil, '-').result(binding)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
extend Debug
|
extend Debug
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,23 @@
|
|||||||
|
require 'yaml'
|
||||||
|
|
||||||
class Noop
|
class Noop
|
||||||
module Facts
|
module Facts
|
||||||
|
|
||||||
|
def override_facts
|
||||||
|
facts = {}
|
||||||
|
return facts unless hiera_facts_override_present?
|
||||||
|
begin
|
||||||
|
override_facts = YAML.load_file facts_yaml_path
|
||||||
|
return {} unless facts.is_a? Hash
|
||||||
|
override_facts.each do |fact, value|
|
||||||
|
facts[fact.to_sym] = value
|
||||||
|
end
|
||||||
|
facts
|
||||||
|
rescue
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def ubuntu_facts
|
def ubuntu_facts
|
||||||
{
|
{
|
||||||
:fqdn => fqdn,
|
:fqdn => fqdn,
|
||||||
@ -13,12 +30,13 @@ class Noop
|
|||||||
:osfamily => 'Debian',
|
:osfamily => 'Debian',
|
||||||
:operatingsystem => 'Ubuntu',
|
:operatingsystem => 'Ubuntu',
|
||||||
:operatingsystemrelease => '14.04',
|
:operatingsystemrelease => '14.04',
|
||||||
|
:operatingsystemmajrelease => '14',
|
||||||
:lsbdistid => 'Ubuntu',
|
:lsbdistid => 'Ubuntu',
|
||||||
:l3_fqdn_hostname => hostname,
|
:l3_fqdn_hostname => hostname,
|
||||||
:l3_default_route => '172.16.1.1',
|
:l3_default_route => '172.16.1.1',
|
||||||
:concat_basedir => '/tmp/',
|
:concat_basedir => '/tmp/',
|
||||||
:l23_os => 'ubuntu',
|
:l23_os => 'ubuntu',
|
||||||
}
|
}.merge override_facts
|
||||||
end
|
end
|
||||||
|
|
||||||
def centos_facts
|
def centos_facts
|
||||||
@ -33,12 +51,13 @@ class Noop
|
|||||||
:osfamily => 'RedHat',
|
:osfamily => 'RedHat',
|
||||||
:operatingsystem => 'CentOS',
|
:operatingsystem => 'CentOS',
|
||||||
:operatingsystemrelease => '6.5',
|
:operatingsystemrelease => '6.5',
|
||||||
|
:operatingsystemmajrelease => '6',
|
||||||
:lsbdistid => 'CentOS',
|
:lsbdistid => 'CentOS',
|
||||||
:l3_fqdn_hostname => hostname,
|
:l3_fqdn_hostname => hostname,
|
||||||
:l3_default_route => '172.16.1.1',
|
:l3_default_route => '172.16.1.1',
|
||||||
:concat_basedir => '/tmp/',
|
:concat_basedir => '/tmp/',
|
||||||
:l23_os => 'centos6',
|
:l23_os => 'centos6',
|
||||||
}
|
}.merge override_facts
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -13,18 +13,23 @@ class Noop
|
|||||||
:yaml => {
|
:yaml => {
|
||||||
:datadir => hiera_data_path,
|
:datadir => hiera_data_path,
|
||||||
},
|
},
|
||||||
:hierarchy => [
|
:hierarchy => hiera_config_hierarhy,
|
||||||
hiera_data_globals,
|
|
||||||
hiera_data_astute,
|
|
||||||
hiera_task_override,
|
|
||||||
],
|
|
||||||
:logger => logger,
|
:logger => logger,
|
||||||
:merge_behavior => :deeper,
|
:merge_behavior => :deeper,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hiera_config_hierarhy
|
||||||
|
elements = []
|
||||||
|
elements << hiera_task_override if hiera_task_override_present?
|
||||||
|
elements << hiera_data_globals
|
||||||
|
elements << hiera_data_astute
|
||||||
|
elements
|
||||||
|
end
|
||||||
|
|
||||||
def hiera_object
|
def hiera_object
|
||||||
return @hiera_object if @hiera_object
|
# hiera may be unstable with mnemoization object
|
||||||
|
# return @hiera_object if @hiera_object
|
||||||
@hiera_object = Hiera.new(:config => hiera_config)
|
@hiera_object = Hiera.new(:config => hiera_config)
|
||||||
Hiera.logger = hiera_config[:logger]
|
Hiera.logger = hiera_config[:logger]
|
||||||
@hiera_object
|
@hiera_object
|
||||||
|
@ -21,21 +21,35 @@ class Noop
|
|||||||
'override'
|
'override'
|
||||||
end
|
end
|
||||||
|
|
||||||
def hiera_override_path
|
def hiera_globals_folder
|
||||||
File.expand_path(File.join(hiera_data_path, hiera_override_folder))
|
'globals'
|
||||||
end
|
end
|
||||||
|
|
||||||
def hiera_task_override_file
|
def hiera_facts_folder
|
||||||
|
'facts'
|
||||||
|
end
|
||||||
|
|
||||||
|
def hiera_task_additional_yaml_file
|
||||||
return nil unless manifest
|
return nil unless manifest
|
||||||
manifest.gsub('/', '-').gsub('.pp', '')
|
manifest.gsub('/', '-').gsub('.pp', '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def hiera_task_override
|
def hiera_task_override
|
||||||
override_file = hiera_task_override_file
|
override_file = hiera_task_additional_yaml_file
|
||||||
return nil unless override_file
|
return nil unless override_file
|
||||||
File.join hiera_override_folder, override_file
|
File.join hiera_override_folder, override_file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hiera_task_override_present?
|
||||||
|
return unless override_yaml_path
|
||||||
|
File.exists? override_yaml_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def hiera_facts_override_present?
|
||||||
|
return unless facts_yaml_path
|
||||||
|
File.exists? facts_yaml_path
|
||||||
|
end
|
||||||
|
|
||||||
def astute_yaml_name
|
def astute_yaml_name
|
||||||
return ENV['SPEC_ASTUTE_FILE_NAME'] if ENV['SPEC_ASTUTE_FILE_NAME']
|
return ENV['SPEC_ASTUTE_FILE_NAME'] if ENV['SPEC_ASTUTE_FILE_NAME']
|
||||||
'novanet-primary-controller.yaml'
|
'novanet-primary-controller.yaml'
|
||||||
@ -46,15 +60,33 @@ class Noop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def astute_yaml_path
|
def astute_yaml_path
|
||||||
File.expand_path(File.join(hiera_data_path, astute_yaml_name))
|
File.expand_path File.join hiera_data_path, astute_yaml_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def globals_yaml_path
|
def globals_yaml_path
|
||||||
File.expand_path(File.join(hiera_data_path, globlas_prefix + astute_yaml_name))
|
File.expand_path File.join hiera_globals_folder_path, astute_yaml_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def globlas_prefix
|
def override_yaml_path
|
||||||
'globals_yaml_for_'
|
return unless hiera_task_additional_yaml_file
|
||||||
|
File.expand_path File.join hiera_override_folder_path, hiera_task_additional_yaml_file + '.yaml'
|
||||||
|
end
|
||||||
|
|
||||||
|
def facts_yaml_path
|
||||||
|
return unless hiera_task_additional_yaml_file
|
||||||
|
File.expand_path File.join hiera_facts_folder_path, hiera_task_additional_yaml_file + '.yaml'
|
||||||
|
end
|
||||||
|
|
||||||
|
def hiera_override_folder_path
|
||||||
|
File.expand_path File.join hiera_data_path, hiera_override_folder
|
||||||
|
end
|
||||||
|
|
||||||
|
def hiera_facts_folder_path
|
||||||
|
File.expand_path File.join hiera_data_path, hiera_facts_folder
|
||||||
|
end
|
||||||
|
|
||||||
|
def hiera_globals_folder_path
|
||||||
|
File.expand_path File.join hiera_data_path, hiera_globals_folder
|
||||||
end
|
end
|
||||||
|
|
||||||
def hiera_data_astute
|
def hiera_data_astute
|
||||||
@ -62,7 +94,7 @@ class Noop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def hiera_data_globals
|
def hiera_data_globals
|
||||||
globlas_prefix + hiera_data_astute
|
File.join hiera_globals_folder, hiera_data_astute
|
||||||
end
|
end
|
||||||
|
|
||||||
def modular_manifests_node_dir
|
def modular_manifests_node_dir
|
||||||
|
@ -15,7 +15,23 @@ class Noop
|
|||||||
@manifest
|
@manifest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hiera_test_tasks
|
||||||
|
return @hiera_test_tasks if @hiera_test_tasks
|
||||||
|
test_tasks = hiera 'test_tasks'
|
||||||
|
return unless test_tasks.is_a? Array
|
||||||
|
@hiera_test_tasks = test_tasks.map do |manifest|
|
||||||
|
manifest.gsub! '_spec.rb', '' if manifest.end_with? '_spec.rb'
|
||||||
|
manifest += '.pp' unless manifest.end_with? '.pp'
|
||||||
|
manifest
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_tasks_present?
|
||||||
|
hiera_test_tasks.is_a? Array
|
||||||
|
end
|
||||||
|
|
||||||
def manifest_present?(manifest)
|
def manifest_present?(manifest)
|
||||||
|
return hiera_test_tasks.include? manifest if test_tasks_present?
|
||||||
manifest_path = File.join self.modular_manifests_node_dir, manifest
|
manifest_path = File.join self.modular_manifests_node_dir, manifest
|
||||||
tasks.each do |task|
|
tasks.each do |task|
|
||||||
next unless task['type'] == 'puppet'
|
next unless task['type'] == 'puppet'
|
||||||
@ -59,7 +75,7 @@ class Noop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_os(context)
|
def current_os(context)
|
||||||
context.facts.fetch(:operatingsystem, '').downcase
|
context.os
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ubuntu?
|
def test_ubuntu?
|
||||||
|
@ -46,6 +46,7 @@ shared_examples 'save_files_list' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'OS' do
|
shared_examples 'OS' do
|
||||||
|
|
||||||
include_examples 'compile'
|
include_examples 'compile'
|
||||||
|
|
||||||
include_examples 'status' if ENV['SPEC_SHOW_STATUS']
|
include_examples 'status' if ENV['SPEC_SHOW_STATUS']
|
||||||
@ -72,9 +73,29 @@ end
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def test_ubuntu_and_centos(manifest_file, force_manifest = false)
|
def test_ubuntu_and_centos(manifest_file, force_manifest = false)
|
||||||
|
run_test(manifest_file, :force_manifest => force_manifest)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ubuntu(manifest_file, force_manifest = false)
|
||||||
|
run_test(manifest_file, :force_manifest => force_manifest, :run_ubuntu => true, :run_centos => false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_centos(manifest_file, force_manifest = false)
|
||||||
|
run_test(manifest_file, :force_manifest => force_manifest, :run_ubuntu => false, :run_centos => true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_test(manifest_file, options)
|
||||||
|
|
||||||
|
default_options = {
|
||||||
|
:force_manifest => false,
|
||||||
|
:run_ubuntu => true,
|
||||||
|
:run_centos => true,
|
||||||
|
}
|
||||||
|
|
||||||
|
options = default_options.merge options
|
||||||
|
|
||||||
# check if task is present in the task list
|
# check if task is present in the task list
|
||||||
unless force_manifest or Noop.manifest_present? manifest_file
|
unless options[:force_manifest] or Noop.manifest_present? manifest_file
|
||||||
Noop.debug "Manifest '#{manifest_file}' is not enabled on the node '#{Noop.hostname}'. Skipping tests."
|
Noop.debug "Manifest '#{manifest_file}' is not enabled on the node '#{Noop.hostname}'. Skipping tests."
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -91,8 +112,11 @@ def test_ubuntu_and_centos(manifest_file, force_manifest = false)
|
|||||||
GC.disable
|
GC.disable
|
||||||
end
|
end
|
||||||
|
|
||||||
if Noop.test_ubuntu?
|
if Noop.test_ubuntu? and options[:run_ubuntu]
|
||||||
context 'on Ubuntu platforms' do
|
context 'on Ubuntu platforms' do
|
||||||
|
let(:os) do
|
||||||
|
'ubuntu'
|
||||||
|
end
|
||||||
before(:all) do
|
before(:all) do
|
||||||
Noop.setup_overrides
|
Noop.setup_overrides
|
||||||
end
|
end
|
||||||
@ -104,8 +128,11 @@ def test_ubuntu_and_centos(manifest_file, force_manifest = false)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Noop.test_centos?
|
if Noop.test_centos? and options[:run_centos]
|
||||||
context 'on CentOS platforms' do
|
context 'on CentOS platforms' do
|
||||||
|
let(:os) do
|
||||||
|
'centos'
|
||||||
|
end
|
||||||
before(:all) do
|
before(:all) do
|
||||||
Noop.setup_overrides
|
Noop.setup_overrides
|
||||||
end
|
end
|
||||||
@ -118,4 +145,3 @@ def test_ubuntu_and_centos(manifest_file, force_manifest = false)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ module NoopTests
|
|||||||
ASTUTE_YAML_VAR = 'SPEC_ASTUTE_FILE_NAME'
|
ASTUTE_YAML_VAR = 'SPEC_ASTUTE_FILE_NAME'
|
||||||
BUNDLE_DIR = '.bundled_gems'
|
BUNDLE_DIR = '.bundled_gems'
|
||||||
BUNDLE_VAR = 'GEM_HOME'
|
BUNDLE_VAR = 'GEM_HOME'
|
||||||
GLOBALS_PREFIX = 'globals_yaml_for_'
|
|
||||||
PUPPET_GEM_VERSION = '~> 3.4.0'
|
PUPPET_GEM_VERSION = '~> 3.4.0'
|
||||||
TEST_LIBRARY_DIR = 'spec/hosts'
|
TEST_LIBRARY_DIR = 'spec/hosts'
|
||||||
|
GLOBALS_YAML_FOLDER = 'globals'
|
||||||
|
|
||||||
def self.options
|
def self.options
|
||||||
return @options if @options
|
return @options if @options
|
||||||
@ -64,9 +64,9 @@ module NoopTests
|
|||||||
opts.separator 'Filter options:'
|
opts.separator 'Filter options:'
|
||||||
opts.on('-s', '--specs SPEC1,SPEC2', Array, 'Run only these specs. Example: "hosts/hosts_spec.rb"') do |specs|
|
opts.on('-s', '--specs SPEC1,SPEC2', Array, 'Run only these specs. Example: "hosts/hosts_spec.rb"') do |specs|
|
||||||
specs = specs.map do |spec|
|
specs = specs.map do |spec|
|
||||||
if spec.end_with? '.pp'
|
spec.strip!
|
||||||
spec.gsub! '.pp', '_spec.rb'
|
spec.gsub! '.pp', '' if spec.end_with? '.pp'
|
||||||
end
|
spec += '_spec.rb' unless spec.end_with? '_spec.rb'
|
||||||
spec
|
spec
|
||||||
end
|
end
|
||||||
@options[:filter_specs] = specs
|
@options[:filter_specs] = specs
|
||||||
@ -203,8 +203,8 @@ module NoopTests
|
|||||||
# @return [Array<String>]
|
# @return [Array<String>]
|
||||||
def self.astute_yaml_files
|
def self.astute_yaml_files
|
||||||
files = []
|
files = []
|
||||||
Dir.new(astute_yaml_directory).each do |file|
|
Dir.entries(astute_yaml_directory).each do |file|
|
||||||
next if file.start_with? GLOBALS_PREFIX
|
next unless File.file? File.join astute_yaml_directory, file
|
||||||
next unless file.end_with? '.yaml'
|
next unless file.end_with? '.yaml'
|
||||||
files << file
|
files << file
|
||||||
end
|
end
|
||||||
@ -307,7 +307,7 @@ module NoopTests
|
|||||||
# @param [String] astute_yaml YAML file
|
# @param [String] astute_yaml YAML file
|
||||||
def self.globals(astute_yaml)
|
def self.globals(astute_yaml)
|
||||||
return if options[:skip_globals]
|
return if options[:skip_globals]
|
||||||
globals_file = File.join astute_yaml_directory, GLOBALS_PREFIX + astute_yaml
|
globals_file = File.join astute_yaml_directory, GLOBALS_YAML_FOLDER, astute_yaml
|
||||||
if File.file? globals_file
|
if File.file? globals_file
|
||||||
begin
|
begin
|
||||||
File.unlink globals_file
|
File.unlink globals_file
|
||||||
|
Loading…
Reference in New Issue
Block a user