Added a batch of initial chefspec tests
* Added pending tests marked as 'TODO' for those which need figuring out * Also added pending tests for template contents
This commit is contained in:
parent
4e030e5fd7
commit
44d46fc8e4
|
@ -1 +1,3 @@
|
|||
*.swp
|
||||
.bundle
|
||||
.cookbooks/
|
||||
Berksfile.lock
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
metadata
|
||||
|
||||
cookbook "keystone",
|
||||
git: "git@github.com:att-cloud/cookbook-keystone.git"
|
||||
cookbook "openstack-common",
|
||||
git: "git@github.com:att-cloud/cookbook-openstack-common.git"
|
|
@ -0,0 +1,6 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem "chef", "~> 10.18.2"
|
||||
gem "berkshelf", "~> 1.4.0"
|
||||
gem "chefspec", "~> 1.0.0"
|
||||
gem "foodcritic", "~> 2.1.0"
|
|
@ -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.3)
|
||||
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.3)
|
||||
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)
|
|
@ -60,12 +60,9 @@ def _upload_qcow(name, url)
|
|||
c_fmt = "--container-format bare"
|
||||
d_fmt = "--disk-format qcow2"
|
||||
|
||||
bash "Uploading QCOW2 image #{name}" do
|
||||
execute "Uploading QCOW2 image #{name}" do
|
||||
cwd "/tmp"
|
||||
user "root"
|
||||
code <<-EOH
|
||||
#{glance_cmd} image-create --name "#{name}" --is-public true #{c_fmt} #{d_fmt} --location "#{url}"
|
||||
EOH
|
||||
command "#{glance_cmd} image-create --name #{name} --is-public true #{c_fmt} #{d_fmt} --location #{url}"
|
||||
not_if "#{glance_cmd} image-list | grep #{name.to_s}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,11 +31,11 @@ end
|
|||
|
||||
platform_options = node["glance"]["platform"]
|
||||
|
||||
package "curl" do
|
||||
action :upgrade
|
||||
package "python-keystone" do
|
||||
action :install
|
||||
end
|
||||
|
||||
package "python-keystone" do
|
||||
package "curl" do
|
||||
action :install
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Cookbook Name:: glance
|
||||
# Recipe:: default
|
||||
#
|
||||
# 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.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
|
@ -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}
|
|
@ -0,0 +1,15 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "glance::api" do
|
||||
describe "redhat" do
|
||||
before do
|
||||
glance_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS
|
||||
@chef_run.converge "glance::api"
|
||||
end
|
||||
|
||||
it "starts glance api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "openstack-glance-api"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,220 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "glance::api" do
|
||||
describe "ubuntu" do
|
||||
before do
|
||||
glance_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
@node = @chef_run.node
|
||||
@node.set["glance"]["syslog"]["use"] = true
|
||||
@chef_run.converge "glance::api"
|
||||
end
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
|
||||
expect_installs_python_keystone
|
||||
|
||||
expect_installs_curl
|
||||
|
||||
expect_installs_ubuntu_glance_packages
|
||||
|
||||
it "starts glance api on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "glance-api"
|
||||
end
|
||||
|
||||
expect_creates_glance_dir
|
||||
|
||||
expect_creates_cache_dir
|
||||
|
||||
describe "policy.json" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/policy.json"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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[glance-api]", :restart
|
||||
end
|
||||
end
|
||||
|
||||
describe "glance-api.conf" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-api.conf"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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[glance-api]", :restart
|
||||
end
|
||||
end
|
||||
|
||||
describe "glance-api-paste.ini" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-api-paste.ini"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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[glance-api]", :restart
|
||||
end
|
||||
end
|
||||
|
||||
describe "glance-cache.conf" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-cache.conf"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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[glance-api]", :restart
|
||||
end
|
||||
end
|
||||
|
||||
describe "glance-cache-paste.ini" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-cache-paste.ini"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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[glance-api]", :restart
|
||||
end
|
||||
end
|
||||
|
||||
describe "glance-scrubber.conf" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-scrubber.conf"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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 "has glance-cache-pruner cronjob running every 30 minutes" do
|
||||
cron = @chef_run.cron "glance-cache-pruner"
|
||||
expect(cron.command).to eq "/usr/bin/glance-cache-pruner"
|
||||
expect(cron.minute).to eq "*/30"
|
||||
end
|
||||
|
||||
it "has glance-cache-cleaner to run at 00:01 each day" do
|
||||
cron = @chef_run.cron "glance-cache-cleaner"
|
||||
expect(cron.command).to eq "/usr/bin/glance-cache-cleaner"
|
||||
expect(cron.minute).to eq "01"
|
||||
expect(cron.hour).to eq "00"
|
||||
end
|
||||
|
||||
describe "glance-scrubber-paste.ini" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-scrubber-paste.ini"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "glance", "glance"
|
||||
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 "uploads qcow images" do
|
||||
glance_stubs
|
||||
opts = {
|
||||
:step_into => ["glance_image"]
|
||||
}
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS.merge(opts)
|
||||
node = chef_run.node
|
||||
node.set["glance"] = {
|
||||
"image_upload" => true,
|
||||
"images" => [
|
||||
"image1"
|
||||
],
|
||||
"image" => {
|
||||
"image1" => "http://example.com/image.qcow2"
|
||||
}
|
||||
}
|
||||
chef_run.converge "glance::api"
|
||||
cmd = "glance --insecure " \
|
||||
"-I glance " \
|
||||
"-K glance-pass " \
|
||||
"-T service " \
|
||||
"-N https://127.0.0.1:35357/v2.0 " \
|
||||
"image-create " \
|
||||
"--name image1 " \
|
||||
"--is-public true " \
|
||||
"--container-format bare "\
|
||||
"--disk-format qcow2 " \
|
||||
"--location http://example.com/image.qcow2"
|
||||
|
||||
expect(chef_run).to execute_command cmd
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "glance::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 "image", "glance", "test-pass"
|
||||
|
||||
converge
|
||||
end
|
||||
|
||||
def converge
|
||||
::Chef::Recipe.any_instance.stub(:db_password).with("glance").
|
||||
and_return "test-pass"
|
||||
|
||||
::ChefSpec::ChefRunner.new(::UBUNTU_OPTS).converge "glance::db"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "horizon::default" do
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "glance::keystone_registration" do
|
||||
#TODO: implement
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "glance::registry" do
|
||||
describe "redhat" do
|
||||
before do
|
||||
glance_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS
|
||||
@chef_run.converge "glance::registry"
|
||||
end
|
||||
|
||||
it "installs mysql python packages" do
|
||||
expect(@chef_run).to install_package "MySQL-python"
|
||||
end
|
||||
|
||||
it "installs glance packages" do
|
||||
expect(@chef_run).to upgrade_package "openstack-glance"
|
||||
expect(@chef_run).to upgrade_package "openstack-swift"
|
||||
expect(@chef_run).to upgrade_package "cronie"
|
||||
end
|
||||
|
||||
it "starts glance registry on boot" do
|
||||
expected = "openstack-glance-registry"
|
||||
expect(@chef_run).to set_service_to_start_on_boot expected
|
||||
end
|
||||
|
||||
it "doesn't version the database" do
|
||||
pending "TODO: how to test this"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,91 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "glance::registry" do
|
||||
describe "ubuntu" do
|
||||
before do
|
||||
glance_stubs
|
||||
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
@node = @chef_run.node
|
||||
@node.set["glance"]["syslog"]["use"] = true
|
||||
@chef_run.converge "glance::registry"
|
||||
end
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
|
||||
expect_installs_python_keystone
|
||||
|
||||
expect_installs_curl
|
||||
|
||||
it "installs mysql python packages" do
|
||||
expect(@chef_run).to install_package "python-mysqldb"
|
||||
end
|
||||
|
||||
expect_installs_ubuntu_glance_packages
|
||||
|
||||
expect_creates_cache_dir
|
||||
|
||||
it "starts glance registry on boot" do
|
||||
expect(@chef_run).to set_service_to_start_on_boot "glance-registry"
|
||||
end
|
||||
|
||||
it "versions the database" do
|
||||
cmd = "glance-manage version_control 0"
|
||||
expect(@chef_run).to execute_command cmd
|
||||
end
|
||||
|
||||
it "deletes glance.sqlite" do
|
||||
expect(@chef_run).to delete_file "/var/lib/glance/glance.sqlite"
|
||||
end
|
||||
|
||||
expect_creates_glance_dir
|
||||
|
||||
describe "glance-registry.conf" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-registry.conf"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "root", "root"
|
||||
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[glance-registry]", :restart
|
||||
end
|
||||
end
|
||||
|
||||
it "runs db migrations" do
|
||||
cmd = "glance-manage db_sync"
|
||||
expect(@chef_run).to execute_command cmd
|
||||
end
|
||||
|
||||
describe "glance-registry-paste.ini" do
|
||||
before do
|
||||
@file = @chef_run.template "/etc/glance/glance-registry-paste.ini"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "root", "root"
|
||||
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[glance-registry]", :restart
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,82 @@
|
|||
require "chefspec"
|
||||
|
||||
::LOG_LEVEL = :fatal
|
||||
::REDHAT_OPTS = {
|
||||
:platform => "redhat",
|
||||
:log_level => ::LOG_LEVEL
|
||||
}
|
||||
::UBUNTU_OPTS = {
|
||||
:platform => "ubuntu",
|
||||
:version => "12.04",
|
||||
:log_level => ::LOG_LEVEL
|
||||
}
|
||||
|
||||
def glance_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(: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("glance").
|
||||
and_return "glance-pass"
|
||||
end
|
||||
|
||||
def expect_runs_openstack_common_logging_recipe
|
||||
it "runs logging recipe if node attributes say to" do
|
||||
expect(@chef_run).to include_recipe "openstack-common::logging"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_creates_cache_dir
|
||||
#TODO: ChefSpec needs to handle guards better. This
|
||||
# should only be created when pki is enabled.
|
||||
describe "/var/cache/glance" do
|
||||
before do
|
||||
@dir = @chef_run.directory "/var/cache/glance"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@dir).to be_owned_by "glance", "glance"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @dir.mode)).to eq "700"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def expect_installs_python_keystone
|
||||
it "installs python-keystone package" do
|
||||
expect(@chef_run).to install_package "python-keystone"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_installs_curl
|
||||
it "installs curl package" do
|
||||
expect(@chef_run).to install_package "curl"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_installs_ubuntu_glance_packages
|
||||
it "installs glance packages" do
|
||||
expect(@chef_run).to upgrade_package "glance"
|
||||
expect(@chef_run).to upgrade_package "python-swift"
|
||||
end
|
||||
end
|
||||
|
||||
def expect_creates_glance_dir
|
||||
describe "/etc/glance" do
|
||||
before do
|
||||
@dir = @chef_run.directory "/etc/glance"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@dir).to be_owned_by "glance", "glance"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @dir.mode)).to eq "700"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue