111 lines
2.9 KiB
Ruby
111 lines
2.9 KiB
Ruby
require 'spec_helper'
|
|
|
|
shared_examples 'package::init' do |es_version,plugins|
|
|
|
|
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
|
|
|
|
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
|
|
it { should be_file }
|
|
it { should contain 'path.plugins: /usr/share/elasticsearch/plugins/node1' }
|
|
it { should contain 'http.port: 9200' }
|
|
it { should contain 'transport.tcp.port: 9300' }
|
|
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9300' }
|
|
end
|
|
|
|
describe file('/etc/elasticsearch/node1/scripts') do
|
|
it { should be_directory }
|
|
it { should be_owned_by 'elasticsearch' }
|
|
end
|
|
|
|
|
|
|
|
describe file('/etc/elasticsearch/node1/scripts/calculate-score.groovy') do
|
|
it { should be_file }
|
|
it { should be_owned_by 'elasticsearch' }
|
|
end
|
|
|
|
describe 'Node listening' do
|
|
it 'listening in port 9200' do
|
|
expect(port 9200).to be_listening
|
|
end
|
|
end
|
|
|
|
describe file('/etc/elasticsearch/templates') do
|
|
it { should be_directory }
|
|
it { should be_owned_by 'elasticsearch' }
|
|
end
|
|
|
|
describe file('/etc/elasticsearch/templates/basic.json') do
|
|
it { should be_file }
|
|
it { should be_owned_by 'elasticsearch' }
|
|
end
|
|
|
|
describe 'Template Installed' do
|
|
it 'should be reported as being installed', :retry => 3, :retry_wait => 10 do
|
|
command = command('curl -s "localhost:9200/_template/basic"')
|
|
expect(command.stdout).to match(/basic/)
|
|
expect(command.exit_status).to eq(0)
|
|
end
|
|
end
|
|
|
|
describe 'version check' do
|
|
it 'should be reported as version '+es_version do
|
|
command = command('curl -s localhost:9200 | grep number')
|
|
expect(command.stdout).to match(es_version)
|
|
expect(command.exit_status).to eq(0)
|
|
end
|
|
end
|
|
|
|
describe file('/usr/share/elasticsearch/plugins/node1') do
|
|
it { should be_directory }
|
|
it { should be_owned_by 'elasticsearch' }
|
|
end
|
|
|
|
|
|
for plugin in plugins
|
|
describe file('/usr/share/elasticsearch/plugins/node1/'+plugin) do
|
|
it { should be_directory }
|
|
it { should be_owned_by 'elasticsearch' }
|
|
end
|
|
|
|
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
|
|
its(:exit_status) { should eq 0 }
|
|
end
|
|
end
|
|
|
|
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
|
|
|
|
describe file('/etc/elasticsearch/logging.yml') do
|
|
it { should_not exist }
|
|
end
|
|
|
|
end
|
|
|