File: cinder_backend_dellemc_powermax_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 (153 lines) | stat: -rw-r--r-- 5,999 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
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
require 'spec_helper'

describe 'cinder::backend::dellemc_powermax' do
  let (:config_group_name) { 'dellemc_powermax' }

  let (:title) { config_group_name }

  let :params do
    {
      :san_ip                    => '127.0.0.2',
      :san_login                 => 'Admin',
      :san_password              => '12345',
      :powermax_array            => '000123456789',
      :powermax_srp              => 'SRP_1',
      :powermax_port_groups      => '[OS-ISCSI-PG]',
    }
  end

  shared_examples 'cinder::backend::dellemc_powermax' do
    context 'with default parameters' do
      it 'should configure an iSCSI dellemc_powermax backend' do
        is_expected.to contain_cinder__backend__dellemc_powermax(config_group_name)
        is_expected.to contain_cinder_config("#{title}/volume_driver").with_value(
          'cinder.volume.drivers.dell_emc.powermax.iscsi.PowerMaxISCSIDriver'
        )
        is_expected.to contain_cinder_config("#{title}/san_ip").with_value('127.0.0.2')
        is_expected.to contain_cinder_config("#{title}/san_login").with_value('Admin')
        is_expected.to contain_cinder_config("#{title}/san_password").with_value('12345')
        is_expected.to contain_cinder_config("#{title}/powermax_array").with_value('000123456789')
        is_expected.to contain_cinder_config("#{title}/powermax_srp").with_value('SRP_1')
        is_expected.to contain_cinder_config("#{title}/powermax_port_groups").with_value('[OS-ISCSI-PG]')
        is_expected.to contain_cinder_config("#{title}/backend_availability_zone").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/reserved_percentage").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/max_over_subscription_ratio").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/image_volume_cache_enabled").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/image_volume_cache_max_size_gb").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/image_volume_cache_max_count").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/rest_api_connect_timeout").with_value('<SERVICE DEFAULT>')
        is_expected.to contain_cinder_config("#{title}/rest_api_read_timeout").with_value('<SERVICE DEFAULT>')

        is_expected.to contain_package('pywbem').with(
          :ensure => 'installed',
          :name   => platform_params[:pywbem_package_name],
          :tag    => 'cinder-support-package',
        )
      end
    end

    context 'with powermax_port_groups without bounds' do
      before do
        params.merge!(:powermax_port_groups => 'OS-ISCSI-PG')
      end
      it 'should add bounds' do
        is_expected.to contain_cinder_config("#{title}/powermax_port_groups").with_value('[OS-ISCSI-PG]')
      end
    end

    context 'with powermax_port_groups set by a list' do
      before do
        params.merge!(:powermax_port_groups => ['OS-ISCSI-PG1', 'OS-ISCSI-PG2'])
      end
      it 'should render a comma-separated list with bounds' do
        is_expected.to contain_cinder_config("#{title}/powermax_port_groups").with_value('[OS-ISCSI-PG1,OS-ISCSI-PG2]')
      end
    end

    context 'with powermax_storage_protocol set to FC' do
      before do
        params.merge!(:powermax_storage_protocol => 'FC',)
      end

      it 'should configure the FC driver' do
        is_expected.to contain_cinder_config("#{title}/volume_driver").with_value(
          'cinder.volume.drivers.dell_emc.powermax.fc.PowerMaxFCDriver'
        )
      end
    end

    context 'with an invalid powermax_storage_protocol' do
      before do
        params.merge!(:powermax_storage_protocol => 'BAD',)
      end

      it 'should raise an error' do
        is_expected.to compile.and_raise_error(/Evaluation Error/)
      end
    end

    context 'with parameters' do
      before do
        params.merge!({
          :backend_availability_zone   => 'my_zone',
          :reserved_percentage         => 10,
          :max_over_subscription_ratio => 1.5,
          :rest_api_connect_timeout    => 30,
          :rest_api_read_timeout       => 31,
        })
      end

      it 'should configure the customized values' do
        is_expected.to contain_cinder_config("#{title}/backend_availability_zone").with_value('my_zone')
        is_expected.to contain_cinder_config("#{title}/reserved_percentage").with_value(10)
        is_expected.to contain_cinder_config("#{title}/max_over_subscription_ratio").with_value(1.5)
        is_expected.to contain_cinder_config("#{title}/rest_api_connect_timeout").with_value(30)
        is_expected.to contain_cinder_config("#{title}/rest_api_read_timeout").with_value(31)
      end
    end

    context 'dellemc_powermax backend with additional configuration' do
      before do
        params.merge!( :extra_options => {'dellemc_powermax/param1' => { 'value' => 'value1' }} )
      end

      it { is_expected.to contain_cinder_config('dellemc_powermax/param1').with_value('value1') }
    end

    context 'dellemc_powermax backend with cinder type' do
      before do
        params.merge!( :manage_volume_type => true )
      end

      it { is_expected.to contain_cinder_type('dellemc_powermax').with(
        :ensure     => 'present',
        :properties => ['volume_backend_name=dellemc_powermax']
      )}
    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'
          {
            :pywbem_package_name => 'python-pywbem'
          }
        when 'RedHat'
          {
            :pywbem_package_name => 'pywbem'
          }
        end
      end

      it_behaves_like 'cinder::backend::dellemc_powermax'
    end
  end
end