File: nova_compute_libvirt_guests_spec.rb

package info (click to toggle)
puppet-module-nova 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,100 kB
  • sloc: ruby: 11,433; python: 38; sh: 10; makefile: 10
file content (186 lines) | stat: -rw-r--r-- 7,166 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require 'spec_helper'

describe 'nova::compute::libvirt_guests' do

  shared_examples 'nova::compute::libvirt_guests' do

    context 'with default parameters' do

      it { is_expected.to contain_class('nova::params')}

      it { is_expected.to contain_file(platform_params[:libvirt_guests_environment_file]).with(
        :ensure => 'present',
        :path   => platform_params[:libvirt_guests_environment_file],
        :tag    => 'libvirt-guests-file'
      )}
      it { is_expected.to contain_file_line('libvirt-guests ON_BOOT').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => 'ON_BOOT=ignore',
        :match => '^ON_BOOT=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests ON_SHUTDOWN').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => 'ON_SHUTDOWN=shutdown',
        :match => '^ON_SHUTDOWN=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests START_DELAY').with(
        :ensure            => 'absent',
        :path              => platform_params[:libvirt_guests_environment_file],
        :match             => '^START_DELAY=.*',
        :match_for_absence => true,
        :tag               => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests SHUTDOWN_TIMEOUT').with(
        :ensure            => 'absent',
        :path              => platform_params[:libvirt_guests_environment_file],
        :match             => '^SHUTDOWN_TIMEOUT=.*',
        :match_for_absence => true,
        :tag               => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests PARALLEL_SHUTDOWN').with(
        :ensure            => 'absent',
        :path              => platform_params[:libvirt_guests_environment_file],
        :match             => '^PARALLEL_SHUTDOWN=.*',
        :match_for_absence => true,
        :tag               => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests BYPASS_CACHE').with(
        :ensure            => 'absent',
        :path              => platform_params[:libvirt_guests_environment_file],
        :match             => '^BYPASS_CACHE=.*',
        :match_for_absence => true,
        :tag               => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests SYNC_TIME').with(
        :ensure            => 'absent',
        :path              => platform_params[:libvirt_guests_environment_file],
        :match             => '^SYNC_TIME=.*',
        :match_for_absence => true,
        :tag               => 'libvirt-guests-file_line'
      ) }

      it { is_expected.to contain_package('libvirt-client').with(
        :name   => platform_params[:libvirt_client_package_name],
        :ensure => 'present'
      ) }

      it { is_expected.to_not contain_service('libvirt-guests')}
    end

    context 'with params' do
      let :params do
        {
          :enabled           => true,
          :manage_service    => true,
          :on_boot           => 'start',
          :on_shutdown       => 'suspend',
          :start_delay       => 0,
          :shutdown_timeout  => 300,
          :parallel_shutdown => 0,
          :bypass_cache      => true,
          :sync_time         => true,
        }
      end

      it { is_expected.to contain_file(platform_params[:libvirt_guests_environment_file]).with(
        :ensure => 'present',
        :path   => platform_params[:libvirt_guests_environment_file],
        :tag    => 'libvirt-guests-file'
      )}
      it { is_expected.to contain_file_line('libvirt-guests ON_BOOT').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => 'ON_BOOT=start',
        :match => '^ON_BOOT=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests ON_SHUTDOWN').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => "ON_SHUTDOWN=suspend",
        :match => '^ON_SHUTDOWN=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests START_DELAY').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => 'START_DELAY=0',
        :match => '^START_DELAY=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests SHUTDOWN_TIMEOUT').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => "SHUTDOWN_TIMEOUT=300",
        :match => '^SHUTDOWN_TIMEOUT=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests PARALLEL_SHUTDOWN').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => "PARALLEL_SHUTDOWN=0",
        :match => '^PARALLEL_SHUTDOWN=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests BYPASS_CACHE').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => "BYPASS_CACHE=1",
        :match => '^BYPASS_CACHE=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }
      it { is_expected.to contain_file_line('libvirt-guests SYNC_TIME').with(
        :path  => platform_params[:libvirt_guests_environment_file],
        :line  => "SYNC_TIME=1",
        :match => '^SYNC_TIME=.*',
        :tag   => 'libvirt-guests-file_line'
      ) }

      it { is_expected.to contain_package('libvirt-client').with(
        :name   => platform_params[:libvirt_client_package_name],
        :ensure => 'present'
      ) }

      it { is_expected.to contain_service('libvirt-guests').with(
        :name   => platform_params[:libvirt_guests_service_name],
        :enable => true,
        :ensure => 'running',
      )}
    end

    context 'while not managing service state' do
      let :params do
        {
          :enabled => true,
        }
      end

      it { is_expected.to_not contain_service('libvirt-guests') }
    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({ :os_workers => 5 }))
      end

      let (:platform_params) do
        case facts[:os]['family']
        when 'Debian'
          {
            :libvirt_client_package_name     => 'libvirt-clients',
            :libvirt_guests_service_name     => 'libvirt-guests',
            :libvirt_guests_environment_file => '/etc/default/libvirt-guests'
          }
        when 'RedHat'
          {
            :libvirt_client_package_name     => 'libvirt-client',
            :libvirt_guests_service_name     => 'libvirt-guests',
            :libvirt_guests_environment_file => '/etc/sysconfig/libvirt-guests'
          }
        end
      end
      it_behaves_like 'nova::compute::libvirt_guests'
    end
  end
end