Skip to content

Commit 19656b6

Browse files
author
Ryan Gard
committed
Merge pull request #144 from phongdly/FM-4614/lvm_automated_test
(FM-4614) LVM automated test
2 parents 9e8ae0a + 92fa8dc commit 19656b6

34 files changed

+1697
-0
lines changed

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ gem 'puppet-lint-unquoted_string-check', :require => false
1919
if RUBY_VERSION < '2.0'
2020
gem 'mime-types', '<3.0', :require => false
2121
end
22+
23+
group :system_tests do
24+
if beaker_version = ENV['BEAKER_VERSION']
25+
gem 'beaker', *location_for(beaker_version)
26+
end
27+
gem 'beaker-puppet_install_helper', :require => false
28+
gem 'master_manipulator', '~> 1.2', :require => false
29+
end
2230
# vim:ft=ruby

tests/beaker/configs/fusion.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
HOSTS:
2+
puppet:
3+
roles:
4+
- master
5+
- dashboard
6+
- database
7+
- agent
8+
platform: el-6-x86_64
9+
snapshot: master_ankeny
10+
hypervisor : fusion
11+
websphere:
12+
roles:
13+
- agent
14+
- frictionless
15+
platform: el-6-x86_64
16+
snapshot: agent_ankeny
17+
hypervisor : fusion
18+
19+
CONFIG:
20+
ssh:
21+
auth_methods: ["password", "publickey"]
22+
password: puppet
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
HOSTS:
2+
redhat-6-x86_64:
3+
roles:
4+
- master
5+
- dashboard
6+
- database
7+
- agent
8+
platform: el-6-x86_64
9+
template: redhat-6-x86_64
10+
hypervisor: vcloud
11+
redhat-6-x86_64-agent:
12+
roles:
13+
- agent
14+
platform: el-6-x86_64
15+
template: redhat-6-x86_64
16+
hypervisor: vcloud
17+
CONFIG:
18+
nfs_server: none
19+
consoleport: 443
20+
datastore: instance0
21+
folder: Delivery/Quality Assurance/Enterprise/Dynamic
22+
resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
23+
pooling_api: http://vcloud.delivery.puppetlabs.net/

