Gave better examples of how to test templates
I wanted to work off what abe did to give examples to others on ways to add attributes and test conditionals.
This commit is contained in:
parent
6ffe37b361
commit
1925451f67
|
@ -160,7 +160,6 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
berkshelf (~> 1.4.0)
|
||||
celluloid (= 0.13.0)
|
||||
chef (~> 10.18.2)
|
||||
chefspec (~> 1.0.0)
|
||||
foodcritic (~> 2.1.0)
|
||||
|
|
|
@ -7,12 +7,18 @@ describe "cinder::api" do
|
|||
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
@node = @chef_run.node
|
||||
@node.set["cinder"]["syslog"]["use"] = true
|
||||
@node.set["cinder"]["volume"]["volume_driver"] = "cinder.volume.driver.RBDDriver"
|
||||
@chef_run.converge "cinder::api"
|
||||
end
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
|
||||
it "doesn't run logging recipe" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).not_to include_recipe "openstack-common::logging"
|
||||
end
|
||||
|
||||
it "installs cinder api packages" do
|
||||
expect(@chef_run).to upgrade_package "cinder-common"
|
||||
expect(@chef_run).to upgrade_package "cinder-api"
|
||||
|
@ -43,6 +49,53 @@ describe "cinder::api" do
|
|||
|
||||
expect_creates_cinder_conf "service[cinder-api]"
|
||||
|
||||
describe "cinder.conf" do
|
||||
before do
|
||||
@file = "/etc/cinder/cinder.conf"
|
||||
end
|
||||
|
||||
it "runs logging recipe if node attributes say to" do
|
||||
expect(@chef_run).to create_file_with_content @file,
|
||||
"log_config = /etc/openstack/logging.conf"
|
||||
end
|
||||
|
||||
it "doesn't run logging recipe" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).not_to create_file_with_content @file,
|
||||
"log_config = /etc/openstack/logging.conf"
|
||||
end
|
||||
|
||||
it "has rbd driver settings" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
node = chef_run.node
|
||||
node.set["cinder"]["volume"] = {
|
||||
"volume_driver" => "cinder.volume.driver.RBDDriver"
|
||||
}
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).to create_file_with_content @file,
|
||||
/^rbd_/
|
||||
expect(chef_run).not_to create_file_with_content @file,
|
||||
/^netapp_/
|
||||
end
|
||||
|
||||
it "has netapp driver settings" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
node = chef_run.node
|
||||
node.set["cinder"]["volume"] = {
|
||||
"volume_driver" => "cinder.volume.netapp.NetAppISCSIDriver"
|
||||
}
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).to create_file_with_content @file,
|
||||
/^netapp_/
|
||||
expect(chef_run).not_to create_file_with_content @file,
|
||||
/^rbd_/
|
||||
end
|
||||
end
|
||||
|
||||
it "runs db migrations" do
|
||||
cmd = "cinder-manage db sync"
|
||||
expect(@chef_run).to execute_command cmd
|
||||
|
@ -61,10 +114,19 @@ describe "cinder::api" do
|
|||
expect(sprintf("%o", @file.mode)).to eq "644"
|
||||
end
|
||||
|
||||
it "template contents" do
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/api-paste.ini", "autogenerated"
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/api-paste.ini", "service"
|
||||
expect(@chef_run).not_to create_file_with_content "/etc/cinder/api-paste.ini", "signing_dir"
|
||||
it "has signing_dir with auth_strategy is pki" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
node = chef_run.node
|
||||
node.set["openstack"]["auth"]["strategy"] = "pki"
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).to create_file_with_content @file.name,
|
||||
"signing_dir = /var/cache/cinder/api"
|
||||
end
|
||||
|
||||
it "does not have signing_dir when auth strategy is not pki" do
|
||||
expect(@chef_run).not_to create_file_with_content @file.name,
|
||||
"signing_dir = /var/cache/cinder/api"
|
||||
end
|
||||
|
||||
it "notifies nova-api-ec2 restart" do
|
||||
|
|
|
@ -7,12 +7,18 @@ describe "cinder::scheduler" do
|
|||
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
@node = @chef_run.node
|
||||
@node.set["cinder"]["syslog"]["use"] = true
|
||||
@node.set["cinder"]["volume"]["volume_driver"] = "cinder.volume.driver.RBDDriver"
|
||||
@chef_run.converge "cinder::scheduler"
|
||||
end
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
|
||||
it "doesn't run logging recipe" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).not_to include_recipe "openstack-common::logging"
|
||||
end
|
||||
|
||||
it "installs cinder api packages" do
|
||||
expect(@chef_run).to upgrade_package "cinder-scheduler"
|
||||
expect(@chef_run).to upgrade_package "python-mysqldb"
|
||||
|
|
|
@ -45,17 +45,6 @@ def expect_creates_cinder_conf service, action=:restart
|
|||
expect(sprintf("%o", @file.mode)).to eq "644"
|
||||
end
|
||||
|
||||
it "template contents" do
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/cinder.conf", "autogenerated"
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/cinder.conf", "logging.conf"
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/cinder.conf", "lock_path=/var/lock/cinder"
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/cinder.conf", "rbd_pool=rbd"
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/cinder.conf", "iscsi_helper=tgtadm"
|
||||
expect(@chef_run).to create_file_with_content "/etc/cinder/cinder.conf", "RBDDriver"
|
||||
expect(@chef_run).not_to create_file_with_content "/etc/cinder/cinder.conf", "NetAppISCSIDriver"
|
||||
|
||||
end
|
||||
|
||||
it "notifies nova-api-ec2 restart" do
|
||||
expect(@file).to notify service, action
|
||||
end
|
||||
|
|
|
@ -30,6 +30,14 @@ describe "cinder::volume" do
|
|||
expect(@chef_run).to set_service_to_start_on_boot "tgtd"
|
||||
end
|
||||
|
||||
it "has redhat include" do
|
||||
file = "/etc/tgt/targets.conf"
|
||||
expect(@chef_run).to create_file_with_content file,
|
||||
"include /var/lib/cinder/volumes/*"
|
||||
expect(@chef_run).not_to create_file_with_content file,
|
||||
"include /etc/tgt/conf.d/*.conf"
|
||||
end
|
||||
|
||||
it "has different tgt" do
|
||||
expect(@chef_run).to create_file_with_content "/etc/tgt/targets.conf", "/var/lib/cinder/volumes"
|
||||
end
|
||||
|
|
|
@ -7,12 +7,18 @@ describe "cinder::volume" do
|
|||
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
@node = @chef_run.node
|
||||
@node.set["cinder"]["syslog"]["use"] = true
|
||||
@node.set["cinder"]["volume"]["volume_driver"] = "cinder.volume.driver.RBDDriver"
|
||||
@chef_run.converge "cinder::volume"
|
||||
end
|
||||
|
||||
expect_runs_openstack_common_logging_recipe
|
||||
|
||||
it "doesn't run logging recipe" do
|
||||
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
|
||||
chef_run.converge "cinder::api"
|
||||
|
||||
expect(chef_run).not_to include_recipe "openstack-common::logging"
|
||||
end
|
||||
|
||||
it "installs cinder volume packages" do
|
||||
expect(@chef_run).to upgrade_package "cinder-volume"
|
||||
expect(@chef_run).to upgrade_package "python-mysqldb"
|
||||
|
@ -45,13 +51,15 @@ describe "cinder::volume" do
|
|||
expect(sprintf("%o", @file.mode)).to eq "600"
|
||||
end
|
||||
|
||||
it "notifies nova-api-ec2 restart" do
|
||||
it "notifies iscsi restart" do
|
||||
expect(@file).to notify "service[iscsitarget]", :restart
|
||||
end
|
||||
|
||||
it "template contents" do
|
||||
expect(@chef_run).to create_file_with_content "/etc/tgt/targets.conf", "autogenerated"
|
||||
expect(@chef_run).to create_file_with_content "/etc/tgt/targets.conf", "/etc/tgt/conf.d"
|
||||
it "has ubuntu include" do
|
||||
expect(@chef_run).to create_file_with_content @file.name,
|
||||
"include /etc/tgt/conf.d/*.conf"
|
||||
expect(@chef_run).not_to create_file_with_content @file.name,
|
||||
"include /var/lib/cinder/volumes/*"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue