This file is indexed.

/usr/share/puppet/modules.available/glance/spec/classes/glance_backend_s3_spec.rb is in puppet-module-glance 9.4.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require 'spec_helper'

describe 'glance::backend::s3' do
  shared_examples_for 'glance::backend::s3' do
    let :params do
      {
        :access_key => 'access',
        :secret_key => 'secret',
        :host       => 'host',
        :bucket     => 'bucket'
      }
    end

    describe 'when default parameters' do

      it 'configures glance-api.conf' do
        is_expected.to contain_glance_api_config('glance_store/default_store').with_value('s3')
        is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access')
        is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret')
        is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host')
        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket')
        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value('<SERVICE DEFAULT>')
        is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('<SERVICE DEFAULT>')
      end
      it 'not configures glance-glare.conf' do
        is_expected.to_not contain_glance_glare_config('glance_store/default_store').with_value('s3')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_access_key').with_value('access')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_secret_key').with_value('secret')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_host').with_value('host')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_bucket').with_value('bucket')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_bucket_url_format').with_value('<SERVICE DEFAULT>')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_create_bucket_on_put').with_value('<SERVICE DEFAULT>')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_large_object_size').with_value('<SERVICE DEFAULT>')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_large_object_chunk_size').with_value('<SERVICE DEFAULT>')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_object_buffer_dir').with_value('<SERVICE DEFAULT>')
        is_expected.to_not contain_glance_glare_config('glance_store/s3_store_thread_pools').with_value('<SERVICE DEFAULT>')
      end

    end

    describe 'when overriding parameters' do
      let :params do
        {
          :access_key               => 'access2',
          :secret_key               => 'secret2',
          :host                     => 'host2',
          :bucket                   => 'bucket2',
          :bucket_url_format        => 'path',
          :create_bucket_on_put     => true,
          :large_object_size        => 200,
          :large_object_chunk_size  => 20,
          :object_buffer_dir        => '/tmp',
          :thread_pools             => 20,
          :glare_enabled            => true,
        }
      end

      it 'configures glance-api.conf' do
        is_expected.to contain_glance_api_config('glance_store/s3_store_access_key').with_value('access2')
        is_expected.to contain_glance_api_config('glance_store/s3_store_secret_key').with_value('secret2')
        is_expected.to contain_glance_api_config('glance_store/s3_store_host').with_value('host2')
        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket').with_value('bucket2')
        is_expected.to contain_glance_api_config('glance_store/s3_store_bucket_url_format').with_value('path')
        is_expected.to contain_glance_api_config('glance_store/s3_store_create_bucket_on_put').with_value('true')
        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_size').with_value('200')
        is_expected.to contain_glance_api_config('glance_store/s3_store_large_object_chunk_size').with_value('20')
        is_expected.to contain_glance_api_config('glance_store/s3_store_object_buffer_dir').with_value('/tmp')
        is_expected.to contain_glance_api_config('glance_store/s3_store_thread_pools').with_value('20')
      end

      it 'configures glance-glare.conf' do
        is_expected.to contain_glance_glare_config('glance_store/s3_store_access_key').with_value('access2')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_secret_key').with_value('secret2')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_host').with_value('host2')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_bucket').with_value('bucket2')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_bucket_url_format').with_value('path')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_create_bucket_on_put').with_value('true')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_large_object_size').with_value('200')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_large_object_chunk_size').with_value('20')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_object_buffer_dir').with_value('/tmp')
        is_expected.to contain_glance_glare_config('glance_store/s3_store_thread_pools').with_value('20')
      end
    end

    describe 'with invalid bucket_url_format' do
      let :params do
        {
          :access_key               => 'access',
          :secret_key               => 'secret',
          :host                     => 'host',
          :bucket                   => 'bucket',
          :bucket_url_format        => 'invalid'
        }
      end

      it 'throws errors' do
        is_expected.to raise_error(Puppet::Error, /glance::backend::s3::bucket_url_format must be either "subdomain" or "path"/)
      end
    end

    describe 'with invalid large_object_chunk_size' do
      let :params do
        {
          :access_key               => 'access',
          :secret_key               => 'secret',
          :host                     => 'host',
          :bucket                   => 'bucket',
          :large_object_chunk_size  => 1
        }
      end

      it 'throws error' do
        is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
      end
    end

    describe 'with non-integer large_object_chunk_size' do
      let :params do
        {
          :access_key               => 'access',
          :secret_key               => 'secret',
          :host                     => 'host',
          :bucket                   => 'bucket',
          :large_object_chunk_size  => 'string'
        }
      end

      it 'throws error' do
        is_expected.to raise_error(Puppet::Error, /glance::backend::s3::large_object_chunk_size must be an integer >= 5/)
      end
    end
  end

  on_supported_os({
    :supported_os   => OSDefaults.get_supported_os
  }).each do |os,facts|
    context "on #{os}" do
      let (:facts) do
        facts.merge!(OSDefaults.get_facts())
      end

      it_configures 'glance::backend::s3'
    end
  end
end