File: heat_wsgi_apache_spec.rb

package info (click to toggle)
puppet-module-heat 25.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,560 kB
  • sloc: ruby: 3,889; python: 38; sh: 10; makefile: 10
file content (101 lines) | stat: -rw-r--r-- 3,469 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
101
require 'spec_helper'

describe 'heat::wsgi::apache' do


  let :params do
    {
      :port => 8000,
    }
  end

  shared_examples_for 'apache serving a service with mod_wsgi' do
    context 'valid title' do
      let (:title) { 'api' }
      it { is_expected.to contain_class('heat::deps') }
      it { is_expected.to contain_class('heat::params') }

      context 'with default parameters' do
        it { is_expected.to contain_openstacklib__wsgi__apache("heat_#{title}_wsgi").with(
          'bind_host'                   => nil,
          'bind_port'                   => '8000',
          'group'                       => 'heat',
          'user'                        => 'heat',
          'ssl'                         => false,
          'wsgi_daemon_process'         => "heat_#{title}",
          'wsgi_process_group'          => "heat_#{title}",
          'wsgi_script_dir'             => platform_params[:wsgi_script_dir],
          'wsgi_script_file'            => "heat_#{title}",
          'allow_encoded_slashes'       => 'on',
          'headers'                     => nil,
          'request_headers'             => nil,
        )}
      end

      context 'with bind host' do
        let(:params) do
          { :bind_host => '1.1.1.1', :port => 9000 }
        end
        it { is_expected.to contain_openstacklib__wsgi__apache("heat_#{title}_wsgi").with(
          'bind_host' => '1.1.1.1',
          'bind_port' => 9000, )
        }
      end

      context 'with api options' do
        let (:title) { 'api' }
        it { is_expected.to contain_openstacklib__wsgi__apache("heat_#{title}_wsgi").with(
          'wsgi_daemon_process'         => "heat_#{title}",
          'wsgi_process_group'          => "heat_#{title}",
          'wsgi_script_dir'             => platform_params[:wsgi_script_dir],
          'wsgi_script_file'            => "heat_#{title}",
          'wsgi_script_source'          => platform_params[:script_source_api],
        )}
      end

      context 'with cfn options' do
        let (:title) { 'api_cfn' }
        it { is_expected.to contain_openstacklib__wsgi__apache("heat_#{title}_wsgi").with(
          'wsgi_daemon_process'         => "heat_#{title}",
          'wsgi_process_group'          => "heat_#{title}",
          'wsgi_script_dir'             => platform_params[:wsgi_script_dir],
          'wsgi_script_file'            => "heat_#{title}",
          'wsgi_script_source'          => platform_params[:script_source_cfn],
        )}
      end

    end

    context 'invalid title' do
      let (:title) { 'someothertitle' }
      it { expect { is_expected.to raise_error(Puppet::Error) } }
    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

      let(:platform_params) do
        case facts[:os]['family']
        when 'Debian'
          { :wsgi_script_dir   => '/usr/lib/cgi-bin/heat',
            :script_source_api => '/usr/bin/heat-wsgi-api',
            :script_source_cfn => '/usr/bin/heat-wsgi-api-cfn',
          }
        when 'RedHat'
          { :wsgi_script_dir   => '/var/www/cgi-bin/heat',
            :script_source_api => '/usr/bin/heat-wsgi-api',
            :script_source_cfn => '/usr/bin/heat-wsgi-api-cfn',
          }
        end
      end
      it_configures 'apache serving a service with mod_wsgi'
    end
  end

end