Add test for modular tasks

* Put tests together with the tasks
* Split tasks into folders

Fuel-CI: disable
Change-Id: I4e09cf80592f7a5125d20ffd72cf8408922d5436
Related-Blueprint: fuel-library-modularization
This commit is contained in:
Dmitry Ilyin 2015-02-16 19:32:55 +03:00 committed by Aleksandr Didenko
parent ed3c8768ec
commit 23b7c6fd83
47 changed files with 881 additions and 145 deletions

View File

@ -40,7 +40,7 @@
required_for: [post_deployment_end]
requires: [upload_nodes_info]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/hosts.pp
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/hosts/hosts.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
cwd: /

View File

@ -0,0 +1,78 @@
require 'hiera'
require 'test/unit'
def process_tree
return $process_tree if $process_tree
$process_tree = {}
ps = `ps haxo pid,ppid,cmd`
ps.split("\n").each do |p|
f = p.split
pid = f.shift.to_i
ppid = f.shift.to_i
cmd = f.join ' '
# create entry for this pid if not present
$process_tree[pid] = {
:children => []
} unless $process_tree.key? pid
# fill this entry
$process_tree[pid][:ppid] = ppid
$process_tree[pid][:pid] = pid
$process_tree[pid][:cmd] = cmd
unless ppid == 0
# create entry for parent process if not present
$process_tree[ppid] = {
:children => [],
:cmd => '',
} unless $process_tree.key? ppid
# fill parent's children
$process_tree[ppid][:children] << pid
end
end
$process_tree
end
def hiera
return $hiera if $hiera
$hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
end
def management_vip
return $management_vip if $management_vip
$management_vip = hiera.lookup 'management_vip', nil, {}
end
def controller_node_address
return $controller_node_address if $controller_node_address
$controller_node_address = hiera.lookup 'controller_node_address', nil, {}
end
def haproxy_stats_url
ip = management_vip
ip = controller_node_address unless ip
raise 'Could not get internal address!' unless ip
port = 10000
"http://#{ip}:#{port}/;csv"
end
def url_accessible?(url)
`curl --fail '#{url}' 1>/dev/null 2>/dev/null`
$?.exitstatus == 0
end
class ClusterHaproxyPostTest < Test::Unit::TestCase
def test_haproxy_config_present
assert File.file?('/etc/haproxy/haproxy.cfg'), 'No haproxy config file!'
end
def test_haproxy_is_running
assert process_tree.find { |pid, proc| proc[:cmd].include? '/usr/sbin/haproxy' }, 'Haproxy is not running!'
end
def test_haproxy_stats_accessible
assert url_accessible?(haproxy_stats_url), "Cannot connect to the HAProxy stats url '#{haproxy_stats_url}'!"
end
end

View File

@ -7,3 +7,5 @@
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/cluster-haproxy/cluster-haproxy.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/cluster-haproxy/cluster-haproxy_post.rb

View File

@ -0,0 +1,69 @@
require 'hiera'
require 'test/unit'
def process_tree
return $process_tree if $process_tree
$process_tree = {}
ps = `ps haxo pid,ppid,cmd`
ps.split("\n").each do |p|
f = p.split
pid = f.shift.to_i
ppid = f.shift.to_i
cmd = f.join ' '
# create entry for this pid if not present
$process_tree[pid] = {
:children => []
} unless $process_tree.key? pid
# fill this entry
$process_tree[pid][:ppid] = ppid
$process_tree[pid][:pid] = pid
$process_tree[pid][:cmd] = cmd
unless ppid == 0
# create entry for parent process if not present
$process_tree[ppid] = {
:children => [],
:cmd => '',
} unless $process_tree.key? ppid
# fill parent's children
$process_tree[ppid][:children] << pid
end
end
$process_tree
end
def pacemaker_online?
`timeout 5 cibadmin -Q`
$?.exitstatus == 0
end
PROCESSES = %w(
crmd
lrmd
pengine
attrd
stonithd
cib
pacemakerd
corosync
)
class ClusterPostTest < Test::Unit::TestCase
def self.create_tests
PROCESSES.each do |process|
method_name = "test_iprocess_#{process}_running"
define_method method_name do
assert process_tree.find { |pid, proc| proc[:cmd].include? process }, "Process '#{process}' is not running!"
end
end
end
def test_pacemaker_is_online
assert pacemaker_online?, 'Could not query Pacemaker CIB!'
end
end
ClusterPostTest.create_tests

View File

@ -7,3 +7,5 @@
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/cluster/cluster.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/cluster/cluster_post.rb

View File