tests/beaker/lib/lvm_helper.rb

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Verify if a physical volume, volume group, logical volume, or filesystem resource type is created
2+
#
3+
# ==== Attributes
4+
#
5+
# * +resource_type+ - resorce type, i.e 'physical_volume', 'volume_group', 'logical_volume', or 'filesystem'
6+
# * +resource_name+ - The name of resource type, i.e '/dev/sdb' for physical volume, vg_1234 for volume group
7+
# * +vg+ - volume group name associated with logical volume (if any)
8+
# * +properties+ - a matching string or regular expression in logical volume properties
9+
# ==== Returns
10+
#
11+
# +nil+
12+
#
13+
# ==== Raises
14+
# assert_match failure message
15+
# ==== Examples
16+
#
17+
# verify_if_created?(agent, 'physical_volume', /dev/sdb', VolumeGroup_123, "Size 7GB")
18+
def verify_if_created?(agent, resource_type, resource_name, vg=nil, properties=nil)
19+
case resource_type
20+
when 'physical_volume'
21+
on(agent, "pvdisplay") do |result|
22+
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
23+
end
24+
when 'volume_group'
25+
on(agent, "vgdisplay") do |result|
26+
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
27+
end
28+
when 'logical_volume'
29+
fail_test "Error: missing volume group that the logical volume is associated with" unless vg
30+
on(agent, "lvdisplay /dev/#{vg}/#{resource_name}") do |result|
31+
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
32+
if properties
33+
assert_match(/#{properties}/, result.stdout, 'Unexpected error was detected')
34+
end
35+
end
36+
end
37+
end
38+
39+
# Clean the box after each test, make sure the newly created logical volumes, volume groups,
40+
# and physical volumes are removed at the end of each test to make the server ready for the
41+
# next test case.
42+
#
43+
# ==== Attributes
44+
#
45+
# * +pv+ - physical volume, can be one volume or an array of multiple volumes
46+
# * +vg+ - volume group, can be one group or an array of multiple volume groups
47+
# * +lv+ - logical volume, can be one volume or an array of multiple volumes
48+
#
49+
# ==== Returns
50+
#
51+
# +nil+
52+
#
53+
# ==== Raises
54+
# +nil+
55+
# ==== Examples
56+
#
57+
# remove_all(agent, '/dev/sdb', 'VolumeGroup_1234', 'LogicalVolume_fa13')
58+
def remove_all(agent, pv=nil, vg=nil, lv=nil)
59+
step 'remove logical volume if any:'
60+
if lv
61+
if lv.kind_of?(Array)
62+
lv.each do |logical_volume|
63+
on(agent, "umount /dev/#{vg}/#{logical_volume}", :acceptable_exit_codes => [0,1])
64+
on(agent, "lvremove /dev/#{vg}/#{logical_volume} --force")
65+
end
66+
else
67+
#note: in some test cases, for example, the test case 'create_vg_property_logical_volume'
68+
# the logical volume must be unmount before being able to delete it
69+
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
70+
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
71+
end
72+
end
73+
74+
step 'remove volume group if any:'
75+
if vg
76+
if vg.kind_of?(Array)
77+
vg.each do |volume_group|
78+
on(agent, "vgremove /dev/#{volume_group}")
79+
end
80+
else
81+
on(agent, "vgremove /dev/#{vg}")
82+
end
83+
end
84+
85+
step 'remove logical volume if any:'
86+
if pv
87+
if pv.kind_of?(Array)
88+
pv.each do |physical_volume|
89+
on(agent, "pvremove #{physical_volume}")
90+
end
91+
else
92+
on(agent, "pvremove #{pv}")
93+
end
94+
end
95+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'master_manipulator'
2+
test_name 'FM-4614 - Cxx - Install Puppet Enterprise'
3+
4+
# Init
5+
step 'Install PE'
6+
install_pe
7+
8+
step 'Disable Node Classifier'
9+
disable_node_classifier(master)
10+
11+
step 'Disable Environment Caching'
12+
disable_env_cache(master)
13+
14+
step 'Restart Puppet Server'
15+
restart_puppet_server(master)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
test_name 'FM-4614 - C97171 - Install the LVM module'
2+
3+
step 'Install LVM Module Dependencies'
4+
on(master, puppet('module install puppetlabs-stdlib'))
5+
6+
step 'Install LVM Module'
7+
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../'))
8+
staging = { :module_name => 'puppetlabs-lvm' }
9+
local = { :module_name => 'lvm', :source => proj_root, :target_module_path => master['distmoduledir'] }
10+
11+
# Check to see if module version is specified.
12+
staging[:version] = ENV['MODULE_VERSION'] if ENV['MODULE_VERSION']
13+
14+
# in CI install from staging forge, otherwise from local
15+
install_dev_puppet_module_on(master, options[:forge_host] ? staging : local)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
test_name 'FM-4614 - C97274 - add extra hard drives for LVM testing'
2+
3+
# Get the auth_token from ENV
4+
auth_tok = ENV['AUTH_TOKEN']
5+
fail_test "AUTH_TOKEN must be set" unless auth_tok
6+
7+
# On the PE agent where LVM running
8+
confine_block(:except, :roles => %w{master dashboard database}) do
9+
agents.each do |agent|
10+
step 'adding an extra disk: /dev/sdc:'
11+
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
12+
sleep(30)
13+
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
14+
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")
15+
16+
#keep trying until the hdd is found
17+
retry_on(agent, "fdisk -l | grep \"/dev/sdc\"", :max_retries => 360, :retry_interval => 5)
18+
19+
step 'adding a second extra disk: /dev/sdd:'
20+
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
21+
sleep(30)
22+
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
23+
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")
24+
25+
#keep trying until the hdd is found
26+
retry_on(agent, "fdisk -l | grep \"/dev/sdd\"", :max_retries => 360, :retry_interval => 5)
27+
28+
step 'Verify the newly add HDDs recognized:'
29+
on(agent, "fdisk -l") do |result|
30+
assert_match(/\/dev\/sdc/, result.stdout, "Unexpected errors is detected")
31+
assert_match(/\/dev\/sdd/, result.stdout, "Unexpected errors is detected")
32+
end
33+
end
34+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Init
4+
SCRIPT_PATH=$(pwd)
5+
BASENAME_CMD="basename ${SCRIPT_PATH}"
6+
SCRIPT_BASE_PATH=`eval ${BASENAME_CMD}`
7+
8+
if [ $SCRIPT_BASE_PATH = "test_run_scripts" ]; then
9+
cd ../
10+
fi
11+
12+
export pe_dist_dir="http://enterprise.delivery.puppetlabs.net/2015.3/ci-ready"
13+
export GEM_SOURCE=http://rubygems.delivery.puppetlabs.net
14+
15+
bundle install --without build development test --path .bundle/gems
16+
17+
bundle exec beaker \
18+
--preserve-host \
19+
--host configs/redhat-6-64mda.yml \
20+
--debug \
21+
--pre-suite pre-suite \
22+
--tests tests \
23+
--keyfile ~/.ssh/id_rsa-acceptance \
24+
--load-path lib
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4614 - C96574 - create logical volume parameter 'alloc'"
6+
7+
#initilize
8+
pv = '/dev/sdc'
9+
vg = "VolumeGroup_" + SecureRandom.hex(2)
10+
lv = ["LogicalVolume_" + SecureRandom.hex(3), "LogicalVolume_" + SecureRandom.hex(3), \
11+
"LogicalVolume_" + SecureRandom.hex(3), "LogicalVolume_" + SecureRandom.hex(3), \
12+
"LogicalVolume_" + SecureRandom.hex(3)]
13+
14+
# Teardown
15+
teardown do
16+
confine_block(:except, :roles => %w{master dashboard database}) do
17+
agents.each do |agent|
18+
remove_all(agent, pv, vg, lv)
19+
end
20+
end
21+
end
22+
23+
pp = <<-MANIFEST
24+
physical_volume {'#{pv}':
25+
ensure => present,
26+
}
27+
->
28+
volume_group {'#{vg}':
29+
ensure => present,
30+
physical_volumes => '#{pv}',
31+
}
32+
->
33+
logical_volume{'#{lv[0]}':
34+
ensure => present,
35+
volume_group => '#{vg}',
36+
alloc => 'anywhere',
37+
size => '20M',
38+
}
39+
->
40+
logical_volume{'#{lv[1]}':
41+
ensure => present,
42+
volume_group => '#{vg}',
43+
alloc => 'contiguous',
44+
size => '10M',
45+
}
46+
->
47+
logical_volume{'#{lv[2]}':
48+
ensure => present,
49+
volume_group => '#{vg}',
50+
alloc => 'cling',
51+
size => '15M',
52+
}
53+
->
54+
logical_volume{'#{lv[3]}':
55+
ensure => present,
56+
volume_group => '#{vg}',
57+
alloc => 'inherit',
58+
size => '30M',
59+
}
60+
->
61+
logical_volume{'#{lv[4]}':
62+
ensure => present,
63+
volume_group => '#{vg}',
64+
alloc => 'normal',
65+
size => '5M',
66+
}
67+
MANIFEST
68+
69+
step 'Inject "site.pp" on Master'
70+
site_pp = create_site_pp(master, :manifest => pp)
71+
inject_site_pp(master, get_site_pp_path(master), site_pp)
72+
73+
step 'Run Puppet Agent to create logical volumes'
74+
confine_block(:except, :roles => %w{master dashboard database}) do
75+
agents.each do |agent|
76+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [0,2]) do |result|
77+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
78+
end
79+
80+
step "Verify the logical volumes are successfully created: #{lv}"
81+
verify_if_created?(agent, 'logical_volume', lv[0], vg, "Allocation\s+anywhere")
82+
verify_if_created?(agent, 'logical_volume', lv[1], vg, "Allocation\s+contiguous")
83+
verify_if_created?(agent, 'logical_volume', lv[2], vg, "Allocation\s+cling")
84+
verify_if_created?(agent, 'logical_volume', lv[3], vg, "Allocation\s+inherit")
85+
verify_if_created?(agent, 'logical_volume', lv[4], vg, "Allocation\s+normal")
86+
end
87+
end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4614 - C96575 - create logical volume with parameter 'extents'"
6+
7+
#initilize
8+
pv = '/dev/sdc'
9+
vg = "VolumeGroup_" + SecureRandom.hex(2)
10+
lv = "LogicalVolume_" + SecureRandom.hex(3)
11+
12+
# Teardown
13+
teardown do
14+
confine_block(:except, :roles => %w{master dashboard database}) do
15+
agents.each do |agent|
16+
remove_all(agent, pv, vg, lv)
17+
end
18+
end
19+
end
20+
21+
pp = <<-MANIFEST
22+
volume_group {'#{vg}':
23+
ensure => present,
24+
physical_volumes => '#{pv}'
25+
}
26+
->
27+
logical_volume{'#{lv}':
28+
ensure => present,
29+
volume_group => '#{vg}',
30+
extents => '50',
31+
}
32+
MANIFEST
33+
34+
step 'Inject "site.pp" on Master'
35+
site_pp = create_site_pp(master, :manifest => pp)
36+
inject_site_pp(master, get_site_pp_path(master), site_pp)
37+
38+
step 'Run Puppet Agent to create logical volumes'
39+
confine_block(:except, :roles => %w{master dashboard database}) do
40+
agents.each do |agent|
41+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [0,2]) do |result|
42+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
43+
end
44+
45+
step "Verify the logical volume is created and with extents is 50: #{lv}"
46+
verify_if_created?(agent, 'logical_volume', lv, vg, "Current LE\s+50")
47+
end
48+
end

0 commit comments

Comments
 (0)