Support for configuration per node and multiple nodes per server

This commit is contained in:
Dale McDiarmid 2015-10-22 19:09:53 +01:00
parent 0c6f326bed
commit d19297adda
30 changed files with 818 additions and 88 deletions

View file

@ -0,0 +1,12 @@
---
#Test explicit setting of parameters and variables
- name: Elasticsearch Package tests
hosts: localhost
roles:
#expand to all available parameters
- { role: elasticsearch, es_unicast_hosts: "localhost:9301", es_http_port: "9201", es_transport_tcp_port: "9301", es_data_node: false, es_master_node: true, es_m_lock_enabled: true, es_multicast_enabled: false, es_node_name_prefix: "node1_", es_cluster_name: "custom-cluster" }
vars:
es_scripts: false
es_templates: false
es_version_lock: false
es_m_lock_enabled: true

View file

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

View file

@ -0,0 +1,42 @@
require 'spec_helper'
context "basic tests" do
describe user('elasticsearch') do
it { should exist }
end
describe service('node1_elasticsearch') do
it { should be_running }
end
describe package('elasticsearch') do
it { should be_installed }
end
describe file('/etc/elasticsearch/node1_elasticsearch/elasticsearch.yml') do
it { should be_file }
end
#test configuration parameters have been set - test all appropriately set in config file
describe file('/etc/elasticsearch/node1_elasticsearch/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 'node.master: true' }
it { should contain 'discovery.zen.ping.multicast.enabled: false' }
it { should contain 'cluster.name: custom-cluster' }
it { should contain 'node.name: node1_localhost' }
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' }
end
#test we started on the correct port was used
describe command('curl "localhost:9201" | grep status') do
#TODO: This is returning an empty string
#its(:stdout) { should match /\"status\" : 200/ }
its(:exit_status) { should eq 0 }
end
end

View file

@ -0,0 +1,2 @@
require 'serverspec'
set :backend, :exec

View file

@ -0,0 +1,8 @@
---
#Test ability to deploy multiple instances to a machine
- name: Elasticsearch Config tests
hosts: localhost
roles:
- { role: elasticsearch, es_node_name_prefix: "node1_", es_unicast_hosts: "localhost:9300", es_http_port: "9201", es_transport_tcp_port: "9301", es_data_node: true, es_master_node: false, es_m_lock_enabled: true, es_multicast_enabled: false }
- { role: elasticsearch, es_node_name_prefix: "master_", es_unicast_hosts: "localhost:9300", es_http_port: "9200", es_transport_tcp_port: "9300", es_data_node: false, es_master_node: true, es_m_lock_enabled: true, es_multicast_enabled: false }
vars:

View file

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

View file

@ -0,0 +1,81 @@
require 'spec_helper'
context "basic tests" do
describe user('elasticsearch') do
it { should exist }
end
describe service('node1_elasticsearch') do
it { should be_running }
end
describe service('master_elasticsearch') do
it { should be_running }
end
describe package('elasticsearch') do
it { should be_installed }
end
describe file('/etc/elasticsearch/node1_elasticsearch/elasticsearch.yml') do
it { should be_file }
end
describe file('/etc/elasticsearch/master_elasticsearch/elasticsearch.yml') do
it { should be_file }
end
#test configuration parameters have been set - test all appropriately set in config file
describe file('/etc/elasticsearch/node1_elasticsearch/elasticsearch.yml') do
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 'discovery.zen.ping.multicast.enabled: false' }
it { should contain 'node.name: node1_localhost' }
end
#test configuration parameters have been set for master - test all appropriately set in config file
describe file('/etc/elasticsearch/master_elasticsearch/elasticsearch.yml') do
it { should contain 'http.port: 9200' }
it { should contain 'transport.tcp.port: 9300' }
it { should contain 'node.data: false' }
it { should contain 'node.master: true' }
it { should contain 'discovery.zen.ping.multicast.enabled: false' }
it { should contain 'node.name: master_localhost' }
end
describe 'Master listening' do
it 'listening in port 9200' do
expect(port 9200).to be_listening
end
end
describe 'Node listening' do
it 'node should be listening in port 9201' do
expect(port 9201).to be_listening
end
end
#test we started on the correct port was used for master
describe 'master started' do
it 'master node should be running', :retry => 3, :retry_wait => 10 do
command = command('curl "localhost:9200" | grep name')
#expect(command.stdout).should match '/*master_localhost*/'
expect(command.exit_status).to eq(0)
end
end
#test we started on the correct port was used for node 1
describe 'node1 started' do
it 'node should be running', :retry => 3, :retry_wait => 10 do
command = command('curl "localhost:9201" | grep name')
#expect(command.stdout).should match '/*node1_localhost*/'
expect(command.exit_status).to eq(0)
end
end
end

View file

@ -0,0 +1,2 @@
require 'serverspec'
set :backend, :exec

View file

@ -2,5 +2,5 @@
- name: Elasticsearch Package tests
hosts: localhost
roles:
- elasticsearch
vars:
- { role: elasticsearch, es_multicast_enabled: true}
vars:

View file

@ -14,7 +14,7 @@ context "basic tests" do
it { should be_installed }
end
describe file('/etc/elasticsearch/elasticsearch.yml') do
describe file('/etc/elasticsearch/elasticsearch/elasticsearch.yml') do
it { should be_file }
end

View file

@ -2,7 +2,7 @@
- name: wrapper playbook for kitchen testing "elasticsearch"
hosts: localhost
roles:
- elasticsearch
- { role: elasticsearch, es_multicast_enabled: true}
vars:
es_use_repository: "true"
es_plugins:

View file

@ -14,7 +14,7 @@ context "basic tests" do
it { should be_installed }
end
describe file('/etc/elasticsearch/elasticsearch.yml') do
describe file('/etc/elasticsearch/elasticsearch/elasticsearch.yml') do
it { should be_file }
end