1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
# frozen_string_literal: true
require 'json'
require 'helpers/acceptance/tests/manifest_shared_examples'
# Main entrypoint for snapshot tests
shared_examples 'snapshot repository acceptance tests' do
describe 'elasticsearch::snapshot_repository', :with_cleanup do
es_config = {
'http.port' => 9200,
'node.name' => 'elasticsearchSnapshot01',
'path.repo' => '/var/lib/elasticsearch'
}
# Override the manifest in order to populate 'path.repo'
let(:manifest) do
package = if v[:is_snapshot]
<<-MANIFEST
manage_repo => false,
package_url => '#{v[:snapshot_package]}',
MANIFEST
else
<<-MANIFEST
# Hard version set here due to plugin incompatibilities.
version => '#{v[:elasticsearch_full_version]}',
MANIFEST
end
<<-MANIFEST
api_timeout => 60,
config => {
#{es_config.map { |k, v| " '#{k}' => '#{v}'," }.join("\n")}
},
jvm_options => [
'-Xms128m',
'-Xmx128m',
],
oss => #{v[:oss]},
#{package}
MANIFEST
end
let(:manifest_class_parameters) { 'restart_on_change => true' }
let(:extra_manifest) do
<<-MANIFEST
elasticsearch::snapshot_repository { 'backup':
ensure => 'present',
api_timeout => 60,
location => '/var/lib/elasticsearch/backup',
max_restore_rate => '20mb',
max_snapshot_rate => '80mb',
}
MANIFEST
end
include_examples('manifest application', es_config)
es_port = es_config['http.port']
describe port(es_port) do
it 'open', :with_retries do
expect(subject).to be_listening
end
end
describe "http://localhost:#{es_port}/_snapshot/backup" do
subject { shell("curl http://localhost:#{es_port}/_snapshot/backup") }
it 'returns the snapshot repository', :with_retries do
expect(JSON.parse(subject.stdout)['backup']).
to include('settings' => a_hash_including(
'location' => '/var/lib/elasticsearch/backup',
'max_restore_rate' => '20mb',
'max_snapshot_rate' => '80mb'
))
end
end
end
end
|