Move all shared tests into the shared test helper

This commit is contained in:
Michael Russell 2018-06-19 21:17:10 +02:00
parent 9673fe4679
commit c325ff79fa
No known key found for this signature in database
GPG key ID: A90C1696496085FE
25 changed files with 205 additions and 611 deletions

View file

@ -1,40 +0,0 @@
---
#Test explicit setting of parameters and variables
- name: Elasticsearch Config initial
hosts: localhost
tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
#expand to all available parameters
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_user_id: 333, es_group_id: 333, es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.memory_lock: false } }
vars:
es_enable_xpack: false
es_scripts: false
es_templates: false
es_version_lock: false
es_heap_size: 1g
es_api_port: 9201
es_plugins:
- plugin: ingest-geoip
#Modify the above configuration. Final test should evaluate this configuration. Also tests the plugins are added and removed.
- name: Elasticsearch Config test modify
hosts: localhost
tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
#expand to all available parameters
- { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_user_id: 333, es_group_id: 333, es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9501", http.port: 9401, transport.tcp.port: 9501, node.data: true, node.master: true, bootstrap.memory_lock: true } }
vars:
es_enable_xpack: false
es_scripts: false
es_templates: false
es_version_lock: false
es_heap_size: 1g
#add a custom log4j file
es_config_log4j2: "./files/logging/log4j2.properties.custom.j2"
es_api_port: 9401
es_max_threads: 3000
es_plugins:
- plugin: ingest-attachment
- plugin: ingest-user-agent

View file

@ -1,2 +0,0 @@
---
- host: test-kitchen

View file

@ -1,8 +0,0 @@
require 'config_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'Config Tests' do
include_examples 'config::init', vars
end

View file

@ -8,21 +8,21 @@ shared_examples 'multi::init' do |vars|
it { should be_running }
end
#test configuration parameters have been set - test all appropriately set in config file
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should be_file }
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' }
it { should contain 'node.name: localhost-node1' }
it { should contain "node.name: localhost-#{vars['es_instance_name']}" }
it { should_not contain 'bootstrap.memory_lock: true' }
if vars['es_major_version'] == '6.x'
it { should_not contain 'path.conf: /etc/elasticsearch/node1' }
it { should_not contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
else
it { should contain 'path.conf: /etc/elasticsearch/node1' }
it { should contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
end
it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
it { should contain "path.data: /opt/elasticsearch/data-1/localhost-#{vars['es_instance_name']},/opt/elasticsearch/data-2/localhost-#{vars['es_instance_name']}" }
it { should contain "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
end
@ -58,9 +58,9 @@ shared_examples 'multi::init' do |vars|
end
#test we started on the correct port was used for node 1
describe 'node1 started' do
describe "#{vars['es_instance_name']} started" do
it 'node should be running', :retry => 3, :retry_wait => 10 do
expect(curl_json('http://localhost:9201')['name']).to eq('localhost-node1')
expect(curl_json('http://localhost:9201')['name']).to eq("localhost-#{vars['es_instance_name']}")
end
end
@ -81,13 +81,13 @@ shared_examples 'multi::init' do |vars|
it { should be_owned_by 'elasticsearch' }
end
describe file('/opt/elasticsearch/data-1/localhost-node1') do
describe file("/opt/elasticsearch/data-1/localhost-#{vars['es_instance_name']}") do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/opt/elasticsearch/data-2/localhost-node1') do
describe file("/opt/elasticsearch/data-2/localhost-#{vars['es_instance_name']}") do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
@ -99,7 +99,7 @@ shared_examples 'multi::init' do |vars|
end
#test to make sure mlock was not applied
describe command('curl -s "localhost:9201/_nodes/localhost-node1/process?pretty=true" | grep mlockall') do
describe command("curl -s 'localhost:9201/_nodes/localhost-#{vars['es_instance_name']}/process?pretty=true' | grep mlockall") do
its(:stdout) { should match /false/ }
its(:exit_status) { should eq 0 }
end

View file

@ -1,105 +1,13 @@
require 'spec_helper'
shared_examples 'oss::init' do |vars|
describe user('elasticsearch') do
it { should exist }
end
describe service('node1_elasticsearch') do
it { should be_running }
end
describe package(vars['es_package_name']) do
it { should be_installed }
end
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/elasticsearch/node1/log4j2.properties') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/log4j2.properties") do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
it { should_not contain 'CUSTOM LOG4J FILE' }
end
describe file('/etc/elasticsearch/node1/jvm.options') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/jvm.options") do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
it { should be_owned_by vars['es_user'] }
end
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
it { should contain 'node.name: localhost-node1' }
it { should contain 'cluster.name: elasticsearch' }
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
describe 'Node listening' do
it 'listening in port 9200' do
expect(port 9200).to be_listening
end
end
describe 'version check' do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
describe file('/etc/init.d/elasticsearch') do
it { should_not exist }
end
if ['debian', 'ubuntu'].include?(os[:family])
describe file('/etc/default/elasticsearch') do
its(:content) { should match '' }
end
end
if ['centos', 'redhat'].include?(os[:family])
describe file('/etc/sysconfig/elasticsearch') do
its(:content) { should match '' }
end
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
for plugin in vars['es_plugins']
name = plugin['plugin']
describe file('/usr/share/elasticsearch/plugins/'+name) do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
it 'should be installed and the right version' do
plugins = curl_json('http://localhost:9200/_nodes/plugins')
version = nil
node, data = plugins['nodes'].first
data['plugins'].each do |plugin|
if plugin['name'] == name
version = plugin['version']
end
end
expect(version).to eql(vars['es_version'])
end
end
end

View file

@ -1,12 +1,4 @@
require 'spec_helper'
shared_examples 'oss_to_xpack_upgrade::init' do |vars|
describe 'version check' do
it 'should be reported as version '+vars['es_version'] do
expect(curl_json('http://localhost:9200', username='elastic', password='changeme')['version']['number']).to eq(vars['es_version'])
end
it 'should be be running the standard (xpack) version' do
expect(curl_json('http://localhost:9200/_xpack', username='elastic', password='changeme')['tagline']).to eq('You know, for X')
end
end
end

View file

@ -1,9 +1,4 @@
require 'spec_helper'
shared_examples 'oss_upgrade::init' do |vars|
describe 'version check' do
it 'should be reported as version '+vars['es_version'] do
expect(curl_json('http://localhost:9200')['version']['number']).to eq(vars['es_version'])
end
end
end

View file

@ -18,11 +18,57 @@ families = {
family = families[vars['ansible_os_family']]
es_api_url = "http://localhost:#{vars['es_api_port']}"
username = vars['es_api_basic_auth_username']
password = vars['es_api_basic_auth_password']
shared_examples 'shared::init' do |vars|
describe 'version check' do
it 'should be reported as version '+vars['es_version'] do
expect(curl_json(es_api_url)['version']['number']).to eq(vars['es_version'])
expect(curl_json(es_api_url, username=username, password=password)['version']['number']).to eq(vars['es_version'])
end
end
describe 'xpack checks' do
if vars['es_enable_xpack']
it 'should be be running the xpack version' do
expect(curl_json("#{es_api_url}/_xpack", username=username, password=password)['tagline']).to eq('You know, for X')
end
it 'xpack should be activated' do
expect(curl_json("#{es_api_url}/_license", username=username, password=password)['license']['status']).to eq('active')
end
features = curl_json("#{es_api_url}/_xpack", username=username, password=password)
curl_json("#{es_api_url}/_xpack", username=username, password=password)['features'].each do |feature,values|
enabled = vars['es_xpack_features'].include? feature
status = if enabled then 'enabled' else 'disabled' end
it "the xpack feature '#{feature}' to be #{status}" do
expect(values['enabled'] = enabled)
end
end
# X-Pack is no longer installed as a plugin in elasticsearch
if vars['es_major_version'] == '5.x'
describe file('/usr/share/elasticsearch/plugins/x-pack') do
it { should be_directory }
it { should be_owned_by vars['es_user'] }
end
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/x-pack") do
it { should be_directory }
it { should be_owned_by vars['es_user'] }
end
describe 'x-pack-core plugin' do
it 'should be installed with the correct version' do
plugins = curl_json("#{es_api_url}/_nodes/plugins", username=username, password=password)
node, data = plugins['nodes'].first
version = 'plugin not found'
name = 'x-pack'
data['plugins'].each do |plugin|
if plugin['name'] == name
version = plugin['version']
end
end
expect(version).to eql(vars['es_version'])
end
end
end
end
end
describe user(vars['es_user']) do
@ -39,7 +85,7 @@ shared_examples 'shared::init' do |vars|
it { should be_installed }
end
describe service('node1_elasticsearch') do
describe service("#{vars['es_instance_name']}_elasticsearch") do
it { should be_running }
end
@ -47,36 +93,31 @@ shared_examples 'shared::init' do |vars|
it { should be_listening.with('tcp') }
end
# if vars['es_templates']
# describe file('/etc/elasticsearch/templates') do
# it { should be_directory }
# it { should be_owned_by vars['es_user'] }
# end
# describe file('/etc/elasticsearch/templates/basic.json') do
# it { should be_file }
# it { should be_owned_by vars['es_user'] }
# end
# describe 'Template Installed' do
# it 'should be reported as being installed', :retry => 3, :retry_wait => 10 do
# command = command('curl localhost:9200/_template/basic')
# expect(command.stdout).to match(/basic/)
# expect(command.exit_status).to eq(0)
# end
# end
# describe 'Template Installed' do
# it 'should be reported as being installed', :retry => 3, :retry_wait => 10 do
# command = command('curl localhost:9201/_template/basic')
# expect(command.stdout).to match(/basic/)
# expect(command.exit_status).to eq(0)
# end
# end
# end
if vars['es_templates']
describe file('/etc/elasticsearch/templates') do
it { should be_directory }
it { should be_owned_by vars['es_user'] }
end
describe file('/etc/elasticsearch/templates/basic.json') do
it { should be_file }
it { should be_owned_by vars['es_user'] }
end
#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
template = curl_json("#{es_api_url}/_template/basic", username=username, password=password)
expect(template.key?('basic'))
expect(template['basic']['settings']['index']['number_of_shards']).to eq("1")
expect(template['basic']['mappings']['type1']['_source']['enabled']).to eq(false)
end
end
end
if vars['es_scripts']
describe file('/etc/elasticsearch/node1/scripts') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/scripts") do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/elasticsearch/node1/scripts/calculate-score.groovy') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/scripts/calculate-score.groovy") do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
end
@ -97,32 +138,33 @@ shared_examples 'shared::init' do |vars|
it { should_not exist }
end
vars['es_plugins'].each do |plugin|
name = plugin['plugin']
describe file('/usr/share/elasticsearch/plugins/'+name) do
it { should be_directory }
it { should be_owned_by vars['es_user'] }
end
it 'should be installed and the right version' do
plugins = curl_json("#{es_api_url}/_nodes/plugins")
version = nil
_node, data = plugins['nodes'].first
data['plugins'].each do |p|
version = p['version'] if p['name'] == name
if vars.key?('es_plugins')
vars['es_plugins'].each do |plugin|
name = plugin['plugin']
describe file('/usr/share/elasticsearch/plugins/'+name) do
it { should be_directory }
it { should be_owned_by vars['es_user'] }
end
it 'should be installed and the right version' do
plugins = curl_json("#{es_api_url}/_nodes/plugins", username=username, password=password)
version = nil
_node, data = plugins['nodes'].first
data['plugins'].each do |p|
version = p['version'] if p['name'] == name
end
expect(version).to eql(vars['es_version'])
end
expect(version).to eql(vars['es_version'])
end
end
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
it { should contain 'node.name: localhost-node1' }
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should contain "node.name: localhost-#{vars['es_instance_name']}" }
it { should contain 'cluster.name: elasticsearch' }
if vars['es_major_version'] == '6.x'
it { should_not contain 'path.conf: /etc/elasticsearch/node1' }
it { should_not contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
else
it { should contain 'path.conf: /etc/elasticsearch/node1' }
it { should contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
end
# it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' }
its(:content) { should match "path.data: /var/lib/elasticsearch/localhost-#{vars['es_instance_name']}" }
its(:content) { should match "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
end
end

View file

@ -1,138 +1,17 @@
require 'spec_helper'
shared_examples 'xpack::init' do |vars|
describe user('elasticsearch') do
it { should exist }
end
describe service('security_node_elasticsearch') do
it { should be_running }
end
describe package(vars['es_package_name']) do
it { should be_installed }
end
describe file('/etc/elasticsearch/security_node/elasticsearch.yml') do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/elasticsearch/security_node/log4j2.properties') do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/elasticsearch/security_node/elasticsearch.yml') do
it { should contain 'node.name: localhost-security_node' }
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should contain "node.name: localhost-#{vars['es_instance_name']}" }
it { should contain 'cluster.name: elasticsearch' }
if vars['es_major_version'] == '6.x'
it { should_not contain 'path.conf: /etc/elasticsearch/security_node' }
else
it { should contain 'path.conf: /etc/elasticsearch/security_node' }
end
it { should contain 'path.data: /var/lib/elasticsearch/localhost-security_node' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-security_node' }
it { should contain "path.data: /var/lib/elasticsearch/localhost-#{vars['es_instance_name']}" }
it { should contain "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
it { should contain 'xpack.security.enabled: false' }
it { should contain 'xpack.watcher.enabled: false' }
end
describe 'Node listening' do
it 'listening in port 9200' do
expect(port 9200).to be_listening
end
end
describe 'version check' do
it 'should be reported as version '+vars['es_version'] do
command = command('curl -s localhost:9200 | grep number')
expect(command.stdout).to match(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
describe file('/etc/init.d/elasticsearch') do
it { should_not exist }
end
if ['debian', 'ubuntu'].include?(os[:family])
describe file('/etc/default/elasticsearch') do
its(:content) { should match '' }
end
end
if ['centos', 'redhat'].include?(os[:family])
describe file('/etc/sysconfig/elasticsearch') do
its(:content) { should match '' }
end
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
#Xpack specific tests
describe file('/usr/share/elasticsearch/plugins') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
#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')
expect(command.stdout).to match('"status" : "active"')
expect(command.exit_status).to eq(0)
end
end
# X-Pack is no longer installed as a plugin in elasticsearch
if vars['es_major_version'] == '5.x'
describe file('/usr/share/elasticsearch/plugins/x-pack') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe 'x-pack-core plugin' do
it 'should be installed with the correct version' do
plugins = curl_json('http://localhost:9200/_nodes/plugins')
node, data = plugins['nodes'].first
version = 'plugin not found'
name = 'x-pack'
data['plugins'].each do |plugin|
if plugin['name'] == name
version = plugin['version']
end
end
expect(version).to eql(vars['es_version'])
end
end
describe file('/etc/elasticsearch/security_node/x-pack') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
end
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
describe command('curl -s localhost:9200/_xpack') do
its(:stdout_as_json) { should include('features' => include('security' => include('enabled' => false))) }
its(:stdout_as_json) { should include('features' => include('watcher' => include('enabled' => false))) }
its(:stdout_as_json) { should include('features' => include('graph' => include('enabled' => true))) }
its(:stdout_as_json) { should include('features' => include('monitoring' => include('enabled' => true))) }
its(:stdout_as_json) { should include('features' => include('ml' => include('enabled' => true))) }
end
end

View file

@ -3,152 +3,26 @@ require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
shared_examples 'xpack_upgrade::init' do |vars|
describe user('elasticsearch') do
it { should exist }
end
describe service('security_node_elasticsearch') do
it { should be_running }
end
describe package(vars['es_package_name']) do
it { should be_installed }
end
describe file('/etc/elasticsearch/security_node/elasticsearch.yml') do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/elasticsearch/security_node/log4j2.properties') do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/elasticsearch/security_node/elasticsearch.yml') do
it { should contain 'node.name: localhost-security_node' }
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should contain "node.name: localhost-#{vars['es_instance_name']}" }
it { should contain 'cluster.name: elasticsearch' }
if vars['es_major_version'] == '6.x'
it { should_not contain 'path.conf: /etc/elasticsearch/security_node' }
it { should_not contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
else
it { should contain 'path.conf: /etc/elasticsearch/security_node' }
end
it { should contain 'path.data: /var/lib/elasticsearch/localhost-security_node' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-security_node' }
end
describe 'Node listening' do
it 'listening in port 9200' do
expect(port 9200).to be_listening
end
end
describe 'version check' 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(vars['es_version'])
expect(command.exit_status).to eq(0)
end
end
describe file('/etc/init.d/elasticsearch') do
it { should_not exist }
end
if ['debian', 'ubuntu'].include?(os[:family])
describe file('/etc/default/elasticsearch') do
its(:content) { should match '' }
end
end
if ['centos', 'redhat'].include?(os[:family])
describe file('/etc/sysconfig/elasticsearch') do
its(:content) { should match '' }
end
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
# X-Pack is no longer installed as a plugin in elasticsearch
if vars['es_major_version'] == '5.x'
describe file('/usr/share/elasticsearch/plugins') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/usr/share/elasticsearch/plugins/x-pack') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
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
describe file('/usr/share/elasticsearch/plugins/x-pack') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe 'xpack plugin' do
it 'should be installed with the correct version' do
plugins = curl_json('http://localhost:9200/_nodes/plugins', username='es_admin', password='changeMeAgain')
node, data = plugins['nodes'].first
version = 'plugin not found'
name = 'x-pack'
data['plugins'].each do |plugin|
if plugin['name'] == name
version = plugin['version']
end
end
expect(version).to eql(vars['es_version'])
end
end
end
#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:changeMeAgain')
expect(command.stdout).to match('"status" : "active"')
expect(command.exit_status).to eq(0)
end
end
describe file('/etc/elasticsearch/security_node/x-pack') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
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":"'+vars['es_version']+'"\'') do
its(:exit_status) { should eq 0 }
it { should contain "path.conf: /etc/elasticsearch/#{vars['es_instance_name']}" }
end
it { should contain "path.data: /var/lib/elasticsearch/localhost-#{vars['es_instance_name']}" }
it { should contain "path.logs: /var/log/elasticsearch/localhost-#{vars['es_instance_name']}" }
end
#Test users file, users_roles and roles.yml
describe file('/etc/elasticsearch/security_node' + vars['es_xpack_conf_subdir'] + '/users_roles') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}#{vars['es_xpack_conf_subdir']}/users_roles") do
it { should be_owned_by 'elasticsearch' }
it { should contain 'admin:es_admin' }
it { should contain 'power_user:testUser' }
end
describe file('/etc/elasticsearch/security_node' + vars['es_xpack_conf_subdir'] + '/users') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}#{vars['es_xpack_conf_subdir']}/users") do
it { should be_owned_by 'elasticsearch' }
it { should contain 'testUser:' }
it { should contain 'es_admin:' }
@ -161,36 +35,7 @@ shared_examples 'xpack_upgrade::init' do |vars|
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" -u es_admin:changeMeAgain')
expect(command.stdout).to match(/basic/)
expect(command.exit_status).to eq(0)
end
end
#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
template = curl_json('http://localhost:9200/_template/basic', username='es_admin', password='changeMeAgain')
expect(template.key?('basic'))
expect(template['basic']['settings']['index']['number_of_shards']).to eq("1")
expect(template['basic']['mappings']['type1']['_source']['enabled']).to eq(false)
end
end
#Test contents of Elasticsearch.yml file
describe file('/etc/elasticsearch/security_node/elasticsearch.yml') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}/elasticsearch.yml") do
it { should contain 'security.authc.realms.file1.order: 0' }
it { should contain 'security.authc.realms.file1.type: file' }
it { should contain 'security.authc.realms.native1.order: 1' }
@ -198,7 +43,7 @@ shared_examples 'xpack_upgrade::init' do |vars|
end
#Test contents of role_mapping.yml
describe file('/etc/elasticsearch/security_node' + vars['es_xpack_conf_subdir'] + '/role_mapping.yml') do
describe file("/etc/elasticsearch/#{vars['es_instance_name']}#{vars['es_xpack_conf_subdir']}/role_mapping.yml") do
it { should be_owned_by 'elasticsearch' }
it { should contain 'power_user:' }
it { should contain '- cn=admins,dc=example,dc=com' }
@ -207,7 +52,6 @@ shared_examples 'xpack_upgrade::init' do |vars|
end
#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 '+vars['es_version'] do
command = command('curl -s localhost:9200/ -u kibana4_server:changeMe | grep number')
@ -257,4 +101,3 @@ shared_examples 'xpack_upgrade::init' do |vars|
end
end
end

View file

@ -5,19 +5,19 @@
- name: Simple Example
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- role: elasticsearch
es_instance_name: "security_node"
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
es_config:
xpack.security.enabled: True
xpack.security.authc.realms.file1.type: "file"
xpack.security.authc.realms.file1.order: 1
xpack.security.authc.realms.native1.type: "native"
xpack.security.authc.realms.native1.order: 0
- elasticsearch
vars:
es_instance_name: "security_node"
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
es_config:
xpack.security.enabled: True
xpack.security.authc.realms.file1.type: "file"
xpack.security.authc.realms.file1.order: 1
xpack.security.authc.realms.native1.type: "native"
xpack.security.authc.realms.native1.order: 0
es_heap_size: "1g"
es_enable_xpack: true
es_plugins:

View file

@ -4,7 +4,18 @@
hosts: localhost
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- elasticsearch
vars:
es_instance_name: "master"
es_data_dirs: ["/opt/elasticsearch/master"]
es_config:
discovery.zen.ping.unicast.hosts: "localhost:9300"
http.port: 9200
transport.tcp.port: 9300
node.data: false
node.master: true
bootstrap.memory_lock: true
es_enable_xpack: false
es_scripts: true
es_templates: true
@ -12,22 +23,13 @@
es_api_port: 9200
es_plugins:
- plugin: ingest-geoip
roles:
- role: elasticsearch
es_instance_name: "master"
es_data_dirs: ["/opt/elasticsearch/master"]
es_config:
discovery.zen.ping.unicast.hosts: "localhost:9300"
http.port: 9200
transport.tcp.port: 9300
node.data: false
node.master: true
bootstrap.memory_lock: true
- name: Elasticsearch Multi test - data on 9201
hosts: localhost
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- role: elasticsearch
vars:
es_enable_xpack: false
es_scripts: true
@ -36,15 +38,13 @@
es_api_port: 9201
es_plugins:
- plugin: ingest-geoip
roles:
- role: elasticsearch
es_instance_name: "node1"
es_data_dirs:
- "/opt/elasticsearch/data-1"
- "/opt/elasticsearch/data-2"
es_config:
discovery.zen.ping.unicast.hosts: "localhost:9300"
http.port: 9201
transport.tcp.port: 9301
node.data: true
node.master: false
es_instance_name: "node1"
es_data_dirs:
- "/opt/elasticsearch/data-1"
- "/opt/elasticsearch/data-2"
es_config:
discovery.zen.ping.unicast.hosts: "localhost:9300"
http.port: 9201
transport.tcp.port: 9301
node.data: true
node.master: false

View file

@ -1,22 +1,24 @@
---
- name: Standard test for single node setup. Tests idempotence.
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_instance_name: "node1" }
- elasticsearch
vars:
es_instance_name: "node1"
es_version: "{{ '6.2.4' if es_major_version == '6.x' else '5.6.9' }}" # This is set to an older version than the current default to force an upgrade
es_enable_xpack: false
es_heap_size: "1g"
- name: Standard test for single node setup. Tests idempotence.
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_instance_name: "node1" }
- elasticsearch
vars:
es_instance_name: "node1"
es_enable_xpack: true
es_api_basic_auth_username: elastic
es_api_basic_auth_password: changeme

View file

@ -1,7 +1,9 @@
require 'oss_to_xpack_upgrade_spec'
require 'shared_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'oss to xpack upgrade Tests' do
include_examples 'shared::init', vars
include_examples 'oss_to_xpack_upgrade::init', vars
end

View file

@ -1,7 +1,7 @@
---
- name: Standard test for single node setup. Tests idempotence.
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_instance_name: "node1" }
@ -12,7 +12,7 @@
- name: Standard test for single node setup. Tests idempotence.
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_instance_name: "node1" }

