memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / spec / classes / neutron_agents_metering_spec.rb
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # Unit tests for neutron::plugins::metering class
19 #
20
21 require 'spec_helper'
22
23 describe 'neutron::agents::metering' do
24
25   let :pre_condition do
26     "class { 'neutron':
27       rabbit_password => 'passw0rd',
28       service_plugins => ['neutron.services.metering.metering_plugin.MeteringPlugin'] }"
29   end
30
31   let :params do
32     {}
33   end
34
35   let :default_params do
36     { :package_ensure   => 'present',
37       :enabled          => true,
38       :debug            => false,
39       :interface_driver => 'neutron.agent.linux.interface.OVSInterfaceDriver',
40       :use_namespaces   => true,
41       :measure_interval => '30',
42       :report_interval  => '300'
43     }
44   end
45
46
47   shared_examples_for 'neutron metering agent' do
48     let :p do
49       default_params.merge(params)
50     end
51
52     it { should contain_class('neutron::params') }
53
54     it 'configures metering_agent.ini' do
55       should contain_neutron_metering_agent_config('DEFAULT/debug').with_value(p[:debug]);
56       should contain_neutron_metering_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]);
57       should contain_neutron_metering_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]);
58       should contain_neutron_metering_agent_config('DEFAULT/measure_interval').with_value(p[:measure_interval]);
59       should contain_neutron_metering_agent_config('DEFAULT/report_interval').with_value(p[:report_interval]);
60     end
61
62     it 'installs neutron metering agent package' do
63       if platform_params.has_key?(:metering_agent_package)
64         should contain_package('neutron-metering-agent').with(
65           :name   => platform_params[:metering_agent_package],
66           :ensure => p[:package_ensure]
67         )
68         should contain_package('neutron').with_before(/Package\[neutron-metering-agent\]/)
69         should contain_package('neutron-metering-agent').with_before(/Neutron_metering_agent_config\[.+\]/)
70         should contain_package('neutron-metering-agent').with_before(/Neutron_config\[.+\]/)
71       else
72         should contain_package('neutron').with_before(/Neutron_metering_agent_config\[.+\]/)
73       end
74     end
75
76     it 'configures neutron metering agent service' do
77       should contain_service('neutron-metering-service').with(
78         :name    => platform_params[:metering_agent_service],
79         :enable  => true,
80         :ensure  => 'running',
81         :require => 'Class[Neutron]'
82       )
83     end
84
85     context 'with manage_service as false' do
86       before :each do
87         params.merge!(:manage_service => false)
88       end
89       it 'should not start/stop service' do
90         should contain_service('neutron-metering-service').without_ensure
91       end
92     end
93   end
94
95   context 'on Debian platforms' do
96     let :facts do
97       { :osfamily => 'Debian' }
98     end
99
100     let :platform_params do
101       { :metering_agent_package => 'neutron-metering-agent',
102         :metering_agent_service => 'neutron-metering-agent' }
103     end
104
105     it_configures 'neutron metering agent'
106   end
107
108   context 'on RedHat platforms' do
109     let :facts do
110       { :osfamily => 'RedHat' }
111     end
112
113     let :platform_params do
114       { :metering_agent_package => 'openstack-neutron-metering-agent',
115         :metering_agent_service => 'neutron-metering-agent' }
116     end
117
118     it_configures 'neutron metering agent'
119   end
120 end