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

View File

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