Support for plugin diffs + improved testing on minor upgrades + fixes

This commit is contained in:
Dale McDiarmid 2017-03-16 21:06:17 +00:00
parent 4e8af6ced5
commit 1bc817a378
17 changed files with 155 additions and 54 deletions

View file

@ -1,6 +1,6 @@
require 'spec_helper'
shared_examples 'config::init' do |es_version|
shared_examples 'config::init' do |es_version,plugins|
describe user('elasticsearch') do
it { should exist }
@ -28,14 +28,14 @@ shared_examples 'config::init' do |es_version|
#test configuration parameters have been set - test all appropriately set in config file
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
it { should contain 'http.port: 9201' }
it { should contain 'transport.tcp.port: 9301' }
it { should contain 'node.data: false' }
it { should contain 'http.port: 9401' }
it { should contain 'transport.tcp.port: 9501' }
it { should contain 'node.data: true' }
it { should contain 'node.master: true' }
it { should contain 'cluster.name: custom-cluster' }
it { should contain 'node.name: node1' }
it { should contain 'bootstrap.memory_lock: true' }
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' }
it { should contain 'bootstrap.memory_lock: false' }
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9501' }
it { should contain 'path.conf: /etc/elasticsearch/node1' }
it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' }
it { should contain 'path.logs: /opt/elasticsearch/logs/localhost-node1' }
@ -63,27 +63,47 @@ shared_examples 'config::init' do |es_version|
end
#test we started on the correct port was used
describe command('curl -s "localhost:9201"') do
describe command('curl -s "localhost:9401"') do
#TODO: This is returning an empty string
#its(:stdout) { should match /\"status\" : 200/ }
its(:exit_status) { should eq 0 }
end
#test to make sure mlock was applied
describe command('curl -s "localhost:9201/_nodes/process?pretty" | grep mlockall') do
its(:stdout) { should match /true/ }
describe command('curl -s "localhost:9401/_nodes/process?pretty" | grep mlockall') do
its(:stdout) { should match /false/ }
its(:exit_status) { should eq 0 }
end
describe 'version check' do
it 'should be reported as version '+es_version do
command = command('curl -s localhost:9201 | grep number')
command = command('curl -s localhost:9401 | grep number')
expect(command.stdout).to match(es_version)
expect(command.exit_status).to eq(0)
end
end
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
describe file('/etc/init.d/elasticsearch') do
it { should_not exist }
end

View file

@ -74,12 +74,13 @@ shared_examples 'package::init' do |es_version,plugins|
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
#confirm plugins are installed and the correct version
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
its(:exit_status) { should eq 0 }
end
end
describe file('/etc/init.d/elasticsearch') do
it { should_not exist }
end

View file

