Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Simpler restart handling + issue-test for recreation of problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale McDiarmid committed Aug 20, 2017
1 parent 2c69fbc commit 5e1873c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ suites:
attributes:
provisioner:
playbook: test/integration/xpack-standard.yml
idempotency_test: true
- name: issue-test
run_list:
attributes:
provisioner:
playbook: test/integration/issue-test.yml
idempotency_test: true
1 change: 0 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
when:
- es_restart_on_change
- es_start_service
- ((plugin_installed is defined and plugin_installed.changed) or (config_updated is defined and config_updated.changed) or (xpack_state.changed) or (debian_elasticsearch_install_from_repo.changed or redhat_elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed))
register: es_restarted
2 changes: 2 additions & 0 deletions tasks/elasticsearch-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
apt: name=elasticsearch{% if es_version is defined and es_version != "" %}={{ es_version }}{% endif %} state=present force={{force_install}} allow_unauthenticated={{ 'no' if es_apt_key else 'yes' }} cache_valid_time=86400
when: es_use_repository
register: debian_elasticsearch_install_from_repo
notify: restart elasticsearch

- name: Debian - Download elasticsearch from url
get_url: url={% if es_custom_package_url is defined %}{{ es_custom_package_url }}{% else %}{{ es_package_url }}-{{ es_version }}.deb{% endif %} dest=/tmp/elasticsearch-{{ es_version }}.deb validate_certs=no
Expand All @@ -37,3 +38,4 @@
apt: deb=/tmp/elasticsearch-{{ es_version }}.deb
when: not es_use_repository
register: elasticsearch_install_from_package
notify: restart elasticsearch
2 changes: 2 additions & 0 deletions tasks/elasticsearch-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
yum: name=elasticsearch{% if es_version is defined and es_version != "" %}-{{ es_version }}{% endif %} state=present update_cache=yes
when: es_use_repository
register: redhat_elasticsearch_install_from_repo
notify: restart elasticsearch
until: '"failed" not in redhat_elasticsearch_install_from_repo'
retries: 5
delay: 10
Expand All @@ -23,3 +24,4 @@
yum: name={% if es_custom_package_url is defined %}{{ es_custom_package_url }}{% else %}{{ es_package_url }}-{{ es_version }}.noarch.rpm{% endif %} state=present
when: not es_use_repository
register: elasticsearch_install_from_package
notify: restart elasticsearch
2 changes: 1 addition & 1 deletion tasks/elasticsearch-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#Copy the config template
- name: Copy Configuration File
template: src=elasticsearch.yml.j2 dest={{conf_dir}}/elasticsearch.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
register: config_updated
register: system_change
notify: restart elasticsearch

#Copy the instance specific default file
Expand Down
4 changes: 4 additions & 0 deletions tasks/elasticsearch-optional-user.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
#Add the elasticsearch user before installing from packages.
- name: Ensure optional elasticsearch group is created with the correct id.
#Restart if these change
notify: restart elasticsearch
group:
state: present
name: "{{ es_group }}"
system: yes
gid: "{{ es_group_id }}"

- name: Ensure optional elasticsearch user is created with the correct id.
#Restart if these change
notify: restart elasticsearch
user:
state: present
name: "{{ es_user }}"
Expand Down
8 changes: 8 additions & 0 deletions test/integration/helpers/serverspec/issue_test_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'spec_helper'

shared_examples 'issue_test::init' do |es_version,plugins|

#Add custom tests here for the issue-test.yml test

end

12 changes: 12 additions & 0 deletions test/integration/issue-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#This file is for users to test issues and reproduce them using the test framework.
#Modify the playbook below and test with kitchen i.e. `kitchen test issue-test`
#To add custom tests modify the serverspec file ./helpers/serverspec/issue_test_spec.rb
#Idempot test is enabled for this test
- name: Simple Example
hosts: localhost
remote_user: root
become: yes
become_method: sudo
roles:
- { role: elasticsearch, es_instance_name: "node1" }
vars:
2 changes: 2 additions & 0 deletions test/integration/issue-test/issue-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- host: test-kitchen
6 changes: 6 additions & 0 deletions test/integration/issue-test/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'issue_test_spec'

describe 'Issue Test' do
include_examples 'issue_test::init', "5.5.1", []
end

0 comments on commit 5e1873c

Please sign in to comment.