Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: output log #698

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following parameters are available in the `python` class:
* [`manage_dev_package`](#-python--manage_dev_package)
* [`manage_venv_package`](#-python--manage_venv_package)
* [`manage_pip_package`](#-python--manage_pip_package)
* [`manage_setuptools`](#-python--manage_setuptools)
* [`venv`](#-python--venv)
* [`gunicorn_package_name`](#-python--gunicorn_package_name)
* [`python_pips`](#-python--python_pips)
Expand Down Expand Up @@ -217,6 +218,14 @@ manage the state for package pip

Default value: `$python::params::manage_pip_package`

##### <a name="-python--manage_setuptools"></a>`manage_setuptools`

Data type: `Boolean`

if true, install python-setuptools

Default value: `$facts['os']['family'] ? { 'Archlinux' => true, default => false`

##### <a name="-python--venv"></a>`venv`

Data type: `Python::Package::Ensure`
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# @param manage_dev_package manage the state of the python development package
# @param manage_venv_package manage the state for package venv
# @param manage_pip_package manage the state for package pip
# @param manage_setuptools if true, install python-setuptools
#
# @example install python from system python
# class { 'python':
Expand Down Expand Up @@ -61,6 +62,7 @@
Stdlib::Absolutepath $anaconda_install_path = '/opt/python',
Boolean $manage_scl = true,
Optional[Python::Umask] $umask = undef,
Boolean $manage_setuptools = $facts['os']['family'] ? { 'Archlinux' => true, default => false, },
) inherits python::params {
$exec_prefix = $provider ? {
'scl' => "/usr/bin/scl enable ${version} -- ",
Expand Down
6 changes: 6 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
'Suse' => "${python}-devel",
}

if $python::manage_setuptools {
package { 'python-distutils-extra':
ensure => 'installed',
}
}

if $python::manage_python_package {
package { 'python':
ensure => $python::ensure,
Expand Down
4 changes: 2 additions & 2 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@
}

exec { "python_virtualenv_${venv_dir}":
command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} --log ${venv_dir}/pip.log install ${pip_upgrade} && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade setuptools",
command => "${virtualenv_cmd} --clear ${system_pkgs_flag} ${prompt_arg} ${venv_dir} && ${pip_cmd} --log ${venv_dir}/pip.log install ${pip_upgrade} && cat ${venv_dir}/pip.log && ${pip_cmd} --log ${venv_dir}/pip.log install --upgrade setuptools && cat ${venv_dir}/pip.log",
user => $owner,
creates => "${venv_dir}/bin/activate",
path => $_path,
cwd => '/tmp',
environment => $environment,
timeout => 600,
unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv
unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate && cat ${venv_dir}/pip.log", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv
require => File[$venv_dir],
}
} elsif $ensure == 'absent' {
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

if facts[:os]['family'] == 'Archlinux'
it { is_expected.not_to contain_package('pip') }
it { is_expected.to contain_package('python-setuptools') }
else
it { is_expected.to contain_package('pip') }
it { is_expected.not_to contain_package('python-setuptools') }
end

if %w[Archlinux RedHat].include?(facts[:os]['family'])
Expand Down Expand Up @@ -154,7 +156,7 @@
it { is_expected.to contain_python__pyvenv('/opt/env1').with_ensure('present') }
it { is_expected.to contain_python__pyvenv('/opt/env2').with_ensure('present') }

it {

Check failure on line 159 in spec/classes/python_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

python on debian-11-x86_64 on Debian OS with python::python_pyvenvs and pip version defined with two pyenvs is expected to contain Exec[python_virtualenv_/opt/env1] that requires File[/opt/env1] Failure/Error: expect(subject).to contain_exec('python_virtualenv_/opt/env1'). with( command: 'python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools', user: 'root', creates: '/opt/env1/bin/activate', path: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' expected that the catalogue would contain Exec[python_virtualenv_/opt/env1] with command set to "python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools" but it is set to "python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && cat /opt/env1/pip.log && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools && cat /opt/env1/pip.log", and parameter unless set to /^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*\/opt\/env1\[\\"\\\\'\]\[\\t \]\*\$' \/opt\/env1\/bin\/activate$/ but it is set to "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*/opt/env1[\\\"\\\\'][\\t ]*$' /opt/env1/bin/activate && cat /opt/env1/pip.log" Diff: @@ -1,4 +1,4 @@ -python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools +python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && cat /opt/env1/pip.log && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools && cat /opt/env1/pip.log -(?-mix:^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*\/opt\/env1\[\\"\\\\'\]\[\\t \]\*\$' \/opt\/env1\/bin\/activate$) +grep '^[\t ]*VIRTUAL_ENV=[\\'\"]*/opt/env1[\"\\'][\t ]*$' /opt/env1/bin/activate && cat /opt/env1/pip.log
expect(subject).to contain_exec('python_virtualenv_/opt/env1').
with(
command: 'python3.8 -m venv --clear /opt/env1 && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade pip && /opt/env1/bin/pip --log /opt/env1/pip.log install --upgrade setuptools',
Expand All @@ -174,7 +176,7 @@
that_requires('File[/opt/env1]')
}

it {

Check failure on line 179 in spec/classes/python_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

python on debian-11-x86_64 on Debian OS with python::python_pyvenvs and pip version defined with two pyenvs is expected to contain Exec[python_virtualenv_/opt/env2] that requires File[/opt/env2] Failure/Error: expect(subject).to contain_exec('python_virtualenv_/opt/env2'). with( command: 'python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade \'pip <= 20.3.4\' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools', user: 'root', creates: '/opt/env2/bin/activate', path: [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' expected that the catalogue would contain Exec[python_virtualenv_/opt/env2] with command set to "python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade 'pip <= 20.3.4' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools" but it is set to "python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade 'pip <= 20.3.4' && cat /opt/env2/pip.log && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools && cat /opt/env2/pip.log", and parameter unless set to /^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*\/opt\/env2\[\\"\\\\'\]\[\\t \]\*\$' \/opt\/env2\/bin\/activate$/ but it is set to "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*/opt/env2[\\\"\\\\'][\\t ]*$' /opt/env2/bin/activate && cat /opt/env2/pip.log" Diff: @@ -1,4 +1,4 @@ -python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade 'pip <= 20.3.4' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools +python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade 'pip <= 20.3.4' && cat /opt/env2/pip.log && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools && cat /opt/env2/pip.log -(?-mix:^grep '\^\[\\t \]\*VIRTUAL_ENV=\[\\\\'\\"\]\*\/opt\/env2\[\\"\\\\'\]\[\\t \]\*\$' \/opt\/env2\/bin\/activate$) +grep '^[\t ]*VIRTUAL_ENV=[\\'\"]*/opt/env2[\"\\'][\t ]*$' /opt/env2/bin/activate && cat /opt/env2/pip.log
expect(subject).to contain_exec('python_virtualenv_/opt/env2').
with(
command: 'python3.8 -m venv --clear /opt/env2 && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade \'pip <= 20.3.4\' && /opt/env2/bin/pip --log /opt/env2/pip.log install --upgrade setuptools',
Expand Down
Loading