@ -40,7 +40,7 @@ shared_examples 'xpack::init' do |es_version,plugins|
describe 'version check' do
it 'should be reported as version '+es_version do
command = command('curl -s localhost:9200 -u es_admin:changeMe | grep number')
command = command('curl -s localhost:9200 -u es_admin:changeMeAgain | grep number')
expect(command.stdout).to match(es_version)
expect(command.exit_status).to eq(0)
end
@ -79,7 +79,7 @@ shared_examples 'xpack::init' do |es_version,plugins|
#Test if x-pack is activated
describe 'x-pack activation' do
it 'should be activated and valid' do
command = command('curl -s localhost:9200/_license?pretty=true -u es_admin:changeMe')
command = command('curl -s localhost:9200/_license?pretty=true -u es_admin:changeMeAgain')
expect(command.stdout).to match('"status" : "active"')
expect(command.exit_status).to eq(0)
end
@ -90,7 +90,7 @@ shared_examples 'xpack::init' do |es_version,plugins|
it { should be_owned_by 'elasticsearch' }
end
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true -u es_admin:changeMe | grep x-pack') do
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true -u es_admin:changeMeAgain | grep x-pack') do
its(:exit_status) { should eq 0 }
end
@ -110,7 +110,7 @@ shared_examples 'xpack::init' do |es_version,plugins|
it { should be_owned_by 'elasticsearch' }
end
describe command('curl -s -u es_admin:changeMe localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
describe command('curl -s localhost:9200/_nodes/plugins -u es_admin:changeMeAgain | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
its(:exit_status) { should eq 0 }
end
end
@ -137,19 +137,11 @@ shared_examples 'xpack::init' do |es_version,plugins|
#Test native roles and users are loaded
describe command('curl -s localhost:9200/_xpack/security/user -u es_admin:changeMe | md5sum | grep 243b362bd47623c0b91a1fafbce2b6f5') do
describe command('curl -s localhost:9200/_xpack/security/user -u es_admin:changeMeAgain | md5sum | grep 74bcc9f9534b253c1204e264df21496c') do
its(:exit_status) { should eq 0 }
end
describe command('curl -s localhost:9200/_xpack/security/user -u es_admin:changeMe | grep "{\"elastic\":{\"username\":\"elastic\",\"roles\":\[\"superuser\"\],\"full_name\":null,\"email\":null,\"metadata\":{\"_reserved\":true},\"enabled\":true},\"kibana\":{\"username\":\"kibana\",\"roles\":\[\"kibana\"\],\"full_name\":null,\"email\":null,\"metadata\":{\"_reserved\":true},\"enabled\":true},\"kibana4_server\":{\"username\":\"kibana4_server\",\"roles\":\[\"kibana4_server\"\],\"full_name\":null,\"email\":null,\"metadata\":{},\"enabled\":true}}"') do
its(:exit_status) { should eq 0 }
end
describe command('curl -s localhost:9200/_xpack/security/role -u es_admin:changeMe | grep "{\"superuser\":{\"cluster\":\[\"all\"\],\"indices\":\[{\"names\":\[\"\*\"\],\"privileges\":\[\"all\"\]}\],\"run_as\":\[\"\*\"\],\"metadata\":{\"_reserved\":true}},\"transport_client\":{\"cluster\":\[\"transport_client\"\],\"indices\":\[\],\"run_as\":\[\],\"metadata\":{\"_reserved\":true}},\"kibana_user\":{\"cluster\":\[\"monitor\"\],\"indices\":\[{\"names\":\[\".kibana\*\"\],\"privileges\":\[\"manage\",\"read\",\"index\",\"delete\"\]}\],\"run_as\":\[\],\"metadata\":{\"_reserved\":true}},\"monitoring_user\":{\"cluster\":\[\],\"indices\":\[{\"names\":\[\"\.marvel-es-\*\",\".monitoring-\*\"\],\"privileges\":\[\"read\"\]}\],\"run_as\":\[\],\"metadata\":{\"_reserved\":true}},\"remote_monitoring_agent\":{\"cluster\":\[\"manage_index_templates\",\"manage_ingest_pipelines\",\"monitor\"\],\"indices\":\[{\"names\":\[\"\.marvel-es-\*\",\"\.monitoring-\*\"\],\"privileges\":\[\"all\"\]}\],\"run_as\":\[\],\"metadata\":{\"_reserved\":true}},\"ingest_admin\":{\"cluster\":\[\"manage_index_templates\",\"manage_pipeline\"\],\"indices\":\[\],\"run_as\":\[\],\"metadata\":{\"_reserved\":true}},\"reporting_user\":{\"cluster\":\[\],\"indices\":\[{\"names\":\[\"\.reporting-\*\"\],\"privileges\":\[\"read\",\"write\"\]}\],\"run_as\":\[\],\"metadata\":{\"_reserved\":true}},\"logstash\":{\"cluster\":\[\"manage_index_templates\"\],\"indices\":\[{\"names\":\[\"logstash-\*\"\],\"privileges\":\[\"write\",\"delete\",\"create_index\"\]}\],\"run_as\":\[\],\"metadata\":{}}}"') do
its(:exit_status) { should eq 0 }
end
describe command('curl -s localhost:9200/_xpack/security/role -u es_admin:changeMe | md5sum | grep 78a0696c9c9690042cec2c1f16860cfc') do
describe command('curl -s localhost:9200/_xpack/security/role -u es_admin:changeMeAgain | md5sum | grep 2bf3ffbb9cabf26bb25de6334c4da323') do
its(:exit_status) { should eq 0 }
end
@ -165,7 +157,7 @@ shared_examples 'xpack::init' do |es_version,plugins|
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" -u es_admin:changeMe')
command = command('curl -s "localhost:9200/_template/basic" -u es_admin:changeMeAgain')
expect(command.stdout).to match(/basic/)
expect(command.exit_status).to eq(0)
end
@ -174,7 +166,7 @@ shared_examples 'xpack::init' do |es_version,plugins|
#This is possibly subject to format changes in the response across versions so may fail in the future
describe 'Template Contents Correct' do
it 'should be reported as being installed', :retry => 3, :retry_wait => 10 do
command = command('curl -s "localhost:9200/_template/basic" -u es_admin:changeMe | md5sum')
command = command('curl -s "localhost:9200/_template/basic" -u es_admin:changeMeAgain | md5sum')
expect(command.stdout).to match(/153b1a45daf48ccee80395b85c61e332/)
end
end