File: nova_spicehtml5proxy_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 (102 lines) | stat: -rw-r--r-- 2,861 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
require 'spec_helper'

describe 'nova::spicehtml5proxy' do

  let :pre_condition do
    'include nova'
  end

  shared_examples 'nova::spicehtml5proxy' do
    it 'configures nova.conf' do
      should contain_nova_config('spice/html5proxy_host').with(:value => '0.0.0.0')
      should contain_nova_config('spice/html5proxy_port').with(:value => '6082')
    end

    it { should contain_package('nova-spicehtml5proxy').with(
      :ensure => 'present',
      :name   => platform_params[:spicehtml5proxy_package_name]
    ) }

    it { should contain_service('nova-spicehtml5proxy').with(
      :ensure    => 'running',
      :name      => platform_params[:spicehtml5proxy_service_name],
      :hasstatus => true
    )}

    context 'with manage_service as false' do
      let :params do
        {
          :manage_service => false
        }
      end

      it { should_not contain_service('nova-spicehtml5proxy') }
    end

    context 'with package version' do
      let :params do
        { :ensure_package => '2012.1-2' }
      end

      it { should contain_package('nova-spicehtml5proxy').with(
        :ensure => params[:ensure_package],
        :name   => platform_params[:spicehtml5proxy_package_name],
      )}
    end
  end

  shared_examples 'nova::spicehtml5proxy on Debian' do
    let :params do
      {
        :enabled => true
      }
    end

    it { should contain_file_line('/etc/default/nova-consoleproxy:NOVA_CONSOLE_PROXY_TYPE').with(
        :path    => '/etc/default/nova-consoleproxy',
        :match   => '^NOVA_CONSOLE_PROXY_TYPE=(.*)$',
        :line    => 'NOVA_CONSOLE_PROXY_TYPE=spicehtml5',
        :tag     => 'nova-consoleproxy',
        :require => 'Anchor[nova::config::begin]',
        :notify  => 'Anchor[nova::config::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

      let (:platform_params) do
        case facts[:os]['family']
        when 'Debian'
          if facts[:os]['name'] == 'Debian' then
            package_name = 'nova-consoleproxy'
            service_name = 'nova-spicehtml5proxy'
          else
            package_name = 'nova-spiceproxy'
            service_name = 'nova-spiceproxy'
          end
          {
            :spicehtml5proxy_package_name => package_name,
            :spicehtml5proxy_service_name => service_name
          }
        when 'RedHat'
          {
            :spicehtml5proxy_package_name => 'openstack-nova-console',
            :spicehtml5proxy_service_name => 'openstack-nova-spicehtml5proxy'
          }
        end
      end

      it_behaves_like 'nova::spicehtml5proxy'

      if facts[:os]['name'] == 'Debian'
        it_behaves_like 'nova::spicehtml5proxy on Debian'
      end
    end
  end
end