@ -0,0 +1,64 @@
require 'hiera'
require 'test/unit'
def iptables
return $iptables if $iptables
output = `iptables-save`
code = $?.exitstatus
return unless code == 0
comments = []
output.split("\n").each do |line|
line =~ /--comment\s+"(.*?)"/
next unless $1
comment = $1.chomp.strip.gsub /^\d+\s+/, ''
comments << comment
end
$iptables = comments
end
RULES = [
'accept all to lo interface',
'accept related established rules',
'ssh',
'http',
'mysql',
'keystone',
'swift',
'glance',
'nova',
'rabbitmq',
'memcached tcp',
'memcached udp',
'rsync',
'iscsi',
'neutron',
'dns-server',
'dhcp-server',
'ntp-server',
'corosync-input',
'corosync-output',
'openvswitch db',
'nrpe-server',
'libvirt',
'libvirt migration',
'vnc ports',
'ceilometer',
'notrack gre',
'accept gre',
'drop all other requests',
'remote puppet',
'remote rabbitmq',
]
class FirewallPostTest < Test::Unit::TestCase
def self.create_tests
RULES.each do |rule|
method_name = "test_iptables_have_rule_#{rule.gsub ' ', '_'}"
define_method method_name do
assert iptables.include?(rule), "Iptables don't have the '#{rule}' rule!'"
end
end
end
end
FirewallPostTest.create_tests

View File

