File: cinder_backend_dellemc_xtremio_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 (130 lines) | stat: -rw-r--r-- 4,013 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
require 'spec_helper'

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

  let (:title) { config_group_name }

  let :params do
    {
      :san_ip                => '172.23.8.101',
      :san_login             => 'Admin',
      :san_password          => '12345',
      :xtremio_cluster_name  => 'Cluster01',
    }
  end

  let :default_params do
    {
      :backend_availability_zone         => '<SERVICE DEFAULT>',
      :image_volume_cache_enabled        => '<SERVICE DEFAULT>',
      :image_volume_cache_max_size_gb    => '<SERVICE DEFAULT>',
      :image_volume_cache_max_count      => '<SERVICE DEFAULT>',
      :reserved_percentage               => '<SERVICE DEFAULT>',
      :max_over_subscription_ratio       => '<SERVICE DEFAULT>',
      :xtremio_array_busy_retry_count    => '<SERVICE DEFAULT>',
      :xtremio_array_busy_retry_interval => '<SERVICE DEFAULT>',
      :xtremio_volumes_per_glance_cache  => '<SERVICE DEFAULT>',
      :xtremio_ports                     => '<SERVICE DEFAULT>',
    }
  end

  let :custom_params do
    {
      :backend_availability_zone         => 'my_zone',
      :image_volume_cache_enabled        => true,
      :image_volume_cache_max_size_gb    => 100,
      :image_volume_cache_max_count      => 101,
      :reserved_percentage               => 10,
      :max_over_subscription_ratio       => 1.5,
      :xtremio_array_busy_retry_count    => 15,
      :xtremio_array_busy_retry_interval => 6,
      :xtremio_volumes_per_glance_cache  => 100,
      :xtremio_ports                     => '58:cc:f0:98:49:22:07:02',
    }
  end

  shared_examples 'dellemc_xtremio volume driver' do
    let :params_hash do
      default_params.merge(params)
    end

    it {
      is_expected.to contain_cinder__backend__dellemc_xtremio(config_group_name)
      is_expected.to contain_cinder_config("#{title}/volume_driver").with_value('cinder.volume.drivers.dell_emc.xtremio.XtremIOISCSIDriver')
    }

    it {
      params_hash.each_pair do |config,value|
        is_expected.to contain_cinder_config("#{config_group_name}/#{config}").with_value( value )
      end
    }
  end

   context 'with xtremio_storage_protocol set to FC' do
      before do
        params.merge!(:xtremio_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.xtremio.XtremIOFCDriver'
        )
      end
    end

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

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

  shared_examples 'cinder::backend::dellemc_xtremio' do
    context 'with default parameters' do
      it_behaves_like 'dellemc_xtremio volume driver'
    end

    context 'with custom parameters' do
      before do
        params.merge(custom_params)
      end

      it_behaves_like 'dellemc_xtremio volume driver'
    end

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

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

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

      it { is_expected.to contain_cinder_type('dellemc_xtremio').with(
        :ensure => 'present',
        :properties => ['volume_backend_name=dellemc_xtremio']
      )}
    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::backend::dellemc_xtremio'
    end
  end
end