Colleen Murphy 8360c894db Fix subunit2sql install guard for idempotency
The exec to install subunit2sql tries to compare the output of pip list
versus pip search to determine whether it is on the latest version.
Without this patch, the pip list command produces a string that has too
many spaces on the end and therefore doesn't match the result of the pip
search command. This means that it will always try to reinstall
subunit2sql even when it doesn't need to, which breaks idempotency
tests. This patch fixes the regex group to exclude trailing spaces.

Change-Id: I92f614db2da936d68d8f2305b348c65ba773b01c
2018-08-06 22:04:45 +02:00

124 lines
3.5 KiB
Puppet

# Copyright 2012-2013 Hewlett-Packard Development Company, L.P.
# Copyright 2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# == Class: subunit2sql
#
class subunit2sql (
) {
include ::pip
package {'python-mysqldb':
ensure => present,
}
package {'python-psycopg2':
ensure => present,
}
package {'python-netifaces':
ensure => present,
}
package { 'python-subunit':
ensure => latest,
provider => openstack_pip,
require => Class['pip'],
}
exec { 'install-subunit2sql-safely':
command => 'pip install --upgrade --upgrade-strategy=only-if-needed subunit2sql',
path => '/usr/local/bin:/usr/bin:/bin/',
# This checks the current installed subunit2sql version with pip list and
# the latest version of subunit2sql on pypi with pip search and if they are
# different then we know we need to upgrade to reconcile the local version
# with the upstream version.
#
# We do this using this check here rather than a pip package resource so we
# can override pip's default upgrade strategy in order to avoid replacing
# deps we've preinstalled from system packages because they lack wheels on
# PyPI and must be otherwise rebuilt from sdist instead (specifically
# netifaces).
onlyif => '/bin/bash -c "test \\"$(pip list --format columns | sed -ne \'s/^subunit2sql\s\+\([[:digit:].]*\)\s*$/\1/p\')\\" != \\"$(pip search \'subunit2sql$\' | sed -ne \'s/^subunit2sql (\(.*\)).*$/\1/p\')\\""',
require => [
Class['pip'],
Package['python-mysqldb'],
Package['python-psycopg2'],
Package['python-netifaces']
],
}
package { 'os-performance-tools':
ensure => latest,
provider => openstack_pip,
require => [
Class['pip']
],
}
package { 'testtools':
ensure => latest,
provider => openstack_pip,
require => Class['pip'],
}
if ! defined(Package['python-daemon']) {
package { 'python-daemon':
ensure => present,
}
}
if ! defined(Package['python-zmq']) {
package { 'python-zmq':
ensure => present,
}
}
if ! defined(Package['gear']) {
package { 'gear':
ensure => latest,
provider => openstack_pip,
require => Class['pip'],
}
}
if ! defined(Package['statsd']) {
package { 'statsd':
# NOTE(cmurphy) If this is not pinned, the openstack_pip provider will
# attempt to install latest and conflict with the <3 cap from
# os-performance-tools. Unpin this when os-performance-tools raises its
# cap.
ensure => '2.1.2',
provider => openstack_pip,
require => Class['pip']
}
}
file { '/usr/local/bin/subunit-gearman-worker.py':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/subunit2sql/subunit-gearman-worker.py',
require => [
Package['python-daemon'],
Package['python-zmq'],
Package['gear'],
Exec['install-subunit2sql-safely'],
Package['python-subunit'],
Package['testtools']
],
}
}