[meta] refactor kitchen tests (#765)
* [meta] refactor kitchen tests This commit update kitchen tests to match important feature to test: - default: test a deployment with all default values - license: test a deployment with a license and default values - trial: test a deployment with security enabled and trial license - oss: test a deployment with oss version and default values (6.x only) - upgrade: test an upgrade from a previous version - oss-upgrade: test an upgrade with oss version (6.x only) - oss-to-default-upgrade: test an upgrade from previous oss to latest default version - custom_config: test a deployment with custom config files - security: test a deployment with security enabled * [meta] fix license test
This commit is contained in:
parent
78e805e6cb
commit
d3e394b071
43 changed files with 272 additions and 406 deletions
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
require 'shared_spec'
|
||||
|
||||
shared_examples 'oss::init' do |vars|
|
||||
shared_examples 'custom_config::init' do |vars|
|
||||
describe file("/etc/elasticsearch/log4j2.properties") do
|
||||
it { should be_file }
|
||||
it { should be_owned_by 'root' }
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
require 'spec_helper'
|
||||
require 'json'
|
||||
vars = JSON.parse(File.read('/tmp/vars.json'))
|
||||
|
||||
shared_examples 'issue_test::init' do |vars|
|
||||
|
||||
#Add custom tests here for the issue-test.yml test
|
||||
|
||||
end
|
||||
|
||||
27
test/integration/helpers/serverspec/license_spec.rb
Normal file
27
test/integration/helpers/serverspec/license_spec.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
require 'spec_helper'
|
||||
require 'json'
|
||||
require 'pathname'
|
||||
vars = JSON.parse(File.read('/tmp/vars.json'))
|
||||
|
||||
es_api_url = "#{vars['es_api_scheme']}://localhost:#{vars['es_api_port']}"
|
||||
username = vars['es_api_basic_auth_username']
|
||||
password = vars['es_api_basic_auth_password']
|
||||
es_keystore = Pathname.new(vars['es_ssl_keystore']).basename.to_s
|
||||
es_truststore = Pathname.new(vars['es_ssl_truststore']).basename.to_s
|
||||
|
||||
if vars['es_major_version'] == '7.x'
|
||||
es_license_api = "_license"
|
||||
else
|
||||
es_license_api = "_xpack/license"
|
||||
end
|
||||
|
||||
shared_examples 'license::init' do |vars|
|
||||
describe 'License check' do
|
||||
result = curl_json("#{es_api_url}/#{es_license_api}", username=username, password=password)
|
||||
it 'should list the license issued by Elastic' do
|
||||
expect(result['license']['status']).to eq('active')
|
||||
expect(result['license']['type']).to eq('trial')
|
||||
expect(result['license']['issued_to']).to eq('Elastic - INTERNAL (non-production environments)')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
shared_examples 'oss_to_xpack_upgrade::init' do |vars|
|
||||
end
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
shared_examples 'oss_upgrade::init' do |vars|
|
||||
end
|
||||
|
|
@ -15,7 +15,7 @@ else
|
|||
es_security_api = "_xpack/security"
|
||||
end
|
||||
|
||||
shared_examples 'xpack_upgrade::init' do |vars|
|
||||
shared_examples 'security::init' do |vars|
|
||||
#Test users file, users_roles and roles.yml
|
||||
describe file("/etc/elasticsearch/users_roles") do
|
||||
it { should be_owned_by 'root' }
|
||||
|
|
@ -39,12 +39,9 @@ shared_examples 'xpack_upgrade::init' do |vars|
|
|||
describe file("/etc/elasticsearch/elasticsearch.yml") do
|
||||
if vars['es_major_version'] == '7.x'
|
||||
it { should contain 'security.authc.realms.file.file1.order: 0' }
|
||||
it { should contain 'security.authc.realms.native.native1.order: 1' }
|
||||
else
|
||||
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' }
|
||||
it { should contain 'security.authc.realms.native1.type: native' }
|
||||
end
|
||||
it { should contain 'xpack.security.transport.ssl.enabled: true' }
|
||||
it { should contain 'xpack.security.http.ssl.enabled: true' }
|
||||
|
|
@ -56,18 +53,10 @@ shared_examples 'xpack_upgrade::init' do |vars|
|
|||
describe file("/etc/elasticsearch/role_mapping.yml") do
|
||||
it { should be_owned_by 'root' }
|
||||
it { should contain 'power_user:' }
|
||||
it { should contain '- cn=admins,dc=example,dc=com' }
|
||||
it { should contain 'user:' }
|
||||
it { should contain '- cn=admins,dc=example,dc=com' }
|
||||
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
|
||||
expect(curl_json(es_api_url, username='kibana4_server', password='changeMe')['version']['number']).to eq(vars['es_version'])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'security users' do
|
||||
result = curl_json("#{es_api_url}/#{es_security_api}/user", username=username, password=password)
|
||||
it 'should have the elastic user' do
|
||||
|
|
@ -80,11 +69,6 @@ shared_examples 'xpack_upgrade::init' do |vars|
|
|||
expect(result['kibana']['roles']).to eq(['kibana_system'])
|
||||
expect(result['kibana']['enabled']).to eq(true)
|
||||
end
|
||||
it 'should have the kibana_server user' do
|
||||
expect(result['kibana4_server']['username']).to eq('kibana4_server')
|
||||
expect(result['kibana4_server']['roles']).to eq(['kibana4_server'])
|
||||
expect(result['kibana4_server']['enabled']).to eq(true)
|
||||
end
|
||||
it 'should have the logstash user' do
|
||||
expect(result['logstash_system']['username']).to eq('logstash_system')
|
||||
expect(result['logstash_system']['roles']).to eq(['logstash_system'])
|
||||
|
|
@ -92,12 +76,6 @@ shared_examples 'xpack_upgrade::init' do |vars|
|
|||
end
|
||||
end
|
||||
|
||||
describe 'logstash_system access check' do
|
||||
it 'should be reported as version '+vars['es_version'] do
|
||||
expect(curl_json(es_api_url, username='logstash_system', password='aNewLogstashPassword')['version']['number']).to eq(vars['es_version'])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'SSL certificate check' do
|
||||
certificates = curl_json("#{es_api_url}/_ssl/certificates", username=username, password=password)
|
||||
it 'should list the keystore file' do
|
||||
Loading…
Add table
Add a link
Reference in a new issue