File: plugin_shared_examples.rb

package info (click to toggle)
puppet-module-voxpupuli-elasticsearch 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,496 kB
  • sloc: ruby: 9,906; sh: 392; makefile: 4
file content (100 lines) | stat: -rw-r--r-- 2,986 bytes parent folder | download
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# frozen_string_literal: true

require 'json'
require 'helpers/acceptance/tests/bad_manifest_shared_examples'
require 'helpers/acceptance/tests/manifest_shared_examples'
require 'helpers/acceptance/tests/plugin_api_shared_examples'

shared_examples 'plugin acceptance tests' do |es_config, plugins|
  describe 'elasticsearch::plugin' do
    before :all do # rubocop:disable RSpec/BeforeAfterAll
      shell "mkdir -p #{default.puppet['codedir']}/modules/another/files"
    end

    describe 'invalid plugins', :with_cleanup do
      let(:extra_manifest) do
        <<-MANIFEST
          elasticsearch::plugin { 'elastic/non-existing': }
        MANIFEST
      end

      include_examples('invalid manifest application')
    end

    plugins.each_pair do |plugin, meta|
      describe plugin do
        # Ensure that instances are restarted to include plugins
        let(:manifest_class_parameters) { 'restart_on_change => true' }

        describe 'installation' do
          describe 'using simple names', :with_cleanup do
            let(:extra_manifest) do
              <<-MANIFEST
                elasticsearch::plugin { '#{plugin}': }
              MANIFEST
            end

            include_examples('manifest application', es_config)

            describe file("/usr/share/elasticsearch/plugins/#{plugin}/") do
              it { is_expected.to be_directory }
            end

            include_examples(
              'plugin API response',
              es_config,
              'reports the plugin as installed',
              'name' => plugin
            )
          end

          describe 'offline via puppet://', :with_cleanup do
            before :all do # rubocop:disable RSpec/BeforeAfterAll
              scp_to(
                default,
                meta[:path],
                "#{default.puppet['codedir']}/modules/another/files/#{plugin}.zip"
              )
            end

            let(:extra_manifest) do
              <<-MANIFEST
                elasticsearch::plugin { '#{plugin}':
                  source => 'puppet:///modules/another/#{plugin}.zip',
                }
              MANIFEST
            end

            include_examples('manifest application', es_config)

            include_examples(
              'plugin API response',
              es_config,
              'reports the plugin as installed',
              'name' => plugin
            )
          end

          describe 'via url', :with_cleanup do
            let(:extra_manifest) do
              <<-MANIFEST
                elasticsearch::plugin { '#{plugin}':
                  url => '#{meta[:url]}',
                }
              MANIFEST
            end

            include_examples('manifest application', es_config)

            include_examples(
              'plugin API response',
              es_config,
              'reports the plugin as installed',
              'name' => plugin
            )
          end
        end
      end
    end
  end
end