Use native package resource to install tox

The native package resource type provides the pip provider which can
be used instead of direct exec call.

Change-Id: I0ffd81116e4cc576caf6f4830becba183fd9e708
This commit is contained in:
Takashi Kajinami 2024-10-02 12:18:55 +09:00
parent 0f3186d298
commit 8ebd4cfe03
2 changed files with 8 additions and 10 deletions

View File

@ -536,15 +536,14 @@ class tempest(
ensure_packages('pip', { ensure_packages('pip', {
name => $::tempest::params::pip_package_name, name => $::tempest::params::pip_package_name,
}) })
Package['pip'] -> Exec['install-tox'] Package['pip'] -> Package['tox']
} else { } else {
warning('pip package is not available in this distribution.') warning('pip package is not available in this distribution.')
} }
exec { 'install-tox': package { 'tox':
command => [$tempest::params::pip_command, 'install', '-U', 'tox'], ensure => present,
unless => 'which tox', provider => 'pip',
path => ['/bin','/usr/bin','/usr/local/bin'],
} }
if $git_clone { if $git_clone {
@ -566,7 +565,7 @@ class tempest(
creates => "${tempest_clone_path}/.venv", creates => "${tempest_clone_path}/.venv",
path => ['/bin', '/usr/bin', '/usr/local/bin'], path => ['/bin', '/usr/bin', '/usr/local/bin'],
require => [ require => [
Exec['install-tox'], Package['tox'],
Package[$tempest::params::dev_packages], Package[$tempest::params::dev_packages],
], ],
} }

View File

@ -182,10 +182,9 @@ describe 'tempest' do
) )
end end
is_expected.to contain_exec('install-tox').with( is_expected.to contain_package('tox').with(
:command => [platform_params[:pip_command], 'install', '-U', 'tox'], :ensure => 'present',
:unless => 'which tox', :provider => 'pip',
:path => ['/bin', '/usr/bin', '/usr/local/bin'],
) )
is_expected.to contain_vcsrepo('/var/lib/tempest').with( is_expected.to contain_vcsrepo('/var/lib/tempest').with(