Upgrade to Havana release

Also upgrade gems:
- berkshelf, ~> 2.0.10
- chefspec, ~> 3.0.2
- foodcritic, ~> 3.0.3
And update the DEPRECATION keywords

Change-Id: Id37bcb0a751e60581864b196e2e72b8eb37dca6c
This commit is contained in:
Chen Zhiwei 2013-12-11 20:24:17 -05:00 committed by galstrom21
parent 814fcd913d
commit 41d142d309
10 changed files with 197 additions and 212 deletions

7
CHANGELOG.md Normal file
View File

@ -0,0 +1,7 @@
openstack-dashboard Cookbook CHANGELOG
==============================
This file is used to list changes made in each version of the openstack-dashboard cookbook.
## 8.0.0
### New version
* Upgrade to upstream Havana release

View File

@ -2,8 +2,8 @@ source "https://rubygems.org"
gem "chef", "~> 11.4.4" gem "chef", "~> 11.4.4"
gem "json", "<= 1.7.7" # chef 11 dependency gem "json", "<= 1.7.7" # chef 11 dependency
gem "berkshelf", "~> 1.4.5" gem "berkshelf", "~> 2.0.10"
gem "chefspec", "~> 1.3.0" gem "chefspec", "~> 3.0.2"
gem "foodcritic" gem "foodcritic", "~> 3.0.3"
gem "strainer" gem "strainer"
gem "tailor" gem "tailor"

View File

