Enable manila-share in acceptance tests

This change enables the manila-share service and lvm backend in
acceptance tests, so that we can test more complete setup.

Change-Id: I8e3c1cda17c897b6c13563ea733988e28dd49f8f
This commit is contained in:
Takashi Kajinami 2022-08-31 00:24:47 +09:00
parent 58732b2f64
commit 715e97a3bf
4 changed files with 137 additions and 2 deletions

View File

@ -0,0 +1,64 @@
# == Class: manila::setup_test_volume
#
# Setup a volume group on a loop device for test purposes.
#
# === Parameters
#
# [*volume_name*]
# (Optional) Volume group name.
# Defaults to 'lvm-shares'.
#
# [*size*]
# (Optional) Volume group size.
# Defaults to '4G'.
#
# [*loopback_device*]
# (Optional) Loop device name.
# Defaults to '/dev/loop2'.
#
# [*volume_path*]
# (Optional) Volume image location.
# Defaults to '/var/lib/manila'.
#
class manila::setup_test_volume(
$volume_name = 'lvm-shares',
$volume_path = '/var/lib/manila',
$size = '4G',
$loopback_device = '/dev/loop2'
) {
include manila::deps
ensure_packages ( 'lvm2', {
ensure => present,
})
Package<| title == 'lvm2' |> { tag +> 'manila-support-package' }
exec { "create_${volume_path}/${volume_name}":
command => "dd if=/dev/zero of=\"${volume_path}/${volume_name}\" bs=1 count=0 seek=${size}",
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => "stat ${volume_path}/${volume_name}",
require => Anchor['manila::install::end'],
subscribe => Package['lvm2']
}
~> file { "${volume_path}/${volume_name}":
mode => '0640',
}
~> exec { "losetup ${loopback_device} ${volume_path}/${volume_name}":
command => "losetup ${loopback_device} ${volume_path}/${volume_name} && udevadm settle",
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => "losetup ${loopback_device}",
refreshonly => true,
}
~> exec { "pvcreate ${loopback_device}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => "pvs ${loopback_device}",
refreshonly => true,
}
~> exec { "vgcreate ${volume_name} ${loopback_device}":
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
unless => "vgs ${volume_name}",
refreshonly => true,
}
-> Anchor['manila::service::begin']
}

View File

@ -0,0 +1,5 @@
---
features:
- |
The ``manila::setup_test_volume`` class has been added. This class prepares
the loop back block device and the volume group for LVM share driver.

View File

@ -55,7 +55,7 @@ describe 'basic manila' do
password => 'a_big_secret',
}
class { 'manila::api':
service_name => 'httpd',
service_name => 'httpd',
}
include apache
class { 'manila::wsgi::apache':
@ -64,7 +64,26 @@ describe 'basic manila' do
class { 'manila::scheduler': }
class { 'manila::cron::db_purge': }
# missing: backends, share, service_instance
class { 'manila::share': }
class { 'manila::backends':
enabled_share_backends => ['lvm']
}
class { 'manila::setup_test_volume':
size => '15G',
}
manila::backend::lvm { 'lvm':
lvm_share_export_ips => $::openstack_integration::config::host,
}
# TODO(tkajinam): This should be fixed in the RDO package
if $::osfamily == 'RedHat' {
file_line { 'manila-sudoers-privsep-helper':
path => '/etc/sudoers.d/manila',
line => 'manila ALL = (root) NOPASSWD: /usr/bin/privsep-helper *',
require => Anchor['manila::config::begin'],
notify => Anchor['manila::config::end']
}
}
manila_type { 'sharetype':
}

View File

@ -0,0 +1,47 @@
require 'spec_helper'
describe 'manila::setup_test_volume' do
shared_examples 'manila::setup_test_volume' do
it { is_expected.to contain_package('lvm2').with(
:ensure => 'installed',
:tag => 'manila-support-package'
)}
it {
is_expected.to contain_exec('create_/var/lib/manila/lvm-shares').with(
:command => 'dd if=/dev/zero of="/var/lib/manila/lvm-shares" bs=1 count=0 seek=4G',
:path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
:unless => 'stat /var/lib/manila/lvm-shares',
)
is_expected.to contain_exec('losetup /dev/loop2 /var/lib/manila/lvm-shares').with(
:command => 'losetup /dev/loop2 /var/lib/manila/lvm-shares && udevadm settle',
:path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
:unless => 'losetup /dev/loop2',
)
is_expected.to contain_exec('pvcreate /dev/loop2').with(
:path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
:unless => 'pvs /dev/loop2',
:refreshonly => true,
)
is_expected.to contain_exec('vgcreate lvm-shares /dev/loop2').with(
:path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
:unless => 'vgs lvm-shares',
:refreshonly => true,
)
}
it { is_expected.to contain_file('/var/lib/manila/lvm-shares').with_mode('0640') }
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'manila::setup_test_volume'
end
end
end