Make class rally work

Class rally is created initially by tool, this patch aims to
update related class, packages and configs:

 - Use package to install rally
 - Add rally_init_spec
 - include releated classes
 - move openstack_client_http_timeout from rally::settings to rally.

Closes-Bug: #1582961
Change-Id: Ibc0b981f7114f0bb49a56f65ffdc1ce3283e63dc
This commit is contained in:
Xingchao Yu
2016-05-18 16:48:48 +08:00
parent 3cb6b7bd9f
commit 72f1118e95
5 changed files with 102 additions and 13 deletions

View File

@@ -1,14 +1,43 @@
# == Class: rally
#
# Full description of class rally here.
# This class is used to specify configuration default section parameters in rally.
#
# === Parameters
# === Parameters:
#
# [*sample_parameter*]
# Explanation of what this parameter affects and what it defaults to.
# [*ensure_package*]
# (optional) The state of rally packages
# Defaults to 'present'.
#
class rally {
# [*rally_debug*]
# (optional) Print debugging output only for Rally. (boolean value)
# Defaults to $::os_service_default.
#
# [*openstack_client_http_timeout*]
# (optional) HTTP timeout for any of OpenStack service in seconds (floating point value)
# Defaults to $::os_service_default.
#
class rally (
$ensure_package = 'present',
$rally_debug = $::os_service_default,
$openstack_client_http_timeout = $::os_service_default
) inherits ::rally::params {
include ::rally::params
include ::rally::db
include ::rally::logging
include ::rally::settings
# Keep backward compatibility
$openstack_client_http_timeout_real = pick($::rally::settings::openstack_client_http_timeout,$openstack_client_http_timeout)
package { 'rally':
ensure => $ensure_package,
name => $::rally::params::package_name,
tag => ['openstack', 'rally-package'],
}
rally_config {
'DEFAULT/rally_debug': value => $rally_debug;
'DEFAULT/openstack_client_http_timeout': value => $openstack_client_http_timeout_real;
}
}

View File

@@ -5,9 +5,11 @@ class rally::params {
case $::osfamily {
'RedHat': {
$sqlite_package_name = undef
$package_name = 'openstack-rally'
}
'Debian': {
$sqlite_package_name = 'python-pysqlite2'
$package_name = 'rally'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem")

View File

@@ -16,9 +16,6 @@
# (Optional) Image disk format
# Defaults to $::os_service_default
#
# [*openstack_client_http_timeout*]
# (Optional) HTTP timeout for any of OpenStack service in seconds
# Defaults to $::os_service_default
#
# [*project_domain*]
# (Optional) ID of domain in which projects will be created.
@@ -36,13 +33,17 @@
# (Optional) ID of domain in which users will be created.
# Defaults to $::os_service_default
#
# [*openstack_client_http_timeout*]
# (optional) HTTP timeout for any of OpenStack service in seconds (floating point value)
# Defaults to undef.
#
class rally::settings (
$cirros_img_url = $::os_service_default,
$openstack_client_http_timeout = $::os_service_default,
$project_domain = $::os_service_default,
$resource_deletion_timeout = $::os_service_default,
$resource_management_workers = $::os_service_default,
$user_domain = $::os_service_default,
$openstack_client_http_timeout = undef,
) {
include ::rally::settings::cinder
@@ -57,7 +58,6 @@ class rally::settings (
include ::rally::settings::swift
rally_config {
'DEFAULT/openstack_client_http_timeout': value => $openstack_client_http_timeout;
'cleanup/resource_deletion_timeout': value => $resource_deletion_timeout;
'image/cirros_img_url': value => $cirros_img_url;
'users_context/project_domain': value => $project_domain;

View File

@@ -0,0 +1,60 @@
require 'spec_helper'
describe 'rally' do
shared_examples 'rally' do
context 'with default parameters' do
it 'contains the logging class' do
is_expected.to contain_class('rally::logging')
end
it 'installs packages' do
is_expected.to contain_package('rally').with(
:name => platform_params[:package_name],
:ensure => 'present',
:tag => ['openstack', 'rally-package']
)
end
it 'configures default rally params' do
is_expected.to contain_rally_config('DEFAULT/rally_debug').with_value('<SERVICE DEFAULT>')
is_expected.to contain_rally_config('DEFAULT/openstack_client_http_timeout').with_value('<SERVICE DEFAULT>')
end
end
context 'with overridden parameters' do
let :params do
{ :rally_debug => true,
:openstack_client_http_timeout => '200' }
end
it 'configures default rally params' do
is_expected.to contain_rally_config('DEFAULT/rally_debug').with_value(true)
is_expected.to contain_rally_config('DEFAULT/openstack_client_http_timeout').with_value('200')
end
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
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :package_name => 'rally' }
when 'RedHat'
{ :package_name => 'openstack-rally' }
end
end
it_behaves_like 'rally'
end
end
end

View File

@@ -20,7 +20,6 @@ describe 'rally::settings' do
shared_examples_for 'with default parameters' do
it 'configures rally settings with default parameters' do
is_expected.to contain_rally_config('DEFAULT/openstack_client_http_timeout').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_rally_config('image/cirros_img_url').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_rally_config('cleanup/resource_deletion_timeout').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_rally_config('users_context/project_domain').with(:value => '<SERVICE DEFAULT>')
@@ -32,7 +31,6 @@ describe 'rally::settings' do
shared_examples_for 'with all parameters' do
before { params.merge!( rally_settings_params ) }
it 'configures rally settings with all parameters' do
is_expected.to contain_rally_config('DEFAULT/openstack_client_http_timeout').with(:value => 180.0)
is_expected.to contain_rally_config('image/cirros_img_url').with(:value => 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img')
is_expected.to contain_rally_config('cleanup/resource_deletion_timeout').with(:value => 600)
is_expected.to contain_rally_config('users_context/project_domain').with(:value => 'default')