cronjob binary path depends on platform

also refactored some tests

Change-Id: I7ef1082a515898efd26be398fa30d32b756c27c3
This commit is contained in:
John Tran
2013-09-22 02:14:55 +00:00
parent af20b1e521
commit bc00347db1
6 changed files with 28 additions and 23 deletions

View File

@@ -2,8 +2,8 @@
"sha": "ba71763fac936d414bd4a63f004357f86f6e1bfb",
"sources": {
"openstack-block-storage": {
"locked_version": "7.0.2",
"constraint": "= 7.0.2",
"locked_version": "7.0.3",
"constraint": "= 7.0.3",
"path": "."
},
"openstack-image": {

View File

@@ -2,6 +2,11 @@ openstack-block-storage Cookbook CHANGELOG
==============================
This file is used to list changes made in each version of the openstack-block-storage cookbook.
v7.0.3
------
### Bug
- change audit cronjob binary path depending on platform, refactored some tests
v7.0.2
------
### Improvement

View File

@@ -108,6 +108,7 @@ default["openstack"]["block-storage"]["syslog"]["config_facility"] = "local2"
default["openstack"]["block-storage"]["api"]["ratelimit"] = "True"
default["openstack"]["block-storage"]["cron"]["minute"] = '00'
default["openstack"]["block-storage"]["cron"]["audit_logfile"] = "/var/log/cinder/audit.log"
default["openstack"]["block-storage"]["volume"]["state_path"] = "/var/lib/cinder"
default["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.driver.ISCSIDriver"

View File

@@ -4,7 +4,7 @@ maintainer_email "cookbooks@lists.tfoundry.com"
license "Apache 2.0"
description "The OpenStack Advanced Volume Management service Cinder."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "7.0.2"
version "7.0.3"
recipe "openstack-block-storage::common", "Defines the common pieces of repeated code from the other recipes"
recipe "openstack-block-storage::api", "Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone"

View File

@@ -55,6 +55,9 @@ service "cinder-scheduler" do
subscribes :restart, "template[/etc/cinder/cinder.conf]"
end
audit_bin_dir = platform?("ubuntu") ? "/usr/bin" : "/usr/local/bin"
audit_log = node["openstack"]["block-storage"]["cron"]["audit_logfile"]
if node["openstack"]["metering"]
scheduler_role = node["openstack"]["block-storage"]["scheduler_role"]
results = search(:node, "roles:#{scheduler_role}")
@@ -67,7 +70,7 @@ if node["openstack"]["metering"]
minute node["openstack"]["block-storage"]["cron"]["minute"]
month node["openstack"]["block-storage"]["cron"]["month"] || '*'
weekday node["openstack"]["block-storage"]["cron"]["weekday"] || '*'
command "/usr/local/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log 2>&1"
command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1"
action cron_node == node.name ? :create : :delete
user node["openstack"]["block-storage"]["user"]
end

View File

@@ -74,38 +74,34 @@ describe "openstack-block-storage::scheduler" do
end
chef_run.converge "openstack-block-storage::scheduler"
cron = chef_run.cron "cinder-volume-usage-audit"
expect(cron.command).to match(/\/usr\/local\/bin\/cinder-volume-usage-audit/)
expect(cron.command).to match(/\/var\/log\/cinder\/audit.log/)
expect(cron.minute).to eq "00"
expect(cron.hour).to eq "*"
expect(cron.day).to eq "*"
expect(cron.weekday).to eq "*"
expect(cron.month).to eq "*"
expect(cron.user).to eq "cinder"
bin_str="/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log"
expect(cron.command).to match(/#{bin_str}/)
crontests = [ [:minute, '00'], [:hour, '*'], [:day, '*'],
[:weekday, '*'], [:month, '*'], [:user, 'cinder'] ]
crontests.each do |k,v|
expect(cron.send(k)).to eq v
end
expect(cron.action).to include :create
end
it "creates cron metering custom" do
crontests = [ [:minute, '50'], [:hour, '23'], [:day, '6'],
[:weekday, '5'], [:month, '11'], [:user, 'foobar'] ]
::Chef::Recipe.any_instance.stub(:search).
with(:node, "roles:os-block-storage-scheduler").
and_return([OpenStruct.new(:name => "foobar")])
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["metering"] = true
n.set["openstack"]["block-storage"]["cron"]["minute"] = 50
n.set["openstack"]["block-storage"]["cron"]["hour"] = 23
n.set["openstack"]["block-storage"]["cron"]["day"] = 6
n.set["openstack"]["block-storage"]["cron"]["weekday"] = 5
n.set["openstack"]["block-storage"]["cron"]["month"] = 11
crontests.each do |k,v|
n.set["openstack"]["block-storage"]["cron"][k.to_s] = v
end
n.set["openstack"]["block-storage"]["user"] = "foobar"
end
chef_run.converge "openstack-block-storage::scheduler"
cron = chef_run.cron "cinder-volume-usage-audit"
expect(cron.minute).to eq "50"
expect(cron.hour).to eq "23"
expect(cron.day).to eq "6"
expect(cron.weekday).to eq "5"
expect(cron.month).to eq "11"
expect(cron.user).to eq "foobar"
crontests.each do |k,v|
expect(cron.send(k)).to eq v
end
expect(cron.action).to include :delete
end