Skip to content

Commit e771e77

Browse files
committed
(FM-4614) abstract out the command lines
1 parent ca8e62e commit e771e77

31 files changed

+233
-255
lines changed

tests/beaker/configs/ec2_config.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/beaker/configs/full_env.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/beaker/lib/lvm_helper.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,60 @@ def verify_if_created?(agent, resource_type, resource_name)
3030
end
3131
end
3232
end
33+
34+
35+
# Clean the box after each test, make sure the newly created logical volumes, volume groups,
36+
# and physical volumes are removed at the end of each test to make the server ready for the
37+
# next test case.
38+
#
39+
# ==== Attributes
40+
#
41+
# * +pv+ - physical volume, can be one volume or an array of multiple volumes
42+
# * +vg+ - volume group, can be one group or an array of multiple volume groups
43+
# * +lv+ - logical volume, can be one volume or an array of multiple volumes
44+
#
45+
# ==== Returns
46+
#
47+
# +nil+
48+
#
49+
# ==== Raises
50+
# +nil+
51+
# ==== Examples
52+
#
53+
# remove_all(agent, '/dev/sdb', 'VolumeGroup_1234', 'LogicalVolume_fa13')
54+
def remove_all(agent, pv=nil, vg=nil, lv=nil)
55+
step 'remove logical volume if any:'
56+
if lv
57+
if lv.kind_of?(Array)
58+
lv.each do |logical_volume|
59+
on(agent, "umount /dev/#{vg}/#{logical_volume}", :acceptable_exit_codes => [0,1])
60+
on(agent, "lvremove /dev/#{vg}/#{logical_volume} --force")
61+
end
62+
else
63+
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
64+
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
65+
end
66+
end
67+
68+
step 'remove volume group if any:'
69+
if vg
70+
if vg.kind_of?(Array)
71+
vg.each do |volume_group|
72+
on(agent, "vgremove /dev/#{volume_group}")
73+
end
74+
else
75+
on(agent, "vgremove /dev/#{vg}")
76+
end
77+
end
78+
79+
step 'remove logical volume if any:'
80+
if pv
81+
if pv.kind_of?(Array)
82+
pv.each do |physical_volume|
83+
on(agent, "pvremove #{physical_volume}")
84+
end
85+
else
86+
on(agent, "pvremove #{pv}")
87+
end
88+
end
89+
end

tests/beaker/pre-suite/01_lvm_module_install.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,12 @@
44
on(master, puppet('module install puppetlabs-stdlib'))
55

66
step 'Install LVM Module'
7-
on(master, puppet('module install puppetlabs-lvm'))
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)

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@
77
# On the PE agent where LVM running
88
confine_block(:except, :roles => %w{master dashboard database}) do
99
agents.each do |agent|
10-
step 'adding an extra disk'
10+
step 'adding an extra disk: /dev/sdc:'
1111
on(agent, "curl -X POST -H X-AUTH-TOKEN:#{auth_tok} --url vcloud/api/v1/vm/#{agent[:vmhostname]}/disk/1")
12-
sleep(120)
13-
12+
sleep(30)
1413
step 'rescan the SCSI bus on the host to make the newly added hdd recognized'
1514
on(agent, "echo \"- - -\" >/sys/class/scsi_host/host0/scan")
1615

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

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

25-
step 'Verify the newly add hdd recognized:'
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:'
2629
on(agent, "fdisk -l") do |result|
2730
assert_match(/\/dev\/sdc/, result.stdout, "Unexpected errors is detected")
2831
assert_match(/\/dev\/sdd/, result.stdout, "Unexpected errors is detected")

tests/beaker/tests/create_lv_with_param_alloc.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
test_name "FM-4579 - C96574 - create logical volume without parameter 'alloc'"
66

77
#initilize
8-
pv = '/dev/sdd'
9-
vg = ("VG_" + SecureRandom.hex(2))
10-
lv = [("LV_" + SecureRandom.hex(3)), ("LV_" + SecureRandom.hex(3)), \
11-
("LV_" + SecureRandom.hex(3)), ("LV_" + SecureRandom.hex(3)), ("LV_" + SecureRandom.hex(3))]
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)), ("LogicalVolume_" + SecureRandom.hex(3))]
1212

1313
# Teardown
1414
teardown do
1515
confine_block(:except, :roles => %w{master dashboard database}) do
16-
lv.each do |logical_volume|
17-
on(agent, "umount /dev/#{vg}/#{logical_volume}", :acceptable_exit_codes => [0,1])
18-
on(agent, "lvremove /dev/#{vg}/#{logical_volume} --force")
16+
agents.each do |agent|
17+
remove_all(agent, pv, vg, lv)
1918
end
20-
on(agent, "vgremove #{vg}")
21-
on(agent, "pvremove #{pv}")
2219
end
2320
end
2421

tests/beaker/tests/create_lv_with_param_extents.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,23 @@
55
test_name "FM-4579 - C96575 - create logical volume with parameter 'extents'"
66

