Skip to content

Commit 194fdd0

Browse files
author
Ryan Gard
committed
Merge pull request #146 from phongdly/FM-4615/automated_test_for_filesystem
(FM-4615) LVM: create automated tests for filesystem
2 parents 19656b6 + c6d1e12 commit 194fdd0

6 files changed

+311
-0
lines changed

tests/beaker/lib/lvm_helper.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,29 @@ def verify_if_created?(agent, resource_type, resource_name, vg=nil, properties=n
3636
end
3737
end
3838

39+
# Verify if a filesystem resource type is successfully created
40+
#
41+
# ==== Attributes
42+
#
43+
# * +volume_group+ - resorce type name, i.e 'VolumeGroup_1234'
44+
# * +logical_volume+ - resorce type name, i.e 'LogicalVolume_a2b3'
45+
# * +fromat_type+ - type of the format of the logical volume, i.e 'ext3'
46+
#
47+
# ==== Returns
48+
#
49+
# +nil+
50+
#
51+
# ==== Raises
52+
# assert_match failure message
53+
# ==== Examples
54+
#
55+
# is_correct_format?(agent, VolumeGroup_1234, LogicalVolume_a2b3, ext3)
56+
def is_correct_format?(agent, volume_group, logical_volume, format_type)
57+
on(agent, "file -sL /dev/#{volume_group}/#{logical_volume}") do |result|
58+
assert_match(/#{format_type}/, result.stdout, "Unexpected error was detected")
59+
end
60+
end
61+
3962
# Clean the box after each test, make sure the newly created logical volumes, volume groups,
4063
# and physical volumes are removed at the end of each test to make the server ready for the
4164
# next test case.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4615 - C97168 - create non-existing format filesystem"
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+
physical_volume {'#{pv}':
23+
ensure => present,
24+
}
25+
->
26+
volume_group {'#{vg}':
27+
ensure => present,
28+
physical_volumes => '#{pv}',
29+
}
30+
->
31+
logical_volume{'#{lv}':
32+
ensure => present,
33+
volume_group => '#{vg}',
34+
size => '20M',
35+
}
36+
->
37+
filesystem {'Create_filesystem':
38+
name => '/dev/#{vg}/#{lv}',
39+
ensure => present,
40+
fs_type => 'non-existing-format',
41+
}
42+
MANIFEST
43+
44+
step 'Inject "site.pp" on Master'
45+
site_pp = create_site_pp(master, :manifest => pp)
46+
inject_site_pp(master, get_site_pp_path(master), site_pp)
47+
48+
step 'Run Puppet Agent to create logical volumes'
49+
confine_block(:except, :roles => %w{master dashboard database}) do
50+
agents.each do |agent|
51+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [1,6]) do |result|
52+
assert_match(/change from absent to present failed/, result.stderr, 'Unexpected error was detected!')
53+
end
54+
end
55+
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4615 - C96567 - create filesystem with property 'ensure' and ext2 format"
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+
physical_volume {'#{pv}':
23+
ensure => present,
24+
}
25+
->
26+
volume_group {'#{vg}':
27+
ensure => present,
28+
physical_volumes => '#{pv}',
29+
}
30+
->
31+
logical_volume{'#{lv}':
32+
ensure => present,
33+
volume_group => '#{vg}',
34+
size => '20M',
35+
}
36+
->
37+
filesystem {'Create_filesystem':
38+
name => '/dev/#{vg}/#{lv}',
39+
ensure => present,
40+
fs_type => 'ext2',
41+
}
42+
MANIFEST
43+
44+
step 'Inject "site.pp" on Master'
45+
site_pp = create_site_pp(master, :manifest => pp)
46+
inject_site_pp(master, get_site_pp_path(master), site_pp)
47+
48+
step 'Run Puppet Agent to create logical volumes'
49+
confine_block(:except, :roles => %w{master dashboard database}) do
50+
agents.each do |agent|
51+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [0,2]) do |result|
52+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
53+
end
54+
55+
step "Verify the logical volume has correct format type: #{lv}"
56+
is_correct_format?(agent, vg, lv, 'ext2')
57+
end
58+
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4615 - C96568 - create filesystem with parameter 'fs_type' and ext4 format"
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+
physical_volume {'#{pv}':
23+
ensure => present,
24+
}
25+
->
26+
volume_group {'#{vg}':
27+
ensure => present,
28+
physical_volumes => '#{pv}',
29+
}
30+
->
31+
logical_volume{'#{lv}':
32+
ensure => present,
33+
volume_group => '#{vg}',
34+
size => '20M',
35+
}
36+
->
37+
filesystem {'Create_filesystem':
38+
name => '/dev/#{vg}/#{lv}',
39+
ensure => present,
40+
fs_type => 'ext4',
41+
}
42+
MANIFEST
43+
44+
step 'Inject "site.pp" on Master'
45+
site_pp = create_site_pp(master, :manifest => pp)
46+
inject_site_pp(master, get_site_pp_path(master), site_pp)
47+
48+
step 'Run Puppet Agent to create logical volumes'
49+
confine_block(:except, :roles => %w{master dashboard database}) do
50+
agents.each do |agent|
51+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [0,2]) do |result|
52+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
53+
end
54+
55+
step "Verify the logical volume has correct format type: #{lv}"
56+
is_correct_format?(agent, vg, lv, 'ext4')
57+
end
58+
end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4615 - C96566 - create filesystem with parameter 'name' and ext3 format"
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+
physical_volume {'#{pv}':
23+
ensure => present,
24+
}
25+
->
26+
volume_group {'#{vg}':
27+
ensure => present,
28+
physical_volumes => '#{pv}',
29+
}
30+
->
31+
logical_volume{'#{lv}':
32+
ensure => present,
33+
volume_group => '#{vg}',
34+
size => '20M',
35+
}
36+
->
37+
filesystem {'Create_filesystem':
38+
name => '/dev/#{vg}/#{lv}',
39+
ensure => present,
40+
fs_type => 'ext3',
41+
}
42+
MANIFEST
43+
44+
step 'Inject "site.pp" on Master'
45+
site_pp = create_site_pp(master, :manifest => pp)
46+
inject_site_pp(master, get_site_pp_path(master), site_pp)
47+
48+
step 'Run Puppet Agent to create logical volumes'
49+
confine_block(:except, :roles => %w{master dashboard database}) do
50+
agents.each do |agent|
51+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [0,2]) do |result|
52+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
53+
end
54+
55+
step "Verify the logical volume has correct format type: #{lv}"
56+
is_correct_format?(agent, vg, lv, 'ext3')
57+
end
58+
end
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require 'master_manipulator'
2+
require 'lvm_helper'
3+
require 'securerandom'
4+
5+
test_name "FM-4615 - C96570 - create filesystem with parameter 'options' and ext4 format"
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+
physical_volume {'#{pv}':
23+
ensure => present,
24+
}
25+
->
26+
volume_group {'#{vg}':
27+
ensure => present,
28+
physical_volumes => '#{pv}',
29+
}
30+
->
31+
logical_volume{'#{lv}':
32+
ensure => present,
33+
volume_group => '#{vg}',
34+
size => '20M',
35+
}
36+
->
37+
filesystem {'Create_filesystem':
38+
name => '/dev/#{vg}/#{lv}',
39+
ensure => present,
40+
fs_type => 'ext4',
41+
options => '-b 4096 -E stride=32,stripe-width=64',
42+
}
43+
MANIFEST
44+
45+
step 'Inject "site.pp" on Master'
46+
site_pp = create_site_pp(master, :manifest => pp)
47+
inject_site_pp(master, get_site_pp_path(master), site_pp)
48+
49+
step 'Run Puppet Agent to create logical volumes'
50+
confine_block(:except, :roles => %w{master dashboard database}) do
51+
agents.each do |agent|
52+
on(agent, puppet('agent -t --environment production'), :acceptable_exit_codes => [0,2]) do |result|
53+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
54+
end
55+
56+
step "Verify the logical volume has correct format type: #{lv}"
57+
is_correct_format?(agent, vg, lv, 'ext4')
58+
end
59+
end

0 commit comments

Comments
 (0)