|
5 | 5 | describe 'python::gunicorn', type: :define do |
6 | 6 | let(:title) { 'test-app' } |
7 | 7 |
|
8 | | - context 'on Debian OS' do |
9 | | - let :facts do |
10 | | - { |
11 | | - id: 'root', |
12 | | - kernel: 'Linux', |
13 | | - lsbdistcodename: 'squeeze', |
14 | | - osfamily: 'Debian', |
15 | | - operatingsystem: 'Debian', |
16 | | - operatingsystemrelease: '6', |
17 | | - path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', |
18 | | - concat_basedir: '/dne' |
19 | | - } |
20 | | - end |
| 8 | + on_supported_os.each do |os, facts| |
| 9 | + context "on #{os}" do |
| 10 | + let(:facts) { facts } |
21 | 11 |
|
22 | | - describe 'test-app with default parameter values' do |
23 | | - context 'configures test app with default parameter values' do |
24 | | - let(:params) { { dir: '/srv/testapp' } } |
| 12 | + describe 'test-app with default parameter values' do |
| 13 | + context 'configures test app with default parameter values' do |
| 14 | + let(:params) { { dir: '/srv/testapp' } } |
| 15 | + let(:expected_workers) do |
| 16 | + # manifests/gunicorn.pp |
| 17 | + processor_count = facts.dig(:processors, 'count') |
25 | 18 |
|
26 | | - it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--log-level=error}) } |
27 | | - end |
| 19 | + # templates/gunicorn.erb |
| 20 | + (processor_count.to_i * 2) + 1 |
| 21 | + end |
28 | 22 |
|
29 | | - context 'test-app with custom log level' do |
30 | | - let(:params) { { dir: '/srv/testapp', log_level: 'info' } } |
| 23 | + it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--log-level=error}) } |
| 24 | + it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--workers=#{expected_workers}}) } |
| 25 | + end |
31 | 26 |
|
32 | | - it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--log-level=info}) } |
33 | | - end |
| 27 | + context 'test-app with custom log level' do |
| 28 | + let(:params) { { dir: '/srv/testapp', log_level: 'info' } } |
| 29 | + |
| 30 | + it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--log-level=info}) } |
| 31 | + end |
| 32 | + |
| 33 | + context 'test-app with custom gunicorn preload arguments' do |
| 34 | + let(:params) { { dir: '/srv/testapp', args: ['--preload'] } } |
| 35 | + |
| 36 | + it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--preload}) } |
| 37 | + end |
34 | 38 |
|
35 | | - context 'test-app with custom gunicorn preload arguments' do |
36 | | - let(:params) { { dir: '/srv/testapp', args: ['--preload'] } } |
| 39 | + context 'test-app with custom workers count' do |
| 40 | + let(:params) { { dir: '/srv/testapp', workers: 42 } } |
37 | 41 |
|
38 | | - it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--preload}) } |
| 42 | + it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--workers=#{params[:workers]}}) } |
| 43 | + end |
39 | 44 | end |
40 | 45 | end |
41 | 46 | end |
|
0 commit comments