View file

@ -1,7 +1,9 @@
require 'oss_upgrade_spec'
require 'shared_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'oss upgrade Tests' do
include_examples 'oss_upgrade::init', vars
include_examples 'shared::init', vars
end

View file

@ -1,11 +1,12 @@
---
- name: Standard test for single node setup. Tests idempotence.
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_instance_name: "node1" }
- elasticsearch
vars:
es_instance_name: "node1"
es_enable_xpack: false
es_heap_size: "1g"
es_plugins:

View file

@ -1,9 +1,11 @@
require 'oss_spec'
require 'shared_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'OSS Tests' do
include_examples 'oss::init', vars
include_examples 'shared::init', vars
end

View file

@ -1,33 +0,0 @@
---
- name: Elasticsearch Package test intial
hosts: localhost
tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_config: { "http.port": 9200, "transport.tcp.port":9300, discovery.zen.ping.unicast.hosts: "localhost:9300" }, es_instance_name: "node1" }
vars:
es_enable_xpack: false
es_scripts: true
es_templates: true
es_heap_size: "1g"
es_api_port: 9200
es_plugins:
- plugin: ingest-geoip
#Tests the plugins have been correctly removed and ES can be upgraded between minor versions. All plugins will be removed and re-installed.
- name: Elasticsearch Package test modify
hosts: localhost
tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_config: { "http.port": 9200, "transport.tcp.port":9300, discovery.zen.ping.unicast.hosts: "localhost:9300" }, es_instance_name: "node1" }
vars:
es_enable_xpack: false
es_scripts: true
es_templates: true
es_heap_size: "1g"
es_api_port: 9200
es_plugins:
- plugin: ingest-attachment
- plugin: ingest-geoip