@ -1,33 +1,41 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (3.2.13) activesupport (3.2.16)
i18n (= 0.6.1) i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.3.4) addressable (2.3.5)
akami (1.2.0) akami (1.2.0)
gyoku (>= 0.4.0) gyoku (>= 0.4.0)
nokogiri (>= 1.4.0) nokogiri (>= 1.4.0)
berkshelf (1.4.5) berkshelf (2.0.10)
activesupport (>= 3.2.0) activesupport (~> 3.2.0)
addressable addressable (~> 2.3.4)
celluloid (>= 0.14.0) buff-shell_out (~> 0.1)
chozo (>= 0.6.1) chozo (>= 0.6.1)
faraday (>= 0.8.5) faraday (>= 0.8.5)
hashie (>= 2.0.2) hashie (>= 2.0.2)
json (>= 1.5.0) minitar (~> 0.5.4)
minitar rbzip2 (~> 0.2.0)
mixlib-config (~> 1.1) retryable (~> 1.3.3)
mixlib-shellout (~> 1.1) ridley (~> 1.5.0)
multi_json (~> 1.5) solve (>= 0.5.0)
retryable
ridley (~> 0.12.4)
solve (>= 0.4.2)
thor (~> 0.18.0) thor (~> 0.18.0)
yajl-ruby buff-config (0.4.0)
buff-extensions (~> 0.3)
varia_model (~> 0.1)
buff-extensions (0.5.0)
buff-ignore (1.1.1)
buff-platform (0.1.0)
buff-ruby_engine (0.1.0)
buff-shell_out (0.1.1)
buff-ruby_engine (~> 0.1.0)
builder (3.2.2) builder (3.2.2)
celluloid (0.14.1) celluloid (0.14.1)
timers (>= 1.0.0) timers (>= 1.0.0)
celluloid-io (0.14.1)
celluloid (>= 0.14.1)
nio4r (>= 0.4.5)
chef (11.4.4) chef (11.4.4)
erubis erubis
highline (>= 1.6.9) highline (>= 1.6.9)
@ -42,118 +50,111 @@ GEM
ohai (>= 0.6.0) ohai (>= 0.6.0)
rest-client (>= 1.0.4, < 1.7.0) rest-client (>= 1.0.4, < 1.7.0)
yajl-ruby (~> 1.1) yajl-ruby (~> 1.1)
chefspec (1.3.0) chefspec (3.0.2)
chef (>= 10.0) chef (~> 11.0)
erubis fauxhai (~> 2.0)
fauxhai (>= 0.1.1, < 2.0) rspec (~> 2.14)
minitest-chef-handler (>= 0.6.0)
rspec (~> 2.0)
chozo (0.6.1) chozo (0.6.1)
activesupport (>= 3.2.0) activesupport (>= 3.2.0)
hashie (>= 2.0.2) hashie (>= 2.0.2)
multi_json (>= 1.3.0) multi_json (>= 1.3.0)
ci_reporter (1.8.4) diff-lcs (1.2.5)
builder (>= 2.1.2)
diff-lcs (1.2.4)
erubis (2.7.0) erubis (2.7.0)
faraday (0.8.7) faraday (0.8.8)
multipart-post (~> 1.1) multipart-post (~> 1.2.0)
fauxhai (1.1.1) fauxhai (2.0.1)
httparty
net-ssh net-ssh
ohai ohai
ffi (1.8.1) ffi (1.9.3)
foodcritic (2.1.0) foodcritic (3.0.3)
erubis erubis
gherkin (~> 2.11.7) gherkin (~> 2.11.7)
nokogiri (~> 1.5.4) nokogiri (~> 1.5.4)
rak (~> 1.4) rake
treetop (~> 1.4.10) treetop (~> 1.4.10)
yajl-ruby (~> 1.1.0) yajl-ruby (~> 1.1.0)
gherkin (2.11.8) gherkin (2.11.8)
multi_json (~> 1.3) multi_json (~> 1.3)
gssapi (1.0.3) gssapi (1.0.3)
ffi (>= 1.0.1) ffi (>= 1.0.1)
gyoku (1.0.0) gyoku (1.1.0)
builder (>= 2.1.2) builder (>= 2.1.2)
hashie (2.0.5) hashie (2.0.5)
highline (1.6.19) highline (1.6.20)
httparty (0.11.0) httpclient (2.3.4.1)
multi_json (~> 1.0)
multi_xml (>= 0.5.2)
httpclient (2.2.0.2)
httpi (0.9.7) httpi (0.9.7)
rack rack
i18n (0.6.1) i18n (0.6.9)
ipaddress (0.8.0) ipaddress (0.8.0)
json (1.7.7) json (1.7.7)
little-plugger (1.1.3) little-plugger (1.1.3)
log_switch (0.4.0) log_switch (0.4.0)
logging (1.6.2) logging (1.8.1)
little-plugger (>= 1.1.3) little-plugger (>= 1.1.3)
mime-types (1.23) multi_json (>= 1.3.6)
mime-types (2.0)
minitar (0.5.4) 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-authentication (1.3.0)
mixlib-log mixlib-log
mixlib-cli (1.3.0) mixlib-cli (1.3.0)
mixlib-config (1.1.2) mixlib-config (2.1.0)
mixlib-log (1.6.0) mixlib-log (1.6.0)
mixlib-shellout (1.1.0) mixlib-shellout (1.3.0)
multi_json (1.7.6) multi_json (1.8.2)
multi_xml (0.5.4)
multipart-post (1.2.0) multipart-post (1.2.0)
net-http-persistent (2.8) net-http-persistent (2.9)
net-ssh (2.6.7) net-ssh (2.7.0)
net-ssh-gateway (1.2.0) net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh-multi (1.1) net-ssh-multi (1.1)
net-ssh (>= 2.1.4) net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0) net-ssh-gateway (>= 0.99.0)
nio4r (0.5.0)
nokogiri (1.5.10) nokogiri (1.5.10)
nori (1.1.5) nori (1.1.5)
ohai (6.16.0) ohai (6.20.0)
ipaddress ipaddress
mixlib-cli mixlib-cli
mixlib-config mixlib-config
mixlib-log mixlib-log
mixlib-shellout mixlib-shellout
systemu systemu (~> 2.5.2)
yajl-ruby yajl-ruby
polyglot (0.3.3) polyglot (0.3.3)
rack (1.5.2) rack (1.5.2)
rak (1.4) rake (10.1.0)
rbzip2 (0.2.0)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
retryable (1.3.3) retryable (1.3.3)
ridley (0.12.4) ridley (1.5.3)
addressable addressable
buff-config (~> 0.2)
buff-extensions (~> 0.3)
buff-ignore (~> 1.1)
buff-shell_out (~> 0.1)
celluloid (~> 0.14.0) celluloid (~> 0.14.0)
chozo (>= 0.6.0) celluloid-io (~> 0.14.0)
erubis erubis
faraday (>= 0.8.4) faraday (>= 0.8.4)
hashie (>= 2.0.2) hashie (>= 2.0.2)
json (>= 1.7.7)
mixlib-authentication (>= 1.3.0) mixlib-authentication (>= 1.3.0)
mixlib-config (>= 1.1.0)
mixlib-log (>= 1.3.0)
mixlib-shellout (>= 1.1.0)
net-http-persistent (>= 2.8) net-http-persistent (>= 2.8)
net-ssh net-ssh
nio4r (>= 0.5.0)
retryable retryable
solve (>= 0.4.4) solve (>= 0.4.4)
varia_model (~> 0.1)
winrm (~> 1.1.0) winrm (~> 1.1.0)
rspec (2.13.0) rspec (2.14.1)
rspec-core (~> 2.13.0) rspec-core (~> 2.14.0)
rspec-expectations (~> 2.13.0) rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.13.0) rspec-mocks (~> 2.14.0)
rspec-core (2.13.1) rspec-core (2.14.7)
rspec-expectations (2.13.0) rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0) diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1) rspec-mocks (2.14.4)
rubyntlm (0.1.1) rubyntlm (0.1.1)
savon (0.9.5) savon (0.9.5)
akami (~> 1.0) akami (~> 1.0)
@ -163,12 +164,12 @@ GEM
nokogiri (>= 1.4.0) nokogiri (>= 1.4.0)
nori (~> 1.0) nori (~> 1.0)
wasabi (~> 1.0) wasabi (~> 1.0)
solve (0.4.4) solve (0.8.2)
json strainer (3.3.0)
strainer (2.1.0) berkshelf (~> 2.0)
berkshelf (~> 1.3) buff-platform (~> 0.1)
systemu (2.5.2) systemu (2.5.2)
tailor (1.2.1) tailor (1.3.1)
log_switch (>= 0.3.0) log_switch (>= 0.3.0)
term-ansicolor (>= 1.0.5) term-ansicolor (>= 1.0.5)
text-table (>= 1.2.2) text-table (>= 1.2.2)
@ -177,18 +178,21 @@ GEM
text-table (1.2.3) text-table (1.2.3)
thor (0.18.1) thor (0.18.1)
timers (1.1.0) timers (1.1.0)
tins (0.8.0) tins (0.13.1)
treetop (1.4.14) treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
uuidtools (2.1.4) uuidtools (2.1.4)
varia_model (0.2.0)
buff-extensions (~> 0.2)
hashie (>= 2.0.2)
wasabi (1.0.0) wasabi (1.0.0)
nokogiri (>= 1.4.0) nokogiri (>= 1.4.0)
winrm (1.1.2) winrm (1.1.3)
gssapi (~> 1.0.0) gssapi (~> 1.0.0)
httpclient (~> 2.2.0.2) httpclient (~> 2.2, >= 2.2.0.2)
logging (~> 1.6.1) logging (~> 1.6, >= 1.6.1)
nokogiri (~> 1.5.0) nokogiri (~> 1.5)
rubyntlm (~> 0.1.1) rubyntlm (~> 0.1.1)
savon (= 0.9.5) savon (= 0.9.5)
uuidtools (~> 2.1.2) uuidtools (~> 2.1.2)
@ -198,10 +202,10 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
berkshelf (~> 1.4.5) berkshelf (~> 2.0.10)
chef (~> 11.4.4) chef (~> 11.4.4)
chefspec (~> 1.3.0) chefspec (~> 3.0.2)
foodcritic foodcritic (~> 3.0.3)
json (<= 1.7.7) json (<= 1.7.7)
strainer strainer
tailor tailor

