Fix the format

Change-Id: I7b19f7292eac53090f79ccfa63c5388cc5ea3288
This commit is contained in:
ZhongShengping 2016-11-22 11:43:14 +08:00
parent ef4d68f1fe
commit e07d6cfe6f

View File

@ -3,10 +3,10 @@ require 'spec_helper'
describe 'openstack_extras::pacemaker::service', :type => :define do describe 'openstack_extras::pacemaker::service', :type => :define do
let :pre_condition do let :pre_condition do
[ [
"class { '::glance::registry::authtoken': password => 'password', }", "class { '::glance::registry::authtoken': password => 'password', }",
"include ::glance::registry", "include ::glance::registry",
] ]
end end
let :facts do let :facts do
@ -20,21 +20,21 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
let :default_params do let :default_params do
{ {
:ensure => 'present', :ensure => 'present',
:ocf_root_path => '/usr/lib/ocf', :ocf_root_path => '/usr/lib/ocf',
:primitive_class => 'ocf', :primitive_class => 'ocf',
:primitive_provider => 'pacemaker', :primitive_provider => 'pacemaker',
:primitive_type => false, :primitive_type => false,
:parameters => false, :parameters => false,
:operations => false, :operations => false,
:metadata => false, :metadata => false,
:ms_metadata => false, :ms_metadata => false,
:use_handler => true, :use_handler => true,
:handler_root_path => '/usr/local/bin', :handler_root_path => '/usr/local/bin',
:ocf_script_template => false, :ocf_script_template => false,
:ocf_script_file => false, :ocf_script_file => false,
:create_primitive => true, :create_primitive => true,
:clone => false :clone => false
} }
end end
@ -45,38 +45,38 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
it 'should override existing service provider' do it 'should override existing service provider' do
is_expected.to contain_service('glance-registry').with( is_expected.to contain_service('glance-registry').with(
{ {
:provider => 'pacemaker' :provider => 'pacemaker'
}) })
end end
it 'should create a pacemaker primitive' do it 'should create a pacemaker primitive' do
is_expected.to contain_cs_primitive('p_glance-registry').with( is_expected.to contain_cs_primitive('p_glance-registry').with(
{ {
'ensure' => default_params[:ensure], 'ensure' => default_params[:ensure],
'primitive_class' => default_params[:primitive_class], 'primitive_class' => default_params[:primitive_class],
'primitive_type' => default_params[:primitive_type], 'primitive_type' => default_params[:primitive_type],
'provided_by' => default_params[:primitive_provider], 'provided_by' => default_params[:primitive_provider],
'parameters' => default_params[:parameters], 'parameters' => default_params[:parameters],
'operations' => default_params[:operations], 'operations' => default_params[:operations],
'metadata' => default_params[:metadata], 'metadata' => default_params[:metadata],
'ms_metadata' => default_params[:ms_metadata], 'ms_metadata' => default_params[:ms_metadata],
}) })
end end
it 'should not create a cloned resource' do it 'should not create a cloned resource' do
is_expected.to contain_cs_clone('p_glance-registry-clone').with( is_expected.to contain_cs_clone('p_glance-registry-clone').with(
{ {
'ensure' => 'absent', 'ensure' => 'absent',
}) })
end end
end end
context 'with custom OCF file' do context 'with custom OCF file' do
let :params do let :params do
default_params.merge( default_params.merge(
{ {
:ocf_script_file => 'foo/scripts/foo.ocf' :ocf_script_file => 'foo/scripts/foo.ocf'
} }
) )
end end
let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" } let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" }
@ -86,25 +86,25 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
it 'should create an OCF file' do it 'should create an OCF file' do
is_expected.to contain_file("#{title}-ocf-file").with( is_expected.to contain_file("#{title}-ocf-file").with(
{ {
'ensure' => 'present', 'ensure' => 'present',
'path' => ocf_script_path, 'path' => ocf_script_path,
'mode' => '0755', 'mode' => '0755',
'owner' => 'root', 'owner' => 'root',
'group' => 'root', 'group' => 'root',
'source' => "puppet:///modules/#{params[:ocf_script_file]}" 'source' => "puppet:///modules/#{params[:ocf_script_file]}"
}) })
end end
it 'should create a handler file' do it 'should create a handler file' do
is_expected.to contain_file("#{ocf_handler_name}").with( is_expected.to contain_file("#{ocf_handler_name}").with(
{ {
'ensure' => 'present', 'ensure' => 'present',
'path' => ocf_handler_path, 'path' => ocf_handler_path,
'owner' => 'root', 'owner' => 'root',
'group' => 'root', 'group' => 'root',
'mode' => '0700', 'mode' => '0700',
}).with_content(/OCF_ROOT/) }).with_content(/OCF_ROOT/)
end end
end end
@ -112,12 +112,12 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
context 'with custom OCF path, provider, erb and w/o a wrapper' do context 'with custom OCF path, provider, erb and w/o a wrapper' do
let(:params) do let(:params) do
default_params.merge( default_params.merge(
{ {
:ocf_script_template => 'openstack_extras/ocf_handler.erb', :ocf_script_template => 'openstack_extras/ocf_handler.erb',
:use_handler => false, :use_handler => false,
:primitive_provider => 'some_provider', :primitive_provider => 'some_provider',
:ocf_root_path => '/usr/lib/some_path', :ocf_root_path => '/usr/lib/some_path',
}) })
end end
let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" } let (:ocf_dir_path) { "#{params[:ocf_root_path]}/resource.d" }
let (:ocf_script_path) { let (:ocf_script_path) {
@ -126,12 +126,12 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
it 'should create an OCF file from template' do it 'should create an OCF file from template' do
is_expected.to contain_file("#{title}-ocf-file").with( is_expected.to contain_file("#{title}-ocf-file").with(
{ {
'path' => ocf_script_path, 'path' => ocf_script_path,
'mode' => '0755', 'mode' => '0755',
'owner' => 'root', 'owner' => 'root',
'group' => 'root' 'group' => 'root'
}).with_content(/monitor/) }).with_content(/monitor/)
end end
it 'should not create a handler file' do it 'should not create a handler file' do
@ -140,32 +140,32 @@ describe 'openstack_extras::pacemaker::service', :type => :define do
it 'should create a pacemaker primitive' do it 'should create a pacemaker primitive' do
is_expected.to contain_cs_primitive('p_glance-registry').with( is_expected.to contain_cs_primitive('p_glance-registry').with(
{ {
'ensure' => params[:ensure], 'ensure' => params[:ensure],
'primitive_class' => params[:primitive_class], 'primitive_class' => params[:primitive_class],
'primitive_type' => params[:primitive_type], 'primitive_type' => params[:primitive_type],
'provided_by' => params[:primitive_provider], 'provided_by' => params[:primitive_provider],
'parameters' => params[:parameters], 'parameters' => params[:parameters],
'operations' => params[:operations], 'operations' => params[:operations],
'metadata' => params[:metadata], 'metadata' => params[:metadata],
'ms_metadata' => params[:ms_metadata], 'ms_metadata' => params[:ms_metadata],
}) })
end end
end end
context 'with cloned resources' do context 'with cloned resources' do
let (:params) do let (:params) do
default_params.merge( default_params.merge(
{ {
:clone => true, :clone => true,
}) })
end end
it 'should create a cloned resource' do it 'should create a cloned resource' do
is_expected.to contain_cs_clone('p_glance-registry-clone').with( is_expected.to contain_cs_clone('p_glance-registry-clone').with(
{ {
'ensure' => 'present', 'ensure' => 'present',
'primitive' => 'p_glance-registry', 'primitive' => 'p_glance-registry',
}) })
end end
end end