Added manifests to install tempest from package

* Install tempest from distro package
* Create tempest workspace

Closes-Bug: #1549366

Change-Id: I9eef83bd56cd3b3a890dbdde34e1c317d4afa0e2
This commit is contained in:
Chandan Kumar 2017-01-25 09:34:38 +00:00
parent 34f7293e2b
commit 4303ee2e7b
6 changed files with 95 additions and 2 deletions

View File

@ -55,4 +55,8 @@ Puppet::Type.newtype(:tempest_config) do
defaultto('<SERVICE DEFAULT>') defaultto('<SERVICE DEFAULT>')
end end
autorequire(:package) do
'tempest'
end
end end

View File

@ -5,6 +5,11 @@
# Note that only parameters for which values are provided will be # Note that only parameters for which values are provided will be
# managed in tempest.conf. # managed in tempest.conf.
# #
# [*ensure_package*]
# (optional) The state of tempest packages
# Defaults to 'present'
# [*tempest_workspace*]
# Deafults to '/var/lib/tempest'
# [*install_from_source*] # [*install_from_source*]
# Defaults to true # Defaults to true
# [*git_clone*] # [*git_clone*]
@ -200,6 +205,8 @@
# Defaults to undef # Defaults to undef
# #
class tempest( class tempest(
$ensure_package = 'present',
$tempest_workspace = '/var/lib/tempest',
$install_from_source = true, $install_from_source = true,
$git_clone = true, $git_clone = true,
$tempest_config_file = '/var/lib/tempest/etc/tempest.conf', $tempest_config_file = '/var/lib/tempest/etc/tempest.conf',
@ -431,6 +438,31 @@ class tempest(
} }
} }
if ! $install_from_source {
package { 'tempest':
ensure => $ensure_package,
name => $::tempest::params::package_name,
tag => ['openstack', 'tempest-package'],
}
$tempest_conf = "${tempest_workspace}/etc/tempest.conf"
# Create tempest workspace by running tempest init.
# It will generate etc/tempest.conf, logs and tempest_lock folder
# in tempest workspace
exec {'tempest-workspace':
command => "tempest init ${tempest_workspace}",
cwd => $tempest_workspace,
path => ['/bin', '/usr/bin'],
refreshonly => true,
require => Package['tempest'],
}
Package['tempest'] ~> Exec['tempest-workspace']
Exec['tempest-workspace'] -> Tempest_config<||>
}
tempest_config { tempest_config {
'auth/admin_domain_name': value => $admin_domain_name; 'auth/admin_domain_name': value => $admin_domain_name;
'auth/admin_password': value => $admin_password, secret => true; 'auth/admin_password': value => $admin_password, secret => true;

View File

@ -37,6 +37,7 @@ class tempest::params {
$python_zaqar_tests = 'python-zaqar-tests' $python_zaqar_tests = 'python-zaqar-tests'
$python_congress_tests = 'python-congress-tests' $python_congress_tests = 'python-congress-tests'
$python_panko_tests = 'python-panko-tests' $python_panko_tests = 'python-panko-tests'
$package_name = 'openstack-tempest'
} }
'Debian': { 'Debian': {
$dev_packages = [ $dev_packages = [
@ -71,6 +72,7 @@ class tempest::params {
$python_zaqar_tests = false $python_zaqar_tests = false
$python_congress_tests = false $python_congress_tests = false
$python_panko_tests = false $python_panko_tests = false
$package_name = 'tempest'
} }
default: { default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \ fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \

View File

@ -0,0 +1,3 @@
---
features:
- Added manifests to install tempest from package

View File

@ -307,6 +307,46 @@ describe 'tempest' do
end end
end end
end end
context 'install Tempest from package' do
let :params do
{:install_from_source => false,
:image_name => 'image name',
:image_name_alt => 'image name alt'}
end
it 'checks for tempest package' do
is_expected.to contain_package('tempest').with(
:ensure => 'present',
:name => platform_params[:package_name],
:tag => ['openstack', 'tempest-package'],
)
end
it 'creates tempest workspace' do
is_expected.to contain_exec('tempest-workspace').with(
:command => 'tempest init /var/lib/tempest',
:cwd => '/var/lib/tempest',
:path => ['/bin', '/usr/bin'],
:refreshonly => true,
:require => 'Package[tempest]'
)
end
end
context 'tempest workspace customization' do
let :params do
{:tempest_workspace => '/tmp/tempest',
:image_name => 'image name',
:image_name_alt => 'image name alt',
:install_from_source => false}
end
it 'supports customizes tempest workspace' do
is_expected.to contain_exec('tempest-workspace').with(
:command => 'tempest init /tmp/tempest',
)
end
end
end end
shared_examples 'tempest with plugins packages' do shared_examples 'tempest with plugins packages' do
@ -383,7 +423,8 @@ describe 'tempest' do
'libffi-dev', 'libffi-dev',
'patch', 'patch',
'gcc', 'gcc',
'python-virtualenv' ] } 'python-virtualenv' ],
:package_name => 'tempest'}
when 'RedHat' when 'RedHat'
{ :dev_packages => ['python-devel', { :dev_packages => ['python-devel',
'libxslt-devel', 'libxslt-devel',
@ -391,7 +432,8 @@ describe 'tempest' do
'openssl-devel', 'openssl-devel',
'libffi-devel', 'libffi-devel',
'patch', 'patch',
'gcc'] } 'gcc'],
:package_name => 'openstack-tempest'}
end end
end end

View File

@ -50,4 +50,14 @@ describe 'Puppet::Type.type(:tempest_config)' do
@tempest_config[:ensure] = :latest @tempest_config[:ensure] = :latest
}.to raise_error(Puppet::Error, /Invalid value/) }.to raise_error(Puppet::Error, /Invalid value/)
end end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'tempest')
catalog.add_resource package, @tempest_config
dependency = @tempest_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@tempest_config)
expect(dependency[0].source).to eq(package)
end
end end