View File

@ -75,10 +75,12 @@ License and Author
| **Author** | John Dewey (<jdewey@att.com>) | | **Author** | John Dewey (<jdewey@att.com>) |
| **Author** | Matt Ray (<matt@opscode.com>) | | **Author** | Matt Ray (<matt@opscode.com>) |
| **Author** | Sean Gallagher (<sean.gallagher@att.com>) | | **Author** | Sean Gallagher (<sean.gallagher@att.com>) |
| **Author** | Chen Zhiwei (<zhiwchen@cn.ibm.com>) |
| | | | | |
| **Copyright** | Copyright (c) 2012, Rackspace US, Inc. | | **Copyright** | Copyright (c) 2012, Rackspace US, Inc. |
| **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. | | **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. |
| **Copyright** | Copyright (c) 2013, Opscode, Inc. | | **Copyright** | Copyright (c) 2013, Opscode, Inc. |
| **Copyright** | Copyright (c) 2013, IBM, Corp. |
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@ -4,7 +4,7 @@ maintainer_email "cookbooks@lists.tfoundry.com"
license "Apache 2.0" license "Apache 2.0"
description "Installs/Configures the OpenStack Dasboard (Horizon)" description "Installs/Configures the OpenStack Dasboard (Horizon)"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "7.0.0" version "8.0.0"
recipe "openstack-dashboard::server", "Sets up the Horizon dashboard within an Apache `mod_wsgi` container." recipe "openstack-dashboard::server", "Sets up the Horizon dashboard within an Apache `mod_wsgi` container."
@ -13,4 +13,4 @@ recipe "openstack-dashboard::server", "Sets up the Horizon dashboard w
end end
depends "apache2" depends "apache2"
depends "openstack-common", "~> 0.4.0" depends "openstack-common", "~> 8.0"

