Merge pull request #8 from bodepd/add_spec_tests

Add spec tests
This commit is contained in:
Dan Bode 2012-10-29 13:00:39 -07:00
commit fb153e9e31
20 changed files with 324 additions and 18 deletions

12
.fixtures.yml Normal file
View File

@ -0,0 +1,12 @@
fixtures:
repositories:
"apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
"keystone": "git://github.com/puppetlabs/puppetlabs-keystone.git"
"mysql": "git://github.com/puppetlabs/puppetlabs-mysql.git"
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"sysctl": "git://github.com/duritong/puppet-sysctl.git"
"rabbitmq": "git://github.com/puppetlabs/puppetlabs-rabbitmq.git"
'inifile': 'git://github.com/cprice-puppet/puppetlabs-inifile'
"create_resources": 'git://github.com/puppetlabs/puppetlabs-create_resources'
symlinks:
"cinder": "#{source_dir}"

5
.gemfile Normal file
View File

@ -0,0 +1,5 @@
source :rubygems
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
spec/fixtures/modules/*
spec/fixtures/manifests/site.pp
*.swp

18
.travis.yml Normal file
View File

@ -0,0 +1,18 @@
language: ruby
rvm:
- 1.8.7
before_script:
after_script:
script: "rake spec"
branches:
only:
- master
- folsom
- essex
env:
- PUPPET_VERSION=2.7.13
- PUPPET_VERSION=2.7.6
- PUPPET_VERSION=2.6.9
notifications:
email: false
gemfile: .gemfile

View File

@ -1,8 +1,8 @@
name 'puppet-cinder' name 'puppet-cinder'
version '0.0.1' version '0.0.1'
source 'https://github.com/jtopjian/puppet-cinder' source 'https://github.com/puppetlabs/puppetlabs-cinder'
author 'Joe Topjian' author 'Joe Topjian'
license 'Apache License 2.0' license 'Apache License 2.0'
summary 'install openstack cinder' summary 'install openstack cinder'
description 'install openstack cinder' description 'install openstack cinder'
project_page 'https://github.com/jtopjian/puppet-cinder' project_page 'https://github.com/puppetlabs/puppetlabs-cinder'

1
Rakefile Normal file
View File

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/rake_tasks'

View File

@ -11,7 +11,7 @@ class cinder::base (
$rabbit_virtual_host = '/', $rabbit_virtual_host = '/',
$rabbit_userid = 'nova', $rabbit_userid = 'nova',
$package_ensure = 'present', $package_ensure = 'present',
$verbose = 'True' $verbose = 'False'
) { ) {
include cinder::params include cinder::params

View File

@ -4,8 +4,7 @@ class cinder::params {
$cinder_conf = '/etc/cinder/cinder.conf' $cinder_conf = '/etc/cinder/cinder.conf'
$cinder_paste_api_ini = '/etc/cinder/api-paste.ini' $cinder_paste_api_ini = '/etc/cinder/api-paste.ini'
case $::osfamily { if $::osfamily == 'Debian' {
'Debian': {
$package_name = 'cinder-common' $package_name = 'cinder-common'
$api_package = 'cinder-api' $api_package = 'cinder-api'
$api_service = 'cinder-api' $api_service = 'cinder-api'
@ -17,7 +16,7 @@ class cinder::params {
$tgt_package_name = 'tgt' $tgt_package_name = 'tgt'
$tgt_service_name = 'tgt' $tgt_service_name = 'tgt'
} else {
} fail("unsuported osfamily ${::osfamily}, currently Debian is the only supported platform")
} }
} }

View File

@ -27,7 +27,7 @@ class cinder::volume (
name => $::cinder::params::volume_service, name => $::cinder::params::volume_service,
enable => $enabled, enable => $enabled,
ensure => $ensure, ensure => $ensure,
require => Package[$::cinder::params::volume_package], require => Package['cinder-volume'],
subscribe => File[$::cinder::params::cinder_conf], subscribe => File[$::cinder::params::cinder_conf],
} }

View File

@ -0,0 +1,50 @@
require 'spec_helper'
describe 'cinder::api' do
let :req_params do
{:keystone_password => 'foo'}
end
let :facts do
{:osfamily => 'Debian'}
end
describe 'with only required params' do
let :params do
req_params
end
it 'should configure cinder api correctly' do
should contain_cinder_config('DEFAULT/auth_strategy').with(
:value => 'keystone'
)
should contain_cinder_api_paste_ini('filter:authtoken/service_protocol').with(
:value => 'http'
)
should contain_cinder_api_paste_ini('filter:authtoken/service_host').with(
:value => 'localhost'
)
should contain_cinder_api_paste_ini('filter:authtoken/service_port').with(
:value => '5000'
)
should contain_cinder_api_paste_ini('filter:authtoken/auth_protocol').with(
:value => 'http'
)
should contain_cinder_api_paste_ini('filter:authtoken/auth_host').with(
:value => 'localhost'
)
should contain_cinder_api_paste_ini('filter:authtoken/auth_port').with(
:value => '35357'
)
should contain_cinder_api_paste_ini('filter:authtoken/admin_tenant_name').with(
:value => 'services'
)
should contain_cinder_api_paste_ini('filter:authtoken/admin_user').with(
:value => 'cinder'
)
should contain_cinder_api_paste_ini('filter:authtoken/admin_password').with(
:value => 'foo'
)
end
end
end

View File

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'cinder::base' do
let :req_params do
{:rabbit_password => 'rpw', :sql_connection => 'mysql://user:password@host/database'}
end
let :facts do
{:osfamily => 'Debian'}
end
describe 'with only required params' do
let :params do
req_params
end
it 'should contain default config' do
should contain_cinder_config('DEFAULT/rabbit_password').with(
:value => 'rpw'
)
should contain_cinder_config('DEFAULT/rabbit_host').with(
:value => '127.0.0.1'
)
should contain_cinder_config('DEFAULT/rabbit_port').with(
:value => '5672'
)
should contain_cinder_config('DEFAULT/rabbit_virtual_host').with(
:value => '/'
)
should contain_cinder_config('DEFAULT/rabbit_userid').with(
:value => 'nova'
)
should contain_cinder_config('DEFAULT/sql_connection').with(
:value => 'mysql://user:password@host/database'
)
should contain_cinder_config('DEFAULT/verbose').with(
:value => 'False'
)
should contain_cinder_config('DEFAULT/api_paste_config').with(
:value => '/etc/cinder/api-paste.ini'
)
end
end
end

View File

@ -0,0 +1,28 @@
require 'spec_helper'
describe 'cinder::db::mysql' do
let :req_params do
{:password => 'pw'}
end
let :facts do
{:osfamily => 'Debian'}
end
let :pre_condition do
'include mysql::server'
end
describe 'with only required params' do
let :params do
req_params
end
it { should contain_mysql__db('cinder').with(
:user => 'cinder',
:password => 'pw',
:host => '127.0.0.1',
:charset => 'latin1'
) }
end
end

View File

@ -0,0 +1,16 @@
require 'spec_helper'
describe 'cinder::db::sync' do
let :facts do
{:osfamily => 'Debian'}
end
it { should contain_exec('cinder-manage db_sync').with(
:command => 'cinder-manage db sync',
:path => '/usr/bin',
:user => 'cinder',
:refreshonly => true,
:logoutput => 'on_failure'
) }
end

View File

@ -0,0 +1,50 @@
require 'spec_helper'
describe 'cinder::keystone::auth' do
let :req_params do
{:password => 'pw'}
end
describe 'with only required params' do
let :params do
req_params
end
it 'should contain auth info' do
should contain_keystone_user('cinder').with(
:ensure => 'present',
:password => 'pw',
:email => 'cinder@localhost',
:tenant => 'services'
)
should contain_keystone_user_role('cinder@services').with(
:ensure => 'present',
:roles => 'admin'
)
should contain_keystone_service('cinder').with(
:ensure => 'present',
:type => 'volume',
:description => 'Cinder Service'
)
end
it { should contain_keystone_endpoint('RegionOne/cinder').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s'
) }
end
describe 'when endpoint should not be configured' do
let :params do
req_params.merge(:configure_endpoint => false)
end
it { should_not contain_keystone_endpoint('RegionOne/cinder') }
end
end

View File

@ -0,0 +1,12 @@
require 'spec_helper'
describe 'cinder::params' do
let :facts do
{:osfamily => 'Debian'}
end
it 'should compile' do
subject
end
end

View File

@ -0,0 +1,10 @@
require 'spec_helper'
describe 'cinder::scheduler' do
let :facts do
{:osfamily => 'Debian'}
end
it { should contain_package('cinder-scheduler') }
it { should contain_service('cinder-scheduler') }
end

View File

@ -0,0 +1,11 @@
require 'spec_helper'
describe 'cinder::setup_test_volume' do
it 'should contain volume creation execs' do
should contain_exec('/bin/dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=4G')
should contain_exec('/sbin/losetup /dev/loop2 cinder-volumes')
should contain_exec('/sbin/pvcreate /dev/loop2')
should contain_exec('/sbin/vgcreate cinder-volumes /dev/loop2')
end
end

View File

@ -0,0 +1,31 @@
require 'spec_helper'
describe 'cinder::volume::iscsi' do
let :req_params do
{:iscsi_ip_address => '127.0.0.2'}
end
let :facts do
{:osfamily => 'Debian'}
end
describe 'with default params' do
let :params do
req_params
end
it { should contain_cinder_config('DEFAULT/iscsi_ip_address').with(
:value => '127.0.0.2'
) }
it { should contain_cinder_config('DEFAULT/iscsi_helper').with(
:value => 'tgtadm'
) }
it { should contain_cinder_config('DEFAULT/volume_group').with(
:value => 'cinder-volumes'
) }
end
end

View File

@ -0,0 +1,15 @@
require 'spec_helper'
describe 'cinder::volume' do
let :pre_condition do
'class { "cinder::base": rabbit_password => "fpp", sql_connection => "mysql://a:b@c/d" }'
end
let :facts do
{:osfamily => 'Debian'}
end
it { should contain_package('cinder-volume') }
it { should contain_service('cinder-volume') }
end

1
spec/spec_helper.rb Normal file
View File

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'