77
#initilize
8-
pv = ['/dev/sdc', '/dev/sdd']
9-
vg = ("VG_" + SecureRandom.hex(2))
10-
lv = ("LV_" + SecureRandom.hex(3))
8+
pv = '/dev/sdc'
9+
vg = ("VolumeGroup_" + SecureRandom.hex(2))
10+
lv = ("LogicalVolume_" + SecureRandom.hex(3))
1111

1212
# Teardown
1313
teardown do
1414
confine_block(:except, :roles => %w{master dashboard database}) do
15-
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
16-
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
17-
on(agent, "vgremove #{vg}")
18-
pv.each do |physical_volume|
19-
on(agent, "pvremove #{physical_volume}")
15+
agents.each do |agent|
16+
remove_all(agent, pv, vg, lv)
2017
end
2118
end
2219
end
2320

2421
pp = <<-MANIFEST
2522
volume_group {'#{vg}':
2623
ensure => present,
27-
physical_volumes => #{pv}
24+
physical_volumes => '#{pv}'
2825
}
2926
->
3027
logical_volume{'#{lv}':

tests/beaker/tests/create_lv_with_param_initial_size.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,29 @@
55
test_name "FM-4579 - C96576 - create logical volume with parameter 'initial_size'"
66

77
#initilize
8-
pv = ['/dev/sdc', '/dev/sdd']
9-
vg = ("VG_" + SecureRandom.hex(2))
10-
lv = ("LV_" + SecureRandom.hex(3))
8+
pv = '/dev/sdc'
9+
vg = ("VolumeGroup_" + SecureRandom.hex(2))
10+
lv = ("LogicalVolume_" + SecureRandom.hex(3))
1111

1212
# Teardown
1313
teardown do
1414
confine_block(:except, :roles => %w{master dashboard database}) do
15-
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
16-
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
17-
on(agent, "vgremove #{vg}")
18-
pv.each do |physical_volume|
19-
on(agent, "pvremove #{physical_volume}")
15+
agents.each do |agent|
16+
remove_all(agent, pv, vg, lv)
2017
end
2118
end
2219
end
2320

2421
pp = <<-MANIFEST
2522
volume_group {'#{vg}':
2623
ensure => present,
27-
physical_volumes => #{pv}
24+
physical_volumes => '#{pv}'
2825
}
2926
->
3027
logical_volume{'#{lv}':
3128
ensure => present,
3229
volume_group => '#{vg}',
33-
initial_size => '2G',
30+
initial_size => '20M',
3431
}
3532
MANIFEST
3633

tests/beaker/tests/create_lv_with_param_name.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
test_name "FM-4579 - C96572 - create logical volume with parameter 'name'"
66

77
#initilize
8-
pv = '/dev/sdd'
9-
vg = ("VG_" + SecureRandom.hex(2))
10-
lv = ("LV_" + SecureRandom.hex(3))
8+
pv = '/dev/sdc'
9+
vg = ("VolumeGroup_" + SecureRandom.hex(2))
10+
lv = ("LogicalVolume_" + SecureRandom.hex(3))
1111

1212
# Teardown
1313
teardown do
1414
confine_block(:except, :roles => %w{master dashboard database}) do
15-
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
16-
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
17-
on(agent, "vgremove #{vg}")
18-
on(agent, "pvremove #{pv}")
15+
agents.each do |agent|
16+
remove_all(agent, pv, vg, lv)
17+
end
1918
end
2019
end
2120

@@ -33,7 +32,7 @@
3332
ensure => present,
3433
name => '#{lv}',
3534
volume_group => '#{vg}',
36-
size => '1G',
35+
size => '500M',
3736
}
3837
MANIFEST
3938

tests/beaker/tests/create_lv_with_param_no_sync.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
test_name "FM-4579 - C96581 - create logical volume with parameter 'no_sync'"
66

77
#initilize
8-
pv = '/dev/sdd'
9-
vg = ("VG_" + SecureRandom.hex(2))
10-
lv = ("LV_" + SecureRandom.hex(3))
8+
pv = '/dev/sdc'
9+
vg = ("VolumeGroup_" + SecureRandom.hex(2))
10+
lv = ("LogicalVolume_" + SecureRandom.hex(3))
1111

1212
# Teardown
1313
teardown do
1414
confine_block(:except, :roles => %w{master dashboard database}) do
15-
on(agent, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1])
16-
on(agent, "lvremove /dev/#{vg}/#{lv} --force")
17-
on(agent, "vgremove #{vg}")
18-
on(agent, "pvremove #{pv}")
15+
agents.each do |agent|
16+
remove_all(agent, pv, vg, lv)
17+
end
1918
end
2019
end
2120

@@ -28,7 +27,7 @@
2827
logical_volume{'#{lv}':
2928
ensure => present,
3029
volume_group => '#{vg}',
31-
size => '1G',
30+
size => '300M',
3231
no_sync => true,
3332
}
3433
MANIFEST

0 commit comments

Comments
 (0)