2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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
18 # Unit tests for neutron::plugins::metering class
23 describe 'neutron::agents::metering' do
27 rabbit_password => 'passw0rd',
28 service_plugins => ['neutron.services.metering.metering_plugin.MeteringPlugin'] }"
35 let :default_params do
36 { :package_ensure => 'present',
39 :interface_driver => 'neutron.agent.linux.interface.OVSInterfaceDriver',
40 :use_namespaces => true,
41 :measure_interval => '30',
42 :report_interval => '300'
47 shared_examples_for 'neutron metering agent' do
49 default_params.merge(params)
52 it { should contain_class('neutron::params') }
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]);
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]
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\[.+\]/)
72 should contain_package('neutron').with_before(/Neutron_metering_agent_config\[.+\]/)
76 it 'configures neutron metering agent service' do
77 should contain_service('neutron-metering-service').with(
78 :name => platform_params[:metering_agent_service],
81 :require => 'Class[Neutron]'
85 context 'with manage_service as false' do
87 params.merge!(:manage_service => false)
89 it 'should not start/stop service' do
90 should contain_service('neutron-metering-service').without_ensure
95 context 'on Debian platforms' do
97 { :osfamily => 'Debian' }
100 let :platform_params do
101 { :metering_agent_package => 'neutron-metering-agent',
102 :metering_agent_service => 'neutron-metering-agent' }
105 it_configures 'neutron metering agent'
108 context 'on RedHat platforms' do
110 { :osfamily => 'RedHat' }
113 let :platform_params do
114 { :metering_agent_package => 'openstack-neutron-metering-agent',
115 :metering_agent_service => 'neutron-metering-agent' }
118 it_configures 'neutron metering agent'