File: keystone_cron_trust_flush_spec.rb

package info (click to toggle)
puppet-module-keystone 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,428 kB
  • sloc: ruby: 9,684; pascal: 295; python: 38; makefile: 10; sh: 10
file content (89 lines) | stat: -rw-r--r-- 2,857 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
78
79
80
81
82
83
84
85
86
87
88
89
require 'spec_helper'

describe 'keystone::cron::trust_flush' do
  let :params do
    {}
  end

  shared_examples 'keystone::cron::trust_flush' do
    context 'with default parameters' do
      it { is_expected.to contain_class('keystone::deps') }

      it { is_expected.to contain_cron('keystone-manage trust_flush').with(
        :ensure      => 'present',
        :command     => 'keystone-manage trust_flush >>/var/log/keystone/keystone-trustflush.log 2>&1',
        :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
        :user        => 'keystone',
        :minute      => 1,
        :hour        => '*',
        :monthday    => '*',
        :month       => '*',
        :weekday     => '*',
        :require     => 'Anchor[keystone::dbsync::end]',
      )}
    end

    context 'with overriden params' do
      before do
        params.merge!(
          :ensure      => 'absent',
          :minute      => 13,
          :hour        => 23,
          :monthday    => 3,
          :month       => 4,
          :weekday     => 2,
          :maxdelay    => 600,
          :destination => '/tmp/trustflush.log',
          :user        => 'nobody' )
      end

      it { is_expected.to contain_class('keystone::deps') }

      it { is_expected.to contain_cron('keystone-manage trust_flush').with(
        :ensure      => params[:ensure],
        :command     => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; keystone-manage trust_flush >>#{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[keystone::dbsync::end]',
      )}
    end

    context 'with age' do
      before do
        params.merge!(
          :age => 14
        )
      end

      it { is_expected.to contain_cron('keystone-manage trust_flush').with(
        :ensure      => 'present',
        :command     => 'keystone-manage trust_flush --date `date --date \'today - 14 days\' +\\%d-\\%m-\\%Y` >>/var/log/keystone/keystone-trustflush.log 2>&1',
        :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
        :user        => 'keystone',
        :minute      => 1,
        :hour        => '*',
        :monthday    => '*',
        :month       => '*',
        :weekday     => '*',
        :require     => 'Anchor[keystone::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 'keystone::cron::trust_flush'
    end
  end
end