File: cinder_cron_db_purge_spec.rb

package info (click to toggle)
puppet-module-cinder 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,504 kB
  • sloc: ruby: 6,697; python: 38; sh: 10; makefile: 10
file content (77 lines) | stat: -rw-r--r-- 2,331 bytes parent folder | download | duplicates (2)
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
require 'spec_helper'

describe 'cinder::cron::db_purge' do
  let :params do
    {
      :minute      => 1,
      :hour        => 0,
      :monthday    => '*',
      :month       => '*',
      :weekday     => '*',
      :user        => 'cinder',
      :age         => '30',
      :maxdelay    => 0,
      :destination => '/var/log/cinder/cinder-rowsflush.log'
    }
  end

  shared_examples 'cinder::cron::db_purge' do
    context 'with required parameters' do
      it { is_expected.to contain_cron('cinder-manage db purge').with(
        :ensure      => :present,
        :command     => "cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1",
        :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
        :user        => params[:user],
        :minute      => params[:minute],
        :hour        => params[:hour],
        :monthday    => params[:monthday],
        :month       => params[:month],
        :weekday     => params[:weekday],
        :require     => 'Anchor[cinder::dbsync::end]'
      )}
    end

    context 'with ensure set to absent' do
      before :each do
        params.merge!(
          :ensure => :absent
        )
      end

      it { should contain_cron('cinder-manage db purge').with_ensure(:absent) }
    end

    context 'with required parameters with max delay enabled' do
      before :each do
        params.merge!(
          :maxdelay => 600
        )
      end

      it { should contain_cron('cinder-manage db purge').with(
        :ensure      => :present,
        :command     => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1",
        :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
        :user        => params[:user],
        :minute      => params[:minute],
        :hour        => params[:hour],
        :monthday    => params[:monthday],
        :month       => params[:month],
        :weekday     => params[:weekday],
        :require     => 'Anchor[cinder::dbsync::end]'
      )}
    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

      it_behaves_like 'cinder::cron::db_purge'
    end
  end
end