View file

@ -1,2 +0,0 @@
---
- host: test-kitchen

View file

@ -1,7 +0,0 @@
require 'package_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'Package Tests' do
include_examples 'package::init', vars
end

View file

@ -1,13 +1,21 @@
---
- name: Elasticsearch Xpack tests initial
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_api_port: 9200, es_config: { "http.port": 9200, "transport.tcp.port":9300, discovery.zen.ping.unicast.hosts: "localhost:9300",
"xpack.security.authc.realms.file1.type": "file","xpack.security.authc.realms.file1.order": 0, "xpack.security.authc.realms.native1.type": "native","xpack.security.authc.realms.native1.order": 1 },
es_instance_name: "security_node" }
- elasticsearch
vars:
es_instance_name: "node1"
es_api_port: 9200
es_config:
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: "localhost:9300"
xpack.security.authc.realms.file1.type: "file"
xpack.security.authc.realms.file1.order: 0
xpack.security.authc.realms.native1.type: "native"
xpack.security.authc.realms.native1.order: 1
es_heap_size: "1g"
es_templates: true
es_version: "{{ '6.2.4' if es_major_version == '6.x' else '5.6.9' }}" # This is set to an older version than the current default to force an upgrade
@ -103,22 +111,22 @@
#modifies the installation. Changes es_admin password and upgrades ES. Tests confirm the correct version is installed.
- name: Elasticsearch Xpack modify
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- role: elasticsearch
es_api_port: 9200
es_instance_name: "security_node"
es_config:
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: "localhost:9300"
xpack.security.enabled: True
xpack.security.authc.realms.file1.type: "file"
xpack.security.authc.realms.file1.order: 0
xpack.security.authc.realms.native1.type: "native"
xpack.security.authc.realms.native1.order: 1
- elasticsearch
vars:
es_api_port: 9200
es_instance_name: "node1"
es_config:
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: "localhost:9300"
xpack.security.enabled: True
xpack.security.authc.realms.file1.type: "file"
xpack.security.authc.realms.file1.order: 0
xpack.security.authc.realms.native1.type: "native"
xpack.security.authc.realms.native1.order: 1
es_heap_size: "1g"
es_templates: true
es_enable_xpack: true

View file

@ -1,7 +1,9 @@
require 'xpack_upgrade_spec'
require 'shared_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'Xpack upgrade Tests' do
include_examples 'shared::init', vars
include_examples 'xpack_upgrade::init', vars
end

View file

@ -2,10 +2,16 @@
---
- name: Elasticsearch Xpack tests - no security and manual download
hosts: localhost
tasks:
post_tasks:
- include: elasticsearch/test/integration/debug.yml
roles:
- { role: elasticsearch, es_api_port: 9200, es_config: { "http.port": 9200, "transport.tcp.port":9300, discovery.zen.ping.unicast.hosts: "localhost:9300" }, es_instance_name: "security_node" }
- role: elasticsearch
es_api_port: 9200
es_instance_name: "node1"
es_config:
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: "localhost:9300"
vars:
es_xpack_custom_url: "https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-{{ es_version }}.zip"
es_heap_size: 2g

View file

@ -1,7 +1,9 @@
require 'xpack_spec'
require 'shared_spec'
require 'json'
vars = JSON.parse(File.read('/tmp/vars.json'))
describe 'Xpack upgrade Tests' do
include_examples 'shared::init', vars
include_examples 'xpack::init', vars
end