|
1 require 'spec_helper_acceptance' |
|
2 |
|
3 describe "Integration testing" do |
|
4 |
|
5 shell("mkdir -p #{default['distmoduledir']}/another/files") |
|
6 shell("echo '#{test_settings['good_json']}' >> #{default['distmoduledir']}/another/files/good.json") |
|
7 shell("echo '#{test_settings['bad_json']}' >> #{default['distmoduledir']}/another/files/bad.json") |
|
8 |
|
9 |
|
10 describe "Setup Elasticsearch", :main => true do |
|
11 |
|
12 it 'should run successfully' do |
|
13 pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
14 elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
15 " |
|
16 |
|
17 # Run it twice and test for idempotency |
|
18 apply_manifest(pp, :catch_failures => true) |
|
19 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero |
|
20 end |
|
21 |
|
22 |
|
23 describe service(test_settings['service_name_a']) do |
|
24 it { should be_enabled } |
|
25 it { should be_running } |
|
26 end |
|
27 |
|
28 describe package(test_settings['package_name']) do |
|
29 it { should be_installed } |
|
30 end |
|
31 |
|
32 describe file(test_settings['pid_file_a']) do |
|
33 it { should be_file } |
|
34 its(:content) { should match /[0-9]+/ } |
|
35 end |
|
36 |
|
37 describe "Elasticsearch serves requests on" do |
|
38 it { |
|
39 curl_with_retries("check ES on #{test_settings['port_a']}", default, "http://localhost:#{test_settings['port_a']}/?pretty=true", 0) |
|
40 } |
|
41 end |
|
42 |
|
43 describe file('/etc/elasticsearch/es-01/elasticsearch.yml') do |
|
44 it { should be_file } |
|
45 it { should contain 'name: elasticsearch001' } |
|
46 end |
|
47 |
|
48 describe file('/usr/share/elasticsearch/templates_import') do |
|
49 it { should be_directory } |
|
50 end |
|
51 |
|
52 end |
|
53 |
|
54 describe "Template tests", :template => true do |
|
55 |
|
56 describe "Insert a template with valid json content" do |
|
57 |
|
58 it 'should run successfully' do |
|
59 pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
60 elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
61 elasticsearch::template { 'foo': ensure => 'present', file => 'puppet:///modules/another/good.json' }" |
|
62 |
|
63 # Run it twice and test for idempotency |
|
64 apply_manifest(pp, :catch_failures => true) |
|
65 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero |
|
66 end |
|
67 |
|
68 it 'should report as existing in Elasticsearch' do |
|
69 curl_with_retries('validate template as installed', default, "http://localhost:#{test_settings['port_a']}/_template/foo | grep logstash", 0) |
|
70 end |
|
71 end |
|
72 |
|
73 if fact('puppetversion') =~ /3\.[2-9]\./ |
|
74 describe "Insert a template with bad json content" do |
|
75 |
|
76 it 'run should fail' do |
|
77 pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
78 elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
79 elasticsearch::template { 'foo': ensure => 'present', file => 'puppet:///modules/another/bad.json' }" |
|
80 |
|
81 apply_manifest(pp, :expect_failures => true) |
|
82 end |
|
83 |
|
84 end |
|
85 |
|
86 else |
|
87 # The exit codes have changes since Puppet 3.2x |
|
88 # Since beaker expectations are based on the most recent puppet code All runs on previous versions fails. |
|
89 end |
|
90 |
|
91 end |
|
92 |
|
93 describe "Plugin tests", :plugin => true do |
|
94 |
|
95 describe "Install a plugin from official repository" do |
|
96 |
|
97 it 'should run successfully' do |
|
98 pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
99 elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
100 elasticsearch::plugin{'lmenezes/elasticsearch-kopf': instances => 'es-01' } |
|
101 " |
|
102 |
|
103 # Run it twice and test for idempotency |
|
104 apply_manifest(pp, :catch_failures => true) |
|
105 expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero |
|
106 end |
|
107 |
|
108 describe service(test_settings['service_name_a']) do |
|
109 it { should be_enabled } |
|
110 it { should be_running } |
|
111 end |
|
112 |
|
113 describe package(test_settings['package_name']) do |
|
114 it { should be_installed } |
|
115 end |
|
116 |
|
117 describe file(test_settings['pid_file_a']) do |
|
118 it { should be_file } |
|
119 its(:content) { should match /[0-9]+/ } |
|
120 end |
|
121 |
|
122 it 'make sure the directory exists' do |
|
123 shell('ls /usr/share/elasticsearch/plugins/kopf/', {:acceptable_exit_codes => 0}) |
|
124 end |
|
125 |
|
126 it 'make sure elasticsearch reports it as existing' do |
|
127 curl_with_retries('validated plugin as installed', default, "http://localhost:#{test_settings['port_a']}/_nodes/?plugin | grep kopf", 0) |
|
128 end |
|
129 |
|
130 end |
|
131 |
|
132 if fact('puppetversion') =~ /3\.[2-9]\./ |
|
133 |
|
134 describe "Install a non existing plugin" do |
|
135 |
|
136 it 'should run successfully' do |
|
137 pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
138 elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
139 elasticsearch::plugin{'elasticsearch/non-existing': module_dir => 'non-existing', instances => 'es-01' } |
|
140 " |
|
141 apply_manifest(pp, :expect_failures => true) |
|
142 end |
|
143 |
|
144 end |
|
145 |
|
146 else |
|
147 # The exit codes have changes since Puppet 3.2x |
|
148 # Since beaker expectations are based on the most recent puppet code All runs on previous versions fails. |
|
149 end |
|
150 |
|
151 end |
|
152 |
|
153 end |