28
|
1 |
require 'spec_helper_acceptance' |
|
2 |
|
|
3 |
describe "Integration testing" do |
|
4 |
|
|
5 |
describe "Setup Elasticsearch" do |
|
6 |
|
|
7 |
it 'should run successfully' do |
|
8 |
pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
9 |
elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
10 |
" |
|
11 |
|
|
12 |
# Run it twice and test for idempotency |
|
13 |
apply_manifest(pp, :catch_failures => true) |
|
14 |
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero |
|
15 |
end |
|
16 |
|
|
17 |
|
|
18 |
describe service(test_settings['service_name_a']) do |
|
19 |
it { should be_enabled } |
|
20 |
it { should be_running } |
|
21 |
end |
|
22 |
|
|
23 |
describe package(test_settings['package_name']) do |
|
24 |
it { should be_installed } |
|
25 |
end |
|
26 |
|
|
27 |
describe file(test_settings['pid_file_a']) do |
|
28 |
it { should be_file } |
|
29 |
its(:content) { should match /[0-9]+/ } |
|
30 |
end |
|
31 |
|
|
32 |
describe "Elasticsearch serves requests on" do |
|
33 |
it { |
|
34 |
curl_with_retries("check ES on #{test_settings['port_a']}", default, "http://localhost:#{test_settings['port_a']}/?pretty=true", 0) |
|
35 |
} |
|
36 |
end |
|
37 |
|
|
38 |
describe file('/etc/elasticsearch/es-01/elasticsearch.yml') do |
|
39 |
it { should be_file } |
|
40 |
it { should contain 'name: elasticsearch001' } |
|
41 |
end |
|
42 |
|
|
43 |
describe file('/usr/share/elasticsearch/templates_import') do |
|
44 |
it { should be_directory } |
|
45 |
end |
|
46 |
|
|
47 |
end |
|
48 |
|
|
49 |
describe "Plugin tests" do |
|
50 |
|
|
51 |
describe "Install a plugin from official repository" do |
|
52 |
|
|
53 |
it 'should run successfully' do |
|
54 |
pp = "class { 'elasticsearch': config => { 'cluster.name' => '#{test_settings['cluster_name']}'}, java_install => true, package_url => '#{test_settings['snapshot_package']}' } |
|
55 |
elasticsearch::instance { 'es-01': config => { 'node.name' => 'elasticsearch001', 'http.port' => '#{test_settings['port_a']}' } } |
|
56 |
elasticsearch::plugin{'#{ENV['LICENSE_PLUGIN_NAME']}': instances => 'es-01', url => '#{ENV['LICENSE_PLUGIN_URL']}' } |
|
57 |
elasticsearch::plugin{'#{ENV['PLUGIN_NAME']}': instances => 'es-01', url => '#{ENV['PLUGIN_URL']}' } |
|
58 |
" |
|
59 |
|
|
60 |
# Run it twice and test for idempotency |
|
61 |
apply_manifest(pp, :catch_failures => true) |
|
62 |
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero |
|
63 |
end |
|
64 |
|
|
65 |
describe service(test_settings['service_name_a']) do |
|
66 |
it { should be_enabled } |
|
67 |
it { should be_running } |
|
68 |
end |
|
69 |
|
|
70 |
describe package(test_settings['package_name']) do |
|
71 |
it { should be_installed } |
|
72 |
end |
|
73 |
|
|
74 |
describe file(test_settings['pid_file_a']) do |
|
75 |
it { should be_file } |
|
76 |
its(:content) { should match /[0-9]+/ } |
|
77 |
end |
|
78 |
|
|
79 |
it 'make sure the directory exists' do |
|
80 |
shell("ls /usr/share/elasticsearch/plugins/#{ENV['PLUGIN_NAME']}", {:acceptable_exit_codes => 0}) |
|
81 |
end |
|
82 |
|
|
83 |
it 'make sure elasticsearch reports it as existing' do |
|
84 |
curl_with_retries('validated plugin as installed', default, "http://localhost:#{test_settings['port_a']}/_nodes/?plugin | grep #{ENV['PLUGIN_NAME']}", 0) |
|
85 |
end |
|
86 |
|
|
87 |
end |
|
88 |
|
|
89 |
end |
|
90 |
|
|
91 |
end |