Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ gem 'puppet-lint-unquoted_string-check', :require => false
if RUBY_VERSION < '2.0'
gem 'mime-types', '<3.0', :require => false
end

group :system_tests do
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
end
gem 'beaker-puppet_install_helper', :require => false
gem 'master_manipulator', '1.1.2', :require => false
end
# vim:ft=ruby
22 changes: 22 additions & 0 deletions tests/beaker/configs/fusion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
HOSTS:
puppet:
roles:
- master
- dashboard
- database
- agent
platform: el-6-x86_64
snapshot: master_ankeny
hypervisor : fusion
websphere:
roles:
- agent
- frictionless
platform: el-6-x86_64
snapshot: agent_ankeny
hypervisor : fusion

CONFIG:
ssh:
auth_methods: ["password", "publickey"]
password: puppet
23 changes: 23 additions & 0 deletions tests/beaker/configs/redhat-6-64mda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
HOSTS:
redhat-6-x86_64:
roles:
- master
- dashboard
- database
- agent
platform: el-6-x86_64
template: redhat-6-x86_64
hypervisor: vcloud
redhat-6-x86_64-agent:
roles:
- agent
platform: el-6-x86_64
template: redhat-6-x86_64
hypervisor: vcloud
CONFIG:
nfs_server: none
consoleport: 443
datastore: instance0
folder: Delivery/Quality Assurance/Enterprise/Dynamic
resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
pooling_api: http://vcloud.delivery.puppetlabs.net/
110 changes: 110 additions & 0 deletions tests/beaker/lib/lvm_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Verify if a physical volume, volume group, or logical volume is created successfully
#
# ==== Attributes
#
# * +resource_type+ - resorce type, i.e 'physical_volume', 'volume_group', 'logical_volume', or 'filesystem'
# * +resource_name+ - The name of resource type, i.e '/dev/sdb' for physical volume, vg_1234 for volume group
#
# ==== Returns
#
# +nil+
#
# ==== Raises
# assert_match failure message
# ==== Examples
#
# verify_if_created?(agent, 'physical_volume', /dev/sdb')
def verify_if_created?(agent, resource_type, resource_name)
case resource_type
when 'physical_volume'
on(agent, "pvdisplay") do |result|
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
end
when 'volume_group'
on(agent, "vgdisplay") do |result|
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
end
when 'logical_volume'
on(agent, "lvdisplay") do |result|
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
end
end
end

