|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'swift::dispersion' do |
| 4 | + |
| 5 | + let :facts do |
| 6 | + { :osfamily => 'Debian' } |
| 7 | + end |
| 8 | + |
| 9 | + it { should contain_file('/etc/swift/dispersion.conf').with( |
| 10 | + :ensure => 'present', |
| 11 | + :owner => 'swift', |
| 12 | + :group => 'swift', |
| 13 | + :mode => '0660', |
| 14 | + :require => 'Package[swift]') |
| 15 | + } |
| 16 | + |
| 17 | + describe 'with default parameters' do |
| 18 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 19 | + .with_content(/^\[dispersion\]$/) |
| 20 | + } |
| 21 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 22 | + .with_content(/^auth_url = http:\/\/127.0.0.1:5000\/v2.0\/$/) |
| 23 | + } |
| 24 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 25 | + .with_content(/^auth_version = 2.0$/) |
| 26 | + } |
| 27 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 28 | + .with_content(/^auth_user = services:dispersion$/) |
| 29 | + } |
| 30 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 31 | + .with_content(/^auth_key = dispersion_password$/) |
| 32 | + } |
| 33 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 34 | + .with_content(/^swift_dir = \/etc\/swift$/) |
| 35 | + } |
| 36 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 37 | + .with_content(/^dispersion_coverage = 1$/) |
| 38 | + } |
| 39 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 40 | + .with_content(/^retries = 5$/) |
| 41 | + } |
| 42 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 43 | + .with_content(/^concurrency = 25$/) |
| 44 | + } |
| 45 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 46 | + .with_content(/^dump_json = no$/) |
| 47 | + } |
| 48 | + it { should contain_exec('swift-dispersion-populate').with( |
| 49 | + :path => ['/bin', '/usr/bin'], |
| 50 | + :subscribe => 'File[/etc/swift/dispersion.conf]', |
| 51 | + :onlyif => "swift -A http://127.0.0.1:5000/v2.0/ -U services:dispersion -K dispersion_password -V 2.0 stat | grep 'Account: '", |
| 52 | + :unless => "swift -A http://127.0.0.1:5000/v2.0/ -U services:dispersion -K dispersion_password -V 2.0 list | grep dispersion_" |
| 53 | + )} |
| 54 | + end |
| 55 | + |
| 56 | + describe 'when parameters are overriden' do |
| 57 | + let :params do |
| 58 | + { |
| 59 | + :auth_url => 'https://169.254.0.1:7000/auth/v8.0/', |
| 60 | + :auth_user => 'foo', |
| 61 | + :auth_tenant => 'bar', |
| 62 | + :auth_pass => 'dummy', |
| 63 | + :auth_version => '1.0', |
| 64 | + :swift_dir => '/usr/local/etc/swift', |
| 65 | + :coverage => 42, |
| 66 | + :retries => 51, |
| 67 | + :concurrency => 4682, |
| 68 | + :dump_json => 'yes' |
| 69 | + } |
| 70 | + end |
| 71 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 72 | + .with_content(/^\[dispersion\]$/) |
| 73 | + } |
| 74 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 75 | + .with_content(/^auth_url = https:\/\/169.254.0.1:7000\/auth\/v8.0\/$/) |
| 76 | + } |
| 77 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 78 | + .with_content(/^auth_version = 1.0$/) |
| 79 | + } |
| 80 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 81 | + .with_content(/^auth_user = bar:foo$/) |
| 82 | + } |
| 83 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 84 | + .with_content(/^auth_key = dummy$/) |
| 85 | + } |
| 86 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 87 | + .with_content(/^swift_dir = \/usr\/local\/etc\/swift$/) |
| 88 | + } |
| 89 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 90 | + .with_content(/^dispersion_coverage = 42$/) |
| 91 | + } |
| 92 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 93 | + .with_content(/^retries = 51$/) |
| 94 | + } |
| 95 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 96 | + .with_content(/^concurrency = 4682$/) |
| 97 | + } |
| 98 | + it { should contain_file('/etc/swift/dispersion.conf') \ |
| 99 | + .with_content(/^dump_json = yes$/) |
| 100 | + } |
| 101 | + it { should contain_exec('swift-dispersion-populate').with( |
| 102 | + :path => ['/bin', '/usr/bin'], |
| 103 | + :subscribe => 'File[/etc/swift/dispersion.conf]', |
| 104 | + :onlyif => "swift -A https://169.254.0.1:7000/auth/v8.0/ -U bar:foo -K dummy -V 1.0 stat | grep 'Account: '", |
| 105 | + :unless => "swift -A https://169.254.0.1:7000/auth/v8.0/ -U bar:foo -K dummy -V 1.0 list | grep dispersion_" |
| 106 | + )} |
| 107 | + end |
| 108 | +end |
0 commit comments