]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/openstacklib/spec/defines/openstacklib_wsgi_apache_spec.rb
try with modules from master
[dsa-puppet.git] / 3rdparty / modules / openstacklib / spec / defines / openstacklib_wsgi_apache_spec.rb
1 #
2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17
18 require 'spec_helper'
19
20 describe 'openstacklib::wsgi::apache' do
21
22   let (:title) { 'keystone_wsgi' }
23
24   let :global_facts do
25     {
26       :processorcount => 42,
27       :concat_basedir => '/var/lib/puppet/concat',
28       :fqdn           => 'some.host.tld'
29     }
30   end
31
32   let :params do
33     {
34       :bind_port          => 5000,
35       :group              => 'keystone',
36       :ssl                => true,
37       :user               => 'keystone',
38       :wsgi_script_dir    => '/var/www/cgi-bin/keystone',
39       :wsgi_script_file   => 'main',
40       :wsgi_script_source => '/usr/share/keystone/keystone.wsgi'
41     }
42   end
43
44   shared_examples_for 'apache serving a service with mod_wsgi' do
45     it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) }
46     it { is_expected.to contain_class('apache') }
47     it { is_expected.to contain_class('apache::mod::wsgi') }
48
49     describe 'with default parameters' do
50
51       it { is_expected.to contain_file('/var/www/cgi-bin/keystone').with(
52         'ensure'  => 'directory',
53         'owner'   => 'keystone',
54         'group'   => 'keystone',
55         'require' => 'Package[httpd]'
56       )}
57
58       it { is_expected.to contain_file('keystone_wsgi').with(
59         'ensure'  => 'file',
60         'path'    => '/var/www/cgi-bin/keystone/main',
61         'source'  => '/usr/share/keystone/keystone.wsgi',
62         'owner'   => 'keystone',
63         'group'   => 'keystone',
64         'mode'    => '0644',
65       )}
66
67       it { is_expected.to contain_apache__vhost('keystone_wsgi').with(
68         'servername'                  => 'some.host.tld',
69         'ip'                          => nil,
70         'port'                        => '5000',
71         'docroot'                     => '/var/www/cgi-bin/keystone',
72         'docroot_owner'               => 'keystone',
73         'docroot_group'               => 'keystone',
74         'ssl'                         => 'true',
75         'wsgi_daemon_process'         => 'keystone_wsgi',
76         'wsgi_process_group'          => 'keystone_wsgi',
77         'wsgi_script_aliases'         => { '/' => "/var/www/cgi-bin/keystone/main" },
78         'wsgi_daemon_process_options' => {
79           'user'      => 'keystone',
80           'group'     => 'keystone',
81           'processes' => 1,
82           'threads'   => global_facts[:processorcount],
83         },
84         'require'                     => 'File[keystone_wsgi]'
85       )}
86       it { is_expected.to contain_file("#{platform_parameters[:httpd_ports_file]}") }
87     end
88
89   end
90
91   context 'on RedHat platforms' do
92     let :facts do
93       global_facts.merge({
94         :osfamily               => 'RedHat',
95         :operatingsystemrelease => '7.0'
96       })
97     end
98
99     let :platform_parameters do
100       {
101         :httpd_service_name => 'httpd',
102         :httpd_ports_file   => '/etc/httpd/conf/ports.conf',
103       }
104     end
105
106     it_configures 'apache serving a service with mod_wsgi'
107   end
108
109   context 'on Debian platforms' do
110     let :facts do
111       global_facts.merge({
112         :osfamily               => 'Debian',
113         :operatingsystem        => 'Debian',
114         :operatingsystemrelease => '7.0'
115       })
116     end
117
118     let :platform_parameters do
119       {
120         :httpd_service_name => 'apache2',
121         :httpd_ports_file   => '/etc/apache2/ports.conf',
122       }
123     end
124
125     it_configures 'apache serving a service with mod_wsgi'
126   end
127 end