Added initial chefspec tests
Does not include template rendering tests. Could use some help with these, as they are fairly important.
This commit is contained in:
parent
1d8da0c886
commit
4bcd9d20c8
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
*.swp
|
||||
cookbooks
|
||||
test/kitchen/.kitchen
|
||||
.bundle
|
||||
.cookbooks/
|
||||
Berksfile.lock
|
||||
|
11
Berksfile
Normal file
11
Berksfile
Normal file
@ -0,0 +1,11 @@
|
||||
metadata
|
||||
|
||||
|
||||
cookbook "glance",
|
||||
git: "git@github.com:att-cloud/cookbook-glance.git"
|
||||
cookbook "keystone",
|
||||
git: "git@github.com:att-cloud/cookbook-keystone.git"
|
||||
cookbook "openstack-common",
|
||||
git: "git@github.com:att-cloud/cookbook-openstack-common.git"
|
||||
cookbook "sysctl",
|
||||
git: "git@github.com:Fewbytes/sysctl-cookbook.git"
|
7
Gemfile
7
Gemfile
@ -1,3 +1,6 @@
|
||||
source :rubygems
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem 'test-kitchen'
|
||||
gem "chef", "~> 10.18.2"
|
||||
gem "berkshelf", "~> 1.4.0"
|
||||
gem "chefspec", "~> 1.0.0"
|
||||
gem "foodcritic", "~> 2.1.0"
|
||||
|
165
Gemfile.lock
Normal file
165
Gemfile.lock
Normal file
@ -0,0 +1,165 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (3.2.13)
|
||||
i18n (= 0.6.1)
|
||||
multi_json (~> 1.0)
|
||||
addressable (2.3.4)
|
||||
berkshelf (1.4.2)
|
||||
activesupport (>= 3.2.0)
|
||||
addressable
|
||||
celluloid (>= 0.13.0)
|
||||
chozo (>= 0.6.1)
|
||||
faraday (>= 0.8.5)
|
||||
hashie (>= 2.0.2)
|
||||
json (>= 1.5.0)
|
||||
minitar
|
||||
mixlib-config (~> 1.1)
|
||||
mixlib-shellout (~> 1.1)
|
||||
multi_json (~> 1.5)
|
||||
retryable
|
||||
ridley (~> 0.9.0)
|
||||
solve (>= 0.4.2)
|
||||
thor (~> 0.18.0)
|
||||
yajl-ruby
|
||||
builder (3.2.0)
|
||||
bunny (0.7.9)
|
||||
celluloid (0.13.0)
|
||||
timers (>= 1.0.0)
|
||||
chef (10.18.2)
|
||||
bunny (>= 0.6.0, < 0.8.0)
|
||||
erubis
|
||||
highline (>= 1.6.9)
|
||||
json (>= 1.4.4, <= 1.6.1)
|
||||
mixlib-authentication (>= 1.3.0)
|
||||
mixlib-cli (>= 1.1.0)
|
||||
mixlib-config (>= 1.1.2)
|
||||
mixlib-log (>= 1.3.0)
|
||||
mixlib-shellout
|
||||
moneta (< 0.7.0)
|
||||
net-ssh (~> 2.2.2)
|
||||
net-ssh-multi (~> 1.1.0)
|
||||
ohai (>= 0.6.0)
|
||||
rest-client (>= 1.0.4, < 1.7.0)
|
||||
treetop (~> 1.4.9)
|
||||
uuidtools
|
||||
yajl-ruby (~> 1.1)
|
||||
chefspec (1.0.0)
|
||||
chef (>= 10.0)
|
||||
erubis
|
||||
fauxhai (~> 0.1)
|
||||
minitest-chef-handler (>= 0.6.0)
|
||||
rspec (~> 2.0)
|
||||
chozo (0.6.1)
|
||||
activesupport (>= 3.2.0)
|
||||
hashie (>= 2.0.2)
|
||||
multi_json (>= 1.3.0)
|
||||
ci_reporter (1.8.4)
|
||||
builder (>= 2.1.2)
|
||||
diff-lcs (1.2.4)
|
||||
erubis (2.7.0)
|
||||
faraday (0.8.7)
|
||||
multipart-post (~> 1.1)
|
||||
fauxhai (0.1.1)
|
||||
chef
|
||||
httparty
|
||||
net-ssh
|
||||
foodcritic (2.1.0)
|
||||
erubis
|
||||
gherkin (~> 2.11.7)
|
||||
nokogiri (~> 1.5.4)
|
||||
rak (~> 1.4)
|
||||
treetop (~> 1.4.10)
|
||||
yajl-ruby (~> 1.1.0)
|
||||
gherkin (2.11.8)
|
||||
multi_json (~> 1.3)
|
||||
hashie (2.0.4)
|
||||
highline (1.6.18)
|
||||
httparty (0.11.0)
|
||||
multi_json (~> 1.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.6.1)
|
||||
ipaddress (0.8.0)
|
||||
json (1.6.1)
|
||||
mime-types (1.23)
|
||||
minitar (0.5.4)
|
||||
minitest (4.7.4)
|
||||
minitest-chef-handler (1.0.1)
|
||||
chef
|
||||
ci_reporter
|
||||
minitest (~> 4.7.3)
|
||||
mixlib-authentication (1.3.0)
|
||||
mixlib-log
|
||||
mixlib-cli (1.3.0)
|
||||
mixlib-config (1.1.2)
|
||||
mixlib-log (1.6.0)
|
||||
mixlib-shellout (1.1.0)
|
||||
moneta (0.6.0)
|
||||
multi_json (1.7.2)
|
||||
multi_xml (0.5.3)
|
||||
multipart-post (1.2.0)
|
||||
net-http-persistent (2.8)
|
||||
net-ssh (2.2.2)
|
||||
net-ssh-gateway (1.1.0)
|
||||
net-ssh (>= 1.99.1)
|
||||
net-ssh-multi (1.1)
|
||||
net-ssh (>= 2.1.4)
|
||||
net-ssh-gateway (>= 0.99.0)
|
||||
nokogiri (1.5.9)
|
||||
ohai (6.16.0)
|
||||
ipaddress
|
||||
mixlib-cli
|
||||
mixlib-config
|
||||
mixlib-log
|
||||
mixlib-shellout
|
||||
systemu
|
||||
yajl-ruby
|
||||
polyglot (0.3.3)
|
||||
rak (1.4)
|
||||
rest-client (1.6.7)
|
||||
mime-types (>= 1.16)
|
||||
retryable (1.3.2)
|
||||
ridley (0.9.1)
|
||||
activesupport (>= 3.2.0)
|
||||
addressable
|
||||
celluloid (~> 0.13.0)
|
||||
chozo (>= 0.6.0)
|
||||
erubis
|
||||
faraday (>= 0.8.4)
|
||||
json (>= 1.5.0)
|
||||
mixlib-authentication (>= 1.3.0)
|
||||
mixlib-config (>= 1.1.0)
|
||||
mixlib-log (>= 1.3.0)
|
||||
mixlib-shellout (>= 1.1.0)
|
||||
multi_json (>= 1.0.4)
|
||||
net-http-persistent (>= 2.8)
|
||||
net-ssh
|
||||
retryable
|
||||
solve (>= 0.4.1)
|
||||
rspec (2.13.0)
|
||||
rspec-core (~> 2.13.0)
|
||||
rspec-expectations (~> 2.13.0)
|
||||
rspec-mocks (~> 2.13.0)
|
||||
rspec-core (2.13.1)
|
||||
rspec-expectations (2.13.0)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.13.1)
|
||||
solve (0.4.2)
|
||||
json
|
||||
systemu (2.5.2)
|
||||
thor (0.18.1)
|
||||
timers (1.1.0)
|
||||
treetop (1.4.12)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
uuidtools (2.1.4)
|
||||
yajl-ruby (1.1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
berkshelf (~> 1.4.0)
|
||||
chef (~> 10.18.2)
|
||||
chefspec (~> 1.0.0)
|
||||
foodcritic (~> 2.1.0)
|
36
README.md
36
README.md
@ -14,12 +14,6 @@ Requirements
|
||||
|
||||
Chef 0.10.0 or higher required (for Chef environment use).
|
||||
|
||||
Platforms
|
||||
--------
|
||||
|
||||
* Ubuntu-12.04
|
||||
* Fedora-17
|
||||
|
||||
Cookbooks
|
||||
---------
|
||||
|
||||
@ -35,8 +29,8 @@ The following cookbooks are dependencies:
|
||||
* sysctl
|
||||
* yum
|
||||
|
||||
Recipes
|
||||
=======
|
||||
Usage
|
||||
=====
|
||||
|
||||
api-ec2
|
||||
----
|
||||
@ -120,19 +114,14 @@ Attributes
|
||||
* `default["nova"]["service_user"]` - User name used by nova when interacting with keystone
|
||||
* `default["nova"]["service_role"]` - User role used by nova when interacting with keystone
|
||||
* `default["nova"]["floating_cmd"]` - Path to the `nova-manage floating create` wrapper script.
|
||||
|
||||
* `default["nova"]["pki"]["signing_dir"]` - Defaults to `/tmp/nova-signing-dir`. Directory where `auth_token` middleware writes certificate
|
||||
|
||||
* `default["nova"]["config"]["volume_api_class"]` - API Class used for Volume support
|
||||
|
||||
* `default["nova"]["compute"]["api"]["protocol"]` - Protocol used for the OS API
|
||||
* `default["nova"]["compute"]["api"]["port"]` - Port on which OS API runs
|
||||
* `default["nova"]["compute"]["api"]["version"]` - Version of the OS API used
|
||||
|
||||
* `default["nova"]["compute"]["adminURL"]` - URL used to access the OS API for admin functions
|
||||
* `default["nova"]["compute"]["internalURL"]` - URL used to access the OS API for user functions from an internal network
|
||||
* `default["nova"]["compute"]["publicURL"]` - URL used to access the OS API for user functions from an external network
|
||||
|
||||
* `default["nova"]["config"]["availability_zone"]` - Nova availability zone. Usually set at the node level to place a compute node in another az
|
||||
* `default["nova"]["config"]["default_schedule_zone"]` - The availability zone to schedule instances in when no az is specified in the request
|
||||
* `default["nova"]["config"]["force_raw_images"]` - Convert all images used as backing files for instances to raw (we default to false)
|
||||
@ -143,7 +132,6 @@ Attributes
|
||||
* `default["nova"]["config"]["snapshot_image_format"]` - Snapshot image format (valid options are : raw, qcow2, vmdk, vdi [we default to qcow2]).
|
||||
* `default["nova"]["config"]["start_guests_on_host_boot"]` - Whether to restart guests when the host reboots
|
||||
* `default["nova"]["config"]["resume_guests_state_on_host_boot"]` - Whether to start guests that were running before the host rebooted
|
||||
|
||||
* `default["nova"]["api"]["signing_dir"]` - Keystone PKI needs a location to hold the signed tokens
|
||||
* `default["nova"]["api"]["signing_dir"]` - Keystone PKI needs a location to hold the signed tokens
|
||||
|
||||
@ -232,20 +220,17 @@ Syslog Configuration Attributes
|
||||
|
||||
OSAPI Compute Extentions
|
||||
------------------------
|
||||
|
||||
* `default["nova"]["plugins"]` - Array of osapi compute exntesions to add to nova
|
||||
|
||||
Templates
|
||||
Testing
|
||||
=====
|
||||
* `api-paste.ini.erb` - Paste config for nova API middleware
|
||||
* `libvirt-bin.erb` - Initscript for starting libvirtd
|
||||
* `libvirtd-ssh-config` - Config file for libvirt SSH auth
|
||||
* `libvirtd-ssh-private-key.erb` - Private SSH key for libvirt SSH
|
||||
* `libvirtd-ssh-public-key.erb` - Public SSH key for libvirt SSH auth
|
||||
* `libvirtd.conf.erb` - Libvirt config file
|
||||
* `local_settings.py.erb` - Dashboard (horizon) config file
|
||||
* `nova.conf.erb` - Basic nova.conf file
|
||||
* `openrc.erb` - Contains environment variable settings to enable easy use of the nova client
|
||||
|
||||
This cookbook is using [ChefSpec](https://github.com/acrmp/chefspec) for
|
||||
testing. Run the following before commiting. It will run your tests,
|
||||
and check for lint errors.
|
||||
|
||||
$ ./run_tests.bash
|
||||
|
||||
License and Author
|
||||
==================
|
||||
@ -258,9 +243,12 @@ Author:: William Kelly (<william.kelly@rackspace.com>)
|
||||
Author:: Darren Birkett (<darren.birkett@rackspace.co.uk>)
|
||||
Author:: Evan Callicoat (<evan.callicoat@rackspace.com>)
|
||||
Author:: Matt Ray (<matt@opscode.com>)
|
||||
Author:: Jay Pipes (<jaypipes@att.com>)
|
||||
Author:: John Dewey (<jdewey@att.com>)
|
||||
|
||||
Copyright 2012, Rackspace US, Inc.
|
||||
Copyright 2012, Opscode, Inc.
|
||||
Copyright 2012-2013, AT&T Services, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
19
run_tests.bash
Executable file
19
run_tests.bash
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# A script to run tests locally before committing.
|
||||
|
||||
set -e
|
||||
|
||||
COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\')
|
||||
if [ -z $COOKBOOK ]; then
|
||||
echo "Cookbook name not defined in metadata.rb"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUNDLE_PATH=${BUNDLE_PATH:-.bundle}
|
||||
BERKSHELF_PATH=${BERKSHELF_PATH:-.cookbooks}
|
||||
|
||||
bundle install --path=${BUNDLE_PATH}
|
||||
bundle exec berks install --path=${BERKSHELF_PATH}
|
||||
bundle exec foodcritic -f any -t ~FC003 -t ~FC023 ${BERKSHELF_PATH}/${COOKBOOK}
|
||||
bundle exec rspec ${BERKSHELF_PATH}/${COOKBOOK}
|
21
spec/api-ec2-redhat_spec.rb
Normal file
21
spec/api-ec2-redhat_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::api-ec2" do
|
||||
describe "redhat" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "redhat",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::api-ec2"
|
||||
end
|
||||
|
||||
it "installs ec2 api packages" do
|
||||
expect(@chef_run).to upgrade_package "openstack-nova-api"
|
||||
end
|
||||
|
||||
it "starts ec2 api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "openstack-nova-api"
|
||||
end
|
||||
end
|
||||
end
|
35
spec/api-ec2_spec.rb
Normal file
35
spec/api-ec2_spec.rb
Normal file
@ -0,0 +1,35 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::api-ec2" do
|
||||
describe "ubuntu" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::api-ec2"
|
||||
end
|
||||
|
||||
expect_runs_nova_common_recipe
|
||||
|
||||
expect_creates_nova_lock_dir
|
||||
|
||||
expect_installs_python_keystone
|
||||
|
||||
it "installs ec2 api packages" do
|
||||
expect(@chef_run).to upgrade_package "nova-api-ec2"
|
||||
end
|
||||
|
||||
it "starts ec2 api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "nova-api-ec2"
|
||||
end
|
||||
|
||||
expect_creates_api_paste
|
||||
|
||||
it "notifies nova-api-ec2 restart" do
|
||||
@file = @chef_run.template "/etc/nova/api-paste.ini"
|
||||
expect(@file).to notify "service[nova-api-ec2]", :restart
|
||||
end
|
||||
end
|
||||
end
|
21
spec/api-metadata-redhat_spec.rb
Normal file
21
spec/api-metadata-redhat_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::api-metadata" do
|
||||
describe "redhat" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "redhat",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::api-ec2"
|
||||
end
|
||||
|
||||
it "installs metadata api packages" do
|
||||
expect(@chef_run).to upgrade_package "openstack-nova-api"
|
||||
end
|
||||
|
||||
it "starts metadata api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "openstack-nova-api"
|
||||
end
|
||||
end
|
||||
end
|
35
spec/api-metadata_spec.rb
Normal file
35
spec/api-metadata_spec.rb
Normal file
@ -0,0 +1,35 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::api-metadata" do
|
||||
describe "ubuntu" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::api-metadata"
|
||||
end
|
||||
|
||||
expect_runs_nova_common_recipe
|
||||
|
||||
expect_creates_nova_lock_dir
|
||||
|
||||
expect_installs_python_keystone
|
||||
|
||||
it "installs metadata api packages" do
|
||||
expect(@chef_run).to upgrade_package "nova-api-metadata"
|
||||
end
|
||||
|
||||
it "starts metadata api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "nova-api-metadata"
|
||||
end
|
||||
|
||||
expect_creates_api_paste
|
||||
|
||||
it "notifies nova-api-metadata restart" do
|
||||
@file = @chef_run.template "/etc/nova/api-paste.ini"
|
||||
expect(@file).to notify "service[nova-api-metadata]", :restart
|
||||
end
|
||||
end
|
||||
end
|
21
spec/api-os-compute-redhat_spec.rb
Normal file
21
spec/api-os-compute-redhat_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::api-os-compute" do
|
||||
describe "redhat" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "redhat",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::api-os-compute"
|
||||
end
|
||||
|
||||
it "installs openstack api packages" do
|
||||
expect(@chef_run).to upgrade_package "openstack-nova-api"
|
||||
end
|
||||
|
||||
it "starts openstack api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "openstack-nova-api"
|
||||
end
|
||||
end
|
||||
end
|
52
spec/api-os-compute_spec.rb
Normal file
52
spec/api-os-compute_spec.rb
Normal file
@ -0,0 +1,52 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::api-os-compute" do
|
||||
describe "ubuntu" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::api-os-compute"
|
||||
end
|
||||
|
||||
expect_runs_nova_common_recipe
|
||||
|
||||
expect_creates_nova_lock_dir
|
||||
|
||||
describe "/var/cache/nova/api" do
|
||||
before do
|
||||
@dir = @chef_run.directory "/var/cache/nova"
|
||||
end
|
||||
|
||||
##
|
||||
#TODO: ChefSpec needs to handle guards better. This
|
||||
# should only be created when pki is enabled.
|
||||
it "has proper owner" do
|
||||
expect(@dir).to be_owned_by "nova", "nova"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @dir.mode)).to eq "700"
|
||||
end
|
||||
end
|
||||
|
||||
expect_installs_python_keystone
|
||||
|
||||
it "installs openstack api packages" do
|
||||
expect(@chef_run).to upgrade_package "nova-api-os-compute"
|
||||
end
|
||||
|
||||
it "starts openstack api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "nova-api-os-compute"
|
||||
end
|
||||
|
||||
expect_creates_api_paste
|
||||
|
||||
it "notifies nova-api-metadata restart" do
|
||||
@file = @chef_run.template "/etc/nova/api-paste.ini"
|
||||
expect(@file).to notify "service[nova-api-os-compute]", :restart
|
||||
end
|
||||
end
|
||||
end
|
28
spec/ceilometer-db_spec.rb
Normal file
28
spec/ceilometer-db_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::ceilometer-db" do
|
||||
it "installs mysql packages" do
|
||||
@chef_run = converge
|
||||
|
||||
expect(@chef_run).to include_recipe "mysql::client"
|
||||
expect(@chef_run).to include_recipe "mysql::ruby"
|
||||
end
|
||||
|
||||
it "creates database and user" do
|
||||
::Chef::Recipe.any_instance.should_receive(:db_create_with_user).
|
||||
with "metering", "ceilometer", "test-pass"
|
||||
|
||||
converge
|
||||
end
|
||||
|
||||
def converge
|
||||
::Chef::Recipe.any_instance.stub(:db_password).with("ceilometer").
|
||||
and_return "test-pass"
|
||||
|
||||
::ChefSpec::ChefRunner.new(
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::ceilometer-db"
|
||||
end
|
||||
end
|
21
spec/compute-redhat_spec.rb
Normal file
21
spec/compute-redhat_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::compute" do
|
||||
describe "redhat" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new(
|
||||
:platform => "redhat",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::compute"
|
||||
end
|
||||
|
||||
it "installs nova compute packages" do
|
||||
expect(@chef_run).to upgrade_package "openstack-nova-compute"
|
||||
end
|
||||
|
||||
it "starts nova compute on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "openstack-nova-compute"
|
||||
end
|
||||
end
|
||||
end
|
72
spec/compute_spec.rb
Normal file
72
spec/compute_spec.rb
Normal file
@ -0,0 +1,72 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::compute" do
|
||||
describe "ubuntu" do
|
||||
before do
|
||||
nova_common_stubs
|
||||
@chef_run_opts = {
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL,
|
||||
}
|
||||
@chef_run = ::ChefSpec::ChefRunner.new @chef_run_opts
|
||||
@chef_run.converge "nova::compute"
|
||||
end
|
||||
|
||||
expect_runs_nova_common_recipe
|
||||
|
||||
it "runs api-metadata recipe" do
|
||||
expect(@chef_run).to include_recipe "nova::api-metadata"
|
||||
end
|
||||
|
||||
it "runs network recipe" do
|
||||
expect(@chef_run).to include_recipe "nova::network"
|
||||
end
|
||||
|
||||
it "installs nova compute packages" do
|
||||
expect(@chef_run).to upgrade_package "nova-compute"
|
||||
end
|
||||
|
||||
it "installs kvm when virt_type is 'kvm'" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new @chef_run_opts
|
||||
node = chef_run.node
|
||||
node.set["nova"]["libvirt"]["virt_type"] = "kvm"
|
||||
chef_run.converge "nova::compute"
|
||||
|
||||
expect(chef_run).to upgrade_package "nova-compute-kvm"
|
||||
expect(chef_run).not_to upgrade_package "nova-compute-qemu"
|
||||
end
|
||||
|
||||
it "installs qemu when virt_type is 'qemu'" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new @chef_run_opts
|
||||
node = chef_run.node
|
||||
node.set["nova"]["libvirt"]["virt_type"] = "qemu"
|
||||
chef_run.converge "nova::compute"
|
||||
|
||||
expect(chef_run).to upgrade_package "nova-compute-qemu"
|
||||
expect(chef_run).not_to upgrade_package "nova-compute-kvm"
|
||||
end
|
||||
|
||||
describe "nova-compute.conf" do
|
||||
before do
|
||||
@file = @chef_run.cookbook_file "/etc/nova/nova-compute.conf"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @file.mode)).to eq "644"
|
||||
end
|
||||
|
||||
it "template contents" do
|
||||
pending "TODO: implement"
|
||||
end
|
||||
end
|
||||
|
||||
it "starts nova compute on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "nova-compute"
|
||||
end
|
||||
|
||||
it "runs libvirt recipe" do
|
||||
expect(@chef_run).to include_recipe "nova::libvirt"
|
||||
end
|
||||
end
|
||||
end
|
28
spec/db_spec.rb
Normal file
28
spec/db_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::db" do
|
||||
it "installs mysql packages" do
|
||||
@chef_run = converge
|
||||
|
||||
expect(@chef_run).to include_recipe "mysql::client"
|
||||
expect(@chef_run).to include_recipe "mysql::ruby"
|
||||
end
|
||||
|
||||
it "creates database and user" do
|
||||
::Chef::Recipe.any_instance.should_receive(:db_create_with_user).
|
||||
with "compute", "nova", "test-pass"
|
||||
|
||||
converge
|
||||
end
|
||||
|
||||
def converge
|
||||
::Chef::Recipe.any_instance.stub(:db_password).with("nova").
|
||||
and_return "test-pass"
|
||||
|
||||
::ChefSpec::ChefRunner.new(
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL
|
||||
).converge "nova::db"
|
||||
end
|
||||
end
|
4
spec/default_spec.rb
Normal file
4
spec/default_spec.rb
Normal file
@ -0,0 +1,4 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe "nova::default" do
|
||||
end
|
66
spec/spec_helper.rb
Normal file
66
spec/spec_helper.rb
Normal file
@ -0,0 +1,66 @@
|
||||
require "chefspec"
|
||||
|
||||
::LOG_LEVEL = :fatal
|
||||
|
||||
def nova_common_stubs
|
||||
::Chef::Recipe.any_instance.stub(:config_by_role).
|
||||
with("rabbitmq-server", "queue").and_return(
|
||||
{'host' => 'rabbit-host', 'port' => 'rabbit-port'}
|
||||
)
|
||||
::Chef::Recipe.any_instance.stub(:config_by_role).
|
||||
with("keystone", "keystone").and_return(
|
||||
{'admin_tenant_name' => 'admin-tenant', 'admin_user' => 'admin-user'}
|
||||
)
|
||||
::Chef::Recipe.any_instance.stub(:db_password).and_return []
|
||||
::Chef::Recipe.any_instance.stub(:user_password).and_return []
|
||||
::Chef::Recipe.any_instance.stub(:service_password).and_return []
|
||||
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return []
|
||||
end
|
||||
|
||||
def expect_runs_nova_common_recipe
|
||||
it "installs nova-common" do
|
||||
expect(@chef_run).to include_recipe "nova::nova-common"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_installs_python_keystone
|
||||
it "installs python-keystone" do
|
||||
expect(@chef_run).to upgrade_package "python-keystone"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_creates_nova_lock_dir
|
||||
describe "/var/lock/nova" do
|
||||
before do
|
||||
@dir = @chef_run.directory "/var/lock/nova"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@dir).to be_owned_by "nova", "nova"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @dir.mode)).to eq "700"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def expect_creates_api_paste
|
||||
describe "api-paste.ini" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/nova/api-paste.ini"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "nova", "nova"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @file.mode)).to eq "644"
|
||||
end
|
||||
|
||||
it "template contents" do
|
||||
pending "TODO: implement"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,4 +0,0 @@
|
||||
cookbook "cookbook-nova" do
|
||||
lint(:ignore => ["FC024"])
|
||||
runtimes []
|
||||
end
|
Loading…
Reference in New Issue
Block a user