cookbook-openstack-common/spec/openrc_spec.rb
ZHU ZHU 5b50abcdb2 Set openrc with OS_VOLUME_API_VERSION with cinder v2
As recently Nova merged commit https://review.openstack.org/#/c/124468/
which have switched to use Cinder v2 api, and cookbook will register
Cinder v2 endpoint. So openrc file also need to be updated
for cinder v2 support.

Change-Id: I3bcd3ca95d5f65c33eb5ddfda611280785412549
2014-11-14 10:53:32 -06:00

67 lines
2.1 KiB
Ruby

# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-common::openrc' do
describe 'ubuntu' do
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
runner.converge(described_recipe)
end
include_context 'common-stubs'
describe '/root/openrc' do
let(:file) { chef_run.template('/root/openrc') }
it 'creates the /root/openrc file' do
expect(chef_run).to create_directory('/root').with(
owner: 'root',
group: 'root',
mode: '0700',
recursive: true
)
expect(chef_run).to create_template(file.name).with(
sensitive: true,
user: 'root',
group: 'root',
mode: '0600'
)
end
it 'contains auth environment variables' do
[
/^export OS_USERNAME=admin$/,
/^export OS_TENANT_NAME=admin$/,
/^export OS_PASSWORD=admin$/,
%r{^export OS_AUTH_URL=http://127.0.0.1:5000/v2.0$},
/^export OS_REGION_NAME=RegionOne$/,
/^export OS_VOLUME_API_VERSION=2$/
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
end
it 'templates misc_openrc array correctly' do
node.set['openstack']['misc_openrc'] = ['export MISC1=OPTION1', 'export MISC2=OPTION2']
expect(chef_run).to render_file(file.name).with_content(
/^export MISC1=OPTION1$/)
expect(chef_run).to render_file(file.name).with_content(
/^export MISC2=OPTION2$/)
end
it 'contains overridden auth environment variables' do
node.set['openstack']['identity']['admin_tenant_name'] = 'admin-tenant-name-override'
node.set['openstack']['identity']['admin_user'] = 'admin-user-override'
[
/^export OS_USERNAME=admin-user-override$/,
/^export OS_TENANT_NAME=admin-tenant-name-override$/
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
end
end
end
end