Write spec test for openstack::compute
* Include the puppetlabs_spec_helper gem for autogeneration of the fixtures dir
This commit is contained in:
		
							
								
								
									
										10
									
								
								.fixtures.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.fixtures.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
fixtures:
 | 
			
		||||
  repositories:
 | 
			
		||||
    "apt": "git://github.com/puppetlabs/puppetlabs-apt.git"
 | 
			
		||||
    "keystone": "git://github.com/puppetlabs/puppetlabs-keystone.git"
 | 
			
		||||
    "mysql": "git://github.com/puppetlabs/puppetlabs-mysql.git"
 | 
			
		||||
    "nova": "git://github.com/puppetlabs/puppetlabs-nova.git"
 | 
			
		||||
    "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
 | 
			
		||||
    "sysctl": "git://github.com/duritong/puppet-sysctl.git"
 | 
			
		||||
  symlinks:
 | 
			
		||||
    "openstack": "#{source_dir}"
 | 
			
		||||
							
								
								
									
										2
									
								
								Rakefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Rakefile
									
									
									
									
									
								
							@@ -5,7 +5,7 @@
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require 'puppet'
 | 
			
		||||
require 'puppetlabs_spec_helper/rake_tasks'
 | 
			
		||||
 | 
			
		||||
repo_file = 'other_repos.yaml'
 | 
			
		||||
default_modulepath = '/etc/puppet/modules'
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,104 @@ require 'spec_helper'
 | 
			
		||||
 | 
			
		||||
describe 'openstack::compute' do
 | 
			
		||||
 | 
			
		||||
  let :default_params do
 | 
			
		||||
    {
 | 
			
		||||
      :private_interface => 'eth0',
 | 
			
		||||
      :internal_address  => '0.0.0.0',
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  let :facts do
 | 
			
		||||
    {
 | 
			
		||||
      :operatingsystem => 'Ubuntu',
 | 
			
		||||
      :osfamily        => 'Debian',
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
  describe "when using default class paramaters" do
 | 
			
		||||
    let :params do
 | 
			
		||||
      default_params
 | 
			
		||||
    end
 | 
			
		||||
    it {
 | 
			
		||||
      should contain_nova_config('multi_host').with({ 'value' => 'False' })
 | 
			
		||||
      should_not contain_class('nova::api')
 | 
			
		||||
      should_not contain_class('nova::volume')
 | 
			
		||||
      should_not contain_class('nova::volume::iscsi')
 | 
			
		||||
      should contain_class('nova::network').with({
 | 
			
		||||
        'enabled' => false,
 | 
			
		||||
        'install_service' => false
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "when enabling volume management" do
 | 
			
		||||
    let :params do
 | 
			
		||||
      default_params.merge({
 | 
			
		||||
        :manage_volumes => true
 | 
			
		||||
      })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it {
 | 
			
		||||
      should contain_nova_config('multi_host').with({ 'value' => 'False'})
 | 
			
		||||
      should_not contain_class('nova::api')
 | 
			
		||||
      should contain_class('nova::volume')
 | 
			
		||||
      should contain_class('nova::volume::iscsi')
 | 
			
		||||
      should contain_class('nova::network').with({
 | 
			
		||||
        'enabled' => false,
 | 
			
		||||
        'install_service' => false
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "when configuring for multi host" do
 | 
			
		||||
    let :params do
 | 
			
		||||
      default_params.merge({
 | 
			
		||||
        :multi_host       => true,
 | 
			
		||||
        :public_interface => 'eth0'
 | 
			
		||||
      })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it {
 | 
			
		||||
      should contain_nova_config('multi_host').with({ 'value' => 'True'})
 | 
			
		||||
      should contain_class('nova::api')
 | 
			
		||||
      should_not contain_class('nova::volume')
 | 
			
		||||
      should_not contain_class('nova::volume::iscsi')
 | 
			
		||||
      should contain_class('nova::network').with({
 | 
			
		||||
        'enabled' => true,
 | 
			
		||||
        'install_service' => true
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "when configuring for multi host without a public interface" do
 | 
			
		||||
    let :params do
 | 
			
		||||
      default_params.merge({
 | 
			
		||||
        :multi_host => true
 | 
			
		||||
      })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it {
 | 
			
		||||
      expect { should raise_error(Puppet::Error) }
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "when enabling volume management and using multi host" do
 | 
			
		||||
    let :params do
 | 
			
		||||
      default_params.merge({
 | 
			
		||||
        :multi_host       => true,
 | 
			
		||||
        :public_interface => 'eth0',
 | 
			
		||||
        :manage_volumes   => true,
 | 
			
		||||
      })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it {
 | 
			
		||||
      should contain_nova_config('multi_host').with({ 'value' => 'True'})
 | 
			
		||||
      should contain_class('nova::api')
 | 
			
		||||
      should contain_class('nova::volume')
 | 
			
		||||
      should contain_class('nova::volume::iscsi')
 | 
			
		||||
      should contain_class('nova::network').with({
 | 
			
		||||
        'enabled' => true,
 | 
			
		||||
        'install_service' => true
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								spec/fixtures/manifests/site.pp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								spec/fixtures/manifests/site.pp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -1,18 +1 @@
 | 
			
		||||
require 'puppet'
 | 
			
		||||
require 'rspec'
 | 
			
		||||
require 'rspec-puppet'
 | 
			
		||||
 | 
			
		||||
def param_value(subject, type, title, param)
 | 
			
		||||
  subject.resource(type, title).send(:parameters)[param.to_sym]
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
def verify_contents(subject, title, expected_lines)
 | 
			
		||||
  content = subject.resource('file', title).send(:parameters)[:content]
 | 
			
		||||
  (content.split("\n") & expected_lines).should == expected_lines
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
RSpec.configure do |c|
 | 
			
		||||
  c.module_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/modules/'))
 | 
			
		||||
  # Using an empty site.pp file to avoid: https://github.com/rodjek/rspec-puppet/issues/15
 | 
			
		||||
  c.manifest_dir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/manifests'))
 | 
			
		||||
end
 | 
			
		||||
require 'puppetlabs_spec_helper/module_spec_helper'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user