diff --git a/Gemfile b/Gemfile index 8340ff8a..b358bcbe 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/tests/beaker/configs/fusion.yml b/tests/beaker/configs/fusion.yml new file mode 100644 index 00000000..38fefa56 --- /dev/null +++ b/tests/beaker/configs/fusion.yml @@ -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 diff --git a/tests/beaker/configs/redhat-6-64mda.yml b/tests/beaker/configs/redhat-6-64mda.yml new file mode 100644 index 00000000..a2c07861 --- /dev/null +++ b/tests/beaker/configs/redhat-6-64mda.yml @@ -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/ diff --git a/tests/beaker/lib/lvm_helper.rb b/tests/beaker/lib/lvm_helper.rb new file mode 100644 index 00000000..587cc5dc --- /dev/null +++ b/tests/beaker/lib/lvm_helper.rb @@ -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) + 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| + 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 diff --git a/tests/beaker/pre-suite/00_pe_install.rb b/tests/beaker/pre-suite/00_pe_install.rb new file mode 100755 index 00000000..fd972394 --- /dev/null +++ b/tests/beaker/pre-suite/00_pe_install.rb @@ -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) diff --git a/tests/beaker/pre-suite/01_lvm_module_install.rb b/tests/beaker/pre-suite/01_lvm_module_install.rb new file mode 100755 index 00000000..18199029 --- /dev/null +++ b/tests/beaker/pre-suite/01_lvm_module_install.rb @@ -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) diff --git a/tests/beaker/pre-suite/02_add_extra_hdd.rb b/tests/beaker/pre-suite/02_add_extra_hdd.rb new file mode 100755 index 00000000..44a836e3 --- /dev/null +++ b/tests/beaker/pre-suite/02_add_extra_hdd.rb @@ -0,0 +1,34 @@ +test_name 'FM-4614 - C97274 - add extra hard drives for LVM testing' + +# Get the auth_token from ENV +auth_tok = ENV['AUTH_TOKEN'] +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 diff --git a/tests/beaker/test_run_scripts/integration_tests.sh b/tests/beaker/test_run_scripts/integration_tests.sh new file mode 100755 index 00000000..8e26d8fd --- /dev/null +++ b/tests/beaker/test_run_scripts/integration_tests.sh @@ -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 diff --git a/tests/beaker/tests/create_lv_with_param_alloc.rb b/tests/beaker/tests/create_lv_with_param_alloc.rb new file mode 100755 index 00000000..a69291b6 --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_alloc.rb @@ -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 diff --git a/tests/beaker/tests/create_lv_with_param_extents.rb b/tests/beaker/tests/create_lv_with_param_extents.rb new file mode 100755 index 00000000..e17692c1 --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_extents.rb @@ -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 diff --git a/tests/beaker/tests/create_lv_with_param_initial_size.rb b/tests/beaker/tests/create_lv_with_param_initial_size.rb new file mode 100755 index 00000000..a0ef33fa --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_initial_size.rb @@ -0,0 +1,48 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96576 - create logical volume with parameter 'initial_size'" + +#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}', + initial_size => '20M', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg, "LV Size\s+20.00 MiB") + end +end diff --git a/tests/beaker/tests/create_lv_with_param_name.rb b/tests/beaker/tests/create_lv_with_param_name.rb new file mode 100755 index 00000000..cbf37700 --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_name.rb @@ -0,0 +1,53 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96572 - create logical volume with parameter 'name'" + +#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 +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {'#{vg}': + ensure => present, + physical_volumes => '#{pv}', +} +-> +logical_volume{'Create Logical Volume with parameter name': + ensure => present, + name => '#{lv}', + volume_group => '#{vg}', + size => '500M', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + end +end diff --git a/tests/beaker/tests/create_lv_with_param_no_sync.rb b/tests/beaker/tests/create_lv_with_param_no_sync.rb new file mode 100755 index 00000000..18828024 --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_no_sync.rb @@ -0,0 +1,49 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96581 - create logical volume with parameter 'no_sync'" + +#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}', + size => '300M', + no_sync => true, +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + end +end diff --git a/tests/beaker/tests/create_lv_with_param_readahead.rb b/tests/beaker/tests/create_lv_with_param_readahead.rb new file mode 100755 index 00000000..ef280e9a --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_readahead.rb @@ -0,0 +1,49 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96583 - create logical volume with parameter 'readahead'" + +#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}', + size => '700M', + readahead => '7', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg, "Read ahead sectors\s+8") + end +end diff --git a/tests/beaker/tests/create_lv_with_param_region_size.rb b/tests/beaker/tests/create_lv_with_param_region_size.rb new file mode 100755 index 00000000..da3b5ccb --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_region_size.rb @@ -0,0 +1,50 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96584 - create logical volume with property 'region_size'" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +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}', + size => '800MB', + mirror => '1', + region_size => '64', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + end +end diff --git a/tests/beaker/tests/create_lv_with_param_size_is_minsize.rb b/tests/beaker/tests/create_lv_with_param_size_is_minsize.rb new file mode 100755 index 00000000..9988dd33 --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_size_is_minsize.rb @@ -0,0 +1,54 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96586 - create logical volume with parameter 'size_is_minsize'" + +#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 +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {'#{vg}': + ensure => present, + physical_volumes => '#{pv}', +} +-> +logical_volume{'Create Logical Volume with parameter name': + ensure => present, + name => '#{lv}', + volume_group => '#{vg}', + size => '900M', + size_is_minsize => true, +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg, "LV Size\s+900.00 MiB") + end +end diff --git a/tests/beaker/tests/create_lv_with_param_stripes.rb b/tests/beaker/tests/create_lv_with_param_stripes.rb new file mode 100755 index 00000000..77cdc241 --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_stripes.rb @@ -0,0 +1,54 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96633 - create logical volume with more than 1 stripes" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +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}', + size => '800M', + stripes => '2', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + + step "Verify the logical volume is striped on #{pv[0]} and #{pv[1]}" + on(agent, "lvs -a -o segtype,devices,vg_name,lv_name") do |result| + assert_match(/striped\s+#{pv[0]}.\d.,#{pv[1]}.\d.\s+#{vg}\s+#{lv}/, result.stdout, "Unexpected error was detected") + end + end +end diff --git a/tests/beaker/tests/create_lv_with_param_stripesize.rb b/tests/beaker/tests/create_lv_with_param_stripesize.rb new file mode 100755 index 00000000..351becdb --- /dev/null +++ b/tests/beaker/tests/create_lv_with_param_stripesize.rb @@ -0,0 +1,55 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96588 - create logical volume with parameter 'stripesize'" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +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}', + size => '900M', + stripes => '2', + stripesize => '256' +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + + step "Verify the stripesize is 256 KB" + on(agent, "lvdisplay -vm /dev/#{vg}/#{lv}") do |result| + assert_match(/Stripe size\s+256.00 KiB/, result.stdout, "Unexpected error was detected") + end + end +end diff --git a/tests/beaker/tests/create_lv_with_property_mirror.rb b/tests/beaker/tests/create_lv_with_property_mirror.rb new file mode 100755 index 00000000..fb8dc57e --- /dev/null +++ b/tests/beaker/tests/create_lv_with_property_mirror.rb @@ -0,0 +1,49 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96578 - create logical volume with property 'mirror'" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +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}', + size => '400M', + mirror => '1', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg, "Mirrored volumes\s+2") + end +end diff --git a/tests/beaker/tests/create_lv_with_property_mirrorlog.rb b/tests/beaker/tests/create_lv_with_property_mirrorlog.rb new file mode 100755 index 00000000..d5935aee --- /dev/null +++ b/tests/beaker/tests/create_lv_with_property_mirrorlog.rb @@ -0,0 +1,85 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96579 - create logical volume with property 'mirrorlog'" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +vg = "VolumeGroup_" + SecureRandom.hex(2) +lv = ["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 +volume_group {'#{vg}': + ensure => present, + physical_volumes => #{pv} +} +-> +logical_volume{'#{lv[0]}': + ensure => present, + volume_group => '#{vg}', + size => '20M', + mirror => '1', + mirrorlog => 'core', +} +-> +logical_volume{'#{lv[1]}': + ensure => present, + volume_group => '#{vg}', + size => '40M', + mirror => '1', + mirrorlog => 'disk', +} +-> +logical_volume{'#{lv[2]}': + ensure => present, + volume_group => '#{vg}', + size => '100M', + mirror => '1', + mirrorlog => 'mirrored', +} +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 successfuly created: #{lv}" + verify_if_created?(agent, 'logical_volume', lv[0], vg) + verify_if_created?(agent, 'logical_volume', lv[1], vg) + verify_if_created?(agent, 'logical_volume', lv[2], vg) + + step 'verify mirrorlog core (stored in mem):' + on(agent, "lvs -a -o mirror_log /dev/#{vg}/#{lv[0]}") do |result| + assert_match(/\s+/, result.stdout, "Unexpected error was detected") + end + + step 'verify mirrorlog disk (stored in disk):' + on(agent, "lvs -a -o mirror_log /dev/#{vg}/#{lv[1]}") do |result| + assert_match(/#{lv}_mlog/, result.stdout, "Unexpected error was detected") + end + + step 'verify mirrorlog mirrored (stored in disk):' + on(agent, "lvs -a -o mirror_log /dev/#{vg}/#{lv[2]}") do |result| + assert_match(/#{lv}_mlog/, result.stdout, "Unexpected error was detected") + end + end +end diff --git a/tests/beaker/tests/create_lv_without_param_name.rb b/tests/beaker/tests/create_lv_without_param_name.rb new file mode 100755 index 00000000..629e033d --- /dev/null +++ b/tests/beaker/tests/create_lv_without_param_name.rb @@ -0,0 +1,52 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96573 - create logical volume with property 'ensure' and without 'name'" + +#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 +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {'#{vg}': + ensure => present, + physical_volumes => '#{pv}', +} +-> +logical_volume{'#{lv}': + ensure => present, + volume_group => '#{vg}', + size => '800M', +} +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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + end +end diff --git a/tests/beaker/tests/create_pv_param_unless_vg.rb b/tests/beaker/tests/create_pv_param_unless_vg.rb new file mode 100755 index 00000000..a7c43669 --- /dev/null +++ b/tests/beaker/tests/create_pv_param_unless_vg.rb @@ -0,0 +1,81 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96593 - create physical volume with parameter 'unless_vg'" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv, vg) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv[0]}': + ensure => present, +} +-> +volume_group {'#{vg}': + ensure => present, + physical_volumes => '#{pv[0]}', +} +-> +physical_volume {'#{pv[1]}': + ensure => present, + unless_vg => '#{vg}' +} +MANIFEST + +pp2 = <<-MANIFEST +physical_volume {'#{pv[1]}': + ensure => present, + unless_vg => 'non-existing-volume-group' +} +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) + + +confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + #Run Puppet Agent with manifest pp + step "Run Puppet Agent to create volume group '#{vg}' on physical volume '#{pv[0]}'" + 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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + + step "Verify physical volume '#{pv[1]}' is NOT created since volume group '#{vg}' DOES exist" + on(agent, "pvdisplay") do |result| + assert_no_match(/#{pv[1]}/, result.stdout, 'Unexpected error was detected') + end + end +end + +#Run Puppet Agent again with manifest pp2 +step 'Inject "site.pp" on Master with new manifest' +site_pp = create_site_pp(master, :manifest => pp2) +inject_site_pp(master, get_site_pp_path(master), site_pp) + +confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + step "Run Puppet Agent to create the physical volume '#{pv[1]}':" + 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 physical volume '#{pv[1]}' is created since volume group 'non-existing-volume-group' DOES NOT exist" + verify_if_created?(agent, 'physical_volume', pv[1]) + end +end diff --git a/tests/beaker/tests/create_pv_w_param_force.rb b/tests/beaker/tests/create_pv_w_param_force.rb new file mode 100755 index 00000000..b679b4ce --- /dev/null +++ b/tests/beaker/tests/create_pv_w_param_force.rb @@ -0,0 +1,38 @@ +require 'master_manipulator' +require 'lvm_helper' +test_name "FM-4614 - C96592 - create physical volume parameter 'force'" + +#initilize +pv = '/dev/sdc' + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, + force => true, +} +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 physical 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 physical volume is created: #{pv}" + verify_if_created?(agent, 'physical_volume', pv) + end +end diff --git a/tests/beaker/tests/create_pv_with_param_name.rb b/tests/beaker/tests/create_pv_with_param_name.rb new file mode 100755 index 00000000..35f2f646 --- /dev/null +++ b/tests/beaker/tests/create_pv_with_param_name.rb @@ -0,0 +1,38 @@ +require 'master_manipulator' +require 'lvm_helper' +test_name "FM-4614 - C96590 - create physical volume with parameter 'name'" + +#initilize +pv = '/dev/sdc' + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv) + end + end +end + +pp = <<-MANIFEST +physical_volume {'Create physical volume': + ensure => present, + name => '#{pv}', +} +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 physical 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 physical volume is created: #{pv}" + verify_if_created?(agent, 'physical_volume', pv) + end +end diff --git a/tests/beaker/tests/create_pv_wo_param_name.rb b/tests/beaker/tests/create_pv_wo_param_name.rb new file mode 100755 index 00000000..454b290d --- /dev/null +++ b/tests/beaker/tests/create_pv_wo_param_name.rb @@ -0,0 +1,37 @@ +require 'master_manipulator' +require 'lvm_helper' +test_name "FM-4614 - C96646 - create physical volume without parameter 'name'" + +#initilize +pv = '/dev/sdc' + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, +} +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 physical 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 physical volume is created: #{pv}" + verify_if_created?(agent, 'physical_volume', pv) + end +end diff --git a/tests/beaker/tests/create_vg_param_createonly.rb b/tests/beaker/tests/create_vg_param_createonly.rb new file mode 100755 index 00000000..e653699b --- /dev/null +++ b/tests/beaker/tests/create_vg_param_createonly.rb @@ -0,0 +1,89 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96596 - create volume group with parameter 'createonly'" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv, vg) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv[0]}': + ensure => present, +} +-> +volume_group {"#{vg}": + ensure => present, + physical_volumes => '#{pv[0]}', +} + +MANIFEST + +pp2 = <<-MANIFEST +physical_volume {'#{pv[1]}': + ensure => present, +} +-> +volume_group {"#{vg}": + ensure => present, + physical_volumes => '#{pv[1]}', + createonly => true, +} + +MANIFEST + +#Create volume group +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + + step "Verify the volume group '#{vg}' associated with physical volume '#{pv[0]}' :" + on(agent, "pvdisplay #{pv[0]}") do |result| + assert_match(/#{vg}/, result.stdout, "Unexpected error was detected") + end + end +end + +#Make sure the volume group is unchange with 'createonly' +step 'Inject "site.pp" on Master' +site_pp = create_site_pp(master, :manifest => pp2) +inject_site_pp(master, get_site_pp_path(master), site_pp) + +step 'Attempt to create a same name volume group with createonly' +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 volume group '#{vg}' still associated with physical volume '#{pv[0]}' :" + on(agent, "pvdisplay #{pv[0]}") do |result| + assert_match(/#{vg}/, result.stdout, "Unexpected error was detected") + end + + step "verify the volume group '#{vg}' IS NOT associated with physical volume '#{pv[1]}' :" + on(agent, "pvdisplay #{pv[1]}") do |result| + assert_no_match(/#{vg}/, result.stdout, "Unexpected error was detected") + end + end +end diff --git a/tests/beaker/tests/create_vg_property_logical_volumes.rb b/tests/beaker/tests/create_vg_property_logical_volumes.rb new file mode 100755 index 00000000..1dd479a8 --- /dev/null +++ b/tests/beaker/tests/create_vg_property_logical_volumes.rb @@ -0,0 +1,50 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C97138 - create volume group with property 'logical_volumes'" + +#initilize +pv = '/dev/sdc' +vg = "VolumeGroup_" + SecureRandom.hex(3) +lv = "LogicalVolume_" + SecureRandom.hex(2) + +# 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 +class { 'lvm': + volume_groups => { + '#{vg}' => { + physical_volumes => '#{pv}', + logical_volumes => { + '#{lv}' => {'size' => '200M'}, + }, + }, + }, +} +include ::lvm + +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + end +end diff --git a/tests/beaker/tests/create_vg_property_physical_volumes.rb b/tests/beaker/tests/create_vg_property_physical_volumes.rb new file mode 100755 index 00000000..db05467b --- /dev/null +++ b/tests/beaker/tests/create_vg_property_physical_volumes.rb @@ -0,0 +1,46 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96597 - create volume group with property 'physical_volumes'" + +#initilize +pv = '/dev/sdc' +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv, vg) + end + end +end + +pp = <<-MANIFEST +class { 'lvm': + volume_groups => { + '#{vg}' => { + physical_volumes => '#{pv}', + }, + }, +} +include ::lvm + +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + end +end diff --git a/tests/beaker/tests/create_vg_w_2_physical_volumes.rb b/tests/beaker/tests/create_vg_w_2_physical_volumes.rb new file mode 100755 index 00000000..1d81623a --- /dev/null +++ b/tests/beaker/tests/create_vg_w_2_physical_volumes.rb @@ -0,0 +1,46 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96632 - create volume group with more than one physical volumes" + +#initilize +pv = ['/dev/sdc', '/dev/sdd'] +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv, vg) + end + end +end + +pp = <<-MANIFEST +class { 'lvm': + volume_groups => { + '#{vg}' => { + physical_volumes => #{pv}, + }, + }, +} +include ::lvm + +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + end +end diff --git a/tests/beaker/tests/create_vg_w_param_name.rb b/tests/beaker/tests/create_vg_w_param_name.rb new file mode 100755 index 00000000..2f4e9bcb --- /dev/null +++ b/tests/beaker/tests/create_vg_w_param_name.rb @@ -0,0 +1,47 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96594 - create volume group without parameter 'name'" + +#initilize +pv = '/dev/sdc' +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv, vg) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {"Create a volume group: #{vg}": + ensure => present, + name => '#{vg}', + physical_volumes => '#{pv}', +} + +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + end +end diff --git a/tests/beaker/tests/create_vg_wo_param_name.rb b/tests/beaker/tests/create_vg_wo_param_name.rb new file mode 100755 index 00000000..d07a8789 --- /dev/null +++ b/tests/beaker/tests/create_vg_wo_param_name.rb @@ -0,0 +1,46 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96595 - create volume group with property 'ensure' and without param 'name'" + +#initilize +pv = '/dev/sdc' +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv, vg) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {"#{vg}": + ensure => present, + physical_volumes => '#{pv}', +} + +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + end +end diff --git a/tests/beaker/tests/remove_lv.rb b/tests/beaker/tests/remove_lv.rb new file mode 100755 index 00000000..b83c8801 --- /dev/null +++ b/tests/beaker/tests/remove_lv.rb @@ -0,0 +1,80 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96615 - remove logical volume" + +#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) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {'#{vg}': + ensure => present, + physical_volumes => '#{pv}', +} +-> +logical_volume{'#{lv}': + ensure => present, + volume_group => '#{vg}', + size => '100M', +} +MANIFEST + +pp2 = <<-MANIFEST +logical_volume {'#{lv}': + ensure => absent, + volume_group => '#{vg}', +} +MANIFEST + +#Creating a logical volume +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, "umount /dev/#{vg}/#{lv}", :acceptable_exit_codes => [0,1]) + 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: #{lv}" + verify_if_created?(agent, 'logical_volume', lv, vg) + end +end + +#removing the logical volume +step 'Inject "site.pp" on Master' +site_pp = create_site_pp(master, :manifest => pp2) +inject_site_pp(master, get_site_pp_path(master), site_pp) + +step "run Puppet Agent to remove logical volume : #{lv}" +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 removed: #{lv}" + on(agent, "lvdisplay") do |result| + assert_no_match(/#{lv}/, result.stdout, 'Unexpected error was detected') + end + end +end diff --git a/tests/beaker/tests/remove_pv.rb b/tests/beaker/tests/remove_pv.rb new file mode 100755 index 00000000..34d6c4fb --- /dev/null +++ b/tests/beaker/tests/remove_pv.rb @@ -0,0 +1,57 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96613 - remove physical volume" + +#initilize +pv = '/dev/sdc' + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, +} +MANIFEST + +pp2 = <<-MANIFEST +physical_volume {"Remove physical volume group: #{pv}": + ensure => absent, + name => '#{pv}', +} +MANIFEST + +#creating physical volume +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 physical volume' +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 physical volume is created: #{pv}" + verify_if_created?(agent, 'physical_volume', pv) + end +end + +#removing the physical volume +step 'Inject "site.pp" on Master' +site_pp = create_site_pp(master, :manifest => pp2) +inject_site_pp(master, get_site_pp_path(master), site_pp) + +step "run Puppet Agent to remove the physical volume: #{pv}" +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 physical volume is removed: #{pv}" + on(agent, "pvdisplay") do |result| + assert_no_match(/#{pv}/, result.stdout, 'Unexpected error was detected') + end + end +end diff --git a/tests/beaker/tests/remove_vg.rb b/tests/beaker/tests/remove_vg.rb new file mode 100755 index 00000000..51d0b786 --- /dev/null +++ b/tests/beaker/tests/remove_vg.rb @@ -0,0 +1,73 @@ +require 'master_manipulator' +require 'lvm_helper' +require 'securerandom' + +test_name "FM-4614 - C96614 - remove volume_group" + +#initilize +pv = '/dev/sdc' +vg = "VolumeGroup_" + SecureRandom.hex(3) + +# Teardown +teardown do + confine_block(:except, :roles => %w{master dashboard database}) do + agents.each do |agent| + remove_all(agent, pv) + end + end +end + +pp = <<-MANIFEST +physical_volume {'#{pv}': + ensure => present, +} +-> +volume_group {"Create a volume group: #{vg}": + ensure => present, + name => '#{vg}', + physical_volumes => '#{pv}', +} +MANIFEST + +pp2 = <<-MANIFEST +volume_group {"Remove a volume group: #{vg}": + ensure => absent, + name => '#{vg}', +} +MANIFEST + +#creating group +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 volume group' +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 volume group is created: #{vg}" + verify_if_created?(agent, 'volume_group', vg) + end +end + +#removing group +step 'Inject "site.pp" on Master' +site_pp = create_site_pp(master, :manifest => pp2) +inject_site_pp(master, get_site_pp_path(master), site_pp) + +step "run Puppet Agent to remove volume group : #{vg}" +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 volume group is removed: #{vg}" + on(agent, "vgdisplay") do |result| + assert_no_match(/#{vg}/, result.stdout, 'Unexpected error was detected') + end + end +end