puppet-manila/spec/defines/manila_service_instance_spec.rb
Simon Fowler b56df2a8a5 Don't always try to create the service image.
This patch makes it possible to create a service_instance resource
without also attempting to upload the image to glance.

This is required because the glance_image resource must be run on the
same host as the glance api service, meaning that it will fail when
trying to create a stand alone manila host.

Defaults to true in order to retain backwards compatibility.

Change-Id: Id863272652db2b01e8d86b94cfd417fa78f7ea1b
2016-07-18 21:10:40 +10:00

66 lines
2.4 KiB
Ruby

require 'spec_helper'
describe 'manila::service_instance' do
let(:title) {'DEFAULT'}
let :params do
{
:create_service_image => true,
:service_instance_name_template => 'manila_service_instance_%s',
:service_instance_user => 'user1',
:service_instance_password => 'pass1',
:manila_service_keypair_name => 'manila-service',
:path_to_public_key => '~/.ssh/id_rsa.pub',
:path_to_private_key => '~/.ssh/id_rsa',
:max_time_to_build_instance => 300,
:service_instance_security_group => 'manila-service',
:service_instance_flavor_id => 1,
:service_network_name => 'manila_service_network',
:service_network_cidr => '10.254.0.0/16',
:service_network_division_mask => 28,
:interface_driver => 'manila.network.linux.interface.OVSInterfaceDriver',
:connect_share_server_to_tenant_network => false,
:service_instance_network_helper_type => 'neutron',
}
end
context 'with default parameters' do
it 'configures service instance' do
expect {
params.each_pair do |config,value|
is_expected.to contain_manila_config("DEFAULT/#{config}").with_value( value )
end
}.to raise_error(Puppet::Error, /Missing required parameter service_image_location/)
end
end
context 'with service image provided' do
let (:req_params) { params.merge!({
:service_image_name => 'manila-service-image',
:service_image_location => 'http://example.com/manila_service_image.iso',
}) }
it 'creates Glance image' do
is_expected.to contain_glance_image(req_params[:service_image_name]).with(
:ensure => 'present',
:is_public => 'yes',
:container_format => 'bare',
:disk_format => 'qcow2',
:source => req_params[:service_image_location]
)
end
end
context 'with create_service_image false' do
let (:req_params) { params.merge!({
:create_service_image => false,
:service_image_name => 'manila-service-image',
}) }
it 'does not create Glance image' do
is_expected.to_not contain_glance_image(req_params[:service_image_name])
end
end
end