2015-10-22 19:09:53 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2015-12-13 22:46:50 +00:00
|
|
|
shared_examples 'config::init' do |es_version|
|
2015-10-22 19:09:53 +01:00
|
|
|
|
|
|
|
|
describe user('elasticsearch') do
|
|
|
|
|
it { should exist }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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
|
2015-10-22 19:09:53 +01:00
|
|
|
it { should contain 'http.port: 9201' }
|
|
|
|
|
it { should contain 'transport.tcp.port: 9301' }
|
|
|
|
|
it { should contain 'node.data: false' }
|
|
|
|
|
it { should contain 'node.master: true' }
|
|
|
|
|
it { should contain 'discovery.zen.ping.multicast.enabled: false' }
|
|
|
|
|
it { should contain 'cluster.name: custom-cluster' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'node.name: node1' }
|
|
|
|
|
it { should contain 'bootstrap.mlockall: true' }
|
2015-10-22 19:09:53 +01:00
|
|
|
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'path.conf: /etc/elasticsearch/node1' }
|
2015-11-25 17:13:45 +00:00
|
|
|
it { should contain 'path.data: /opt/elasticsearch/data/localhost-node1' }
|
|
|
|
|
it { should contain 'path.work: /opt/elasticsearch/temp/localhost-node1' }
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
describe file('/opt/elasticsearch/data/localhost-node1') do
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
describe file('/opt/elasticsearch/temp/localhost-node1') do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/etc/init.d/node1_elasticsearch') do
|
|
|
|
|
it { should be_file }
|
2015-10-22 19:09:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#test we started on the correct port was used
|
2015-12-13 22:46:50 +00:00
|
|
|
describe command('curl -s "localhost:9201"') 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
|
2015-11-27 19:58:54 +00:00
|
|
|
describe command('curl -s "localhost:9201/_nodes/process?pretty" | grep mlockall') do
|
|
|
|
|
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
|
|
|
|
|
command = command('curl -s localhost:9201 | grep number')
|
|
|
|
|
expect(command.stdout).to match(es_version)
|
|
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#Not copied on Debian 8
|
|
|
|
|
#describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do
|
|
|
|
|
# it { should be_file }
|
|
|
|
|
# it { should contain 'LimitMEMLOCK=infinity' }
|
|
|
|
|
#end
|
|
|
|
|
|
2015-10-22 19:09:53 +01:00
|
|
|
end
|
|
|
|
|
|