Skip to content

Commit 2a24ccc

Browse files
committed
Added test for the RPM install
1 parent f54faab commit 2a24ccc

File tree

5 files changed

+40
-26
lines changed

5 files changed

+40
-26
lines changed

Berksfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"locked_version": "5.2.12"
1919
},
2020
"percona": {
21-
"locked_version": "0.15.1"
21+
"locked_version": "0.15.2"
2222
},
2323
"apt": {
2424
"locked_version": "2.4.0"

metadata.rb

+2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
recipe "sphinx", "Installs sphinx"
99
recipe "sphinx::package", "Installs sphinx from a package"
1010
recipe "sphinx::source", "Installs sphinx from source"
11+
recipe "sphinx::rpm", "Installs sphinx from rpm"
1112

1213
provides "sphinx::default"
1314
provides "sphinx::package"
1415
provides "sphinx::source"
16+
provides "sphinx::rpm"
1517

1618
depends "build-essential", ">= 1.1.2"
1719
depends "mysql"

recipes/rpm.rb

+17-24
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
end
88

99
if platform_family?('rhel')
10-
%w( unixODBC
11-
postgresql-libs
12-
mysql-libs).each do |rpm_package|
13-
yum_package rpm_package do
14-
action :install
15-
end
10+
%w( unixODBC postgresql-libs mysql-libs).each do |rpm_package|
11+
yum_package rpm_package do
12+
action :install
13+
end
1614
end
1715
end
1816

@@ -21,41 +19,36 @@
2119
action :install
2220
end
2321

24-
#delete the default config on first run
25-
execute "rm -f /etc/sphinx/sphinx.conf" do
26-
command "rm -f /etc/sphinx/sphinx.conf"
27-
not_if { ::File.exists?("/etc/sphinx/conf.d")}
22+
# delete the default config on first run
23+
execute 'rm -f /etc/sphinx/sphinx.conf' do
24+
command 'rm -f /etc/sphinx/sphinx.conf'
25+
not_if { ::File.exist?('/etc/sphinx/conf.d') }
2826
end
2927

30-
#create direcotry for providers
28+
# create direcotry for providers
3129
directory '/etc/sphinx/conf.d/' do
3230
owner 'root'
3331
group 'root'
3432
mode 0755
3533
action :create
3634
end
3735

38-
#create direcotry for index
36+
# create direcotry for index
3937
directory '/etc/sphinx/data/' do
4038
owner 'root'
4139
group 'root'
4240
mode 0755
4341
action :create
4442
end
4543

46-
template "/etc/sphinx/sphinx.conf" do
47-
source "sphinx.conf.erb"
44+
template '/etc/sphinx/sphinx.conf' do
45+
source 'sphinx.conf.erb'
4846
owner node[:sphinx][:user]
4947
group node[:sphinx][:group]
5048
mode '0644'
51-
variables :install_path => node[:sphinx][:rpm][:conf_path],
52-
:searchd => node[:sphinx][:searchd],
53-
:indexer => node[:sphinx][:indexer]
49+
variables(
50+
:install_path => node[:sphinx][:rpm][:conf_path],
51+
:searchd => node[:sphinx][:searchd],
52+
:indexer => node[:sphinx][:indexer]
53+
)
5454
end
55-
56-
#service "searchd" do
57-
# supports :start => true, :stop => true, :restart => true
58-
# action :nothing
59-
#end
60-
61-

resources/source.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
attribute :name, :kind_of => String, :name_attribute => true, :required => true
55

6-
attribute :type, :kind_of => String
6+
attribute :type, :kind_of => String, :required => true
77
attribute :params, :kind_of => Hash, :required => true, :default => {}

spec/default_spec.rb

+19
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,23 @@
5050
end
5151
end
5252
end
53+
54+
context 'installation method: rpm' do
55+
context 'platform: redhat' do
56+
let(:chef_run) do
57+
runner = ChefSpec::Runner.new(:log_level => :debug)
58+
runner.node.set['sphinx']['install_method'] = 'rpm'
59+
runner.node.set['sphinx']['rpm']['name'] = 'sphinx-2.2.3-1.rhel6.x86_64.rpm'
60+
runner.node.set['sphinx']['rpm']['base_url'] = 'http://sphinxsearch.com/files/'
61+
runner.node.set['platform_family'] = 'redhat'
62+
runner.converge('sphinx::default')
63+
end
64+
65+
it 'installs sphinx package via rpm' do
66+
regex = /Put files to be included in \/etc\/sphinx\/conf.d/
67+
expect(chef_run).to render_file('/etc/sphinx/sphinx.conf').with_content(regex)
68+
end
69+
end
70+
end
71+
5372
end

0 commit comments

Comments
 (0)