Skip to content

Commit 815594e

Browse files
author
Ryan Gard
committed
Merge pull request #150 from phongdly/fm-4969/lvm_automate_test_phy-log-volume_volume-group_on_aix
(FM-4969) aix auto tests for physical/logical volume and volume_group on aix
2 parents 194fdd0 + ec9c353 commit 815594e

File tree

9 files changed

+346
-50
lines changed

9 files changed

+346
-50
lines changed
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+
pe-aix-71-spec:
12+
roles:
13+
- agent
14+
platform: aix-7.1-power
15+
hypervisor: none
16+
vmhostname: pe-aix-71-spec.delivery.puppetlabs.net
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: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# ==== Attributes
44
#
5-
# * +resource_type+ - resorce type, i.e 'physical_volume', 'volume_group', 'logical_volume', or 'filesystem'
5+
# * +resource_type+ - resorce type, i.e 'physical_volume', 'volume_group', 'logical_volume', 'filesystem',
6+
# * 'aix_physical_volume', 'aix_volume_group', or 'aix_logical_volume'.
67
# * +resource_name+ - The name of resource type, i.e '/dev/sdb' for physical volume, vg_1234 for volume group
78
# * +vg+ - volume group name associated with logical volume (if any)
89
# * +properties+ - a matching string or regular expression in logical volume properties
@@ -26,13 +27,29 @@ def verify_if_created?(agent, resource_type, resource_name, vg=nil, properties=n
2627
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
2728
end
2829
when 'logical_volume'
29-
fail_test "Error: missing volume group that the logical volume is associated with" unless vg
30+
raise ArgumentError, 'Missing volume group that the logical volume is associated with' unless vg
3031
on(agent, "lvdisplay /dev/#{vg}/#{resource_name}") do |result|
3132
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
3233
if properties
3334
assert_match(/#{properties}/, result.stdout, 'Unexpected error was detected')
3435
end
3536
end
37+
when 'aix_physical_volume'
38+
on(agent, "lspv #{resource_name}") do |result|
39+
assert_match(/Physical volume #{resource_name} is not assigned to/, result.stdout, 'Unexpected error was detected')
40+
end
41+
when 'aix_volume_group'
42+
on(agent, "lsvg") do |result|
43+
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
44+
end
45+
when 'aix_logical_volume'
46+
raise ArgumentError, 'Missing volume group that the logical volume is associated with' unless vg
47+
on(agent, "lslv #{resource_name}") do |result|
48+
assert_match(/#{resource_name}/, result.stdout, 'Unexpected error was detected')
49+
if properties
50+
assert_match(/#{properties}/, result.stdout, 'Unexpected error was detected')
51+
end
52+
end
3653
end
3754
end
3855

@@ -68,6 +85,7 @@ def is_correct_format?(agent, volume_group, logical_volume, format_type)
6885
# * +pv+ - physical volume, can be one volume or an array of multiple volumes
6986
# * +vg+ - volume group, can be one group or an array of multiple volume groups
7087
# * +lv+ - logical volume, can be one volume or an array of multiple volumes
88+
# * +aix+ - if the agent is an AIX server.
7189
#
7290
# ==== Returns
7391
#
@@ -78,41 +96,47 @@ def is_correct_format?(agent, volume_group, logical_volume, format_type)
7896
# ==== Examples
7997
#
8098
# remove_all(agent, '/dev/sdb', 'VolumeGroup_1234', 'LogicalVolume_fa13')
81-
def remove_all(agent, pv=nil, vg=nil, lv=nil)
82-
step 'remove logical volume if any:'
83-
if lv
84-
if lv.kind_of?(Array)
85-
lv.each do |logical_volume|
86-
on(agent, "umount /dev/#{vg}/#{logical_volume}", :acceptable_exit_codes => [0,1])
87-
on(agent, "lvremove /dev/#{vg}/#{logical_volume} --force")
99+
def remove_all(agent, pv=nil, vg=nil, lv=nil, aix=false)
100+
if aix
101+
step 'remove aix volume group, physical/logical volume '
102+
on(agent, "reducevg -d -f #{vg} #{pv}")
103+
on(agent, "rm -rf /dev/#{vg} /dev/#{lv}")
104+
else
105+
step 'remove logical volume if any:'
106+
if lv
107+
if lv.kind_of?(Array)
108+
lv.each do |logical_volume|
109+
on(agent, "umount /dev/#{vg}/#{logical_volume}", :acceptable_exit_codes => [0,1])
110+
on(agent, "lvremove /dev/#{vg}/#{logical_volume} --force")
111+
end
112+
else
113+
#note: in some test cases, for example, the test case 'create_vg_property_logical_volume'
114+
# the logical volume must be unmount before being able to delete it
115+
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
116+
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
88117
end
89-
else
90-
#note: in some test cases, for example, the test case 'create_vg_property_logical_volume'
91-
# the logical volume must be unmount before being able to delete it
92-
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
93-
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
94118
end
95-
end
96119

97-
step 'remove volume group if any:'
98-
if vg
99-
if vg.kind_of?(Array)
100-
vg.each do |volume_group|
101-
on(agent, "vgremove /dev/#{volume_group}")
120+
step 'remove volume group if any:'
121+
if vg
122+
if vg.kind_of?(Array)
123+
vg.each do |volume_group|
124+
on(agent, "vgremove /dev/#{volume_group}")
125+
end
126+
else
127+
on(agent, "vgremove /dev/#{vg}")
102128
end
103-
else
104-
on(agent, "vgremove /dev/#{vg}")
105129
end
106-
end
107130

108-
step 'remove logical volume if any:'
109-
if pv
110-
if pv.kind_of?(Array)
111-
pv.each do |physical_volume|
112-
on(agent, "pvremove #{physical_volume}")
131+
step 'remove logical volume if any:'
132+
if pv
133+
if pv.kind_of?(Array)
134+
pv.each do |physical_volume|
135+
on(agent, "pvremove #{physical_volume}")
136+
end
137+
else
138+
on(agent, "pvremove #{pv}")
113139
end
114-
else
115-
on(agent, "pvremove #{pv}")
116140
end
117141
end
118142
end

tests/beaker/pre-suite/02_add_extra_hdd.rb

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,32 @@
66

77
# On the PE agent where LVM running
88
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")
159

16-
#keep trying until the hdd is found
17-
retry_on(agent, "fdisk -l | grep \"/dev/sdc\"", :max_retries => 360, :retry_interval => 5)
10+
agents.each do |agent|
11+
unless (agent['platform'] =~ /windows/ && agent['platform'] =~ /aix/)
12+
step 'adding an extra disk: /dev/sdc:'
13+
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
14+
sleep(30)
15+
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
16+
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")
1817

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")
18+
#keep trying until the hdd is found
19+
retry_on(agent, "fdisk -l | grep \"/dev/sdc\"", :max_retries => 420, :retry_interval => 5)
2420

25-
#keep trying until the hdd is found
26-
retry_on(agent, "fdisk -l | grep \"/dev/sdd\"", :max_retries => 360, :retry_interval => 5)
21+
step 'adding a second extra disk: /dev/sdd:'
22+
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
23+
sleep(30)
24+
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
25+
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")
2726

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
27+
#keep trying until the hdd is found
28+
retry_on(agent, "fdisk -l | grep \"/dev/sdd\"", :max_retries => 420, :retry_interval => 5)
29+
30+
step 'Verify the newly add HDDs recognized:'
31+
on(agent, "fdisk -l") do |result|
32+
assert_match(/\/dev\/sdc/, result.stdout, "Unexpected errors is detected")
33+
assert_match(/\/dev\/sdd/, result.stdout, "Unexpected errors is detected")
34+
end
35+
end
3336
end
3437
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://pe-releases.puppetlabs.lan/2015.3.3"
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+
--no-provision \
19+
--host configs/aix-71-spec.yml \
20+
--debug \
21+
--pre-suite pre-suite \
22+
--tests tests/aix \
23+
--keyfile ~/.ssh/id_rsa-acceptance \
24+
--load-path lib
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4969 - C97367 - create logical volume with parameter max 'range'"
6+
7+
#initilize
8+
pv = 'hdisk1'
9+
vg = "VG_" + SecureRandom.hex(2)
10+
lv = "LV_" + 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, aix = true)
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+
initial_size => '5M',
31+
range => 'maximum',
32+
}
33+
MANIFEST
34+
35+
step 'Inject "site.pp" on Master'
36+
site_pp = create_site_pp(master, :manifest => pp)
37+
inject_site_pp(master, get_site_pp_path(master), site_pp)
38+
39+
step 'Run Puppet Agent to create logical volumes'
40+
confine_block(:except, :roles => %w{master dashboard database}) do
41+
agents.each do |agent|
42+
on(agent,"/opt/puppetlabs/puppet/bin/puppet agent -t --environment production", :acceptable_exit_codes => [0,2]) do |result|
43+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
44+
end
45+
46+
step "Verify the logical volume with param maximum is created: #{lv}"
47+
verify_if_created?(agent, 'aix_logical_volume', lv, vg, "INTER-POLICY:\s+maximum")
48+
end
49+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4969 - C97372 - create logical volume with parameter min 'range'"
6+
7+
#initilize
8+
pv = 'hdisk1'
9+
vg = "VG_" + SecureRandom.hex(2)
10+
lv = "LV_" + 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, aix = true)
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+
initial_size => '20M',
31+
range => 'minimum',
32+
}
33+
MANIFEST
34+
35+
step 'Inject "site.pp" on Master'
36+
site_pp = create_site_pp(master, :manifest => pp)
37+
inject_site_pp(master, get_site_pp_path(master), site_pp)
38+
39+
step 'Run Puppet Agent to create logical volumes'
40+
confine_block(:except, :roles => %w{master dashboard database}) do
41+
agents.each do |agent|
42+
on(agent,"/opt/puppetlabs/puppet/bin/puppet agent -t --environment production", :acceptable_exit_codes => [0,2]) do |result|
43+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
44+
end
45+
46+
step "Verify the logical volume with param minimum is created: #{lv}"
47+
verify_if_created?(agent, 'aix_logical_volume', lv, vg, "INTER-POLICY:\s+minimum")
48+
end
49+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4969 - C97368 - create logical volume with param 'type'"
6+
7+
#initilize
8+
pv = 'hdisk1'
9+
vg = "VG_" + SecureRandom.hex(2)
10+
lv = "LV_" + 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, aix = true)
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+
initial_size => '5M',
31+
type => 'jfs',
32+
}
33+
MANIFEST
34+
35+
step 'Inject "site.pp" on Master'
36+
site_pp = create_site_pp(master, :manifest => pp)
37+
inject_site_pp(master, get_site_pp_path(master), site_pp)
38+
39+
step 'Run Puppet Agent to create logical volumes'
40+
confine_block(:except, :roles => %w{master dashboard database}) do
41+
agents.each do |agent|
42+
on(agent,"/opt/puppetlabs/puppet/bin/puppet agent -t --environment production", :acceptable_exit_codes => [0,2]) do |result|
43+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
44+
end
45+
46+
step "Verify the logical volume with param maximum is created: #{lv}"
47+
verify_if_created?(agent, 'aix_logical_volume', lv, vg, "TYPE:\s+jfs")
48+
end
49+
end

0 commit comments

Comments
 (0)