From bddb7ee20bde7711e4fea992b94f7a40e6f4111c Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Thu, 26 Nov 2015 14:45:00 +0000 Subject: [PATCH] Tests for scripts, templates and mlock all on multi node installs --- tasks/checkParameters.yml | 2 +- test/integration/multi.yml | 6 +- .../multi/serverspec/default_spec.rb | 59 +++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/tasks/checkParameters.yml b/tasks/checkParameters.yml index 3fbf5d9..34d52d3 100644 --- a/tasks/checkParameters.yml +++ b/tasks/checkParameters.yml @@ -14,4 +14,4 @@ #If the user attempts to lock memory they must specify a heap size - fail: msg="If locking memory with bootstrap.mlockall a heap size must be specified" - when: es_config['bootstrap.mlockall'] == True and es_heap_size is not defined \ No newline at end of file + when: es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True and es_heap_size is not defined \ No newline at end of file diff --git a/test/integration/multi.yml b/test/integration/multi.yml index cec17ea..7943b44 100644 --- a/test/integration/multi.yml +++ b/test/integration/multi.yml @@ -3,6 +3,8 @@ - name: Elasticsearch Config tests hosts: localhost roles: - - { role: elasticsearch, es_instance_name: "master", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } } + - { role: elasticsearch, es_heap_size: "1g", es_instance_name: "master", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } } - { role: elasticsearch, es_instance_name: "node1", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, discovery.zen.ping.multicast.enabled: false } } - vars: \ No newline at end of file + vars: + es_scripts: true + es_templates: true \ No newline at end of file diff --git a/test/integration/multi/serverspec/default_spec.rb b/test/integration/multi/serverspec/default_spec.rb index 9ce6b7b..6d09358 100644 --- a/test/integration/multi/serverspec/default_spec.rb +++ b/test/integration/multi/serverspec/default_spec.rb @@ -87,5 +87,64 @@ context "basic tests" do end end + #test to make sure mlock was applied + describe command('curl "localhost:9200/_nodes/process?pretty" | grep mlockall') do + its(:stdout) { should match /\"mlockall\" : true/ } + its(:exit_status) { should eq 0 } + end + + #test to make sure mlock was not applied + describe command('curl "localhost:9201/_nodes/process?pretty" | grep mlockall') do + its(:stdout) { should match /\"mlockall\" : false/ } + its(:exit_status) { should eq 0 } + 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 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 + + #Confirm scripts are on both nodes + describe file('/etc/elasticsearch/node1/scripts') do + it { should be_directory } + it { should be_owned_by 'elasticsearch' } + end + + describe file('/etc/elasticsearch/node1/scripts/calculate-score.groovy') do + it { should be_file } + it { should be_owned_by 'elasticsearch' } + end + + describe file('/etc/elasticsearch/master/scripts') do + it { should be_directory } + it { should be_owned_by 'elasticsearch' } + end + + describe file('/etc/elasticsearch/master/scripts/calculate-score.groovy') do + it { should be_file } + it { should be_owned_by 'elasticsearch' } + end + end