Refactoring ChefSpec tests
Adding strict dependency on python cookbook version. This removes the requirement for carrying a matcher in this cookbook for the python LWRPs. Change-Id: I3e58c029044aa76fef71372e6a06f8f307d29df7
This commit is contained in:
parent
05e9ad01df
commit
92fdeed919
|
@ -23,4 +23,4 @@ depends 'openstack-common', '~> 8.0'
|
|||
depends 'openstack-identity', '~> 8.0'
|
||||
depends 'openstack-image', '~> 8.0'
|
||||
depends 'selinux'
|
||||
depends 'python'
|
||||
depends 'python', '>= 1.4.6'
|
||||
|
|
|
@ -5,33 +5,30 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::api' do
|
||||
before { block_storage_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::api'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs cinder api packages' do
|
||||
expect(@chef_run).to upgrade_package 'openstack-cinder-api'
|
||||
expect(chef_run).to upgrade_package 'openstack-cinder-api'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'python-mysql'
|
||||
expect(chef_run).to upgrade_package 'python-mysql'
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'python-mysql'
|
||||
end
|
||||
|
||||
it 'starts cinder api on boot' do
|
||||
expect(@chef_run).to enable_service 'openstack-cinder-api'
|
||||
expect(chef_run).to enable_service 'openstack-cinder-api'
|
||||
end
|
||||
|
||||
expect_creates_policy_json(
|
||||
|
|
|
@ -5,26 +5,23 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::api' do
|
||||
before { block_storage_stubs }
|
||||
describe 'redhat' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::api'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs cinder api packages' do
|
||||
expect(@chef_run).to upgrade_package 'python-cinderclient'
|
||||
expect(chef_run).to upgrade_package 'python-cinderclient'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'MySQL-python'
|
||||
expect(chef_run).to upgrade_package 'MySQL-python'
|
||||
end
|
||||
|
||||
it 'installs db2 python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'db2'
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
['python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
|
||||
expect(chef_run).to upgrade_package pkg
|
||||
|
@ -32,17 +29,14 @@ describe 'openstack-block-storage::api' do
|
|||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'MySQL-python'
|
||||
end
|
||||
|
||||
it 'starts cinder api on boot' do
|
||||
expect(@chef_run).to enable_service 'openstack-cinder-api'
|
||||
expect(chef_run).to enable_service 'openstack-cinder-api'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
169
spec/api_spec.rb
169
spec/api_spec.rb
|
@ -5,158 +5,139 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::api' do
|
||||
before { block_storage_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::api'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
|
||||
it 'does not run logging recipe' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).not_to include_recipe 'openstack-common::logging'
|
||||
end
|
||||
|
||||
it 'installs cinder api packages' do
|
||||
expect(@chef_run).to upgrade_package 'cinder-api'
|
||||
expect(@chef_run).to upgrade_package 'python-cinderclient'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'python-mysqldb'
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'python-mysqldb'
|
||||
end
|
||||
|
||||
describe '/var/cache/cinder' do
|
||||
before do
|
||||
@dir = @chef_run.directory '/var/cache/cinder'
|
||||
end
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@dir.owner).to eq('cinder')
|
||||
expect(@dir.group).to eq('cinder')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @dir.mode)).to eq '700'
|
||||
end
|
||||
end
|
||||
|
||||
it 'starts cinder api on boot' do
|
||||
expect(@chef_run).to enable_service 'cinder-api'
|
||||
end
|
||||
include_context 'block-storage-stubs'
|
||||
include_examples 'common-logging'
|
||||
|
||||
expect_creates_cinder_conf 'service[cinder-api]', 'cinder', 'cinder'
|
||||
|
||||
describe 'cinder.conf' do
|
||||
before do
|
||||
@file = '/etc/cinder/cinder.conf'
|
||||
it 'installs cinder api packages' do
|
||||
expect(chef_run).to upgrade_package('cinder-api')
|
||||
expect(chef_run).to upgrade_package('python-cinderclient')
|
||||
end
|
||||
|
||||
it 'starts cinder api on boot' do
|
||||
expect(chef_run).to enable_service('cinder-api')
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(chef_run).to upgrade_package('python-mysqldb')
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
|
||||
expect(chef_run).to upgrade_package('python-psycopg2')
|
||||
expect(chef_run).not_to upgrade_package('python-mysqldb')
|
||||
end
|
||||
|
||||
describe '/var/cache/cinder' do
|
||||
let(:dir) { chef_run.directory('/var/cache/cinder') }
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(dir.owner).to eq('cinder')
|
||||
expect(dir.group).to eq('cinder')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', dir.mode)).to eq('700')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'cinder.conf' do
|
||||
let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
|
||||
|
||||
it 'runs logging recipe if node attributes say to' do
|
||||
expect(@chef_run).to render_file(@file).with_content('log_config = /etc/openstack/logging.conf')
|
||||
node.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
|
||||
expect(chef_run).to render_file(file.name).with_content('log_config = /etc/openstack/logging.conf')
|
||||
end
|
||||
|
||||
it 'does not run logging recipe' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).not_to render_file(@file).with_content('log_config = /etc/openstack/logging.conf')
|
||||
end
|
||||
|
||||
it 'has rbd driver settings' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume'] = {
|
||||
context 'rdb driver' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume'] = {
|
||||
'driver' => 'cinder.volume.drivers.rbd.RBDDriver'
|
||||
}
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).to render_file(@file).with_content(/^rbd_/)
|
||||
expect(chef_run).not_to render_file(@file).with_content(/^netapp_/)
|
||||
# FIXME(galstrom21): this block needs to check all of the default
|
||||
# rdb_* configuration options
|
||||
it 'has default rbd_* options set' do
|
||||
expect(chef_run).to render_file(file.name).with_content(/^rbd_/)
|
||||
expect(chef_run).not_to render_file(file.name).with_content(/^netapp_/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'has netapp driver settings' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume'] = {
|
||||
context 'netapp driver' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume'] = {
|
||||
'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
|
||||
}
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::api'
|
||||
|
||||
expect(chef_run).to render_file(@file).with_content(/^netapp_/)
|
||||
expect(chef_run).not_to render_file(@file).with_content(/^rbd_/)
|
||||
# FIXME(galstrom21): this block needs to check all of the default
|
||||
# netapp_* configuration options
|
||||
it 'has default netapp_* options set' do
|
||||
expect(chef_run).to render_file(file.name).with_content(/^netapp_/)
|
||||
expect(chef_run).not_to render_file(file.name).with_content(/^rbd_/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'runs db migrations' do
|
||||
cmd = 'cinder-manage db sync'
|
||||
|
||||
expect(@chef_run).to run_execute(cmd)
|
||||
expect(chef_run).to run_execute('cinder-manage db sync')
|
||||
end
|
||||
|
||||
expect_creates_policy_json 'service[cinder-api]', 'cinder', 'cinder'
|
||||
|
||||
describe 'api-paste.ini' do
|
||||
before do
|
||||
@file = @chef_run.template '/etc/cinder/api-paste.ini'
|
||||
end
|
||||
let(:file) { chef_run.template('/etc/cinder/api-paste.ini') }
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@file.owner).to eq('cinder')
|
||||
expect(@file.group).to eq('cinder')
|
||||
expect(file.owner).to eq('cinder')
|
||||
expect(file.group).to eq('cinder')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @file.mode)).to eq '644'
|
||||
expect(sprintf('%o', file.mode)).to eq('644')
|
||||
end
|
||||
|
||||
it 'has signing_dir' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('signing_dir = /var/cache/cinder/api')
|
||||
expect(chef_run).to render_file(file.name).with_content('signing_dir = /var/cache/cinder/api')
|
||||
end
|
||||
|
||||
it 'notifies cinder-api restart' do
|
||||
expect(@file).to notify('service[cinder-api]').to(:restart)
|
||||
expect(file).to notify('service[cinder-api]').to(:restart)
|
||||
end
|
||||
|
||||
it 'has auth_uri' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('auth_uri = http://127.0.0.1:5000/v2.0')
|
||||
expect(chef_run).to render_file(file.name).with_content('auth_uri = http://127.0.0.1:5000/v2.0')
|
||||
end
|
||||
|
||||
it 'has auth_host' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('auth_host = 127.0.0.1')
|
||||
expect(chef_run).to render_file(file.name).with_content('auth_host = 127.0.0.1')
|
||||
end
|
||||
|
||||
it 'has auth_port' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('auth_port = 35357')
|
||||
expect(chef_run).to render_file(file.name).with_content('auth_port = 35357')
|
||||
end
|
||||
|
||||
it 'has auth_protocol' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('auth_protocol = http')
|
||||
expect(chef_run).to render_file(file.name).with_content('auth_protocol = http')
|
||||
end
|
||||
|
||||
it 'has no auth_version when auth_version is v2.0' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('auth_version = v2.0')
|
||||
expect(chef_run).not_to render_file(file.name).with_content('auth_version = v2.0')
|
||||
end
|
||||
|
||||
it 'has auth_version when auth version is not v2.0' do
|
||||
@chef_run.node.set['openstack']['block-storage']['api']['auth']['version'] = 'v3.0'
|
||||
expect(@chef_run).to render_file(@file.name).with_content('auth_version = v3.0')
|
||||
node.set['openstack']['block-storage']['api']['auth']['version'] = 'v3.0'
|
||||
|
||||
expect(chef_run).to render_file(file.name).with_content('auth_version = v3.0')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,18 +5,15 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::cinder-common' do
|
||||
before { block_storage_stubs }
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
|
||||
n.set['openstack']['mq'] = {
|
||||
'host' => '127.0.0.1'
|
||||
}
|
||||
n.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
describe 'rhel' do
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'installs the openstack-cinder package' do
|
||||
expect(@chef_run).to upgrade_package 'openstack-cinder'
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs the openstack-cinder package' do
|
||||
expect(chef_run).to upgrade_package 'openstack-cinder'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,18 +5,15 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::cinder-common' do
|
||||
before { block_storage_stubs }
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS do |n|
|
||||
n.set['openstack']['mq'] = {
|
||||
'host' => '127.0.0.1'
|
||||
}
|
||||
n.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
describe 'suse' do
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'installs the openstack-cinder package' do
|
||||
expect(@chef_run).to upgrade_package 'openstack-cinder'
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs the openstack-cinder package' do
|
||||
expect(chef_run).to upgrade_package 'openstack-cinder'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,359 +5,335 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::cinder-common' do
|
||||
before { block_storage_stubs }
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['mq'] = {
|
||||
'host' => '127.0.0.1'
|
||||
}
|
||||
n.set['openstack']['mq']['block-storage']['rabbit']['notification_topic'] = 'rabbit_topic'
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
node.set['openstack']['mq']['host'] = '127.0.0.1'
|
||||
node.set['openstack']['mq']['block-storage']['rabbit']['notification_topic'] = 'rabbit_topic'
|
||||
|
||||
it 'installs the cinder-common package' do
|
||||
expect(@chef_run).to upgrade_package 'cinder-common'
|
||||
end
|
||||
|
||||
describe '/etc/cinder' do
|
||||
before do
|
||||
@dir = @chef_run.directory '/etc/cinder'
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@dir.owner).to eq('cinder')
|
||||
expect(@dir.group).to eq('cinder')
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs the cinder-common package' do
|
||||
expect(chef_run).to upgrade_package 'cinder-common'
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @dir.mode)).to eq '750'
|
||||
end
|
||||
end
|
||||
describe '/etc/cinder' do
|
||||
let(:dir) { chef_run.directory('/etc/cinder') }
|
||||
|
||||
describe 'cinder.conf' do
|
||||
before do
|
||||
@file = @chef_run.template '/etc/cinder/cinder.conf'
|
||||
end
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@file.owner).to eq('cinder')
|
||||
expect(@file.group).to eq('cinder')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @file.mode)).to eq '644'
|
||||
end
|
||||
|
||||
it 'has name templates' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('volume_name_template=volume-%s')
|
||||
expect(@chef_run).to render_file(@file.name).with_content('snapshot_name_template=snapshot-%s')
|
||||
end
|
||||
|
||||
it 'has rpc_backend set' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rpc_backend=cinder.openstack.common.rpc.impl_kombu')
|
||||
end
|
||||
|
||||
it 'has has volumes_dir set' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('volumes_dir=/var/lib/cinder/volumes')
|
||||
end
|
||||
|
||||
it 'has correct volume.driver set' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver')
|
||||
end
|
||||
|
||||
it 'has rpc_thread_pool_size' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rpc_thread_pool_size=64')
|
||||
end
|
||||
|
||||
it 'has rpc_conn_pool_size' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rpc_conn_pool_size=30')
|
||||
end
|
||||
|
||||
it 'has rpc_response_timeout' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rpc_response_timeout=60')
|
||||
end
|
||||
|
||||
it 'has rabbit_host' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_host=127.0.0.1')
|
||||
end
|
||||
|
||||
it 'does not have rabbit_hosts' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_hosts=')
|
||||
end
|
||||
|
||||
it 'does not have rabbit_ha_queues' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_ha_queues=')
|
||||
end
|
||||
|
||||
it 'has log_file' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('log_file = /var/log/cinder/cinder.log')
|
||||
end
|
||||
|
||||
it 'has log_config when syslog is true' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
it 'has proper owner' do
|
||||
expect(dir.owner).to eq('cinder')
|
||||
expect(dir.group).to eq('cinder')
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
|
||||
expect(chef_run).to render_file(@file.name).with_content('log_config = /etc/openstack/logging.conf')
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', dir.mode)).to eq '750'
|
||||
end
|
||||
end
|
||||
|
||||
it 'has rabbit_port' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_port=5672')
|
||||
end
|
||||
describe 'cinder.conf' do
|
||||
let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
|
||||
|
||||
it 'has rabbit_use_ssl' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_use_ssl=false')
|
||||
end
|
||||
it 'has proper owner' do
|
||||
expect(file.owner).to eq('cinder')
|
||||
expect(file.group).to eq('cinder')
|
||||
end
|
||||
|
||||
it 'has rabbit_userid' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_userid=guest')
|
||||
end
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', file.mode)).to eq '644'
|
||||
end
|
||||
|
||||
it 'has rabbit_password' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_password=mq-pass')
|
||||
end
|
||||
it 'has name templates' do
|
||||
expect(chef_run).to render_file(file.name).with_content('volume_name_template=volume-%s')
|
||||
expect(chef_run).to render_file(file.name).with_content('snapshot_name_template=snapshot-%s')
|
||||
end
|
||||
|
||||
it 'has rabbit_virtual_host' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_virtual_host=/')
|
||||
end
|
||||
it 'has rpc_backend set' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rpc_backend=cinder.openstack.common.rpc.impl_kombu')
|
||||
end
|
||||
|
||||
it 'has rabbit notification_topics' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('notification_topics=rabbit_topic')
|
||||
end
|
||||
it 'has has volumes_dir set' do
|
||||
expect(chef_run).to render_file(file.name).with_content('volumes_dir=/var/lib/cinder/volumes')
|
||||
end
|
||||
|
||||
describe 'rabbit ha' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
|
||||
n.set['openstack']['mq']['block-storage']['rabbit']['ha'] = true
|
||||
it 'has correct volume.driver set' do
|
||||
expect(chef_run).to render_file(file.name).with_content('volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver')
|
||||
end
|
||||
|
||||
it 'has rpc_thread_pool_size' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rpc_thread_pool_size=64')
|
||||
end
|
||||
|
||||
it 'has rpc_conn_pool_size' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rpc_conn_pool_size=30')
|
||||
end
|
||||
|
||||
it 'has rpc_response_timeout' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rpc_response_timeout=60')
|
||||
end
|
||||
|
||||
it 'has rabbit_host' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_host=127.0.0.1')
|
||||
end
|
||||
|
||||
it 'does not have rabbit_hosts' do
|
||||
expect(chef_run).not_to render_file(file.name).with_content('rabbit_hosts=')
|
||||
end
|
||||
|
||||
it 'does not have rabbit_ha_queues' do
|
||||
expect(chef_run).not_to render_file(file.name).with_content('rabbit_ha_queues=')
|
||||
end
|
||||
|
||||
it 'has log_file' do
|
||||
expect(chef_run).to render_file(file.name).with_content('log_file = /var/log/cinder/cinder.log')
|
||||
end
|
||||
|
||||
it 'has log_config when syslog is true' do
|
||||
node.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
|
||||
expect(chef_run).to render_file(file.name).with_content('log_config = /etc/openstack/logging.conf')
|
||||
end
|
||||
|
||||
it 'has rabbit_port' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_port=5672')
|
||||
end
|
||||
|
||||
it 'has rabbit_use_ssl' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_use_ssl=false')
|
||||
end
|
||||
|
||||
it 'has rabbit_userid' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_userid=guest')
|
||||
end
|
||||
|
||||
it 'has rabbit_password' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_password=mq-pass')
|
||||
end
|
||||
|
||||
it 'has rabbit_virtual_host' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_virtual_host=/')
|
||||
end
|
||||
|
||||
it 'has rabbit notification_topics' do
|
||||
expect(chef_run).to render_file(file.name).with_content('notification_topics=rabbit_topic')
|
||||
end
|
||||
|
||||
describe 'rabbit ha' do
|
||||
before do
|
||||
node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
it 'has rabbit_hosts' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672')
|
||||
end
|
||||
|
||||
it 'has rabbit_ha_queues' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('rabbit_ha_queues=True')
|
||||
end
|
||||
|
||||
it 'does not have rabbit_host' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_host=127.0.0.1')
|
||||
end
|
||||
|
||||
it 'does not have rabbit_port' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_port=5672')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'qpid' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
|
||||
n.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
|
||||
n.set['openstack']['block-storage']['notification_driver'] = 'cinder.test_driver'
|
||||
n.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_topic'
|
||||
# we set username here since the attribute in common currently
|
||||
# defaults to ''
|
||||
n.set['openstack']['mq']['block-storage']['qpid']['username'] = 'guest'
|
||||
it 'has rabbit_hosts' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672')
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
it 'has qpid_hostname' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_hostname=127.0.0.1')
|
||||
end
|
||||
|
||||
it 'has qpid_port' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_port=5672')
|
||||
end
|
||||
|
||||
it 'has qpid_username' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_username=guest')
|
||||
end
|
||||
|
||||
it 'has qpid_password' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_password=mq-pass')
|
||||
end
|
||||
|
||||
it 'has qpid_sasl_mechanisms' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_sasl_mechanisms=')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_timeout' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_timeout=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_limit' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_limit=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_interval_min' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_min=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_interval_max' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_max=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_interval' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect=true')
|
||||
end
|
||||
|
||||
it 'has qpid_heartbeat' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_heartbeat=60')
|
||||
end
|
||||
|
||||
it 'has qpid_protocol' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_protocol=tcp')
|
||||
end
|
||||
|
||||
it 'has qpid_tcp_nodelay' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('qpid_tcp_nodelay=true')
|
||||
end
|
||||
|
||||
it 'has notification_driver' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('notification_driver=cinder.test_driver')
|
||||
end
|
||||
|
||||
it 'has notification_topics' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('notification_topics=qpid_topic')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'lvm settings' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
|
||||
n.set['openstack']['block-storage']['volume']['volume_group'] = 'test-group'
|
||||
n.set['openstack']['block-storage']['volume']['volume_clear_size'] = 100
|
||||
n.set['openstack']['block-storage']['volume']['volume_clear'] = 'none'
|
||||
it 'has rabbit_ha_queues' do
|
||||
expect(chef_run).to render_file(file.name).with_content('rabbit_ha_queues=True')
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
it 'has volume_group' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('volume_group=test-group')
|
||||
end
|
||||
|
||||
it 'has volume_clear_size' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('volume_clear_size=100')
|
||||
end
|
||||
|
||||
it 'has volume_clear' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('volume_clear=none')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'solidfire settings' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.solidfire.SolidFire'
|
||||
n.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'test'
|
||||
n.set['openstack']['block-storage']['solidfire']['san_ip'] = '203.0.113.10'
|
||||
n.set['openstack']['block-storage']['solidfire']['san_login'] = 'solidfire_admin'
|
||||
it 'does not have rabbit_host' do
|
||||
expect(chef_run).not_to render_file(file.name).with_content('rabbit_host=127.0.0.1')
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
it 'has solidfire sf_emulate set' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('sf_emulate_512=test')
|
||||
end
|
||||
|
||||
it 'has solidfire san_ip set' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('san_ip=203.0.113.10')
|
||||
end
|
||||
|
||||
it 'has solidfire san_login' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('san_login=solidfire_admin')
|
||||
end
|
||||
|
||||
it 'has solidfire password' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('san_password=solidfire_testpass')
|
||||
end
|
||||
|
||||
it 'does not have iscsi_ip_prefix not specified' do
|
||||
expect(@chef_run).to_not render_file(@file.name).with_content('iscsi_ip_prefix')
|
||||
end
|
||||
|
||||
it 'does have iscsi_ip_prefix when specified' do
|
||||
@chef_run.node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = '203.0.113.*'
|
||||
|
||||
expect(@chef_run).to render_file(@file.name).with_content('iscsi_ip_prefix=203.0.113.*')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'emc settings' do
|
||||
before do
|
||||
@chef_run.node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
@chef_run.node.set['openstack']['block-storage']['emc']['iscsi_target_prefix'] = 'test.prefix'
|
||||
@chef_run.node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = '/etc/test/config.file'
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
it 'has emc iscsi_target_prefix' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('iscsi_target_prefix=test.prefix')
|
||||
end
|
||||
|
||||
it 'has cinder_emc_config_file' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('cinder_emc_config_file=/etc/test/config.file')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'vmware vmdk settings' do
|
||||
before do
|
||||
@chef_run.node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
|
||||
@chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
[
|
||||
/^vmware_host_ip = $/,
|
||||
/^vmware_host_username = $/,
|
||||
/^vmware_host_password = $/,
|
||||
/^vmware_api_retry_count = 10$/,
|
||||
/^vmware_task_poll_interval = 5$/,
|
||||
/^vmware_volume_folder = cinder-volumes/,
|
||||
/^vmware_image_transfer_timeout_secs = 7200$/,
|
||||
/^vmware_max_objects_retrieval = 100$/
|
||||
].each do |content|
|
||||
it "has a #{content.source[1...-1]} line" do
|
||||
expect(@chef_run).to render_file(@file.name).with_content(content)
|
||||
it 'does not have rabbit_port' do
|
||||
expect(chef_run).not_to render_file(file.name).with_content('rabbit_port=5672')
|
||||
end
|
||||
end
|
||||
|
||||
it 'has no wsdl_location line' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('vmware_wsdl_location = ')
|
||||
end
|
||||
|
||||
it 'has wsdl_location line' do
|
||||
chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
|
||||
n.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
|
||||
describe 'qpid' do
|
||||
before do
|
||||
node.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
|
||||
node.set['openstack']['block-storage']['notification_driver'] = 'cinder.test_driver'
|
||||
node.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_topic'
|
||||
# we set username here since the attribute in common currently
|
||||
# defaults to ''
|
||||
node.set['openstack']['mq']['block-storage']['qpid']['username'] = 'guest'
|
||||
end
|
||||
|
||||
it 'has qpid_hostname' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_hostname=127.0.0.1')
|
||||
end
|
||||
|
||||
it 'has qpid_port' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_port=5672')
|
||||
end
|
||||
|
||||
it 'has qpid_username' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_username=guest')
|
||||
end
|
||||
|
||||
it 'has qpid_password' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_password=mq-pass')
|
||||
end
|
||||
|
||||
it 'has qpid_sasl_mechanisms' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_sasl_mechanisms=')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_timeout' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_reconnect_timeout=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_limit' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_reconnect_limit=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_interval_min' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_reconnect_interval_min=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_interval_max' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_reconnect_interval_max=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect_interval' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_reconnect_interval=0')
|
||||
end
|
||||
|
||||
it 'has qpid_reconnect' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_reconnect=true')
|
||||
end
|
||||
|
||||
it 'has qpid_heartbeat' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_heartbeat=60')
|
||||
end
|
||||
|
||||
it 'has qpid_protocol' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_protocol=tcp')
|
||||
end
|
||||
|
||||
it 'has qpid_tcp_nodelay' do
|
||||
expect(chef_run).to render_file(file.name).with_content('qpid_tcp_nodelay=true')
|
||||
end
|
||||
|
||||
it 'has notification_driver' do
|
||||
expect(chef_run).to render_file(file.name).with_content('notification_driver=cinder.test_driver')
|
||||
end
|
||||
|
||||
it 'has notification_topics' do
|
||||
expect(chef_run).to render_file(file.name).with_content('notification_topics=qpid_topic')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'lvm settings' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
|
||||
node.set['openstack']['block-storage']['volume']['volume_group'] = 'test-group'
|
||||
node.set['openstack']['block-storage']['volume']['volume_clear_size'] = 100
|
||||
node.set['openstack']['block-storage']['volume']['volume_clear'] = 'none'
|
||||
end
|
||||
|
||||
it 'has volume_group' do
|
||||
expect(chef_run).to render_file(file.name).with_content('volume_group=test-group')
|
||||
end
|
||||
|
||||
it 'has volume_clear_size' do
|
||||
expect(chef_run).to render_file(file.name).with_content('volume_clear_size=100')
|
||||
end
|
||||
|
||||
it 'has volume_clear' do
|
||||
expect(chef_run).to render_file(file.name).with_content('volume_clear=none')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'solidfire settings' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.solidfire.SolidFire'
|
||||
node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'test'
|
||||
node.set['openstack']['block-storage']['solidfire']['san_ip'] = '203.0.113.10'
|
||||
node.set['openstack']['block-storage']['solidfire']['san_login'] = 'solidfire_admin'
|
||||
end
|
||||
|
||||
it 'has solidfire sf_emulate set' do
|
||||
expect(chef_run).to render_file(file.name).with_content('sf_emulate_512=test')
|
||||
end
|
||||
|
||||
it 'has solidfire san_ip set' do
|
||||
expect(chef_run).to render_file(file.name).with_content('san_ip=203.0.113.10')
|
||||
end
|
||||
|
||||
it 'has solidfire san_login' do
|
||||
expect(chef_run).to render_file(file.name).with_content('san_login=solidfire_admin')
|
||||
end
|
||||
|
||||
it 'has solidfire password' do
|
||||
expect(chef_run).to render_file(file.name).with_content('san_password=solidfire_testpass')
|
||||
end
|
||||
|
||||
it 'does not have iscsi_ip_prefix not specified' do
|
||||
expect(chef_run).to_not render_file(file.name).with_content('iscsi_ip_prefix')
|
||||
end
|
||||
|
||||
it 'does have iscsi_ip_prefix when specified' do
|
||||
chef_run.node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = '203.0.113.*'
|
||||
|
||||
expect(chef_run).to render_file(file.name).with_content('iscsi_ip_prefix=203.0.113.*')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'emc settings' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
node.set['openstack']['block-storage']['emc']['iscsi_target_prefix'] = 'test.prefix'
|
||||
node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = '/etc/test/config.file'
|
||||
end
|
||||
|
||||
it 'has emc iscsi_target_prefix' do
|
||||
expect(chef_run).to render_file(file.name).with_content('iscsi_target_prefix=test.prefix')
|
||||
end
|
||||
|
||||
it 'has cinder_emc_config_file' do
|
||||
expect(chef_run).to render_file(file.name).with_content('cinder_emc_config_file=/etc/test/config.file')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'vmware vmdk settings' do
|
||||
before do
|
||||
chef_run.node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
|
||||
chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
end
|
||||
|
||||
[
|
||||
/^vmware_host_ip = $/,
|
||||
/^vmware_host_username = $/,
|
||||
/^vmware_host_password = $/,
|
||||
/^vmware_api_retry_count = 10$/,
|
||||
/^vmware_task_poll_interval = 5$/,
|
||||
/^vmware_volume_folder = cinder-volumes/,
|
||||
/^vmware_image_transfer_timeout_secs = 7200$/,
|
||||
/^vmware_max_objects_retrieval = 100$/
|
||||
].each do |content|
|
||||
it "has a #{content.source[1...-1]} line" do
|
||||
expect(chef_run).to render_file(file.name).with_content(content)
|
||||
end
|
||||
end
|
||||
|
||||
it 'has no wsdl_location line' do
|
||||
expect(chef_run).not_to render_file(file.name).with_content('vmware_wsdl_location = ')
|
||||
end
|
||||
|
||||
it 'has wsdl_location line' do
|
||||
node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
|
||||
|
||||
expect(chef_run).to render_file(file.name).with_content('vmware_wsdl_location = http://127.0.0.1/wsdl')
|
||||
end
|
||||
filename = '/etc/cinder/cinder.conf'
|
||||
chef_run.converge 'openstack-block-storage::cinder-common'
|
||||
expect(chef_run).to render_file(filename).with_content('vmware_wsdl_location = http://127.0.0.1/wsdl')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '/var/lock/cinder' do
|
||||
before do
|
||||
@dir = @chef_run.directory '/var/lock/cinder'
|
||||
end
|
||||
describe '/var/lock/cinder' do
|
||||
let(:dir) { chef_run.directory('/var/lock/cinder') }
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@dir.owner).to eq('cinder')
|
||||
expect(@dir.group).to eq('cinder')
|
||||
end
|
||||
it 'has proper owner' do
|
||||
expect(dir.owner).to eq('cinder')
|
||||
expect(dir.group).to eq('cinder')
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @dir.mode)).to eq '700'
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', dir.mode)).to eq '700'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::client' do
|
||||
|
||||
describe 'redhat' do
|
||||
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::client' do
|
||||
|
||||
describe 'ubuntu' do
|
||||
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
|
|
|
@ -5,114 +5,77 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::identity_registration' do
|
||||
before do
|
||||
block_storage_stubs
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::identity_registration'
|
||||
end
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'registers cinder volume service' do
|
||||
resource = @chef_run.find_resource(
|
||||
'openstack-identity_register',
|
||||
'Register Cinder Volume Service'
|
||||
).to_hash
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
expect(resource).to include(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_name: 'cinder',
|
||||
service_type: 'volume',
|
||||
service_description: 'Cinder Volume Service',
|
||||
endpoint_region: 'RegionOne',
|
||||
endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
action: [:create_service]
|
||||
)
|
||||
end
|
||||
|
||||
it 'overrides cinder volume service region' do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['region'] = 'serviceRegion'
|
||||
it 'registers cinder volume service' do
|
||||
expect(chef_run).to create_service_openstack_identity_register(
|
||||
'Register Cinder Volume Service'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_name: 'cinder',
|
||||
service_type: 'volume',
|
||||
service_description: 'Cinder Volume Service',
|
||||
endpoint_region: 'RegionOne',
|
||||
endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
|
||||
)
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::identity_registration'
|
||||
resource = @chef_run.find_resource(
|
||||
'openstack-identity_register',
|
||||
'Register Cinder Volume Service'
|
||||
).to_hash
|
||||
|
||||
expect(resource).to include(
|
||||
endpoint_region: 'serviceRegion',
|
||||
action: [:create_service]
|
||||
)
|
||||
end
|
||||
context 'registers volume endpoint' do
|
||||
it 'with default values' do
|
||||
expect(chef_run).to create_endpoint_openstack_identity_register(
|
||||
'Register Cinder Volume Endpoint'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_name: 'cinder',
|
||||
service_type: 'volume',
|
||||
service_description: 'Cinder Volume Service',
|
||||
endpoint_region: 'RegionOne',
|
||||
endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
|
||||
)
|
||||
end
|
||||
|
||||
it 'registers cinder volume endpoint' do
|
||||
resource = @chef_run.find_resource(
|
||||
'openstack-identity_register',
|
||||
'Register Cinder Volume Endpoint'
|
||||
).to_hash
|
||||
|
||||
expect(resource).to include(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_name: 'cinder',
|
||||
service_type: 'volume',
|
||||
service_description: 'Cinder Volume Service',
|
||||
endpoint_region: 'RegionOne',
|
||||
endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
action: [:create_endpoint]
|
||||
)
|
||||
end
|
||||
|
||||
it 'overrides cinder volume endpoint region' do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['region'] = 'volumeRegion'
|
||||
it 'with custom region override' do
|
||||
node.set['openstack']['block-storage']['region'] = 'volumeRegion'
|
||||
expect(chef_run).to create_endpoint_openstack_identity_register(
|
||||
'Register Cinder Volume Endpoint'
|
||||
).with(endpoint_region: 'volumeRegion')
|
||||
end
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::identity_registration'
|
||||
resource = @chef_run.find_resource(
|
||||
'openstack-identity_register',
|
||||
'Register Cinder Volume Endpoint'
|
||||
).to_hash
|
||||
|
||||
expect(resource).to include(
|
||||
endpoint_region: 'volumeRegion',
|
||||
action: [:create_endpoint]
|
||||
)
|
||||
end
|
||||
it 'registers service user' do
|
||||
expect(chef_run).to create_user_openstack_identity_register(
|
||||
'Register Cinder Service User'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'cinder',
|
||||
user_pass: 'cinder-pass',
|
||||
user_enabled: true
|
||||
)
|
||||
end
|
||||
|
||||
it 'registers service user' do
|
||||
resource = @chef_run.find_resource(
|
||||
'openstack-identity_register',
|
||||
'Register Cinder Service User'
|
||||
).to_hash
|
||||
|
||||
expect(resource).to include(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'cinder',
|
||||
user_pass: 'cinder-pass',
|
||||
user_enabled: true,
|
||||
action: [:create_user]
|
||||
)
|
||||
end
|
||||
|
||||
it 'grants admin role to service user for service tenant' do
|
||||
resource = @chef_run.find_resource(
|
||||
'openstack-identity_register',
|
||||
'Grant service Role to Cinder Service User for Cinder Service Tenant'
|
||||
).to_hash
|
||||
|
||||
expect(resource).to include(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'cinder',
|
||||
role_name: 'admin',
|
||||
action: [:grant_role]
|
||||
)
|
||||
it 'grants admin role to service user for service tenant' do
|
||||
expect(chef_run).to grant_role_openstack_identity_register(
|
||||
'Grant service Role to Cinder Service User for Cinder Service Tenant'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'cinder',
|
||||
role_name: 'admin'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,33 +5,35 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::scheduler' do
|
||||
before { block_storage_stubs }
|
||||
describe 'redhat' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::scheduler'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs cinder scheduler packages' do
|
||||
expect(@chef_run).to upgrade_package 'openstack-cinder'
|
||||
expect(chef_run).to upgrade_package 'openstack-cinder'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler' do
|
||||
expect(chef_run).to start_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler on boot' do
|
||||
expect(chef_run).to enable_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'does not upgrade stevedore' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
expect(chef_run).not_to upgrade_python_pip 'stevedore'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'MySQL-python'
|
||||
expect(chef_run).to upgrade_package 'MySQL-python'
|
||||
end
|
||||
|
||||
it 'installs db2 python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'db2'
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
['python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
|
||||
expect(chef_run).to upgrade_package pkg
|
||||
|
@ -39,21 +41,10 @@ describe 'openstack-block-storage::scheduler' do
|
|||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'MySQL-python'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler' do
|
||||
expect(@chef_run).to start_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler on boot' do
|
||||
expect(@chef_run).to enable_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,44 +5,38 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::scheduler' do
|
||||
before { block_storage_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::scheduler'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs cinder scheduler packages' do
|
||||
expect(@chef_run).to upgrade_package 'openstack-cinder-scheduler'
|
||||
expect(chef_run).to upgrade_package 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler' do
|
||||
expect(chef_run).to start_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler on boot' do
|
||||
expect(chef_run).to enable_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'does not upgrade stevedore' do
|
||||
chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
expect(chef_run).not_to upgrade_python_pip 'stevedore'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'python-mysql'
|
||||
expect(chef_run).to upgrade_package 'python-mysql'
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'python-mysql'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler' do
|
||||
expect(@chef_run).to start_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler on boot' do
|
||||
expect(@chef_run).to enable_service 'openstack-cinder-scheduler'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,66 +5,49 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::scheduler' do
|
||||
before { block_storage_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::scheduler'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
include_context 'block-storage-stubs'
|
||||
include_examples 'common-logging'
|
||||
|
||||
it 'does not run logging recipe' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
expect(chef_run).not_to include_recipe 'openstack-common::logging'
|
||||
end
|
||||
expect_creates_cinder_conf 'service[cinder-scheduler]', 'cinder', 'cinder'
|
||||
|
||||
it 'installs cinder scheduler packages' do
|
||||
expect(@chef_run).to upgrade_package 'cinder-scheduler'
|
||||
expect(chef_run).to upgrade_package 'cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler' do
|
||||
expect(chef_run).to start_service 'cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler on boot' do
|
||||
expect(chef_run).to enable_service 'cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'python-mysqldb'
|
||||
expect(chef_run).to upgrade_package 'python-mysqldb'
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'python-mysqldb'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler' do
|
||||
expect(@chef_run).to start_service 'cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'starts cinder scheduler on boot' do
|
||||
expect(@chef_run).to enable_service 'cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'does not run logging recipe' do
|
||||
expect(@chef_run).to enable_service 'cinder-scheduler'
|
||||
end
|
||||
|
||||
it 'does not setup cron when no metering' do
|
||||
expect(@chef_run.cron('cinder-volume-usage-audit')).to be_nil
|
||||
expect(chef_run.cron('cinder-volume-usage-audit')).to be_nil
|
||||
end
|
||||
|
||||
it 'creates cron metering default' do
|
||||
::Chef::Recipe.any_instance.stub(:search)
|
||||
.with(:node, 'roles:os-block-storage-scheduler')
|
||||
.and_return([OpenStruct.new(name: 'fauxhai.local')])
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['telemetry'] = true
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
node.set['openstack']['telemetry'] = true
|
||||
|
||||
cron = chef_run.cron 'cinder-volume-usage-audit'
|
||||
bin_str = '/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log'
|
||||
expect(cron.command).to match(/#{bin_str}/)
|
||||
|
@ -82,21 +65,17 @@ describe 'openstack-block-storage::scheduler' do
|
|||
::Chef::Recipe.any_instance.stub(:search)
|
||||
.with(:node, 'roles:os-block-storage-scheduler')
|
||||
.and_return([OpenStruct.new(name: 'foobar')])
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['telemetry'] = true
|
||||
crontests.each do |k, v|
|
||||
n.set['openstack']['block-storage']['cron'][k.to_s] = v
|
||||
end
|
||||
n.set['openstack']['block-storage']['user'] = 'foobar'
|
||||
node.set['openstack']['telemetry'] = true
|
||||
crontests.each do |k, v|
|
||||
node.set['openstack']['block-storage']['cron'][k.to_s] = v
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::scheduler'
|
||||
node.set['openstack']['block-storage']['user'] = 'foobar'
|
||||
|
||||
cron = chef_run.cron 'cinder-volume-usage-audit'
|
||||
crontests.each do |k, v|
|
||||
expect(cron.send(k)).to eq v
|
||||
end
|
||||
expect(cron.action).to include :delete
|
||||
end
|
||||
|
||||
expect_creates_cinder_conf 'service[cinder-scheduler]', 'cinder', 'cinder'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,102 +5,124 @@
|
|||
require 'chefspec'
|
||||
require 'chefspec/berkshelf'
|
||||
require 'chef/application'
|
||||
require_relative 'support/matcher'
|
||||
|
||||
::LOG_LEVEL = :fatal
|
||||
::SUSE_OPTS = {
|
||||
LOG_LEVEL = :fatal
|
||||
SUSE_OPTS = {
|
||||
platform: 'suse',
|
||||
version: '11.03',
|
||||
log_level: ::LOG_LEVEL
|
||||
log_level: LOG_LEVEL
|
||||
}
|
||||
::REDHAT_OPTS = {
|
||||
REDHAT_OPTS = {
|
||||
platform: 'redhat',
|
||||
version: '6.3',
|
||||
log_level: ::LOG_LEVEL
|
||||
log_level: LOG_LEVEL
|
||||
}
|
||||
::UBUNTU_OPTS = {
|
||||
UBUNTU_OPTS = {
|
||||
platform: 'ubuntu',
|
||||
version: '12.04',
|
||||
log_level: ::LOG_LEVEL
|
||||
log_level: LOG_LEVEL
|
||||
}
|
||||
|
||||
def block_storage_stubs # rubocop:disable MethodLength
|
||||
::Chef::Recipe.any_instance.stub(:rabbit_servers)
|
||||
.and_return('1.1.1.1:5672,2.2.2.2:5672')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', anything)
|
||||
.and_return('')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('db', anything)
|
||||
.and_return('')
|
||||
::Chef::Recipe.any_instance.stub(:secret)
|
||||
.with('secrets', 'openstack_identity_bootstrap_token')
|
||||
.and_return('bootstrap-token')
|
||||
::Chef::Recipe.any_instance.stub(:secret)
|
||||
.with('secrets', 'rbd_secret_uuid')
|
||||
.and_return('b0ff3bba-e07b-49b1-beed-09a45552b1ad')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mq-pass')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'solidfire_admin')
|
||||
.and_return('solidfire_testpass')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'openstack-block-storage')
|
||||
.and_return('cinder-pass')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'openstack_image_cephx_key')
|
||||
.and_return('cephx-key')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'admin')
|
||||
.and_return('emc_test_pass')
|
||||
::Chef::Application.stub(:fatal!)
|
||||
shared_context 'block-storage-stubs' do
|
||||
before do
|
||||
Chef::Recipe.any_instance.stub(:rabbit_servers)
|
||||
.and_return('1.1.1.1:5672,2.2.2.2:5672')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', anything)
|
||||
.and_return('')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('db', anything)
|
||||
.and_return('')
|
||||
Chef::Recipe.any_instance.stub(:secret)
|
||||
.with('secrets', 'openstack_identity_bootstrap_token')
|
||||
.and_return('bootstrap-token')
|
||||
Chef::Recipe.any_instance.stub(:secret)
|
||||
.with('secrets', 'rbd_secret_uuid')
|
||||
.and_return('b0ff3bba-e07b-49b1-beed-09a45552b1ad')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mq-pass')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'solidfire_admin')
|
||||
.and_return('solidfire_testpass')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'netapp')
|
||||
.and_return 'netapp-pass'
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'openstack-block-storage')
|
||||
.and_return('cinder-pass')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'openstack_image_cephx_key')
|
||||
.and_return('cephx-key')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'admin')
|
||||
.and_return('emc_test_pass')
|
||||
Chef::Application.stub(:fatal!)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'common-logging' do
|
||||
context 'when syslog.use is true' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
end
|
||||
|
||||
it 'runs logging recipe if node attributes say to' do
|
||||
expect(chef_run).to include_recipe 'openstack-common::logging'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when syslog.use is false' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['syslog']['use'] = false
|
||||
end
|
||||
|
||||
it 'runs logging recipe if node attributes say to' do
|
||||
expect(chef_run).to_not include_recipe 'openstack-common::logging'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def expect_runs_openstack_common_logging_recipe
|
||||
it 'runs logging recipe if node attributes say to' do
|
||||
expect(@chef_run).to include_recipe 'openstack-common::logging'
|
||||
expect(chef_run).to include_recipe 'openstack-common::logging'
|
||||
end
|
||||
end
|
||||
|
||||
def expect_creates_cinder_conf(service, user, group, action = :restart) # rubocop:disable MethodLength
|
||||
describe 'cinder.conf' do
|
||||
before do
|
||||
@file = @chef_run.template '/etc/cinder/cinder.conf'
|
||||
end
|
||||
let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@file.owner).to eq(user)
|
||||
expect(@file.group).to eq(group)
|
||||
expect(file.owner).to eq(user)
|
||||
expect(file.group).to eq(group)
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @file.mode)).to eq '644'
|
||||
expect(sprintf('%o', file.mode)).to eq '644'
|
||||
end
|
||||
|
||||
it 'notifies service restart' do
|
||||
expect(@file).to notify(service).to(action)
|
||||
expect(file).to notify(service).to(action)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def expect_creates_policy_json(service, user, group, action = :restart) # rubocop:disable MethodLength
|
||||
describe 'policy.json' do
|
||||
before do
|
||||
@file = @chef_run.template '/etc/cinder/policy.json'
|
||||
end
|
||||
let(:file) { chef_run.template('/etc/cinder/policy.json') }
|
||||
|
||||
it 'has proper owner' do
|
||||
expect(@file.owner).to eq(user)
|
||||
expect(@file.group).to eq(group)
|
||||
expect(file.owner).to eq(user)
|
||||
expect(file.group).to eq(group)
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @file.mode)).to eq '644'
|
||||
expect(sprintf('%o', file.mode)).to eq '644'
|
||||
end
|
||||
|
||||
it 'notifies service restart' do
|
||||
expect(@file).to notify(service).to(action)
|
||||
expect(file).to notify(service).to(action)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# encoding: UTF-8
|
||||
#
|
||||
# Cookbook Name:: openstack-block-storage
|
||||
|
||||
def upgrade_python_pip(pkgname)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:python_pip, :upgrade, pkgname)
|
||||
end
|
|
@ -5,79 +5,77 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::volume' do
|
||||
before { block_storage_stubs }
|
||||
describe 'redhat' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'MySQL-python'
|
||||
expect(chef_run).to upgrade_package('MySQL-python')
|
||||
end
|
||||
|
||||
it 'installs db2 python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'db2'
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
['python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
|
||||
expect(chef_run).to upgrade_package pkg
|
||||
expect(chef_run).to upgrade_package(pkg)
|
||||
end
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'MySQL-python'
|
||||
expect(chef_run).to upgrade_package('python-psycopg2')
|
||||
expect(chef_run).not_to upgrade_package('MySQL-python')
|
||||
end
|
||||
|
||||
it 'installs cinder iscsi packages' do
|
||||
expect(@chef_run).to upgrade_package 'scsi-target-utils'
|
||||
expect(chef_run).to upgrade_package('scsi-target-utils')
|
||||
end
|
||||
|
||||
it 'starts cinder volume' do
|
||||
expect(@chef_run).to start_service 'openstack-cinder-volume'
|
||||
expect(chef_run).to start_service('openstack-cinder-volume')
|
||||
end
|
||||
|
||||
it 'starts cinder volume on boot' do
|
||||
expected = 'openstack-cinder-volume'
|
||||
expect(@chef_run).to enable_service expected
|
||||
expect(chef_run).to enable_service('openstack-cinder-volume')
|
||||
end
|
||||
|
||||
it 'starts iscsi target on boot' do
|
||||
expect(@chef_run).to enable_service 'tgtd'
|
||||
end
|
||||
|
||||
it 'installs nfs packages' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
context 'ISCSI' do
|
||||
let(:file) { chef_run.template('/etc/tgt/targets.conf') }
|
||||
it 'starts iscsi target on boot' do
|
||||
expect(chef_run).to enable_service('tgtd')
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'nfs-utils'
|
||||
expect(chef_run).to upgrade_package 'nfs-utils-lib'
|
||||
end
|
||||
|
||||
it 'installs emc packages' do
|
||||
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
it 'has redhat include' do
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
'include /var/lib/cinder/volumes/*')
|
||||
expect(chef_run).not_to render_file(file.name).with_content(
|
||||
'include /etc/tgt/conf.d/*.conf')
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'pywbem'
|
||||
end
|
||||
|
||||
it 'has redhat include' do
|
||||
file = '/etc/tgt/targets.conf'
|
||||
context 'NFS Driver' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
end
|
||||
|
||||
expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*')
|
||||
expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf')
|
||||
it 'installs nfs packages' do
|
||||
expect(chef_run).to upgrade_package('nfs-utils')
|
||||
expect(chef_run).to upgrade_package('nfs-utils-lib')
|
||||
end
|
||||
end
|
||||
|
||||
context 'EMC ISCSI Driver' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
end
|
||||
|
||||
it 'installs emc packages' do
|
||||
expect(chef_run).to upgrade_package('pywbem')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,72 +5,71 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::volume' do
|
||||
before { block_storage_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'block-storage-stubs'
|
||||
|
||||
it 'installs cinder volume packages' do
|
||||
expect(@chef_run).to upgrade_package 'openstack-cinder-volume'
|
||||
expect(chef_run).to upgrade_package('openstack-cinder-volume')
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'python-mysql'
|
||||
expect(chef_run).to upgrade_package('python-mysql')
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'python-mysql'
|
||||
expect(chef_run).to upgrade_package('python-psycopg2')
|
||||
expect(chef_run).not_to upgrade_package('python-mysql')
|
||||
end
|
||||
|
||||
it 'installs cinder iscsi packages' do
|
||||
expect(@chef_run).to upgrade_package 'tgt'
|
||||
expect(chef_run).to upgrade_package('tgt')
|
||||
end
|
||||
|
||||
it 'starts cinder volume' do
|
||||
expect(@chef_run).to start_service 'openstack-cinder-volume'
|
||||
expect(chef_run).to start_service('openstack-cinder-volume')
|
||||
end
|
||||
|
||||
it 'starts cinder volume on boot' do
|
||||
expected = 'openstack-cinder-volume'
|
||||
expect(@chef_run).to enable_service expected
|
||||
expect(chef_run).to enable_service('openstack-cinder-volume')
|
||||
end
|
||||
|
||||
it 'starts iscsi target on boot' do
|
||||
expect(@chef_run).to enable_service 'tgtd'
|
||||
end
|
||||
|
||||
it 'installs nfs packages' do
|
||||
chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
context 'ISCSI' do
|
||||
let(:file) { chef_run.template('/etc/tgt/targets.conf') }
|
||||
it 'starts iscsi target on boot' do
|
||||
expect(chef_run).to enable_service('tgtd')
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'nfs-utils'
|
||||
expect(chef_run).not_to upgrade_package 'nfs-utils-lib'
|
||||
end
|
||||
|
||||
it 'installs emc packages' do
|
||||
chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
it 'has suse include' do
|
||||
expect(chef_run).to render_file(file.name).with_content('include /var/lib/cinder/volumes/*')
|
||||
expect(chef_run).not_to render_file(file.name).with_content('include /etc/tgt/conf.d/*.conf')
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-pywbem'
|
||||
end
|
||||
|
||||
it 'has suse include' do
|
||||
file = '/etc/tgt/targets.conf'
|
||||
context 'NFS Driver' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
end
|
||||
|
||||
expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*')
|
||||
expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf')
|
||||
it 'installs nfs packages' do
|
||||
expect(chef_run).to upgrade_package('nfs-utils')
|
||||
expect(chef_run).not_to upgrade_package('nfs-utils-lib')
|
||||
end
|
||||
end
|
||||
|
||||
context 'EMC ISCSI Driver' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
end
|
||||
|
||||
it 'installs emc packages' do
|
||||
expect(chef_run).to upgrade_package('python-pywbem')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,303 +5,256 @@
|
|||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-block-storage::volume' do
|
||||
before { block_storage_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['syslog']['use'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
include_context 'block-storage-stubs'
|
||||
include_examples 'common-logging'
|
||||
|
||||
it 'does not run logging recipe' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).not_to include_recipe 'openstack-common::logging'
|
||||
end
|
||||
expect_creates_cinder_conf('service[cinder-volume]', 'cinder', 'cinder')
|
||||
|
||||
it 'installs cinder volume packages' do
|
||||
expect(@chef_run).to upgrade_package 'cinder-volume'
|
||||
expect(chef_run).to upgrade_package 'cinder-volume'
|
||||
end
|
||||
|
||||
it 'starts cinder volume' do
|
||||
expect(chef_run).to start_service 'cinder-volume'
|
||||
end
|
||||
|
||||
it 'starts cinder volume on boot' do
|
||||
expect(chef_run).to enable_service 'cinder-volume'
|
||||
end
|
||||
|
||||
it 'starts iscsi target on boot' do
|
||||
expect(chef_run).to enable_service 'tgt'
|
||||
end
|
||||
|
||||
it 'installs mysql python packages by default' do
|
||||
expect(@chef_run).to upgrade_package 'python-mysqldb'
|
||||
expect(chef_run).to upgrade_package 'python-mysqldb'
|
||||
end
|
||||
|
||||
it 'installs postgresql python packages if explicitly told' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
node = chef_run.node
|
||||
node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-psycopg2'
|
||||
expect(chef_run).not_to upgrade_package 'python-mysqldb'
|
||||
end
|
||||
|
||||
it 'installs cinder iscsi packages' do
|
||||
expect(@chef_run).to upgrade_package 'tgt'
|
||||
expect(chef_run).to upgrade_package 'tgt'
|
||||
end
|
||||
|
||||
it 'installs emc packages' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
|
||||
expect(chef_run).to upgrade_package 'python-pywbem'
|
||||
end
|
||||
|
||||
it 'installs nfs packages' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to upgrade_package 'nfs-common'
|
||||
end
|
||||
|
||||
it 'creates the nfs mount point' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
expect(chef_run).to create_directory '/mnt/cinder-volumes'
|
||||
end
|
||||
|
||||
it 'configures netapp dfm password' do
|
||||
::Chef::Recipe.any_instance.stub(:get_password).with('service', 'netapp')
|
||||
.and_return 'netapp-pass'
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password']
|
||||
|
||||
expect(n).to eq 'netapp-pass'
|
||||
end
|
||||
|
||||
describe 'RBD Ceph as block-storage backend' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
|
||||
n.set['openstack']['block-storage']['rbd_secret_name'] = 'rbd_secret_uuid'
|
||||
# TODO: Remove work around once https://github.com/customink/fauxhai/pull/77 merges
|
||||
n.set['cpu']['total'] = 1
|
||||
context 'NetApp Driver' do
|
||||
describe 'NFS' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
@filename = '/etc/ceph/ceph.client.cinder.keyring'
|
||||
@file = @chef_run.template(@filename)
|
||||
|
||||
it 'installs nfs packages' do
|
||||
expect(chef_run).to upgrade_package 'nfs-common'
|
||||
end
|
||||
|
||||
it 'creates the nfs mount point' do
|
||||
expect(chef_run).to create_directory '/mnt/cinder-volumes'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ISCSI' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
|
||||
end
|
||||
|
||||
it 'configures netapp dfm password' do
|
||||
n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password']
|
||||
expect(n).to eq 'netapp-pass'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Ceph (RBD) Driver' do
|
||||
let(:file) { chef_run.template('/etc/ceph/ceph.client.cinder.keyring') }
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
|
||||
node.set['openstack']['block-storage']['rbd_secret_name'] = 'rbd_secret_uuid'
|
||||
end
|
||||
|
||||
it 'fetches the rbd_uuid_secret' do
|
||||
n = @chef_run.node['openstack']['block-storage']['rbd_secret_uuid']
|
||||
n = chef_run.node['openstack']['block-storage']['rbd_secret_uuid']
|
||||
expect(n).to eq 'b0ff3bba-e07b-49b1-beed-09a45552b1ad'
|
||||
end
|
||||
|
||||
it 'includes the ceph_client recipe' do
|
||||
expect(@chef_run).to include_recipe('openstack-common::ceph_client')
|
||||
expect(chef_run).to include_recipe('openstack-common::ceph_client')
|
||||
end
|
||||
|
||||
it 'installs the needed ceph packages by default' do
|
||||
%w{ python-ceph ceph-common }.each do |pkg|
|
||||
expect(@chef_run).to install_package(pkg)
|
||||
expect(chef_run).to install_package(pkg)
|
||||
end
|
||||
end
|
||||
|
||||
it 'honors package option platform overrides for cinder_ceph_packages' do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
|
||||
n.set['openstack']['block-storage']['rbd_secret_name'] = 'rbd_secret_uuid'
|
||||
n.set['openstack']['block-storage']['platform']['package_overrides'] = '--override1 --override2'
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
it 'honors package option platform overrides for python-ceph' do
|
||||
node.set['openstack']['block-storage']['rbd_secret_name'] = 'rbd_secret_uuid'
|
||||
node.set['openstack']['block-storage']['platform']['package_overrides'] = '--override1 --override2'
|
||||
|
||||
%w{ python-ceph ceph-common }.each do |pkg|
|
||||
expect(@chef_run).to install_package(pkg).with(options: '--override1 --override2')
|
||||
expect(chef_run).to install_package(pkg).with(options: '--override1 --override2')
|
||||
end
|
||||
end
|
||||
|
||||
it 'honors package name platform overrides for cinder_ceph_packages' do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
|
||||
n.set['openstack']['block-storage']['rbd_secret_name'] = 'rbd_secret_uuid'
|
||||
n.set['openstack']['block-storage']['platform']['cinder_ceph_packages'] = ['my-ceph', 'my-other-ceph']
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
it 'honors package name platform overrides for python-ceph' do
|
||||
node.set['openstack']['block-storage']['rbd_secret_name'] = 'rbd_secret_uuid'
|
||||
node.set['openstack']['block-storage']['platform']['cinder_ceph_packages'] = ['my-ceph', 'my-other-ceph']
|
||||
|
||||
%w{my-ceph my-other-ceph}.each do |pkg|
|
||||
expect(@chef_run).to install_package(pkg)
|
||||
expect(chef_run).to install_package(pkg)
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates a cephx client keyring correctly' do
|
||||
[/^\[client\.cinder\]$/,
|
||||
/^ key = cephx-key$/].each do |content|
|
||||
expect(@chef_run).to render_file(@filename).with_content(content)
|
||||
expect(chef_run).to render_file(file.name).with_content(content)
|
||||
end
|
||||
expect(@chef_run).to create_template(@filename).with(cookbook: 'openstack-common')
|
||||
expect(@file.owner).to eq('cinder')
|
||||
expect(@file.group).to eq('cinder')
|
||||
expect(sprintf('%o', @file.mode)).to eq '600'
|
||||
expect(chef_run).to create_template(file.name).with(cookbook: 'openstack-common')
|
||||
expect(file.owner).to eq('cinder')
|
||||
expect(file.group).to eq('cinder')
|
||||
expect(sprintf('%o', file.mode)).to eq '600'
|
||||
end
|
||||
end
|
||||
|
||||
it 'configures storewize private key' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
|
||||
context 'Storewize Driver' do
|
||||
let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
|
||||
before do
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
|
||||
end
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
san_key = chef_run.file chef_run.node['openstack']['block-storage']['san']['san_private_key']
|
||||
expect(san_key.mode).to eq('0400')
|
||||
end
|
||||
|
||||
it 'configures storewize with iscsi' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
|
||||
n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
|
||||
it 'configures storewize private key' do
|
||||
san_key = chef_run.file chef_run.node['openstack']['block-storage']['san']['san_private_key']
|
||||
expect(san_key.mode).to eq('0400')
|
||||
end
|
||||
conf = '/etc/cinder/cinder.conf'
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
# Test that the FC specific options are not set when connected via iSCSI
|
||||
expect(chef_run).not_to render_file(conf).with_content('storwize_svc_multipath_enabled')
|
||||
end
|
||||
context 'ISCSI' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
|
||||
end
|
||||
|
||||
it 'configures storewize with fc' do
|
||||
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
|
||||
n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC'
|
||||
it 'configures storewize with iscsi' do
|
||||
# Test that the FC specific options are not set when connected via iSCSI
|
||||
expect(chef_run).not_to render_file(file.name).with_content('storwize_svc_multipath_enabled')
|
||||
end
|
||||
end
|
||||
conf = '/etc/cinder/cinder.conf'
|
||||
chef_run.converge 'openstack-block-storage::volume'
|
||||
|
||||
# Test that the iSCSI specific options are not set when connected via FC
|
||||
expect(chef_run).not_to render_file(conf).with_content('storwize_svc_iscsi_chap_enabled')
|
||||
end
|
||||
context 'FC' do
|
||||
before do
|
||||
node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC'
|
||||
end
|
||||
|
||||
it 'starts cinder volume' do
|
||||
expect(@chef_run).to start_service 'cinder-volume'
|
||||
end
|
||||
|
||||
it 'starts cinder volume on boot' do
|
||||
expect(@chef_run).to enable_service 'cinder-volume'
|
||||
end
|
||||
|
||||
expect_creates_cinder_conf 'service[cinder-volume]', 'cinder', 'cinder'
|
||||
|
||||
it 'starts iscsi target on boot' do
|
||||
expect(@chef_run).to enable_service 'tgt'
|
||||
it 'configures storewize with fc' do
|
||||
# Test that the iSCSI specific options are not set when connected via FC
|
||||
expect(chef_run).not_to render_file(file.name).with_content('storwize_svc_iscsi_chap_enabled')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'targets.conf' do
|
||||
before do
|
||||
@file = @chef_run.template '/etc/tgt/targets.conf'
|
||||
end
|
||||
let(:file) { chef_run.template('/etc/tgt/targets.conf') }
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @file.mode)).to eq '600'
|
||||
expect(sprintf('%o', file.mode)).to eq '600'
|
||||
end
|
||||
|
||||
it 'notifies iscsi restart' do
|
||||
expect(@file).to notify('service[iscsitarget]').to(:restart)
|
||||
expect(file).to notify('service[iscsitarget]').to(:restart)
|
||||
end
|
||||
|
||||
it 'has ubuntu include' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('include /etc/tgt/conf.d/*.conf')
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('include /var/lib/cinder/volumes/*')
|
||||
expect(chef_run).to render_file(file.name).with_content('include /etc/tgt/conf.d/*.conf')
|
||||
expect(chef_run).not_to render_file(file.name).with_content('include /var/lib/cinder/volumes/*')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'create_vg' do
|
||||
let(:file) { chef_run.template('/etc/init.d/cinder-group-active') }
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
|
||||
n.set['openstack']['block-storage']['volume']['create_volume_group'] = true
|
||||
end
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
|
||||
node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
|
||||
stub_command('vgs cinder-volumes').and_return(false)
|
||||
@filename = '/etc/init.d/cinder-group-active'
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
@file = @chef_run.template(@filename)
|
||||
end
|
||||
|
||||
it 'cinder vg active' do
|
||||
expect(@chef_run).to enable_service 'cinder-group-active'
|
||||
expect(chef_run).to enable_service 'cinder-group-active'
|
||||
end
|
||||
|
||||
it 'create volume group' do
|
||||
volume_size = @chef_run.node['openstack']['block-storage']['volume']['volume_group_size']
|
||||
volume_size = chef_run.node['openstack']['block-storage']['volume']['volume_group_size']
|
||||
seek_count = volume_size.to_i * 1024
|
||||
group_name = @chef_run.node['openstack']['block-storage']['volume']['volume_group']
|
||||
path = @chef_run.node['openstack']['block-storage']['volume']['state_path']
|
||||
group_name = chef_run.node['openstack']['block-storage']['volume']['volume_group']
|
||||
path = chef_run.node['openstack']['block-storage']['volume']['state_path']
|
||||
vg_file = "#{path}/#{group_name}.img"
|
||||
cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})"
|
||||
expect(@chef_run).to run_execute(cmd)
|
||||
expect(chef_run).to run_execute(cmd)
|
||||
end
|
||||
|
||||
it 'notifies cinder group active start' do
|
||||
expect(@file).to notify('service[cinder-group-active]').to(:start)
|
||||
expect(file).to notify('service[cinder-group-active]').to(:start)
|
||||
end
|
||||
|
||||
it 'creates cinder group active template file' do
|
||||
expect(@chef_run).to create_template(@filename)
|
||||
expect(chef_run).to create_template(file.name)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'cinder_emc_config.xml' do
|
||||
let(:file) { chef_run.template('/etc/cinder/cinder_emc_config.xml') }
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
@filename = '/etc/cinder/cinder_emc_config.xml'
|
||||
@file = @chef_run.template(@filename)
|
||||
node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
end
|
||||
|
||||
it 'creates cinder emc config file' do
|
||||
expect(@chef_run).to create_template(@filename)
|
||||
expect(chef_run).to create_template(file.name)
|
||||
end
|
||||
|
||||
it 'has proper modes' do
|
||||
expect(sprintf('%o', @file.mode)).to eq('644')
|
||||
expect(sprintf('%o', file.mode)).to eq('644')
|
||||
end
|
||||
|
||||
it 'has StorageType' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('<StorageType>0</StorageType>')
|
||||
expect(chef_run).to render_file(file.name).with_content('<StorageType>0</StorageType>')
|
||||
end
|
||||
|
||||
it 'has EcomServerIp' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('<EcomServerIp>127.0.0.1</EcomServerIp>')
|
||||
expect(chef_run).to render_file(file.name).with_content('<EcomServerIp>127.0.0.1</EcomServerIp>')
|
||||
end
|
||||
|
||||
it 'has EcomServerPort' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('<EcomServerPort>5988</EcomServerPort>')
|
||||
expect(chef_run).to render_file(file.name).with_content('<EcomServerPort>5988</EcomServerPort>')
|
||||
end
|
||||
|
||||
it 'has EcomUserName' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('<EcomUserName>admin</EcomUserName>')
|
||||
expect(chef_run).to render_file(file.name).with_content('<EcomUserName>admin</EcomUserName>')
|
||||
end
|
||||
|
||||
it 'has EcomPassword' do
|
||||
expect(@chef_run).to render_file(@file.name).with_content('<EcomPassword>emc_test_pass</EcomPassword>')
|
||||
expect(chef_run).to render_file(file.name).with_content('<EcomPassword>emc_test_pass</EcomPassword>')
|
||||
end
|
||||
|
||||
it 'does not have MaskingView when not specified' do
|
||||
expect(@chef_run).not_to render_file(@file.name).with_content('<MaskingView>')
|
||||
expect(chef_run).not_to render_file(file.name).with_content('<MaskingView>')
|
||||
end
|
||||
|
||||
it 'has MaskingView when specified' do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['block-storage']['emc']['MaskingView'] = 'testMaskingView'
|
||||
n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
|
||||
end
|
||||
@chef_run.converge 'openstack-block-storage::volume'
|
||||
node.set['openstack']['block-storage']['emc']['MaskingView'] = 'testMaskingView'
|
||||
|
||||
expect(@chef_run).to render_file(@file.name).with_content('<MaskingView>testMaskingView</MaskingView>')
|
||||
expect(chef_run).to render_file(file.name).with_content('<MaskingView>testMaskingView</MaskingView>')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue