File: murano_logging_cfapi_spec.rb

package info (click to toggle)
puppet-module-murano 23.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 928 kB
  • sloc: ruby: 2,856; python: 38; sh: 10; makefile: 10
file content (148 lines) | stat: -rw-r--r-- 5,731 bytes parent folder | download | duplicates (3)
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
require 'spec_helper'

describe 'murano::logging_cfapi' do

  let :params do
    {
    }
  end

  let :log_params do
    {
        :debug                         => 'true',
        :use_syslog                    => 'true',
        :use_json                      => 'true',
        :use_journal                   => 'true',
        :use_stderr                    => 'false',
        :log_facility                  => 'LOG_LOCAL0',
        :log_dir                       => '/tmp/murano_cfapi',
        :log_file                      => '/tmp/murano_cfapi/murano.log',
        :logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
        :logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
        :logging_debug_format_suffix   => '%(funcName)s %(pathname)s:%(lineno)d',
        :logging_exception_prefix      => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
        :log_config_append             => '/etc/murano/logging-cfapi.conf',
        :publish_errors                => true,
        :default_log_levels            => {
            'amqp'       => 'WARN',
            'amqplib'    => 'WARN',
            'boto'       => 'WARN',
            'sqlalchemy' => 'WARN',
            'suds'       => 'INFO',
            'iso8601'    => 'WARN',
            'requests.packages.urllib3.connectionpool' => 'WARN' },
        :fatal_deprecations            => true,
        :instance_format               => '[instance: %(uuid)s] ',
        :instance_uuid_format          => '[instance: %(uuid)s] ',
        :log_date_format               => '%Y-%m-%d %H:%M:%S',
    }
  end

  shared_examples_for 'murano-logging-cfapi' do

    context 'with basic logging options defaults' do
      it_behaves_like 'basic logging options defaults'
    end

    context 'with basic logging options passed' do
      before { params.merge!( log_params ) }
      it_behaves_like 'basic logging options passed'
    end

    context 'with extended logging options' do
      before { params.merge!( log_params ) }
      it_behaves_like 'logging params set'
    end

    context 'without extended logging options' do
      it_behaves_like 'logging params unset'
    end

  end

  shared_examples_for 'basic logging options defaults' do

    context 'with defaults' do
     it { is_expected.to contain_oslo__log('murano_cfapi_config').with(
        :use_syslog  => '<SERVICE DEFAULT>',
        :use_json    => '<SERVICE DEFAULT>',
        :use_journal => '<SERVICE DEFAULT>',
        :use_stderr  => '<SERVICE DEFAULT>',
        :log_dir     => '/var/log/murano_cfapi',
        :log_file    => '<SERVICE DEFAULT>',
        :debug       => '<SERVICE DEFAULT>',
      )}
    end

    context 'with syslog enabled and default log facility' do
      let :params do
        { :use_syslog   => 'true' }
      end

      it { is_expected.to contain_oslo__log('murano_cfapi_config').with(
        :use_syslog          => true,
        :syslog_log_facility => '<SERVICE DEFAULT>',
      )}
    end
  end

  shared_examples_for 'basic logging options passed' do
    context 'with passed params' do
      it { is_expected.to contain_oslo__log('murano_cfapi_config').with(
        :use_syslog          => true,
        :use_json            => true,
        :use_journal         => true,
        :use_stderr          => false,
        :syslog_log_facility => 'LOG_LOCAL0',
        :log_dir             => '/tmp/murano_cfapi',
        :log_file            => '/tmp/murano_cfapi/murano.log',
        :debug               => true,
      )}
    end
  end

  shared_examples_for 'logging params set' do
    it 'enables logging params' do
      is_expected.to contain_oslo__log('murano_cfapi_config').with(
        :logging_context_format_string =>
          '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
        :logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
        :logging_debug_format_suffix   => '%(funcName)s %(pathname)s:%(lineno)d',
        :logging_exception_prefix      => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
        :log_config_append             => '/etc/murano/logging-cfapi.conf',
        :publish_errors                => true,
        :default_log_levels            => {
          'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
          'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN',
          'requests.packages.urllib3.connectionpool' => 'WARN' },
       :fatal_deprecations             => true,
       :instance_format                => '[instance: %(uuid)s] ',
       :instance_uuid_format           => '[instance: %(uuid)s] ',
       :log_date_format                => '%Y-%m-%d %H:%M:%S',
      )
    end
  end

  shared_examples_for 'logging params unset' do
   [ :logging_context_format_string, :logging_default_format_string,
     :logging_debug_format_suffix, :logging_exception_prefix,
     :log_config_append, :publish_errors,
     :default_log_levels, :fatal_deprecations,
     :instance_format, :instance_uuid_format,
     :log_date_format, ].each { |param|
        it { is_expected.to contain_oslo__log('murano_cfapi_config').with("#{param}" => '<SERVICE DEFAULT>') }
      }
  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_behaves_like 'murano-logging-cfapi'
    end
  end

end