volume: unit tests (full coverage)

Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi
2014-01-05 20:49:52 +01:00
parent a58e84427f
commit 5db2e202e9
5 changed files with 220 additions and 12 deletions

View File

@@ -24,11 +24,10 @@ class privatecloud::volume(
$rabbit_password = $os_params::rabbit_password,
$ks_keystone_internal_host = $os_params::ks_keystone_internal_host,
$ks_cinder_password = $os_params::ks_cinder_password,
$ks_glance_internal_host = $os_params::ks_glance_internal_host,
$verbose = $os_params::verbose,
$debug = $os_params::debug,
) {
$encoded_user = uriescape($cinder_db_user)
$encoded_password = uriescape($cinder_db_password)
@@ -45,11 +44,12 @@ class privatecloud::volume(
use_syslog => true
}
class { 'cinder::ceilometer': }
class { 'cinder::glance':
glance_api_servers => $ks_glance_internal_host,
glance_request_timeout => '10'
#TODO(EmilienM) While https://review.openstack.org/#/c/65008/ got merged
# we can't declare ceilometer class due to bug LP #1266259
# class { 'cinder::ceilometer': }
# Temp fix:
cinder_config {
'DEFAULT/notification_driver': value => 'cinder.openstack.common.notifier.rpc_notifier';
}
}

View File

@@ -23,6 +23,7 @@ class privatecloud::volume::controller(
$ks_swift_internal_proto = $os_params::ks_swift_internal_proto,
$ks_swift_internal_host = $os_params::ks_swift_internal_host,
$ks_swift_internal_port = $os_params::ks_swift_internal_port,
$ks_glance_internal_host = $os_params::ks_glance_internal_host,
$api_eth = $os_params::api_eth,
) {
@@ -42,6 +43,11 @@ class privatecloud::volume::controller(
backup_swift_url => "${ks_swift_internal_proto}://${ks_swift_internal_host}:${ks_swift_internal_port}/v1/AUTH"
}
class { 'cinder::glance':
glance_api_servers => $ks_glance_internal_host,
glance_request_timeout => '10'
}
@@haproxy::balancermember{"${::fqdn}-cinder_api":
listening_service => 'cinder_api_cluster',
server_names => $::hostname,

View File

@@ -16,15 +16,20 @@
# Volume storage
#
class privatecloud::volume::storage {
class privatecloud::volume::storage(
$cinder_rbd_pool = $os_params::cinder_rbd_pool,
$glance_api_version = $os_params::glance_api_version,
$cinder_rbd_user = $os_params::cinder_rbd_user,
$cinder_rbd_secret_uuid = $os_params::cinder_rbd_secret_uuid,
) {
include 'privatecloud::volume'
class { 'cinder::volume::rbd':
rbd_pool => $os_params::cinder_rbd_pool,
glance_api_version => $os_params::glance_api_version,
rbd_user => $os_params::cinder_rbd_user,
rbd_secret_uuid => $os_params::cinder_rbd_secret_uuid
rbd_pool => $cinder_rbd_pool,
glance_api_version => $glance_api_version,
rbd_user => $cinder_rbd_user,
rbd_secret_uuid => $cinder_rbd_secret_uuid
}
}

View File

@@ -0,0 +1,109 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# 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.
#
# Unit tests for privatecloud::volume::controller class
#
require 'spec_helper'
describe 'privatecloud::volume::controller' do
shared_examples_for 'openstack volume controller' do
let :pre_condition do
"class { 'privatecloud::volume':
cinder_db_host => '10.0.0.1',
cinder_db_user => 'cinder',
cinder_db_password => 'secrete',
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
ks_keystone_internal_host => '10.0.0.1',
ks_cinder_password => 'secrete',
verbose => true,
debug => true }"
end
let :params do
{ :ks_cinder_password => 'secrete',
:ks_cinder_internal_port => '8776',
:ks_keystone_internal_host => '10.0.0.1',
:ks_glance_internal_host => '10.0.0.1',
:ks_swift_internal_port => '8080',
:ks_swift_internal_host => '10.0.0.1',
:ks_swift_internal_proto => 'http',
:api_eth => '10.0.0.1' }
end
it 'configure cinder common' do
should contain_class('cinder').with(
:verbose => true,
:debug => true,
:rabbit_userid => 'cinder',
:rabbit_hosts => ['10.0.0.1'],
:rabbit_password => 'secrete',
:rabbit_virtual_host => '/',
:log_facility => 'LOG_LOCAL0',
:use_syslog => true
)
should contain_cinder_config('DEFAULT/notification_driver').with('value' => 'cinder.openstack.common.notifier.rpc_notifier')
end
it 'configure cinder scheduler' do
should contain_class('cinder::scheduler')
end
it 'configure cinder glance backend' do
should contain_class('cinder::glance').with(
:glance_api_servers => '10.0.0.1',
:glance_request_timeout => '10'
)
end
it 'configure cinder api' do
should contain_class('cinder::api').with(
:keystone_password => 'secrete',
:keystone_auth_host => '10.0.0.1',
:bind_host => '10.0.0.1'
)
end
it 'configure cinder backup using swift backend' do
should contain_class('cinder::backup')
should contain_class('cinder::backup::swift').with(
:backup_swift_url => 'http://10.0.0.1:8080/v1/AUTH',
)
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'openstack volume controller'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'openstack volume controller'
end
end

View File

@@ -0,0 +1,88 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# 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.
#
# Unit tests for privatecloud::volume::storage class
#
require 'spec_helper'
describe 'privatecloud::volume::storage' do
shared_examples_for 'openstack volume storage' do
let :pre_condition do
"class { 'privatecloud::volume':
cinder_db_host => '10.0.0.1',
cinder_db_user => 'cinder',
cinder_db_password => 'secrete',
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
ks_keystone_internal_host => '10.0.0.1',
ks_cinder_password => 'secrete',
verbose => true,
debug => true }"
end
let :params do
{ :cinder_rbd_pool => 'cinder',
:cinder_rbd_user => 'ceph-cinder',
:cinder_rbd_secret_uuid => 'secrete',
:glance_api_version => '2' }
end
it 'configure cinder common' do
should contain_class('cinder').with(
:verbose => true,
:debug => true,
:rabbit_userid => 'cinder',
:rabbit_hosts => ['10.0.0.1'],
:rabbit_password => 'secrete',
:rabbit_virtual_host => '/',
:log_facility => 'LOG_LOCAL0',
:use_syslog => true
)
should contain_cinder_config('DEFAULT/notification_driver').with('value' => 'cinder.openstack.common.notifier.rpc_notifier')
end
it 'configure cinder volume with rbd backend' do
should contain_class('cinder::volume::rbd').with(
:rbd_pool => 'cinder',
:glance_api_version => '2',
:rbd_user => 'ceph-cinder',
:rbd_secret_uuid => 'secrete'
)
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'openstack volume storage'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'openstack volume storage'
end
end