2015-10-22 19:09:53 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2017-03-16 21:06:17 +00:00
|
|
|
shared_examples 'config::init' do |es_version,plugins|
|
2015-10-22 19:09:53 +01:00
|
|
|
|
|
|
|
|
describe user('elasticsearch') do
|
|
|
|
|
it { should exist }
|
|
|
|
|
end
|
2016-01-22 12:14:09 -08:00
|
|
|
|
|
|
|
|
describe group('elasticsearch') do
|
|
|
|
|
it { should have_gid 333 }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe user('elasticsearch') do
|
|
|
|
|
it { should have_uid 333 }
|
|
|
|
|
end
|
2015-10-22 19:09:53 +01:00
|
|
|
|
|
|
|
|
describe service('node1_elasticsearch') do
|
|
|
|
|
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-10-22 19:09:53 +01:00
|
|
|
it { should be_file }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#test configuration parameters have been set - test all appropriately set in config file
|
2015-11-25 15:28:09 +00:00
|
|
|
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
|
2017-03-16 21:06:17 +00:00
|
|
|
it { should contain 'http.port: 9401' }
|
|
|
|
|
it { should contain 'transport.tcp.port: 9501' }
|
|
|
|
|
it { should contain 'node.data: true' }
|
2015-10-22 19:09:53 +01:00
|
|
|
it { should contain 'node.master: true' }
|
|
|
|
|
it { should contain 'cluster.name: custom-cluster' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'node.name: node1' }
|
2017-03-17 00:20:50 +00:00
|
|
|
it { should contain 'bootstrap.memory_lock: true' }
|
2017-03-16 21:06:17 +00:00
|
|
|
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9501' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
2016-03-18 19:30:11 +00:00
|
|
|
it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' }
|
2015-11-25 17:13:45 +00:00
|
|
|
it { should contain 'path.logs: /opt/elasticsearch/logs/localhost-node1' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#test directories exist
|
|
|
|
|
describe file('/etc/elasticsearch/node1') do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
|
2016-03-18 19:30:11 +00:00
|
|
|
describe file('/opt/elasticsearch/data-1/localhost-node1') do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/opt/elasticsearch/data-2/localhost-node1') do
|
2015-11-25 17:13:45 +00:00
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/opt/elasticsearch/logs/localhost-node1') do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
2017-01-17 15:33:51 +00:00
|
|
|
|
2015-10-22 19:09:53 +01:00
|
|
|
#test we started on the correct port was used
|
2017-03-16 21:06:17 +00:00
|
|
|
describe command('curl -s "localhost:9401"') do
|
2015-10-22 19:09:53 +01:00
|
|
|
#TODO: This is returning an empty string
|
|
|
|
|
#its(:stdout) { should match /\"status\" : 200/ }
|
|
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
|
|
|
|
|
2015-11-26 14:19:25 +00:00
|
|
|
#test to make sure mlock was applied
|
2017-03-16 21:06:17 +00:00
|
|
|
describe command('curl -s "localhost:9401/_nodes/process?pretty" | grep mlockall') do
|
2017-03-17 00:20:50 +00:00
|
|
|
its(:stdout) { should match /true/ }
|
2015-11-26 14:19:25 +00:00
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
2015-10-22 19:09:53 +01:00
|
|
|
|
2015-12-13 22:46:50 +00:00
|
|
|
|
|
|
|
|
describe 'version check' do
|
|
|
|
|
it 'should be reported as version '+es_version do
|
2017-03-16 21:06:17 +00:00
|
|
|
command = command('curl -s localhost:9401 | grep number')
|
2015-12-13 22:46:50 +00:00
|
|
|
expect(command.stdout).to match(es_version)
|
|
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-03-16 21:06:17 +00:00
|
|
|
for plugin in plugins
|
|
|
|
|
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
|
|
|
|
|
describe command('curl -s localhost:9401/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
|
|
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#explit test to make sure ingest-geoip is not installed
|
|
|
|
|
describe file('/usr/share/elasticsearch/plugins/ingest-geoip') do
|
|
|
|
|
it { should_not exist }
|
|
|
|
|
end
|
|
|
|
|
#confirm plugins are installed and the correct version
|
|
|
|
|
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"ingest-geoip","version":"'+es_version+'"\'') do
|
|
|
|
|
its(:exit_status) { should eq 1 }
|
|
|
|
|
end
|
|
|
|
|
|
2016-03-18 19:30:11 +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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2016-03-21 14:34:43 +00:00
|
|
|
#Init vs Systemd tests
|
|
|
|
|
#Ubuntu 15 and up
|
|
|
|
|
#Debian 8 and up
|
|
|
|
|
#Centos 7 and up
|
|
|
|
|
|
2016-03-21 16:40:10 +00:00
|
|
|
if (((os[:family] == 'redhat' || os[:family] == 'centos') && os[:release].to_f >= 7.0) ||
|
2016-03-21 14:34:43 +00:00
|
|
|
(os[:family] == 'ubuntu' && os[:release].to_f >= 15.0) ||
|
|
|
|
|
(os[:family] == 'debian' && os[:release].to_f >= 8.0))
|
|
|
|
|
describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do
|
|
|
|
|
it { should be_file }
|
|
|
|
|
it { should contain 'LimitMEMLOCK=infinity' }
|
2017-08-18 16:32:00 +01:00
|
|
|
it { should contain 'LimitNPROC=3000' }
|
2016-03-21 14:34:43 +00:00
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
describe file('/etc/init.d/node1_elasticsearch') do
|
|
|
|
|
it { should be_file }
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-08-17 18:52:02 +01:00
|
|
|
|
|
|
|
|
describe file('/etc/elasticsearch/node1/log4j2.properties') do
|
|
|
|
|
it { should be_file }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
it { should contain 'CUSTOM LOG4J FILE' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2015-10-22 19:09:53 +01:00
|
|
|
end
|
|
|
|
|
|