# Verify if a filesystem resource type is successfully created
#
# ==== Attributes
#
# * +volume_group+ - resorce type name, i.e 'VolumeGroup_1234'
# * +logical_volume+ - resorce type name, i.e 'LogicalVolume_a2b3'
#
# ==== Returns
#
# +nil+
#
# ==== Raises
# assert_match failure message
# ==== Examples
#
# is_correct_format?(agent, VolumeGroup_1234, LogicalVolume_a2b3, ext3)
def is_correct_format?(agent, volume_group, logical_volume, format_type)
on(agent, "file -sL /dev/#{volume_group}/#{logical_volume}") do |result|
assert_match(/#{format_type}/, result.stdout, "Unexpected error was detected")
end
end

# Clean the box after each test, make sure the newly created logical volumes, volume groups,
# and physical volumes are removed at the end of each test to make the server ready for the
# next test case.
#
# ==== Attributes
#
# * +pv+ - physical volume, can be one volume or an array of multiple volumes
# * +vg+ - volume group, can be one group or an array of multiple volume groups
# * +lv+ - logical volume, can be one volume or an array of multiple volumes
#
# ==== Returns
#
# +nil+
#
# ==== Raises
# +nil+
# ==== Examples
#
# remove_all(agent, '/dev/sdb', 'VolumeGroup_1234', 'LogicalVolume_fa13')
def remove_all(agent, pv=nil, vg=nil, lv=nil)
step 'remove logical volume if any:'
if lv
if lv.kind_of?(Array)
lv.each do |logical_volume|
on(agent, "umount /dev/#{vg}/#{logical_volume}", :acceptable_exit_codes => [0,1])
on(agent, "lvremove /dev/#{vg}/#{logical_volume} --force")
end
else
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
end
end

step 'remove volume group if any:'
if vg
if vg.kind_of?(Array)
vg.each do |volume_group|
on(agent, "vgremove /dev/#{volume_group}")
end
else
on(agent, "vgremove /dev/#{vg}")
end
end

step 'remove logical volume if any:'
if pv
if pv.kind_of?(Array)
pv.each do |physical_volume|
on(agent, "pvremove #{physical_volume}")
end
else
on(agent, "pvremove #{pv}")
end
end
end
15 changes: 15 additions & 0 deletions tests/beaker/pre-suite/00_pe_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'master_manipulator'
test_name 'FM-3808 - Cxx - Install Puppet Enterprise'

# Init
step 'Install PE'
install_pe

step 'Disable Node Classifier'
disable_node_classifier(master)

step 'Disable Environment Caching'
disable_env_cache(master)

step 'Restart Puppet Server'
restart_puppet_server(master)
15 changes: 15 additions & 0 deletions tests/beaker/pre-suite/01_lvm_module_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
test_name 'FM-4614 - C97171 - Install the LVM module'

step 'Install LVM Module Dependencies'
on(master, puppet('module install puppetlabs-stdlib'))

step 'Install LVM Module'
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../'))
staging = { :module_name => 'puppetlabs-lvm' }
local = { :module_name => 'lvm', :source => proj_root, :target_module_path => master['distmoduledir'] }

# Check to see if module version is specified.
staging[:version] = ENV['MODULE_VERSION'] if ENV['MODULE_VERSION']

# in CI install from staging forge, otherwise from local
install_dev_puppet_module_on(master, options[:forge_host] ? staging : local)
34 changes: 34 additions & 0 deletions tests/beaker/pre-suite/02_add_extra_hdd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
test_name 'Add extra hard drive for LVM testing'


# Get the auth_token from ENV
auth_tok = ENV['AUTH_TOKEN']

# On the PE agent where LVM running
confine_block(:except, :roles => %w{master dashboard database}) do
agents.each do |agent|
step 'adding an extra disk: /dev/sdc:'
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
sleep(30)
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")

#keep trying until the hdd is found
retry_on(agent, "fdisk -l | grep \"/dev/sdc\"", :max_retries => 360, :retry_interval => 5)

step 'adding a second extra disk: /dev/sdd:'
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
sleep(30)
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")

#keep trying until the hdd is found
retry_on(agent, "fdisk -l | grep \"/dev/sdd\"", :max_retries => 360, :retry_interval => 5)

step 'Verify the newly add HDDs recognized:'
on(agent, "fdisk -l") do |result|
assert_match(/\/dev\/sdc/, result.stdout, "Unexpected errors is detected")
assert_match(/\/dev\/sdd/, result.stdout, "Unexpected errors is detected")
end
end
end
27 changes: 27 additions & 0 deletions tests/beaker/test_run_scripts/integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Init
SCRIPT_PATH=$(pwd)
BASENAME_CMD="basename ${SCRIPT_PATH}"
SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`

if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
cd ../
fi

# Work-around for RE-5005
export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem

export pe_dist_dir="http://enterprise.delivery.puppetlabs.net/2015.3/ci-ready"
export GEM_SOURCE=http://rubygems.delivery.puppetlabs.net

bundle install --without build development test --path .bundle/gems

bundle exec beaker \
--preserve-host \
--host configs/redhat-6-64mda.yml \
--debug \
--pre-suite pre-suite \
--tests tests \
--keyfile ~/.ssh/id_rsa-acceptance \
--load-path lib
58 changes: 58 additions & 0 deletions tests/beaker/tests/create_ext2_filesystem_with_ensure_property.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
require 'master_manipulator'
require 'lvm_helper'
require 'securerandom'

test_name "FM-4615 - C96567 - create filesystem with property 'ensure' and ext2 format"

#initilize
pv = '/dev/sdc'
vg = ("VolumeGroup_" + SecureRandom.hex(2))
lv = ("LogicalVolume_" + SecureRandom.hex(3))

# Teardown
teardown do
confine_block(:except, :roles => %w{master dashboard database}) do
agents.each do |agent|
remove_all(agent, pv, vg, lv)
end
end
end

pp = <<-MANIFEST
physical_volume {'#{pv}':
ensure => present,
}
->
volume_group {'#{vg}':
ensure => present,
physical_volumes => '#{pv}',
}
->
logical_volume{'#{lv}':
ensure => present,
volume_group => '#{vg}',
size => '20M',
}
->
filesystem {'Create_filesystem':
name => '/dev/#{vg}/#{lv}',
ensure => present,
fs_type => 'ext2',
}
MANIFEST

step 'Inject "site.pp" on Master'
site_pp = create_site_pp(master, :manifest => pp)
inject_site_pp(master, get_site_pp_path(master), site_pp)

step 'Run Puppet Agent to create logical volumes'
confine_block(:except, :roles => %w{master dashboard database}) do
agents.each do |agent|
on(agent, puppet('agent -t --graph --environment production'), :acceptable_exit_codes => [0,2]) do |result|
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
end

step "Verify the logical volume has correct format type: #{lv}"
is_correct_format?(agent, vg, lv, 'ext2')
end
end
58 changes: 58 additions & 0 deletions tests/beaker/tests/create_ext3_filesystem_with_param_name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
require 'master_manipulator'
require 'lvm_helper'
require 'securerandom'

test_name "FM-4615 - C96566 - create filesystem with parameter 'name'"

#initilize
pv = '/dev/sdc'
vg = ("VolumeGroup_" + SecureRandom.hex(2))
lv = ("LogicalVolume_" + SecureRandom.hex(3))

# Teardown
teardown do
confine_block(:except, :roles => %w{master dashboard database}) do
agents.each do |agent|
remove_all(agent, pv, vg, lv)
end
end
end

pp = <<-MANIFEST
physical_volume {'#{pv}':
ensure => present,
}
->
volume_group {'#{vg}':
ensure => present,
physical_volumes => '#{pv}',
}
->
logical_volume{'#{lv}':
ensure => present,
volume_group => '#{vg}',
size => '20M',
}
->
filesystem {'Create_filesystem':
name => '/dev/#{vg}/#{lv}',
ensure => present,
fs_type => 'ext3',
}
MANIFEST

step 'Inject "site.pp" on Master'
site_pp = create_site_pp(master, :manifest => pp)
inject_site_pp(master, get_site_pp_path(master), site_pp)

step 'Run Puppet Agent to create logical volumes'
confine_block(:except, :roles => %w{master dashboard database}) do
agents.each do |agent|
on(agent, puppet('agent -t --graph --environment production'), :acceptable_exit_codes => [0,2]) do |result|
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
end

step "Verify the logical volume has correct format type: #{lv}"
is_correct_format?(agent, vg, lv, 'ext3')
end
end
Loading