2015-07-09 16:29:06 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2018-01-31 08:14:24 +01:00
|
|
|
shared_examples 'standard::init' do |vars|
|
2015-07-09 16:29:06 +02:00
|
|
|
|
|
|
|
|
describe user('elasticsearch') do
|
|
|
|
|
it { should exist }
|
|
|
|
|
end
|
|
|
|
|
|
2015-11-25 15:28:09 +00:00
|
|
|
describe service('node1_elasticsearch') do
|
2015-07-09 16:29:06 +02:00
|
|
|
it { should be_running }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe package('elasticsearch') do
|
|
|
|
|
it { should be_installed }
|
|
|
|
|
end
|
|
|
|
|
|
2015-11-25 15:28:09 +00:00
|
|
|
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
|
2015-07-09 16:29:06 +02:00
|
|
|
it { should be_file }
|
2015-11-26 10:20:58 +00:00
|
|
|
it { should be_owned_by 'elasticsearch' }
|
2015-07-09 16:29:06 +02:00
|
|
|
end
|
|
|
|
|
|
2017-01-13 12:51:25 +00:00
|
|
|
describe file('/etc/elasticsearch/node1/log4j2.properties') do
|
|
|
|
|
it { should be_file }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
2017-08-17 18:52:02 +01:00
|
|
|
it { should_not contain 'CUSTOM LOG4J FILE' }
|
2017-01-13 12:51:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/etc/elasticsearch/node1/jvm.options') do
|
2015-11-25 23:43:01 +00:00
|
|
|
it { should be_file }
|
2015-11-26 10:20:58 +00:00
|
|
|
it { should be_owned_by 'elasticsearch' }
|
2015-11-25 23:43:01 +00:00
|
|
|
end
|
|
|
|
|
|
2015-11-25 15:28:09 +00:00
|
|
|
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
|
|
|
|
|
it { should contain 'node.name: localhost-node1' }
|
2015-11-25 17:13:45 +00:00
|
|
|
it { should contain 'cluster.name: elasticsearch' }
|
2018-01-31 08:14:24 +01:00
|
|
|
if vars['es_major_version'] == '6.x'
|
|
|
|
|
it { should_not contain 'path.conf: /etc/elasticsearch/node1' }
|
|
|
|
|
else
|
|
|
|
|
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
|
|
|
|
end
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' }
|
|
|
|
|
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'Node listening' do
|
|
|
|
|
it 'listening in port 9200' do
|
|
|
|
|
expect(port 9200).to be_listening
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-12-13 22:46:50 +00:00
|
|
|
describe 'version check' do
|
2018-01-31 08:14:24 +01:00
|
|
|
it 'should be reported as version '+vars['es_version'] do
|
2015-12-13 22:46:50 +00:00
|
|
|
command = command('curl -s localhost:9200 | grep number')
|
2018-01-31 08:14:24 +01:00
|
|
|
expect(command.stdout).to match(vars['es_version'])
|
2015-10-19 12:44:09 +02:00
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
2015-07-09 16:29:06 +02:00
|
|
|
end
|
|
|
|
|
|
2016-01-18 14:37:15 +00:00
|
|
|
describe file('/etc/init.d/elasticsearch') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/etc/default/elasticsearch') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/etc/sysconfig/elasticsearch') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/usr/lib/systemd/system/elasticsearch.service') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
|
2016-03-18 19:30:11 +00:00
|
|
|
describe file('/etc/elasticsearch/elasticsearch.yml') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
|
2016-03-21 20:16:29 +00:00
|
|
|
describe file('/etc/elasticsearch/logging.yml') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
|
2018-01-31 08:14:24 +01:00
|
|
|
for plugin in vars['es_plugins']
|
|
|
|
|
plugin = plugin['plugin']
|
|
|
|
|
|
2017-08-15 14:31:56 +01:00
|
|
|
describe file('/usr/share/elasticsearch/plugins/'+plugin) do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
#confirm plugins are installed and the correct version
|
2018-01-31 08:14:24 +01:00
|
|
|
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+vars['es_version']+'"\'') do
|
2017-08-15 14:31:56 +01:00
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2015-07-09 16:29:06 +02:00
|
|
|
end
|
|
|
|
|
|