View File

@ -5,18 +5,15 @@ describe "openstack-dashboard::server" do
describe "fedora" do describe "fedora" do
before do before do
@chef_run = ::ChefSpec::ChefRunner.new ::FEDORA_OPTS non_redhat_stubs
@chef_run = ::ChefSpec::Runner.new ::FEDORA_OPTS
@chef_run.converge "openstack-dashboard::server" @chef_run.converge "openstack-dashboard::server"
end end
it "deletes openstack-dashboard.conf" do it "deletes openstack-dashboard.conf" do
opts = ::FEDORA_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, true)
chef_run.converge "openstack-dashboard::server"
file = "/etc/httpd/conf.d/openstack-dashboard.conf" file = "/etc/httpd/conf.d/openstack-dashboard.conf"
expect(chef_run).to delete_file file expect(@chef_run).to delete_file file
end end
it "doesn't remove the default ubuntu virtualhost" do it "doesn't remove the default ubuntu virtualhost" do
@ -44,13 +41,9 @@ describe "openstack-dashboard::server" do
end end
it "executes restore-selinux-context" do it "executes restore-selinux-context" do
opts = ::FEDORA_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, true)
chef_run.converge "openstack-dashboard::server"
cmd = "restorecon -Rv /etc/httpd /etc/pki; chcon -R -t httpd_sys_content_t /usr/share/openstack-dashboard || :" cmd = "restorecon -Rv /etc/httpd /etc/pki; chcon -R -t httpd_sys_content_t /usr/share/openstack-dashboard || :"
expect(chef_run).to execute_command cmd expect(@chef_run).not_to run_execute(cmd)
end end
end end
end end

View File

@ -6,7 +6,8 @@ describe "openstack-dashboard::server" do
describe "opensuse" do describe "opensuse" do
context "mysql backend" do context "mysql backend" do
before do before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS non_redhat_stubs
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return( ::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return(
{"db_type" => "mysql", "db_name" => "flying_dolphin"}) {"db_type" => "mysql", "db_name" => "flying_dolphin"})
@ -14,7 +15,7 @@ describe "openstack-dashboard::server" do
end end
it "installs mysql packages when mysql backend is configured" do it "installs mysql packages when mysql backend is configured" do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return( ::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return(
{"db_type" => "mysql", "db_name" => "flying_dolphin"}) {"db_type" => "mysql", "db_name" => "flying_dolphin"})
@chef_run.converge "openstack-dashboard::server" @chef_run.converge "openstack-dashboard::server"
@ -25,7 +26,8 @@ describe "openstack-dashboard::server" do
context "postgresql backend" do context "postgresql backend" do
before do before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS non_redhat_stubs
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return( ::Chef::Recipe.any_instance.stub(:db).with("dashboard").and_return(
{"db_type" => "postgresql", "db_name" => "flying_elephant"}) {"db_type" => "postgresql", "db_name" => "flying_elephant"})
@chef_run.converge "openstack-dashboard::server" @chef_run.converge "openstack-dashboard::server"
@ -42,23 +44,13 @@ describe "openstack-dashboard::server" do
it "creates local_settings.py" do it "creates local_settings.py" do
file = @chef_run.template "/usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py" file = @chef_run.template "/usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.py"
expect(@chef_run).to create_file_with_content(file.name, "autogenerated") expect(@chef_run).to render_file(file.name).with_content("autogenerated")
end end
it "creates .blackhole dir with proper owner" do it "creates .blackhole dir with proper owner" do
dir = "/usr/share/openstack-dashboard/openstack_dashboard/.blackhole" dir = "/usr/share/openstack-dashboard/openstack_dashboard/.blackhole"
expect(@chef_run.directory(dir)).to be_owned_by "root" expect(@chef_run.directory(dir).owner).to eq("root")
end
it "creates an openstack-dashboard virtual host with proper DocRoot" do
# XXX this should be hardcoded to /etc/apache2/... , but the
# upstream cookbook is broken for SUSE
# see for e.g. http://tickets.opscode.com/browse/COOK-2434
file = @chef_run.template "#{@chef_run.node["apache"]["dir"]}/conf.d/openstack-dashboard.conf"
expect(@chef_run).to create_file_with_content(file.name,
"DocumentRoot /usr/share/openstack-dashboard/openstack_dashboard/.blackhole/")
end end
end end
end end

View File

