Skip to content
Merged
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.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/
95 changes: 95 additions & 0 deletions tests/beaker/lib/lvm_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Verify if a physical volume, volume group, logical volume, or filesystem resource type is created
#
# ==== 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
# * +vg+ - volume group name associated with logical volume (if any)
# * +properties+ - a matching string or regular expression in logical volume properties
# ==== Returns
#
# +nil+
#
# ==== Raises
# assert_match failure message
# ==== Examples
#
# verify_if_created?(agent, 'physical_volume', /dev/sdb', VolumeGroup_123, "Size 7GB")
def verify_if_created?(agent, resource_type, resource_name, vg=nil, properties=nil)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method signature is confusing to use. Consider instead using the "opts={}" hash convention for Ruby.

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'
fail_test "Error: missing volume group that the logical volume is associated with" unless vg
on(agent, "lvdisplay /dev/#{vg}/#{resource_name}") do |result|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the caller fails to provide the "vg" argument then this will blow up. You should catch this issue and provide a reasonable failure message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added: fail_test "Error: missing volume group that the logical volume is associated with" unless vg

assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
if properties
assert_match(/#{properties}/, result.stdout, 'Unexpected error was detected')
end
end
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
#note: in some test cases, for example, the test case 'create_vg_property_logical_volume'
# the logical volume must be unmount before being able to delete it
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-4614 - 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 'FM-4614 - C97274 - add extra hard drives for LVM testing'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous newline.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to force a failure if the token is not set otherwise a test run failure because of a missing token is hard to discover.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added:
fail_test "AUTH_TOKEN must be set" unless auth_tok

fail_test "AUTH_TOKEN must be set" unless auth_tok

# 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
24 changes: 24 additions & 0 deletions tests/beaker/test_run_scripts/integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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

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
87 changes: 87 additions & 0 deletions tests/beaker/tests/create_lv_with_param_alloc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
require 'master_manipulator'
require 'lvm_helper'
require 'securerandom'

test_name "FM-4614 - C96574 - create logical volume parameter 'alloc'"

#initilize
pv = '/dev/sdc'
vg = "VolumeGroup_" + SecureRandom.hex(2)
lv = ["LogicalVolume_" + SecureRandom.hex(3), "LogicalVolume_" + SecureRandom.hex(3), \
"LogicalVolume_" + SecureRandom.hex(3), "LogicalVolume_" + SecureRandom.hex(3), \
"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[0]}':
ensure => present,
volume_group => '#{vg}',
alloc => 'anywhere',
size => '20M',
}
->
logical_volume{'#{lv[1]}':
ensure => present,
volume_group => '#{vg}',
alloc => 'contiguous',
size => '10M',
}
->
logical_volume{'#{lv[2]}':
ensure => present,
volume_group => '#{vg}',
alloc => 'cling',
size => '15M',
}
->
logical_volume{'#{lv[3]}':
ensure => present,
volume_group => '#{vg}',
alloc => 'inherit',
size => '30M',
}
->
logical_volume{'#{lv[4]}':
ensure => present,
volume_group => '#{vg}',
alloc => 'normal',
size => '5M',
}
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 --environment production'), :acceptable_exit_codes => [0,2]) do |result|
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
end

step "Verify the logical volumes are successfully created: #{lv}"
verify_if_created?(agent, 'logical_volume', lv[0], vg, "Allocation\s+anywhere")
verify_if_created?(agent, 'logical_volume', lv[1], vg, "Allocation\s+contiguous")
verify_if_created?(agent, 'logical_volume', lv[2], vg, "Allocation\s+cling")
verify_if_created?(agent, 'logical_volume', lv[3], vg, "Allocation\s+inherit")
verify_if_created?(agent, 'logical_volume', lv[4], vg, "Allocation\s+normal")
end
end
48 changes: 48 additions & 0 deletions tests/beaker/tests/create_lv_with_param_extents.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'master_manipulator'
require 'lvm_helper'
require 'securerandom'

test_name "FM-4614 - C96575 - create logical volume with parameter 'extents'"

#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
volume_group {'#{vg}':
ensure => present,
physical_volumes => '#{pv}'
}
->
logical_volume{'#{lv}':
ensure => present,
volume_group => '#{vg}',
extents => '50',
}
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 --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 is created and with extents is 50: #{lv}"
verify_if_created?(agent, 'logical_volume', lv, vg, "Current LE\s+50")
end
end
Loading