From f41a63ebce7cfb55972dac4bf30f934c3efcc9b6 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 3 Nov 2024 18:09:25 +0900 Subject: [PATCH] Switch to built-in venv Python provides the built-in venv functionality which can replace virtualenv since Python 3.3 . Depends-on: https://review.opendev.org/934007 Change-Id: I201684c953e30f6e148573ee0340e1807518de70 --- manifests/init.pp | 18 +----------------- manifests/params.pp | 8 +------- spec/classes/tempest_init_spec.rb | 20 +++----------------- 3 files changed, 5 insertions(+), 41 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5ef7ad8a..657ddcf4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -581,20 +581,6 @@ class tempest( ensure_packages(['git']) ensure_packages($tempest::params::dev_packages) - if $::tempest::params::pip_package_name { - ensure_packages('pip', { - name => $::tempest::params::pip_package_name, - }) - Package['pip'] -> Package['tox'] - } else { - warning('pip package is not available in this distribution.') - } - - package { 'tox': - ensure => present, - provider => 'pip', - } - if $git_clone { vcsrepo { $tempest_clone_path: ensure => 'present', @@ -608,13 +594,11 @@ class tempest( } if $setup_venv { - # virtualenv will be installed along with tox exec { 'create-venv': - command => ['virtualenv', '-p', 'python3', "${tempest_clone_path}/.venv"], + command => ['python3', '-m', 'venv', "${tempest_clone_path}/.venv"], creates => "${tempest_clone_path}/.venv", path => ['/bin', '/usr/bin', '/usr/local/bin'], require => [ - Package['tox'], Package[$tempest::params::dev_packages], ], } diff --git a/manifests/params.pp b/manifests/params.pp index 3bf75ac9..90564a58 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -33,10 +33,6 @@ class tempest::params { $python_barbican_tests = 'python3-barbican-tests-tempest' $python_manila_tests = 'python3-manila-tests-tempest' $package_name = 'openstack-tempest' - $pip_package_name = $facts['os']['name'] ? { - 'RedHat' => undef, - default => 'python3-pip' - } } 'Debian': { $dev_packages = [ @@ -46,8 +42,7 @@ class tempest::params { 'libssl-dev', 'libffi-dev', 'patch', - 'gcc', - 'python3-virtualenv', + 'gcc' ] $python_telemetry_tests = 'telemetry-tempest-plugin' $python_cinder_tests = 'cinder-tempest-plugin' @@ -68,7 +63,6 @@ class tempest::params { $python_barbican_tests = 'barbican-tempest-plugin' $python_manila_tests = 'manila-tempest-plugin' $package_name = 'tempest' - $pip_package_name = 'python3-pip' } default: { fail("Unsupported osfamily: ${facts['os']['family']}") diff --git a/spec/classes/tempest_init_spec.rb b/spec/classes/tempest_init_spec.rb index 8da1c5b3..3970ee28 100644 --- a/spec/classes/tempest_init_spec.rb +++ b/spec/classes/tempest_init_spec.rb @@ -176,17 +176,6 @@ describe 'tempest' do is_expected.to contain_class('tempest::params') - if platform_params[:pip_package_name] - is_expected.to contain_package('pip').with( - :name => platform_params[:pip_package_name], - ) - end - - is_expected.to contain_package('tox').with( - :ensure => 'present', - :provider => 'pip', - ) - is_expected.to contain_vcsrepo('/var/lib/tempest').with( :ensure => 'present', :source => 'https://opendev.org/openstack/tempest', @@ -400,7 +389,7 @@ describe 'tempest' do it 'sets up virtualenv for tempest' do is_expected.to contain_exec('create-venv').with( - :command => ['virtualenv', '-p', 'python3', '/var/lib/tempest/.venv'], + :command => ['python3', '-m', 'venv', '/var/lib/tempest/.venv'], :creates => '/var/lib/tempest/.venv', :path => ['/bin', '/usr/bin', '/usr/local/bin'] ) @@ -409,7 +398,7 @@ describe 'tempest' do it 'installs tempest into the virtualenv' do is_expected.to contain_exec('install-tempest').with( :command => [ - 'virtualenv', '-p', 'python3', '/var/lib/tempest/.venv' + 'pytho3', '-m' 'venv', '/var/lib/tempest/.venv' ], :command => [ "/var/lib/tempest/.venv/bin/#{platform_params[:pip_command]}", 'install', @@ -583,11 +572,9 @@ describe 'tempest' do 'libssl-dev', 'libffi-dev', 'patch', - 'gcc', - 'python3-virtualenv'], + 'gcc'], :package_name => 'tempest', :pip_command => 'pip3', - :pip_package_name => 'python3-pip', :python_heat_tests => 'heat-tempest-plugin', :python_keystone_tests => 'keystone-tempest-plugin', :python_neutron_tests => 'neutron-tempest-plugin', @@ -602,7 +589,6 @@ describe 'tempest' do 'gcc'], :package_name => 'openstack-tempest', :pip_command => 'pip3', - :pip_package_name => 'python3-pip', :python_heat_tests => 'python3-heat-tests-tempest', :python_keystone_tests => 'python3-keystone-tests-tempest', :python_neutron_tests => 'python3-neutron-tests-tempest',