Files
cookbook-openstack-compute/spec/spec_helper.rb
John Dewey 34da9ece10 Removed the use of non-standard ohai plugin
We now have a helper method `#address_for` to return the
IP of a given interface. Switched out the ohai use
in favor of `#address_for`. Also, updated berkshelf
to 2.x which handles dep resolution correctly. I run
into problems getting berkshelf to lock to the new 0.3.0
openstack-common w/o updating berkshelf.

Change-Id: Iaf39cee98589d8d1c4b90e610b94e5440ac51fd8
2013-06-28 21:50:18 -07:00

106 lines
2.6 KiB
Ruby

require "chefspec"
::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = {
:platform => "opensuse",
:version => "12.3",
:log_level => ::LOG_LEVEL
}
::REDHAT_OPTS = {
:platform => "redhat",
:version => "6.3",
:log_level => ::LOG_LEVEL
}
::UBUNTU_OPTS = {
:platform => "ubuntu",
:version => "12.04",
:log_level => ::LOG_LEVEL
}
def compute_stubs
::Chef::Recipe.any_instance.stub(:address_for).
with("lo").
and_return "127.0.1.1"
::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("os-identity").and_return(
{
'openstack' => {
'identity' => {
'admin_tenant_name' => 'admin-tenant',
'admin_user' => 'admin-user'
}
}
}
)
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "openstack_identity_bootstrap_token").
and_return "bootstrap-token"
::Chef::Recipe.any_instance.stub(:db_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).and_return String.new
::Chef::Recipe.any_instance.stub(:service_password).with("openstack-compute").
and_return "nova-pass"
::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 "openstack-compute::nova-common"
end
end
def expect_runs_ceilometer_common_recipe
it "installs nova-ceilometer" do
expect(@chef_run).to include_recipe "openstack-compute::ceilometer-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 service, action=:restart
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
it "notifies nova-api-ec2 restart" do
expect(@file).to notify service, action
end
end
end