2015-10-22 19:09:53 +01:00
|
|
|
require 'spec_helper'
|
2018-01-31 08:14:24 +01:00
|
|
|
require 'json'
|
|
|
|
|
vars = JSON.parse(File.read('/tmp/vars.json'))
|
2015-10-22 19:09:53 +01:00
|
|
|
|
2018-01-31 08:14:24 +01:00
|
|
|
shared_examples 'multi::init' do |vars|
|
2015-10-22 19:09:53 +01:00
|
|
|
|
|
|
|
|
describe service('master_elasticsearch') do
|
|
|
|
|
it { should be_running }
|
|
|
|
|
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-11-27 19:58:54 +00:00
|
|
|
it { should be_file }
|
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: true' }
|
|
|
|
|
it { should contain 'node.master: false' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'node.name: localhost-node1' }
|
2017-01-16 10:40:01 +00:00
|
|
|
it { should_not contain 'bootstrap.memory_lock: true' }
|
2018-01-31 08:17:44 +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
|
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 15:28:09 +00:00
|
|
|
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
|
2015-10-22 19:09:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#test configuration parameters have been set for master - test all appropriately set in config file
|
2015-11-25 15:28:09 +00:00
|
|
|
describe file('/etc/elasticsearch/master/elasticsearch.yml') do
|
2015-11-27 19:58:54 +00:00
|
|
|
it { should be_file }
|
2015-10-22 19:09:53 +01:00
|
|
|
it { should contain 'http.port: 9200' }
|
|
|
|
|
it { should contain 'transport.tcp.port: 9300' }
|
|
|
|
|
it { should contain 'node.data: false' }
|
|
|
|
|
it { should contain 'node.master: true' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'node.name: localhost-master' }
|
2017-01-16 10:40:01 +00:00
|
|
|
it { should contain 'bootstrap.memory_lock: true' }
|
2018-01-31 08:17:44 +01:00
|
|
|
if vars['es_major_version'] == '6.x'
|
2018-01-31 12:07:32 +01:00
|
|
|
it { should_not contain 'path.conf: /etc/elasticsearch/master' }
|
2018-01-31 08:17:44 +01:00
|
|
|
else
|
2018-01-31 12:07:32 +01:00
|
|
|
it { should contain 'path.conf: /etc/elasticsearch/master' }
|
2018-01-31 08:17:44 +01:00
|
|
|
end
|
2016-03-18 19:30:11 +00:00
|
|
|
it { should contain 'path.data: /opt/elasticsearch/master/localhost-master' }
|
2015-11-25 15:28:09 +00:00
|
|
|
it { should contain 'path.logs: /var/log/elasticsearch/localhost-master' }
|
2015-10-22 19:09:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'Master listening' do
|
|
|
|
|
it 'listening in port 9200' do
|
|
|
|
|
expect(port 9200).to be_listening
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#test we started on the correct port was used for master
|
|
|
|
|
describe 'master started' do
|
|
|
|
|
it 'master node should be running', :retry => 3, :retry_wait => 10 do
|
2018-06-19 12:15:10 +02:00
|
|
|
expect(json_curl('http://localhost:9200')['name']).to eq('localhost-node1')
|
2015-10-22 19:09:53 +01:00
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#test we started on the correct port was used for node 1
|
|
|
|
|
describe 'node1 started' do
|
|
|
|
|
it 'node should be running', :retry => 3, :retry_wait => 10 do
|
|
|
|
|
command = command('curl "localhost:9201" | grep name')
|
|
|
|
|
#expect(command.stdout).should match '/*node1_localhost*/'
|
|
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-11-26 14:45:00 +00:00
|
|
|
#Confirm scripts are on both nodes
|
|
|
|
|
describe file('/etc/elasticsearch/master/scripts') do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe file('/etc/elasticsearch/master/scripts/calculate-score.groovy') do
|
|
|
|
|
it { should be_file }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
|
|
|
|
|
2015-11-26 15:58:48 +00:00
|
|
|
#Confirm that the data directory has only been set for the first node
|
2016-03-18 19:30:11 +00:00
|
|
|
describe file('/opt/elasticsearch/master/localhost-master') do
|
2015-11-26 15:58:48 +00:00
|
|
|
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' }
|
2015-11-26 15:58:48 +00:00
|
|
|
end
|
|
|
|
|
|
2016-03-18 19:30:11 +00:00
|
|
|
|
|
|
|
|
describe file('/opt/elasticsearch/data-2/localhost-node1') do
|
2015-11-26 15:58:48 +00:00
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
2015-11-27 19:39:47 +00:00
|
|
|
|
|
|
|
|
#test to make sure mlock was applied
|
2017-01-16 11:36:05 +00:00
|
|
|
describe command('curl -s "localhost:9200/_nodes/localhost-master/process?pretty=true" | grep mlockall') do
|
2015-11-27 19:39:47 +00:00
|
|
|
its(:stdout) { should match /true/ }
|
|
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#test to make sure mlock was not applied
|
2017-01-16 11:36:05 +00:00
|
|
|
describe command('curl -s "localhost:9201/_nodes/localhost-node1/process?pretty=true" | grep mlockall') do
|
2015-11-27 19:39:47 +00:00
|
|
|
its(:stdout) { should match /false/ }
|
|
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
2015-11-27 19:58:54 +00:00
|
|
|
|
2015-12-13 22:46:50 +00:00
|
|
|
describe 'version check on master' 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-12-13 22:46:50 +00:00
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'version check on data' 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:9201 | grep number')
|
2018-01-31 08:14:24 +01:00
|
|
|
expect(command.stdout).to match(vars['es_version'])
|
2015-12-13 22:46:50 +00:00
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-01-31 08:14:24 +01:00
|
|
|
for plugin in vars['es_plugins']
|
|
|
|
|
plugin = plugin['plugin']
|
2015-12-14 19:34:09 +00:00
|
|
|
|
|
|
|
|
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
|
|
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe command('curl -s localhost:9201/_nodes/plugins?pretty=true | grep '+plugin) do
|
|
|
|
|
its(:exit_status) { should eq 0 }
|
|
|
|
|
end
|
2016-07-23 20:18:58 +01:00
|
|
|
|
2016-07-23 19:51:53 +01:00
|
|
|
describe file('/usr/share/elasticsearch/plugins/'+plugin) do
|
|
|
|
|
it { should be_directory }
|
|
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
end
|
2015-12-14 19:34:09 +00:00
|
|
|
end
|
2018-06-19 12:15:10 +02:00
|
|
|
end
|