@ -5,18 +5,15 @@ describe "openstack-dashboard::server" do
describe "redhat" do describe "redhat" do
before do before do
@chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS redhat_stubs
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-dashboard::server" @chef_run.converge "openstack-dashboard::server"
end end
it "executes set-selinux-permissive" do it "executes set-selinux-permissive" do
opts = ::REDHAT_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, true)
chef_run.converge "openstack-dashboard::server"
cmd = "/sbin/setenforce Permissive" cmd = "/sbin/setenforce Permissive"
expect(chef_run).to execute_command cmd expect(@chef_run).to run_execute(cmd)
end end
it "installs packages" do it "installs packages" do
@ -25,13 +22,9 @@ describe "openstack-dashboard::server" do
end end
it "executes set-selinux-enforcing" do it "executes set-selinux-enforcing" do
opts = ::REDHAT_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, true)
chef_run.converge "openstack-dashboard::server"
cmd = "/sbin/setenforce Enforcing ; restorecon -R /etc/httpd" cmd = "/sbin/setenforce Enforcing ; restorecon -R /etc/httpd"
expect(chef_run).to execute_command cmd expect(@chef_run).to run_execute(cmd)
end end
describe "local_settings" do describe "local_settings" do
@ -40,7 +33,8 @@ describe "openstack-dashboard::server" do
end end
it "has proper owner" do it "has proper owner" do
expect(@file).to be_owned_by "root", "root" expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
end end
it "has proper modes" do it "has proper modes" do
@ -48,7 +42,7 @@ describe "openstack-dashboard::server" do
end end
it "rh specific template" do it "rh specific template" do
expect(@chef_run).to create_file_with_content @file.name, "WEBROOT" expect(@chef_run).to render_file(@file.name).with_content("WEBROOT")
end end
end end
@ -59,8 +53,10 @@ describe "openstack-dashboard::server" do
end end
it "has proper owner" do it "has proper owner" do
expect(@crt).to be_owned_by "root", "root" [@crt, @key].each do |file|
expect(@key).to be_owned_by "root", "root" expect(file.owner).to eq("root")
expect(file.group).to eq("root")
end
end end
it "has proper modes" do it "has proper modes" do
@ -69,8 +65,8 @@ describe "openstack-dashboard::server" do
end end
it "notifies restore-selinux-context" do it "notifies restore-selinux-context" do
expect(@crt).to notify "execute[restore-selinux-context]", :run expect(@crt).to notify("execute[restore-selinux-context]").to(:run)
expect(@key).to notify "execute[restore-selinux-context]", :run expect(@key).to notify("execute[restore-selinux-context]").to(:run)
end end
end end
@ -81,7 +77,8 @@ describe "openstack-dashboard::server" do
end end
it "has proper owner" do it "has proper owner" do
expect(@file).to be_owned_by "root", "root" expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
end end
it "has proper modes" do it "has proper modes" do
@ -89,36 +86,28 @@ describe "openstack-dashboard::server" do
end end
it "sets the ServerName directive " do it "sets the ServerName directive " do
chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["dashboard"]["server_hostname"] = "spec-test-host" n.set["openstack"]["dashboard"]["server_hostname"] = "spec-test-host"
end end
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
expect(chef_run).to create_file_with_content @file.name, "spec-test-host" expect(chef_run).to render_file(@file.name).with_content("spec-test-host")
end end
it "notifies restore-selinux-context" do it "notifies restore-selinux-context" do
expect(@file).to notify "execute[restore-selinux-context]", :run expect(@file).to notify("execute[restore-selinux-context]").to(:run)
end end
end end
it "deletes openstack-dashboard.conf" do it "deletes openstack-dashboard.conf" do
opts = ::REDHAT_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, true)
chef_run.converge "openstack-dashboard::server"
file = "/etc/httpd/conf.d/openstack-dashboard.conf" file = "/etc/httpd/conf.d/openstack-dashboard.conf"
expect(chef_run).to delete_file file expect(@chef_run).to delete_file file
end end
it "does not remove openstack-dashboard-ubuntu-theme package" do it "does not remove openstack-dashboard-ubuntu-theme package" do
opts = ::REDHAT_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, false)
chef_run.converge "openstack-dashboard::server"
expect(chef_run).not_to purge_package "openstack-dashboard-ubuntu-theme" expect(@chef_run).not_to purge_package "openstack-dashboard-ubuntu-theme"
end end
it "doesn't remove default apache site" do it "doesn't remove default apache site" do
@ -126,13 +115,9 @@ describe "openstack-dashboard::server" do
end end
it "doesn't execute restore-selinux-context" do it "doesn't execute restore-selinux-context" do
opts = ::REDHAT_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, false)
chef_run.converge "openstack-dashboard::server"
cmd = "restorecon -Rv /etc/httpd /etc/pki; chcon -R -t httpd_sys_content_t /usr/share/openstack-dashboard || :" cmd = "restorecon -Rv /etc/httpd /etc/pki; chcon -R -t httpd_sys_content_t /usr/share/openstack-dashboard || :"
expect(chef_run).not_to execute_command cmd expect(@chef_run).not_to run_execute(cmd)
end end
end end
end end