@ -0,0 +1,14 @@
import subprocess
import unittest
class FirewallPreTest(unittest.TestCase):
def test_iptables_installed(self):
hiera = subprocess.Popen(['which', 'iptables'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
hiera.communicate()
self.assertEqual(hiera.returncode, 0, 'Iptables not installed!')
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,13 @@
- id: firewall
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [netconfig]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/firewall/firewall.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_pre:
cmd: python /etc/puppet/modules/osnailyfacter/modular/firewall/firewall_pre.py
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/firewall/firewall_post.rb

View File

@ -0,0 +1,21 @@
import os
import unittest
class GlobalsPostTest(unittest.TestCase):
FILE = '/etc/hiera/globals.yaml'
def test_has_globals_yaml(self):
self.assertTrue(os.path.isfile(self.FILE),
'Globals yaml not found!')
def test_has_use_neutron_key(self):
globals_file = open(self.FILE, 'r')
globals_data = globals_file.read()
globals_file.close()
self.assertTrue('use_neutron' in globals_data,
'use_neutron was not found in globals!')
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,13 @@
import subprocess
import unittest
class GlobalsPreTest(unittest.TestCase):
def test_can_get_uid(self):
hiera = subprocess.Popen(['hiera', 'uid'], stdout=subprocess.PIPE)
out = hiera.communicate()[0].rstrip()
self.assertNotEqual(out, 'nil',
'Could not get "uid" string from Hiera!')
if __name__ == '__main__':
unittest.main()

View File

@ -4,7 +4,7 @@ dir = File.dirname(__FILE__)
Dir.chdir dir
globals = 'globals.pp'
template_dir = '../templates'
template_dir = '../../templates'
raise 'No globlas.pp!' unless File.exist? globals
raise 'No template dir!' unless File.directory? template_dir

View File

@ -0,0 +1,15 @@
- id: globals
type: puppet
groups: [primary-controller, controller,
cinder, compute, ceph-osd,
zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [hiera]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/globals/globals.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_pre:
cmd: python /etc/puppet/modules/osnailyfacter/modular/globals/globals_pre.py
test_post:
cmd: python /etc/puppet/modules/osnailyfacter/modular/globals/globals_post.py

View File

@ -0,0 +1,22 @@
import os
import subprocess
import unittest
class HieraPostTest(unittest.TestCase):
def test_has_hiera_config(self):
self.assertTrue(os.path.isfile('/etc/hiera.yaml'),
'Hiera config not found!')
def test_has_hiera_puppet_config(self):
self.assertTrue(os.path.isfile('/etc/puppet/hiera.yaml'),
'Puppet Hiera config not found!')
def test_can_get_uid(self):
hiera = subprocess.Popen(['hiera', 'uid'], stdout=subprocess.PIPE)
out = hiera.communicate()[0].rstrip()
self.assertNotEqual(out, 'nil',
'Could not get "uid" string from Hiera!')
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,14 @@
import subprocess
import unittest
class HieraPreTest(unittest.TestCase):
def test_hiera_installed(self):
hiera = subprocess.Popen(['which', 'hiera'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
hiera.communicate()
self.assertEqual(hiera.returncode, 0, 'Hiera is not installed!')
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,13 @@
- id: hiera
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
requires: [deploy_start]
required_for: [deploy_end]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/hiera/hiera.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_pre:
cmd: python /etc/puppet/modules/osnailyfacter/modular/hiera/hiera_pre.py
test_post:
cmd: python /etc/puppet/modules/osnailyfacter/modular/hiera/hiera_post.py

View File

@ -0,0 +1,18 @@
require 'hiera'
require 'test/unit'
class HostsPostTest < Test::Unit::TestCase
def test_hosts_file_has_all_nodes
hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
nodes_array = hiera.lookup 'nodes', nil, {}
raise 'No nodes data!' unless nodes_array and nodes_array.is_a? Array
hosts_file = File.read '/etc/hosts'
nodes_array.each do |node|
host_regexp1 = Regexp.new "#{node['internal_address']}\\s+#{node['fqdn']}\\s+#{node['name']}"
host_regexp2 = Regexp.new "#{node['internal_address']}\\s+#{node['name']}\\s+#{node['fqdn']}"
assert (hosts_file =~ host_regexp1 or hosts_file =~ host_regexp2), "Host #{node['name']} was not found in hosts file!"
end
end
end

View File

@ -0,0 +1,25 @@
require 'hiera'
require 'test/unit'
class HostsPreTest < Test::Unit::TestCase
def test_hiera_has_nodes_data
hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
nodes_array = hiera.lookup 'nodes', nil, {}
assert nodes_array.is_a?(Array), 'Nodes data not found!'
assert nodes_array.any?
end
def test_nodes_are_correct
hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
nodes_array = hiera.lookup 'nodes', nil, {}
nodes_array.each do |node|
error = "Node #{node.inspect} is not correct!"
assert node['internal_address'], error
assert node['fqdn'], error
assert node['name'], error
end
end
end

View File

@ -0,0 +1,13 @@
- id: hosts
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [netconfig]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/hosts/hosts.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_pre:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/hosts/hosts_pre.rb
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/hosts/hosts_post.rb

View File

@ -0,0 +1,9 @@
- id: logging
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [globals]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/logging/logging.pp
puppet_modules: /etc/puppet/modules
timeout: 3600

View File

@ -0,0 +1,86 @@
require 'hiera'
require 'test/unit'
def ips
return $ips if $ips
ip_out = `ip addr`
return unless $?.exitstatus == 0
ips = []
ip_out.split("\n").each do |line|
if line =~ /\s+inet\s+([\d\.]*)/
ips << $1
end
end
$ips = ips
end
def router
return $router if $router
routes = `ip route`
return unless $?.exitstatus == 0
routes.split("\n").each do |line|
if line =~ /^default via ([\d\.]*)/
return $router = $1
end
end
nil
end
def ping(host)
`ping -q -c 1 -W 3 '#{host}'`
$?.exitstatus == 0
end
def hiera
return $hiera if $hiera
$hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
end
def fqdn
return $fqdn if $fqdn
$fqdn = hiera.lookup 'fqdn', nil, {}
end
def nodes
return $nodes if $nodes
$nodes = hiera.lookup 'nodes', [], {}
end
def role
return $role if $role
$role = hiera.lookup 'role', nil, {}
end
def master_ip
return $master_ip if $master_ip
$master_ip = hiera.lookup 'master_ip', nil, {}
end
class NetconfigPostTest < Test::Unit::TestCase
def test_management_ip_present
ip = nodes.find { |node| node['fqdn'] == fqdn }['internal_address']
assert ips.include?(ip), 'Management address is not set!'
end
def test_public_ip_present
if %w(controller primary-controller).include? role
ip = nodes.find { |node| node['fqdn'] == fqdn }['public_address']
assert ips.include?(ip), 'Public address is not set!'
end
end
def test_storage_ip_present
ip = nodes.find { |node| node['fqdn'] == fqdn }['storage_address']
assert ips.include?(ip), 'Storage address is not set!'
end
def test_can_ping_the_master_node
assert ping(master_ip), 'Cannot ping the master node!'
end
def test_can_ping_the_default_router
assert ping(router), 'Cannot ping the default router!'
end
end

View File

@ -0,0 +1,22 @@
require 'hiera'
require 'test/unit'
def hiera
return $hiera if $hiera
$hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
end
def nodes
return $nodes if $nodes
$nodes = hiera.lookup 'nodes', nil, {}
end
class NetconfigPreTest < Test::Unit::TestCase
def test_nodes_present_in_hiera
assert nodes, 'Could not get the nodes data!'
assert nodes.is_a?(Array), 'Incorrect nodes data!'
assert nodes.any?, 'Empty nodes data!'
end
end

View File

@ -0,0 +1,13 @@
- id: netconfig
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [logging]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/netconfig/netconfig.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_pre:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/netconfig/netconfig_pre.rb
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/netconfig/netconfig_post.rb

View File

@ -0,0 +1,103 @@
require 'hiera'
require 'test/unit'
require 'open-uri'
def hiera
return $hiera if $hiera
$hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
end
def management_vip
return $management_vip if $management_vip
$management_vip = hiera.lookup 'management_vip', nil, {}
end
def controller_node_address
return $controller_node_address if $controller_node_address
$controller_node_address = hiera.lookup 'controller_node_address', nil, {}
end
def sahara_enabled?
return $sahara_enabled if $sahara_enabled
sahara = hiera.lookup 'sahara', {}, {}
$sahara_enabled = sahara.fetch 'enabled', false
end
def murano_enabled?
return $murano_enabled if $murano_enabled
murano = hiera.lookup 'murano', {}, {}
$murano_enabled = murano.fetch 'enabled', false
end
def haproxy_stats_url
ip = management_vip
ip = controller_node_address unless ip
raise 'Could not get internal address!' unless ip
port = 10000
"http://#{ip}:#{port}/;csv"
end
def csv
return $csv if $csv
begin
url = open(haproxy_stats_url)
csv = url.read
rescue
nil
end
return nil unless csv and not csv.empty?
$csv = csv
end
def haproxy_backends
return $backends if $backends
raise 'Could not get CSV from HAProxy stats!' unless csv
backends = []
csv.split("\n").each do |line|
next if line.start_with? '#'
next unless line.include? 'BACKEND'
backend = line.split(',').first
backends << backend
end
$backends = backends
end
def expected_backends
return $expected_backends if $expected_backends
backends = %w(
Stats
horizon
keystone-1
keystone-2
nova-api-1
nova-api-2
nova-metadata-api
cinder-api
glance-api
neutron
glance-registry
rabbitmq
mysqld
swift
heat-api
heat-api-cfn
heat-api-cloudwatch
nova-novncproxy
)
backends += %w(sahara) if sahara_enabled?
backends += %w(murano murano_rabbitmq) if murano_enabled?
$expected_backends = backends
end
class OpenstackHaproxyPostTest < Test::Unit::TestCase
def self.create_tests
expected_backends.each do |backend|
method_name = "test_backend_#{backend}_present"
define_method method_name do
assert haproxy_backends.include?(backend), "There is no '#{backend}' HAProxy backend!"
end
end
end
end
OpenstackHaproxyPostTest.create_tests

View File

@ -0,0 +1,43 @@
require 'test/unit'
def process_tree
return $process_tree if $process_tree
$process_tree = {}
ps = `ps haxo pid,ppid,cmd`
ps.split("\n").each do |p|
f = p.split
pid = f.shift.to_i
ppid = f.shift.to_i
cmd = f.join ' '
# create entry for this pid if not present
$process_tree[pid] = {
:children => []
} unless $process_tree.key? pid
# fill this entry
$process_tree[pid][:ppid] = ppid
$process_tree[pid][:pid] = pid
$process_tree[pid][:cmd] = cmd
unless ppid == 0
# create entry for parent process if not present
$process_tree[ppid] = {
:children => [],
:cmd => '',
} unless $process_tree.key? ppid
# fill parent's children
$process_tree[ppid][:children] << pid
end
end
$process_tree
end
class OpenstackHaproxyPreTest < Test::Unit::TestCase
def test_haproxy_is_running
assert process_tree.find { |pid, proc| proc[:cmd].include? '/usr/sbin/haproxy' }, 'Haproxy is not running!'
end
end

View File

@ -7,3 +7,7 @@
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/openstack-haproxy/openstack-haproxy.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_pre:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/openstack-haproxy/openstack-haproxy_pre.rb
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/openstack-haproxy/openstack-haproxy_post.rb

View File

@ -0,0 +1,60 @@
- id: top-role-controller
type: puppet
groups: [primary-controller, controller]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/roles/controller.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-compute
type: puppet
groups: [compute]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/roles/compute.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-cinder
type: puppet
groups: [cinder]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/roles/cinder.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-ceph-osd
type: puppet
groups: [ceph-osd]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/roles/ceph-osd.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-primary-mongo
type: puppet
groups: [primary-mongo]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/roles/mongo_primary.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-mongo
type: puppet
groups: [mongo]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/roles/mongo.pp
puppet_modules: /etc/puppet/modules
timeout: 3600

View File

@ -1,143 +0,0 @@
- id: netconfig
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [logging]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/netconfig.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: logging
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [globals]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/logging.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: tools
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [logging]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/tools.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: hosts
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [netconfig]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/hosts.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: firewall
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [netconfig]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/firewall.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: hiera
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
requires: [deploy_start]
required_for: [deploy_end]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/hiera.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: globals
type: puppet
groups: [primary-controller, controller,
cinder, compute, ceph-osd,
zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [hiera]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/globals.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-controller
type: puppet
groups: [primary-controller, controller]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/controller.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-compute
type: puppet
groups: [compute]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/compute.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-cinder
type: puppet
groups: [cinder]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/cinder.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-ceph-osd
type: puppet
groups: [ceph-osd]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/ceph-osd.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-primary-mongo
type: puppet
groups: [primary-mongo]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/mongo_primary.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: top-role-mongo
type: puppet
groups: [mongo]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/mongo.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
- id: zabbix
type: puppet
groups: [primary-controller, controller,
cinder, compute, ceph-osd,
zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/zabbix.pp
puppet_modules: /etc/puppet/modules
timeout: 3600

View File

@ -0,0 +1,11 @@
- id: tools
type: puppet
groups: [primary-controller, controller, cinder, compute, ceph-osd, zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [logging]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/tools/tools.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/tools/tools_post.rb

View File

@ -0,0 +1,31 @@
require 'test/unit'
def tool_present(tool)
`which '#{tool}' 1>/dev/null 2>/dev/null`
$?.exitstatus == 0
end
TOOLS = %w(
screen
tmux
man
htop
tcpdump
strace
atop
puppet-pull
haproxy-status
)
class ToolsPostTest < Test::Unit::TestCase
def self.create_tests
TOOLS.each do |tool|
method_name = "test_tool_#{tool}_present"
define_method method_name do
assert tool_present(tool), "There is no '#{tool}' installed!"
end
end
end
end
ToolsPostTest.create_tests

View File

@ -7,3 +7,5 @@
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/virtual_ips/virtual_ips.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/virtual_ips/virtual_ips_post.rb

View File

@ -0,0 +1,43 @@
require 'hiera'
require 'test/unit'
def ping(host)
`ping -q -c 1 -W 3 '#{host}'`
$?.exitstatus == 0
end
def hiera
return $hiera if $hiera
$hiera = Hiera.new(:config => '/etc/puppet/hiera.yaml')
end
def public_vip
return $public_vip if $public_vip
$public_vip = hiera.lookup 'public_vip', nil, {}
end
def management_vip
return $management_vip if $management_vip
$management_vip = hiera.lookup 'management_vip', nil, {}
end
def deployment_mode
return $deployment_mode if $deployment_mode
$deployment_mode = hiera.lookup 'deployment_mode', nil, {}
end
def is_ha?
%w(ha ha_compact).include? deployment_mode
end
class VirtualIPsPostTest < Test::Unit::TestCase
def test_public_vip_ping
assert ping(public_vip), "Could not ping the public vip '#{public_vip}'!" if is_ha?
end
def test_management_vip_ping
assert ping(management_vip), "Could not ping the management vip '#{management_vip}'!" if is_ha?
end
end

View File

@ -0,0 +1,13 @@
- id: zabbix
type: puppet
groups: [primary-controller, controller,
cinder, compute, ceph-osd,
zabbix-server, primary-mongo, mongo]
required_for: [deploy_end]
requires: [hosts, firewall]
parameters:
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/zabbix/zabbix.pp
puppet_modules: /etc/puppet/modules
timeout: 3600
test_post:
cmd: ruby /etc/puppet/modules/osnailyfacter/modular/zabbix/zabbix_post.rb

View File

@ -0,0 +1,43 @@
require 'test/unit'
def process_tree
return $process_tree if $process_tree
$process_tree = {}
ps = `ps haxo pid,ppid,cmd`
ps.split("\n").each do |p|
f = p.split
pid = f.shift.to_i
ppid = f.shift.to_i
cmd = f.join ' '
# create entry for this pid if not present
$process_tree[pid] = {
:children => []
} unless $process_tree.key? pid
# fill this entry
$process_tree[pid][:ppid] = ppid
$process_tree[pid][:pid] = pid
$process_tree[pid][:cmd] = cmd
unless ppid == 0
# create entry for parent process if not present
$process_tree[ppid] = {
:children => [],
:cmd => '',
} unless $process_tree.key? ppid
# fill parent's children
$process_tree[ppid][:children] << pid
end
end
$process_tree
end
class ZabbixPostTest < Test::Unit::TestCase
def test_zabbix_is_running
assert process_tree.find { |pid, proc| proc[:cmd].include? 'zabbix_server' }, 'Zabbix server is not running!'
end
end