Merge "Add support for swift-recon-cron job"

This commit is contained in:
Zuul 2020-02-07 06:05:46 +00:00 committed by Gerrit Code Review
commit 560c3d66ef
3 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,69 @@
#
# Copyright (C) 2019 Red Hat
#
# 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: swift::storage::cron::recon
#
# Configure cron job to reflect statistics related to async pendings into recon
#
# === Parameters
#
# [*minute*]
# (optional) Defaults to '*/5'.
#
# [*hour*]
# (optional) Defaults to '*'.
#
# [*monthday*]
# (optional) Defaults to '*'.
#
# [*month*]
# (optional) Defaults to '*'.
#
# [*weekday*]
# (optional) Defaults to '*'.
#
# [*configfile*]
# (optional) Path to object server config file.
# Defaults to '/etc/swift/object-server.conf'.
#
# [*user*]
# (optional) User with access to swift files.
# swift::storage::server::user will be used if this is undef.
# Defaults to 'swift'.
#
class swift::storage::cron::recon(
$minute = '*/5',
$hour = '*',
$monthday = '*',
$month = '*',
$weekday = '*',
$configfile = '/etc/swift/object-server.conf',
$user = 'swift'
) {
include ::swift::deps
include ::swift::params
cron { 'swift-recon-cron':
command => "swift-recon-cron ${configfile}",
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
user => $user,
minute => $minute,
hour => $hour,
monthday => $monthday,
month => $month,
weekday => $weekday,
}
}

View File

@ -0,0 +1,4 @@
---
features:
- |
Add ability to configure swift-recon-cron job.

View File

@ -0,0 +1,59 @@
require 'spec_helper'
describe 'swift::storage::cron::recon' do
shared_examples 'swift::storage::cron::recon' do
let :pre_condition do
"class { 'swift': swift_hash_path_suffix => 'foo' }
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
end
let :params do
{}
end
context 'with no parameters specified' do
it { is_expected.to contain_cron('swift-recon-cron').with(
:command => 'swift-recon-cron /etc/swift/object-server.conf',
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'swift',
:minute => '*/5',
:hour => '*',
:monthday => '*',
:month => '*',
:weekday => '*',
)}
end
context 'with parameters specified' do
before :each do
params.merge!({
:configfile => '/opt/swift/object-server.conf',
:user => 'foo',
:minute => '*/1'
})
end
it { is_expected.to contain_cron('swift-recon-cron').with(
:command => 'swift-recon-cron /opt/swift/object-server.conf',
:user => 'foo',
:minute => '*/1',
:hour => '*',
:monthday => '*',
:month => '*',
:weekday => '*',
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'swift::storage::cron::recon'
end
end
end