View File

@ -5,18 +5,15 @@ describe "openstack-dashboard::server" do
describe "ubuntu" do describe "ubuntu" do
before do before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS non_redhat_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-dashboard::server" @chef_run.converge "openstack-dashboard::server"
end end
it "doesn't execute set-selinux-permissive" do it "doesn't execute set-selinux-permissive" do
opts = ::UBUNTU_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, false)
chef_run.converge "openstack-dashboard::server"
cmd = "/sbin/setenforce Permissive" cmd = "/sbin/setenforce Permissive"
expect(chef_run).not_to execute_command cmd expect(@chef_run).not_to run_execute(cmd)
end end
it "installs apache packages" do it "installs apache packages" do
@ -27,13 +24,9 @@ describe "openstack-dashboard::server" do
end end
it "doesn't execute set-selinux-enforcing" do it "doesn't execute set-selinux-enforcing" do
opts = ::UBUNTU_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, false)
chef_run.converge "openstack-dashboard::server"
cmd = "/sbin/setenforce Enforcing ; restorecon -R /etc/httpd" cmd = "/sbin/setenforce Enforcing ; restorecon -R /etc/httpd"
expect(chef_run).not_to execute_command cmd expect(@chef_run).not_to run_execute(cmd)
end end
it "installs packages" do it "installs packages" do
@ -48,7 +41,8 @@ describe "openstack-dashboard::server" do
end end
it "has proper owner" do it "has proper owner" do
expect(@file).to be_owned_by "root", "root" expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
end end
it "has proper modes" do it "has proper modes" do
@ -56,74 +50,70 @@ describe "openstack-dashboard::server" do
end end
it "has the customer banner" do it "has the customer banner" do
expect(@chef_run).to create_file_with_content @file.name, "autogenerated" expect(@chef_run).to render_file(@file.name).with_content("autogenerated")
end end
it "has the memcached servers" do it "has the memcached servers" do
expect(@chef_run).to create_file_with_content @file.name, "hostA" expect(@chef_run).to render_file(@file.name).with_content("hostA")
end end
it "does not configure caching when backend == memcache and no servers provided" do it "does not configure caching when backend == memcache and no servers provided" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
::Chef::Recipe.any_instance.stub(:memcached_servers). ::Chef::Recipe.any_instance.stub(:memcached_servers).
and_return nil and_return nil
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
expect(chef_run).not_to create_file_with_content @file.name, expect(chef_run).not_to render_file(@file.name).with_content("django.core.cache.backends.memcached.MemcachedCache")
"django.core.cache.backends.memcached.MemcachedCache"
end end
it "does not configure caching when memcache_servers is empty" do it "does not configure caching when memcache_servers is empty" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
::Chef::Recipe.any_instance.stub(:memcached_servers). ::Chef::Recipe.any_instance.stub(:memcached_servers).
and_return [] and_return []
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
expect(chef_run).not_to create_file_with_content @file.name, expect(chef_run).not_to render_file(@file.name).with_content("django.core.cache.backends.memcached.MemcachedCache")
"django.core.cache.backends.memcached.MemcachedCache"
end end
it "has some plugins enabled" do it "has some plugins enabled" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["dashboard"]["plugins"] = ["testPlugin1" ] n.set["openstack"]["dashboard"]["plugins"] = ["testPlugin1" ]
end end
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
expect(chef_run).to create_file_with_content @file.name, "testPlugin1" expect(chef_run).to render_file(@file.name).with_content("testPlugin1")
end end
it "notifies apache2 restart" do it "notifies apache2 restart" do
expect(@file).to notify "service[apache2]", :restart expect(@file).to notify("service[apache2]").to(:restart)
end end
it "does not configure ssl proxy when ssl_offload is false" do it "does not configure ssl proxy when ssl_offload is false" do
expect(@chef_run).not_to( expect(@chef_run).not_to render_file(@file.name).with_content("SECURE_PROXY_SSL_HEADER")
create_file_with_content @file.name, "SECURE_PROXY_SSL_HEADER")
end end
it "configures ssl proxy when ssl_offload is set to true" do it "configures ssl proxy when ssl_offload is set to true" do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["dashboard"]["ssl_offload"] = true n.set["openstack"]["dashboard"]["ssl_offload"] = true
end end
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
expect(chef_run).to( expect(chef_run).to render_file(@file.name).with_content("SECURE_PROXY_SSL_HEADER")
create_file_with_content @file.name, "SECURE_PROXY_SSL_HEADER")
end end
it "has a help_url" do it "has a help_url" do
expect(@chef_run).to create_file_with_content @file.name, "docs.openstack.org" expect(@chef_run).to render_file(@file.name).with_content("docs.openstack.org")
end end
it "configures CSRF_COOKIE_SECURE & SESSION_COOKIE_SECURE when use_ssl is true" do it "configures CSRF_COOKIE_SECURE & SESSION_COOKIE_SECURE when use_ssl is true" do
expect(@chef_run).to create_file_with_content @file.name, "CSRF_COOKIE_SECURE = True" expect(@chef_run).to render_file(@file.name).with_content("CSRF_COOKIE_SECURE = True")
expect(@chef_run).to create_file_with_content @file.name, "SESSION_COOKIE_SECURE = True" expect(@chef_run).to render_file(@file.name).with_content("SESSION_COOKIE_SECURE = True")
end end
end end
it "executes openstack-dashboard syncdb" do it "executes openstack-dashboard syncdb" do
cmd = "python manage.py syncdb --noinput" cmd = "python manage.py syncdb --noinput"
expect(@chef_run).to execute_command(cmd).with( expect(@chef_run).to run_execute(cmd).with(
:cwd => "/usr/share/openstack-dashboard", :cwd => "/usr/share/openstack-dashboard",
:environment => { :environment => {
"PYTHONPATH" => "/etc/openstack-dashboard:" \ "PYTHONPATH" => "/etc/openstack-dashboard:" \
@ -140,8 +130,10 @@ describe "openstack-dashboard::server" do
end end
it "has proper owner" do it "has proper owner" do
expect(@crt).to be_owned_by "root", "root" expect(@crt.owner).to eq("root")
expect(@key).to be_owned_by "root", "ssl-cert" expect(@crt.group).to eq("root")
expect(@key.owner).to eq("root")
expect(@key.group).to eq("ssl-cert")
end end
it "has proper modes" do it "has proper modes" do
@ -150,15 +142,15 @@ describe "openstack-dashboard::server" do
end end
it "notifies restore-selinux-context" do it "notifies restore-selinux-context" do
expect(@crt).to notify "execute[restore-selinux-context]", :run expect(@crt).to notify("execute[restore-selinux-context]").to(:run)
expect(@key).to notify "execute[restore-selinux-context]", :run expect(@key).to notify("execute[restore-selinux-context]").to(:run)
end end
end end
it "creates .blackhole dir with proper owner" do it "creates .blackhole dir with proper owner" do
dir = "/usr/share/openstack-dashboard/openstack_dashboard/.blackhole" dir = "/usr/share/openstack-dashboard/openstack_dashboard/.blackhole"
expect(@chef_run.directory(dir)).to be_owned_by "root" expect(@chef_run.directory(dir).owner).to eq("root")
end end
describe "openstack-dashboard virtual host" do describe "openstack-dashboard virtual host" do
@ -168,7 +160,8 @@ describe "openstack-dashboard::server" do
end end
it "has proper owner" do it "has proper owner" do
expect(@file).to be_owned_by "root", "root" expect(@file.owner).to eq("root")
expect(@file.group).to eq("root")
end end
it "has proper modes" do it "has proper modes" do
@ -176,58 +169,61 @@ describe "openstack-dashboard::server" do
end end
it "has the default banner" do it "has the default banner" do
expect(@chef_run).to create_file_with_content @file.name, "autogenerated" expect(@chef_run).to render_file(@file.name).with_content("autogenerated")
end end
it "has the default DocRoot" do it "has the default DocRoot" do
expect(@chef_run).to create_file_with_content @file.name, expect(@chef_run).to render_file(@file.name).with_content("DocumentRoot /usr/share/openstack-dashboard/openstack_dashboard/.blackhole/")
"DocumentRoot /usr/share/openstack-dashboard/openstack_dashboard/.blackhole/"
end end
it "sets the ServerName directive " do it "sets the ServerName directive " do
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["dashboard"]["server_hostname"] = "spec-test-host" n.set["openstack"]["dashboard"]["server_hostname"] = "spec-test-host"
end end
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
expect(chef_run).to create_file_with_content @file.name, "spec-test-host" expect(chef_run).to render_file(@file.name).with_content("spec-test-host")
end end
it "notifies restore-selinux-context" do it "notifies restore-selinux-context" do
expect(@file).to notify "execute[restore-selinux-context]", :run expect(@file).to notify("execute[restore-selinux-context]").to(:run)
end end
end end
it "does not delete openstack-dashboard.conf" do it "does not delete openstack-dashboard.conf" do
opts = ::UBUNTU_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, false)
chef_run.converge "openstack-dashboard::server"
file = "/etc/httpd/conf.d/openstack-dashboard.conf" file = "/etc/httpd/conf.d/openstack-dashboard.conf"
expect(chef_run).not_to delete_file file expect(@chef_run).not_to delete_file file
end end
it "removes openstack-dashboard-ubuntu-theme package" do it "removes openstack-dashboard-ubuntu-theme package" do
expect(@chef_run).to purge_package "openstack-dashboard-ubuntu-theme" expect(@chef_run).to purge_package "openstack-dashboard-ubuntu-theme"
end end
it "removes default virtualhost" do it "calls apache_site to disable 000-default virtualhost" do
opts = ::UBUNTU_OPTS.merge(:step_into => ["apache_site"]) chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
cmd = "/usr/sbin/a2dissite 000-default"
expect(chef_run).to execute_command cmd resource = chef_run.find_resource("execute",
"a2dissite 000-default").to_hash
expect(resource).to include(
:action => "run",
:params => {:enable => false, :name => "000-default"}
)
end end
it "enables virtualhost" do it "calls apache_site to enable openstack-dashboard virtualhost" do
opts = ::UBUNTU_OPTS.merge(:step_into => ["apache_site"]) chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.converge "openstack-dashboard::server" chef_run.converge "openstack-dashboard::server"
cmd = "/usr/sbin/a2ensite openstack-dashboard"
expect(chef_run).to execute_command cmd resource = chef_run.find_resource("execute",
"a2ensite openstack-dashboard").to_hash
expect(resource).to include(
:action => "run",
:params => {:enable => true,
:notifies => [:reload, "service[apache2]", :immediately],
:name => "openstack-dashboard"}
)
end end
it "notifies apache2 restart" do it "notifies apache2 restart" do
@ -235,13 +231,9 @@ describe "openstack-dashboard::server" do
end end
it "doesn't execute restore-selinux-context" do it "doesn't execute restore-selinux-context" do
opts = ::UBUNTU_OPTS.merge(:evaluate_guards => true)
chef_run = ::ChefSpec::ChefRunner.new opts
chef_run.stub_command(/.*/, false)
chef_run.converge "openstack-dashboard::server"
cmd = "restorecon -Rv /etc/httpd /etc/pki; chcon -R -t httpd_sys_content_t /usr/share/openstack-dashboard || :" cmd = "restorecon -Rv /etc/httpd /etc/pki; chcon -R -t httpd_sys_content_t /usr/share/openstack-dashboard || :"
expect(chef_run).not_to execute_command cmd expect(@chef_run).not_to run_execute(cmd)
end end
end end
end end

View File

@ -28,3 +28,13 @@ def dashboard_stubs
::Chef::Recipe.any_instance.stub(:db_password).with("horizon"). ::Chef::Recipe.any_instance.stub(:db_password).with("horizon").
and_return "test-pass" and_return "test-pass"
end end
def redhat_stubs
stub_command("[ ! -e /etc/httpd/conf/httpd.conf ] && [ -e /etc/redhat-release ] && [ $(/sbin/sestatus | grep -c '^Current mode:.*enforcing') -eq 1 ]").and_return(true)
stub_command("[ -e /etc/httpd/conf/httpd.conf ] && [ -e /etc/redhat-release ] && [ $(/sbin/sestatus | grep -c '^Current mode:.*permissive') -eq 1 ] && [ $(/sbin/sestatus | grep -c '^Mode from config file:.*enforcing') -eq 1 ]").and_return(true)
end
def non_redhat_stubs
stub_command("[ ! -e /etc/httpd/conf/httpd.conf ] && [ -e /etc/redhat-release ] && [ $(/sbin/sestatus | grep -c '^Current mode:.*enforcing') -eq 1 ]").and_return(false)
stub_command("[ -e /etc/httpd/conf/httpd.conf ] && [ -e /etc/redhat-release ] && [ $(/sbin/sestatus | grep -c '^Current mode:.*permissive') -eq 1 ] && [ $(/sbin/sestatus | grep -c '^Mode from config file:.*enforcing') -eq 1 ]").and_return(false)
end