From 4303ee2e7b28313e0ab84bc7189a255f214e1451 Mon Sep 17 00:00:00 2001 From: Chandan Kumar Date: Wed, 25 Jan 2017 09:34:38 +0000 Subject: [PATCH] Added manifests to install tempest from package * Install tempest from distro package * Create tempest workspace Closes-Bug: #1549366 Change-Id: I9eef83bd56cd3b3a890dbdde34e1c317d4afa0e2 --- lib/puppet/type/tempest_config.rb | 4 ++ manifests/init.pp | 32 +++++++++++++ manifests/params.pp | 2 + ...tempest-from-package-dbf74b77aced0ec4.yaml | 3 ++ spec/classes/tempest_init_spec.rb | 46 ++++++++++++++++++- spec/unit/type/tempest_config_spec.rb | 10 ++++ 6 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/manifests-to-install-tempest-from-package-dbf74b77aced0ec4.yaml diff --git a/lib/puppet/type/tempest_config.rb b/lib/puppet/type/tempest_config.rb index faf7500d..0846bc1a 100644 --- a/lib/puppet/type/tempest_config.rb +++ b/lib/puppet/type/tempest_config.rb @@ -55,4 +55,8 @@ Puppet::Type.newtype(:tempest_config) do defaultto('') end + autorequire(:package) do + 'tempest' + end + end diff --git a/manifests/init.pp b/manifests/init.pp index 6e9012bd..b5737e5e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -5,6 +5,11 @@ # Note that only parameters for which values are provided will be # 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*] # Defaults to true # [*git_clone*] @@ -200,6 +205,8 @@ # Defaults to undef # class tempest( + $ensure_package = 'present', + $tempest_workspace = '/var/lib/tempest', $install_from_source = true, $git_clone = true, $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 { 'auth/admin_domain_name': value => $admin_domain_name; 'auth/admin_password': value => $admin_password, secret => true; diff --git a/manifests/params.pp b/manifests/params.pp index aec98ced..0f184414 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -37,6 +37,7 @@ class tempest::params { $python_zaqar_tests = 'python-zaqar-tests' $python_congress_tests = 'python-congress-tests' $python_panko_tests = 'python-panko-tests' + $package_name = 'openstack-tempest' } 'Debian': { $dev_packages = [ @@ -71,6 +72,7 @@ class tempest::params { $python_zaqar_tests = false $python_congress_tests = false $python_panko_tests = false + $package_name = 'tempest' } default: { fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \ diff --git a/releasenotes/notes/manifests-to-install-tempest-from-package-dbf74b77aced0ec4.yaml b/releasenotes/notes/manifests-to-install-tempest-from-package-dbf74b77aced0ec4.yaml new file mode 100644 index 00000000..a15c7ab7 --- /dev/null +++ b/releasenotes/notes/manifests-to-install-tempest-from-package-dbf74b77aced0ec4.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added manifests to install tempest from package diff --git a/spec/classes/tempest_init_spec.rb b/spec/classes/tempest_init_spec.rb index 9fd5c085..61a08529 100644 --- a/spec/classes/tempest_init_spec.rb +++ b/spec/classes/tempest_init_spec.rb @@ -307,6 +307,46 @@ describe 'tempest' do 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 shared_examples 'tempest with plugins packages' do @@ -383,7 +423,8 @@ describe 'tempest' do 'libffi-dev', 'patch', 'gcc', - 'python-virtualenv' ] } + 'python-virtualenv' ], + :package_name => 'tempest'} when 'RedHat' { :dev_packages => ['python-devel', 'libxslt-devel', @@ -391,7 +432,8 @@ describe 'tempest' do 'openssl-devel', 'libffi-devel', 'patch', - 'gcc'] } + 'gcc'], + :package_name => 'openstack-tempest'} end end diff --git a/spec/unit/type/tempest_config_spec.rb b/spec/unit/type/tempest_config_spec.rb index 18da06bd..88c8f5e2 100644 --- a/spec/unit/type/tempest_config_spec.rb +++ b/spec/unit/type/tempest_config_spec.rb @@ -50,4 +50,14 @@ describe 'Puppet::Type.type(:tempest_config)' do @tempest_config[:ensure] = :latest }.to raise_error(Puppet::Error, /Invalid value/) 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