Update tests to work with dynamic es_versions

This commit is contained in:
Michael Russell 2018-01-31 08:14:24 +01:00
parent 92244a7a71
commit 94b059080b
No known key found for this signature in database
GPG key ID: A90C1696496085FE
23 changed files with 127 additions and 65 deletions

View file

@ -1,6 +1,6 @@
require 'spec_helper'
shared_examples 'config::init' do |es_version,plugins|
shared_examples 'config::init' do |vars|
describe user('elasticsearch') do
it { should exist }
@ -77,20 +77,21 @@ shared_examples 'config::init' do |es_version,plugins|
describe 'version check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9401 | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
for plugin in plugins
for plugin in vars['es_plugins']
plugin = plugin['plugin']
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
describe command('curl -s localhost:9401/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 0 }
end
end
@ -100,7 +101,7 @@ shared_examples 'config::init' do |es_version,plugins|
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
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"ingest-geoip","version":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 1 }
end

View file

@ -1,6 +1,8 @@
require 'spec_helper'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'issue_test::init' do |es_version,plugins|
shared_examples 'issue_test::init' do |vars|
#Add custom tests here for the issue-test.yml test

View file

@ -1,6 +1,8 @@
require 'spec_helper'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'multi::init' do |es_version,plugins|
shared_examples 'multi::init' do |vars|
describe user('elasticsearch') do
it { should exist }
@ -154,22 +156,23 @@ shared_examples 'multi::init' do |es_version,plugins|
end
describe 'version check on master' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
describe 'version check on data' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9201 | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
for plugin in plugins
for plugin in vars['es_plugins']
plugin = plugin['plugin']
describe command('curl -s localhost:9200/_nodes/plugins?pretty=true | grep '+plugin) do
its(:exit_status) { should eq 0 }

View file

@ -1,6 +1,8 @@
require 'spec_helper'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'package::init' do |es_version,plugins|
shared_examples 'package::init' do |vars|
describe user('elasticsearch') do
it { should exist }
@ -56,9 +58,9 @@ shared_examples 'package::init' do |es_version,plugins|
end
describe 'version check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
@ -69,13 +71,14 @@ shared_examples 'package::init' do |es_version,plugins|
end
for plugin in plugins
for plugin in vars['es_plugins']
plugin = plugin['plugin']
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:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 0 }
end
end

View file

@ -8,4 +8,4 @@ RSpec.configure do |config|
config.verbose_retry = true
# show exception that triggers a retry if verbose_retry is set to true
config.display_try_failure_messages = true
end
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
shared_examples 'standard::init' do |es_version,plugins|
shared_examples 'standard::init' do |vars|
describe user('elasticsearch') do
it { should exist }
@ -33,7 +33,11 @@ shared_examples 'standard::init' do |es_version,plugins|
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
it { should contain 'node.name: localhost-node1' }
it { should contain 'cluster.name: elasticsearch' }
it { should contain 'path.conf: /etc/elasticsearch/node1' }
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
it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
end
@ -45,9 +49,9 @@ shared_examples 'standard::init' do |es_version,plugins|
end
describe 'version check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
@ -76,13 +80,15 @@ shared_examples 'standard::init' do |es_version,plugins|
it { should_not exist }
end
for plugin in plugins
for plugin in vars['es_plugins']
plugin = plugin['plugin']
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:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 0 }
end
end

View file

@ -1,6 +1,8 @@
require 'spec_helper'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'xpack::init' do |es_version,plugins|
shared_examples 'xpack::init' do |vars|
describe user('elasticsearch') do
it { should exist }
@ -39,9 +41,9 @@ shared_examples 'xpack::init' do |es_version,plugins|
end
describe 'version check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 -u es_admin:changeMeAgain | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
@ -104,13 +106,15 @@ shared_examples 'xpack::init' do |es_version,plugins|
it { should be_owned_by 'elasticsearch' }
end
for plugin in plugins
for plugin in vars['es_plugins']
plugin = plugin['plugin']
describe file('/usr/share/elasticsearch/plugins/'+plugin) do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe command('curl -s localhost:9200/_nodes/plugins -u es_admin:changeMeAgain | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
describe command('curl -s localhost:9200/_nodes/plugins -u es_admin:changeMeAgain | grep \'"name":"'+plugin+'","version":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 0 }
end
end
@ -203,9 +207,9 @@ shared_examples 'xpack::init' do |es_version,plugins|
#check accounts are correct i.e. we can auth and they have the correct roles
describe 'kibana4_server access check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200/ -u kibana4_server:changeMe | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
@ -216,9 +220,9 @@ shared_examples 'xpack::init' do |es_version,plugins|
describe 'logstash_system access check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200/ -u logstash_system:aNewLogstashPassword | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
@ -228,9 +232,9 @@ shared_examples 'xpack::init' do |es_version,plugins|
end
describe 'kibana access check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200/ -u kibana:changeme | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
shared_examples 'xpack_standard::init' do |es_version,plugins|
shared_examples 'xpack_standard::init' do |vars|
describe user('elasticsearch') do
it { should exist }
@ -42,9 +42,9 @@ shared_examples 'xpack_standard::init' do |es_version,plugins|
end
describe 'version check' do
it 'should be reported as version '+es_version do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(es_version)
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
@ -107,13 +107,15 @@ shared_examples 'xpack_standard::init' do |es_version,plugins|
it { should be_owned_by 'elasticsearch' }
end
for plugin in plugins
for plugin in vars['es_plugins']
plugin = plugin['plugin']
describe file('/usr/share/elasticsearch/plugins/'+plugin) do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+es_version+'"\'') do
describe command('curl -s localhost:9200/_nodes/plugins | grep \'"name":"'+plugin+'","version":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 0 }
end
end