Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit d3e394b

Browse files
authored
[meta] refactor kitchen tests (elastic#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
1 parent 78e805e commit d3e394b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+272
-406
lines changed

.kitchen.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,31 +149,39 @@ platforms:
149149
use_sudo: false
150150

151151
suites:
152+
- name: custom-config
153+
provisioner:
154+
idempotency_test: true
155+
playbook: test/integration/custom-config.yml
156+
- name: default
157+
provisioner:
158+
playbook: test/integration/default.yml
159+
idempotency_test: true
160+
- name: license
161+
provisioner:
162+
playbook: test/integration/license.yml
163+
idempotency_test: true
152164
- name: oss
153165
provisioner:
154166
idempotency_test: true
155167
playbook: test/integration/oss.yml
156-
- name: oss-upgrade
168+
- name: oss-to-default-upgrade
157169
provisioner:
158-
playbook: test/integration/oss-upgrade.yml
170+
playbook: test/integration/oss-to-default-upgrade.yml
159171
idempotency_test: false
160-
- name: oss-to-xpack-upgrade
172+
- name: oss-upgrade
161173
provisioner:
162-
playbook: test/integration/oss-to-xpack-upgrade.yml
174+
playbook: test/integration/oss-upgrade.yml
163175
idempotency_test: false
164-
- name: xpack
176+
- name: security
165177
provisioner:
166-
playbook: test/integration/xpack.yml
178+
playbook: test/integration/security.yml
167179
idempotency_test: true
168-
- name: xpack-upgrade
180+
- name: trial
169181
provisioner:
170-
playbook: test/integration/xpack-upgrade.yml
171-
idempotency_test: false
172-
- name: issue-test
173-
provisioner:
174-
playbook: test/integration/issue-test.yml
175-
idempotency_test: false
176-
- name: xpack-upgrade-trial
182+
playbook: test/integration/trial.yml
183+
idempotency_test: false # es_xpack_trial is not idempotent currently
184+
- name: upgrade
177185
provisioner:
178-
playbook: test/integration/xpack-upgrade-trial.yml
186+
playbook: test/integration/upgrade.yml
179187
idempotency_test: false

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ default: build
22

33
SHELL:=/bin/bash -eux
44
export VERSION := 7.x
5-
PATTERN := xpack-ubuntu-1604
5+
PATTERN := default-ubuntu-1804
66

77
.PHONY: converge verify test login destroy list
88

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ This playbook uses [Kitchen](https://kitchen.ci/) for CI and local testing.
9797
### Running the tests
9898

9999
* Ensure you have checked out this repository to `elasticsearch`, not `ansible-elasticsearch`.
100-
* If you don't have a Gold or Platinum license to test with you can run the trial versions of the `xpack-upgrade` and `issue-test` suites by appending `-trial` to the `PATTERN` variable.
100+
* If you don't have a Gold or Platinum license to test with you can run the trial versions of the `xpack-upgrade` suites by appending `-trial` to the `PATTERN` variable.
101101
* You may need to explicitly specify `VERSION=7.x` if some suites are failing.
102102

103103
Install the ruby dependencies with bundler

test/integration/custom-config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Setup Elasticsearch with custom config files
3+
hosts: localhost
4+
post_tasks:
5+
- include: elasticsearch/test/integration/debug.yml
6+
roles:
7+
- elasticsearch
8+
vars:
9+
es_config_default: "test/integration/files/custom_config/elasticsearch"
10+
es_config_log4j2: "test/integration/files/custom_config/log4j2.properties"
11+
es_config_jvm: "test/integration/files/custom_config/jvm.options"
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
require 'xpack_upgrade_spec'
1+
require 'custom_config_spec'
22
require 'shared_spec'
33
require 'json'
44
vars = JSON.parse(File.read('/tmp/vars.json'))
55

6-
describe 'Xpack upgrade Tests' do
6+
describe 'Custom Config Tests' do
7+
include_examples 'custom_config::init', vars
78
include_examples 'shared::init', vars
8-
include_examples 'xpack_upgrade::init', vars
99
end

test/integration/default.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Setup Elasticsearch using default configuration
3+
hosts: localhost
4+
post_tasks:
5+
- include: elasticsearch/test/integration/debug.yml
6+
roles:
7+
- elasticsearch

test/integration/xpack/serverspec/default_spec.rb renamed to test/integration/default/serverspec/default_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
require 'json'
33
vars = JSON.parse(File.read('/tmp/vars.json'))
44

5-
describe 'Xpack upgrade Tests' do
5+
describe 'default tests' do
66
include_examples 'shared::init', vars
77
end

test/integration/helpers/serverspec/oss_spec.rb renamed to test/integration/helpers/serverspec/custom_config_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22
require 'shared_spec'
33

4-
shared_examples 'oss::init' do |vars|
4+
shared_examples 'custom_config::init' do |vars|
55
describe file("/etc/elasticsearch/log4j2.properties") do
66
it { should be_file }
77
it { should be_owned_by 'root' }

test/integration/helpers/serverspec/issue_test_spec.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require 'spec_helper'
2+
require 'json'
3+
require 'pathname'
4+
vars = JSON.parse(File.read('/tmp/vars.json'))
5+
6+
es_api_url = "#{vars['es_api_scheme']}://localhost:#{vars['es_api_port']}"
7+
username = vars['es_api_basic_auth_username']
8+
password = vars['es_api_basic_auth_password']
9+
es_keystore = Pathname.new(vars['es_ssl_keystore']).basename.to_s
10+
es_truststore = Pathname.new(vars['es_ssl_truststore']).basename.to_s
11+
12+
if vars['es_major_version'] == '7.x'
13+
es_license_api = "_license"
14+
else
15+
es_license_api = "_xpack/license"
16+
end
17+
18+
shared_examples 'license::init' do |vars|
19+
describe 'License check' do
20+
result = curl_json("#{es_api_url}/#{es_license_api}", username=username, password=password)
21+
it 'should list the license issued by Elastic' do
22+
expect(result['license']['status']).to eq('active')
23+
expect(result['license']['type']).to eq('trial')
24+
expect(result['license']['issued_to']).to eq('Elastic - INTERNAL (non-production environments)')
25+
end
26+
end
27+
end

test/integration/helpers/serverspec/oss_to_xpack_upgrade_spec.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/integration/helpers/serverspec/oss_upgrade_spec.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/integration/helpers/serverspec/xpack_upgrade_spec.rb renamed to test/integration/helpers/serverspec/security_spec.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
es_security_api = "_xpack/security"
1616
end
1717

18-
shared_examples 'xpack_upgrade::init' do |vars|
18+
shared_examples 'security::init' do |vars|
1919
#Test users file, users_roles and roles.yml
2020
describe file("/etc/elasticsearch/users_roles") do
2121
it { should be_owned_by 'root' }
@@ -39,12 +39,9 @@
3939
describe file("/etc/elasticsearch/elasticsearch.yml") do
4040
if vars['es_major_version'] == '7.x'
4141
it { should contain 'security.authc.realms.file.file1.order: 0' }
42-
it { should contain 'security.authc.realms.native.native1.order: 1' }
4342
else
4443
it { should contain 'security.authc.realms.file1.order: 0' }
4544
it { should contain 'security.authc.realms.file1.type: file' }
46-
it { should contain 'security.authc.realms.native1.order: 1' }
47-
it { should contain 'security.authc.realms.native1.type: native' }
4845
end
4946
it { should contain 'xpack.security.transport.ssl.enabled: true' }
5047
it { should contain 'xpack.security.http.ssl.enabled: true' }
@@ -56,18 +53,10 @@
5653
describe file("/etc/elasticsearch/role_mapping.yml") do
5754
it { should be_owned_by 'root' }
5855
it { should contain 'power_user:' }
59-
it { should contain '- cn=admins,dc=example,dc=com' }
6056
it { should contain 'user:' }
61-
it { should contain '- cn=admins,dc=example,dc=com' }
6257
end
6358

6459
#check accounts are correct i.e. we can auth and they have the correct roles
65-
describe 'kibana4_server access check' do
66-
it 'should be reported as version '+vars['es_version'] do
67-
expect(curl_json(es_api_url, username='kibana4_server', password='changeMe')['version']['number']).to eq(vars['es_version'])
68-
end
69-
end
70-
7160
describe 'security users' do
7261
result = curl_json("#{es_api_url}/#{es_security_api}/user", username=username, password=password)
7362
it 'should have the elastic user' do
@@ -80,24 +69,13 @@
8069
expect(result['kibana']['roles']).to eq(['kibana_system'])
8170
expect(result['kibana']['enabled']).to eq(true)
8271
end
83-
it 'should have the kibana_server user' do
84-
expect(result['kibana4_server']['username']).to eq('kibana4_server')
85-
expect(result['kibana4_server']['roles']).to eq(['kibana4_server'])
86-
expect(result['kibana4_server']['enabled']).to eq(true)
87-
end
8872
it 'should have the logstash user' do
8973
expect(result['logstash_system']['username']).to eq('logstash_system')
9074
expect(result['logstash_system']['roles']).to eq(['logstash_system'])
9175
expect(result['logstash_system']['enabled']).to eq(true)
9276
end
9377
end
9478

95-
describe 'logstash_system access check' do
96-
it 'should be reported as version '+vars['es_version'] do
97-
expect(curl_json(es_api_url, username='logstash_system', password='aNewLogstashPassword')['version']['number']).to eq(vars['es_version'])
98-
end
99-
end
100-
10179
describe 'SSL certificate check' do
10280
certificates = curl_json("#{es_api_url}/_ssl/certificates", username=username, password=password)
10381
it 'should list the keystore file' do

test/integration/issue-test.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

test/integration/issue-test/serverspec/default_spec.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/integration/license.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
- name: Elasticsearch Xpack HTTP different keystore and truststore with password
3+
hosts: localhost
4+
post_tasks:
5+
- include: elasticsearch/test/integration/debug.yml
6+
roles:
7+
- elasticsearch
8+
vars:
9+
es_config_6x:
10+
xpack.security.authc.realms.file1.order: 0
11+
xpack.security.authc.realms.file1.type: file
12+
es_config_7x:
13+
xpack.security.authc.realms.file.file1.order: 0
14+
es_config: "{{ es_config_7x if es_major_version == '7.x' else es_config_6x }}"
15+
es_xpack_license: "{{ lookup('file', '/tmp/license.json') }}"
16+
es_api_basic_auth_username: elastic
17+
es_api_basic_auth_password: changeme
18+
es_api_sleep: 5
19+
es_enable_http_ssl: true
20+
es_enable_transport_ssl: true
21+
es_ssl_keystore: "test/integration/files/certs/keystore-password.p12"
22+
es_ssl_truststore: "test/integration/files/certs/truststore-password.p12"
23+
es_ssl_keystore_password: password1
24+
es_ssl_truststore_password: password2
25+
es_validate_certs: no
26+
es_users:
27+
file:
28+
es_admin:
29+
password: changeMe
30+
roles:
31+
- admin
32+
testUser:
33+
password: changeMeAlso!
34+
roles:
35+
- power_user
36+
- user
37+
es_roles:
38+
file:
39+
admin:
40+
cluster:
41+
- all
42+
indices:
43+
- names: '*'
44+
privileges:
45+
- all
46+
power_user:
47+
cluster:
48+
- monitor
49+
indices:
50+
- names: '*'
51+
privileges:
52+
- all
53+
user:
54+
indices:
55+
- names: '*'
56+
privileges:
57+
- read
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'license_spec'
2+
require 'shared_spec'
3+
require 'json'
4+
vars = JSON.parse(File.read('/tmp/vars.json'))
5+
6+
describe 'license tests' do
7+
include_examples 'shared::init', vars
8+
include_examples 'license::init', vars
9+
end
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Standard test for single node setup. Tests idempotence.
2+
- name: Deploy Elasticsearch OSS version
33
hosts: localhost
44
post_tasks:
55
- include: elasticsearch/test/integration/debug.yml
@@ -8,14 +8,12 @@
88
vars:
99
es_version: "{{ '7.0.0' if es_major_version == '7.x' else '6.7.1' }}" # This is set to an older version than the current default to force an upgrade
1010
oss_version: true
11-
es_heap_size: "1g"
1211

13-
- name: Standard test for single node setup. Tests idempotence.
12+
- name: Upgrade to Elasticsearch default version
1413
hosts: localhost
1514
post_tasks:
1615
- include: elasticsearch/test/integration/debug.yml
1716
roles:
1817
- elasticsearch
1918
vars:
2019
oss_version: false
21-
es_heap_size: "1g"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'shared_spec'
2+
require 'json'
3+
vars = JSON.parse(File.read('/tmp/vars.json'))
4+
5+
describe 'oss to default upgrade tests' do
6+
include_examples 'shared::init', vars
7+
end

test/integration/oss-to-xpack-upgrade/serverspec/default_spec.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)