Merge "Rubocop testing of the attributes and testing documentation."

This commit is contained in:
Jenkins
2014-01-02 20:07:12 +00:00
committed by Gerrit Code Review
5 changed files with 179 additions and 144 deletions

View File

@@ -111,15 +111,7 @@ TODO: move rabbit parameters under openstack["block-storage"]["mq"]
Testing
=====
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
Tests are defined in Strainerfile.
To run tests:
$ bundle install # install gem dependencies
$ bundle exec berks install # install cookbook dependencies
$ bundle exec strainer test # run tests
Please refer to the [TESTING.md](TESTING.md) for instructions for testing the cookbook.
License and Author
==================

View File

@@ -1,5 +1,7 @@
# Strainerfile
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/attributes/
# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
# may want to add rubocop check for Berksfile and Gemfile
knife test: bundle exec knife cookbook test $COOKBOOK
foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK
foodcritic: bundle exec foodcritic -f any -t ~FC003 $SANDBOX/$COOKBOOK
chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec

33
TESTING.md Normal file
View File

@@ -0,0 +1,33 @@
# Testing the Cookbook #
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
Tests are defined in [Strainerfile](Strainerfile), which in turn calls rubocop, knife, foodcritic and chefspec.
To run the tests:
$ bundle install --path=.bundle # install gem dependencies
$ bundle exec berks install --path=.cookbooks # install cookbook dependencies
$ bundle exec strainer test -s Strainerfile # run tests
## Rubocop ##
[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.
### Attribute Rules ###
There is a [.rubocop.yml](attributes/.rubocop.yml) specific to `attributes`, with the rationale for ignored styles within the file.
## Knife ##
[knife cookbook test](http://docs.opscode.com/chef/knife.html#test) is used to check the cookbook's Ruby and ERB files for basic syntax errors.
## Foodcritic ##
[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules:
[FC003](http://acrmp.github.io/foodcritic/#FC003) these cookbooks are not intended for Chef Solo.
## Chefspec
[ChefSpec](http://code.sethvargo.com/chefspec/) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.

7
attributes/.rubocop.yml Normal file
View File

@@ -0,0 +1,7 @@
# embedded attributes make for long lines
LineLength:
Enabled: false
# %w or %W have not generally been used in attribute files
WordArray:
Enabled: false

View File

@@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-block-storage
# Attributes:: default
@@ -23,194 +24,194 @@
########################################################################
# Toggles - These can be overridden at the environment level
default["developer_mode"] = false # we want secure passwords by default
default['developer_mode'] = false # we want secure passwords by default
########################################################################
# Set to some text value if you want templated config files
# to contain a custom banner at the top of the written file
default["openstack"]["block-storage"]["custom_template_banner"] = "
default['openstack']['block-storage']['custom_template_banner'] = '
# This file autogenerated by Chef
# Do not edit, changes will be overwritten
"
'
default["openstack"]["block-storage"]["verbose"] = "False"
default["openstack"]["block-storage"]["debug"] = "False"
default['openstack']['block-storage']['verbose'] = 'False'
default['openstack']['block-storage']['debug'] = 'False'
# Default lock_path
default["openstack"]["block-storage"]["lock_path"] = "/var/lock/cinder"
# Availability zone/region for the Openstack"]["Block-Storage service
default["openstack"]["block-storage"]["region"] = "RegionOne"
default["openstack"]["block-storage"]["scheduler_role"] = "os-block-storage-scheduler"
default['openstack']['block-storage']['lock_path'] = '/var/lock/cinder'
# Availability zone/region for the OpenStack Block-Storage service
default['openstack']['block-storage']['region'] = 'RegionOne'
default['openstack']['block-storage']['scheduler_role'] = 'os-block-storage-scheduler'
# The name of the Chef role that knows about the message queue server
# that Cinder uses
default["openstack"]["block-storage"]["rabbit_server_chef_role"] = "os-ops-messaging"
default['openstack']['block-storage']['rabbit_server_chef_role'] = 'os-ops-messaging'
# This is the name of the Chef role that will install the Keystone Service API
default["openstack"]["block-storage"]["keystone_service_chef_role"] = "keystone"
default['openstack']['block-storage']['keystone_service_chef_role'] = 'keystone'
# Keystone PKI signing directory. Only written to the filter:authtoken section
# of the api-paste.ini when node["openstack"]["auth"]["strategy"] == "pki"
default["openstack"]["block-storage"]["api"]["auth"]["cache_dir"] = "/var/cache/cinder/api"
# of the api-paste.ini when node['openstack']['auth']['strategy'] == 'pki'
default['openstack']['block-storage']['api']['auth']['cache_dir'] = '/var/cache/cinder/api'
# Maximum allocatable gigabytes
# Should equal total backend storage, default is 10TB
default["openstack"]["block-storage"]["max_gigabytes"] = "10000"
default['openstack']['block-storage']['max_gigabytes'] = '10000'
# Storage availability zone
# Default is nova
default["openstack"]["block-storage"]["storage_availability_zone"] = "nova"
default['openstack']['block-storage']['storage_availability_zone'] = 'nova'
# Quota definitions
default["openstack"]["block-storage"]["quota_volumes"] = "10"
default["openstack"]["block-storage"]["quota_gigabytes"] = "1000"
default["openstack"]["block-storage"]["quota_driver"] = "cinder.quota.DbQuotaDriver"
default['openstack']['block-storage']['quota_volumes'] = '10'
default['openstack']['block-storage']['quota_gigabytes'] = '1000'
default['openstack']['block-storage']['quota_driver'] = 'cinder.quota.DbQuotaDriver'
# Common rpc definitions
default["openstack"]["block-storage"]["rpc_thread_pool_size"] = 64
default["openstack"]["block-storage"]["rpc_conn_pool_size"] = 30
default["openstack"]["block-storage"]["rpc_response_timeout"] = 60
default['openstack']['block-storage']['rpc_thread_pool_size'] = 64
default['openstack']['block-storage']['rpc_conn_pool_size'] = 30
default['openstack']['block-storage']['rpc_response_timeout'] = 60
# MQ options
default["openstack"]["block-storage"]["mq"]["service_type"] = node["openstack"]["mq"]["service_type"]
default["openstack"]["block-storage"]["mq"]["qpid"]["host"] = "127.0.0.1"
default["openstack"]["block-storage"]["mq"]["qpid"]["port"] = "5672"
default["openstack"]["block-storage"]["mq"]["qpid"]["qpid_hosts"] = ['127.0.0.1:5672']
default['openstack']['block-storage']['mq']['service_type'] = node['openstack']['mq']['service_type']
default['openstack']['block-storage']['mq']['qpid']['host'] = '127.0.0.1'
default['openstack']['block-storage']['mq']['qpid']['port'] = '5672'
default['openstack']['block-storage']['mq']['qpid']['qpid_hosts'] = ['127.0.0.1:5672']
default["openstack"]["block-storage"]["mq"]["qpid"]["username"] = ""
default["openstack"]["block-storage"]["mq"]["qpid"]["password"] = ""
default["openstack"]["block-storage"]["mq"]["qpid"]["sasl_mechanisms"] = ""
default["openstack"]["block-storage"]["mq"]["qpid"]["reconnect"] = true
default["openstack"]["block-storage"]["mq"]["qpid"]["reconnect_timeout"] = 0
default["openstack"]["block-storage"]["mq"]["qpid"]["reconnect_limit"] = 0
default["openstack"]["block-storage"]["mq"]["qpid"]["reconnect_interval_min"] = 0
default["openstack"]["block-storage"]["mq"]["qpid"]["reconnect_interval_max"] = 0
default["openstack"]["block-storage"]["mq"]["qpid"]["reconnect_interval"] = 0
default["openstack"]["block-storage"]["mq"]["qpid"]["heartbeat"] = 60
default["openstack"]["block-storage"]["mq"]["qpid"]["protocol"] = "tcp"
default["openstack"]["block-storage"]["mq"]["qpid"]["tcp_nodelay"] = true
default['openstack']['block-storage']['mq']['qpid']['username'] = ''
default['openstack']['block-storage']['mq']['qpid']['password'] = ''
default['openstack']['block-storage']['mq']['qpid']['sasl_mechanisms'] = ''
default['openstack']['block-storage']['mq']['qpid']['reconnect'] = true
default['openstack']['block-storage']['mq']['qpid']['reconnect_timeout'] = 0
default['openstack']['block-storage']['mq']['qpid']['reconnect_limit'] = 0
default['openstack']['block-storage']['mq']['qpid']['reconnect_interval_min'] = 0
default['openstack']['block-storage']['mq']['qpid']['reconnect_interval_max'] = 0
default['openstack']['block-storage']['mq']['qpid']['reconnect_interval'] = 0
default['openstack']['block-storage']['mq']['qpid']['heartbeat'] = 60
default['openstack']['block-storage']['mq']['qpid']['protocol'] = 'tcp'
default['openstack']['block-storage']['mq']['qpid']['tcp_nodelay'] = true
# This user's password is stored in an encrypted databag
# and accessed with openstack-common cookbook library's
# user_password routine. You are expected to create
# the user, pass, vhost in a wrapper rabbitmq cookbook.
default["openstack"]["block-storage"]["rabbit"]["username"] = "guest"
default["openstack"]["block-storage"]["rabbit"]["vhost"] = "/"
default["openstack"]["block-storage"]["rabbit"]["port"] = 5672
default["openstack"]["block-storage"]["rabbit"]["host"] = "127.0.0.1"
default["openstack"]["block-storage"]["rabbit"]["ha"] = false
default['openstack']['block-storage']['rabbit']['username'] = 'guest'
default['openstack']['block-storage']['rabbit']['vhost'] = '/'
default['openstack']['block-storage']['rabbit']['port'] = 5672
default['openstack']['block-storage']['rabbit']['host'] = '127.0.0.1'
default['openstack']['block-storage']['rabbit']['ha'] = false
default["openstack"]["block-storage"]["db"]["username"] = "cinder"
default['openstack']['block-storage']['db']['username'] = 'cinder'
default["openstack"]["block-storage"]["service_tenant_name"] = "service"
default["openstack"]["block-storage"]["service_user"] = "cinder"
default["openstack"]["block-storage"]["service_role"] = "admin"
default['openstack']['block-storage']['service_tenant_name'] = 'service'
default['openstack']['block-storage']['service_user'] = 'cinder'
default['openstack']['block-storage']['service_role'] = 'admin'
# Netapp support
default["openstack"]["block-storage"]["netapp"]["protocol"] = "http"
default["openstack"]["block-storage"]["netapp"]["dfm_hostname"] = nil
default["openstack"]["block-storage"]["netapp"]["dfm_login"] = nil
default["openstack"]["block-storage"]["netapp"]["dfm_password"] = nil
default["openstack"]["block-storage"]["netapp"]["dfm_port"] = "8088"
default["openstack"]["block-storage"]["netapp"]["dfm_web_port"] = "8080"
default["openstack"]["block-storage"]["netapp"]["storage_service"] = "storage_service"
default['openstack']['block-storage']['netapp']['protocol'] = 'http'
default['openstack']['block-storage']['netapp']['dfm_hostname'] = nil
default['openstack']['block-storage']['netapp']['dfm_login'] = nil
default['openstack']['block-storage']['netapp']['dfm_password'] = nil
default['openstack']['block-storage']['netapp']['dfm_port'] = '8088'
default['openstack']['block-storage']['netapp']['dfm_web_port'] = '8080'
default['openstack']['block-storage']['netapp']['storage_service'] = 'storage_service'
# Netapp direct NFS
default["openstack"]["block-storage"]["netapp"]["netapp_server_port"] = "80"
default["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"] = nil
default["openstack"]["block-storage"]["netapp"]["netapp_server_password"] = nil
default["openstack"]["block-storage"]["netapp"]["netapp_server_login"] = nil
default["openstack"]["block-storage"]["netapp"]["export"] = nil
default["openstack"]["block-storage"]["nfs"]["shares_config"] = "/etc/cinder/shares.conf"
default["openstack"]["block-storage"]["nfs"]["mount_point_base"] = "/mnt/cinder-volumes"
default["openstack"]["block-storage"]["nfs"]["nfs_disk_util"] = "df"
default["openstack"]["block-storage"]["nfs"]["nfs_sparsed_volumes"] = "true"
default['openstack']['block-storage']['netapp']['netapp_server_port'] = '80'
default['openstack']['block-storage']['netapp']['netapp_server_hostname'] = nil
default['openstack']['block-storage']['netapp']['netapp_server_password'] = nil
default['openstack']['block-storage']['netapp']['netapp_server_login'] = nil
default['openstack']['block-storage']['netapp']['export'] = nil
default['openstack']['block-storage']['nfs']['shares_config'] = '/etc/cinder/shares.conf'
default['openstack']['block-storage']['nfs']['mount_point_base'] = '/mnt/cinder-volumes'
default['openstack']['block-storage']['nfs']['nfs_disk_util'] = 'df'
default['openstack']['block-storage']['nfs']['nfs_sparsed_volumes'] = 'true'
# logging attribute
default["openstack"]["block-storage"]["syslog"]["use"] = false
default["openstack"]["block-storage"]["syslog"]["facility"] = "LOG_LOCAL2"
default["openstack"]["block-storage"]["syslog"]["config_facility"] = "local2"
default['openstack']['block-storage']['syslog']['use'] = false
default['openstack']['block-storage']['syslog']['facility'] = 'LOG_LOCAL2'
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']['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"
default["openstack"]["block-storage"]["volume"]["volume_group"] = "cinder-volumes"
default["openstack"]["block-storage"]["volume"]["volume_group_size"] = 40
default["openstack"]["block-storage"]["volume"]["create_volume_group"] = false
default["openstack"]["block-storage"]["volume"]["iscsi_helper"] = "tgtadm"
default["openstack"]["block-storage"]["volume"]["iscsi_ip_address"] = node["ipaddress"]
default["openstack"]["block-storage"]["volume"]["iscsi_port"] = "3260"
default['openstack']['block-storage']['volume']['state_path'] = '/var/lib/cinder'
default['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.driver.ISCSIDriver'
default['openstack']['block-storage']['volume']['volume_group'] = 'cinder-volumes'
default['openstack']['block-storage']['volume']['volume_group_size'] = 40
default['openstack']['block-storage']['volume']['create_volume_group'] = false
default['openstack']['block-storage']['volume']['iscsi_helper'] = 'tgtadm'
default['openstack']['block-storage']['volume']['iscsi_ip_address'] = node['ipaddress']
default['openstack']['block-storage']['volume']['iscsi_port'] = '3260'
# Ceph/RADOS options
default["openstack"]["block-storage"]["rbd_pool"] = "rbd"
default["openstack"]["block-storage"]["rbd_user"] = nil
default["openstack"]["block-storage"]["rbd_secret_uuid"] = nil
default['openstack']['block-storage']['rbd_pool'] = 'rbd'
default['openstack']['block-storage']['rbd_user'] = nil
default['openstack']['block-storage']['rbd_secret_uuid'] = nil
# Cinder Policy defaults
default["openstack"]["block-storage"]["policy"]["context_is_admin"] = '["role:admin"]'
default["openstack"]["block-storage"]["policy"]["default"] = '["rule:admin_or_owner"]'
default["openstack"]["block-storage"]["policy"]["admin_or_owner"] = '["is_admin:True"], ["project_id:%(project_id)s"]'
default["openstack"]["block-storage"]["policy"]["admin_api"] = '["is_admin:True"]'
default['openstack']['block-storage']['policy']['context_is_admin'] = '["role:admin"]'
default['openstack']['block-storage']['policy']['default'] = '["rule:admin_or_owner"]'
default['openstack']['block-storage']['policy']['admin_or_owner'] = '["is_admin:True"], ["project_id:%(project_id)s"]'
default['openstack']['block-storage']['policy']['admin_api'] = '["is_admin:True"]'
case platform
when "fedora", "redhat", "centos" # :pragma-foodcritic: ~FC024 - won't fix this
when 'fedora', 'redhat', 'centos' # :pragma-foodcritic: ~FC024 - won't fix this
# operating system user and group names
default["openstack"]["block-storage"]["user"] = "cinder"
default["openstack"]["block-storage"]["group"] = "cinder"
default['openstack']['block-storage']['user'] = 'cinder'
default['openstack']['block-storage']['group'] = 'cinder'
default["openstack"]["block-storage"]["platform"] = {
"mysql_python_packages" => ["MySQL-python"],
"postgresql_python_packages" => ["python-psycopg2"],
"cinder_common_packages" => ["openstack-cinder"],
"cinder_api_packages" => ["python-cinderclient"],
"cinder_api_service" => "openstack-cinder-api",
"cinder_volume_packages" => [],
"cinder_volume_service" => "openstack-cinder-volume",
"cinder_scheduler_packages" => [],
"cinder_scheduler_service" => "openstack-cinder-scheduler",
"cinder_iscsitarget_packages" => ["scsi-target-utils"],
"cinder_iscsitarget_service" => "tgtd",
"cinder_nfs_packages" => ["nfs-utils", "nfs-utils-lib"],
"package_overrides" => ""
default['openstack']['block-storage']['platform'] = {
'mysql_python_packages' => ['MySQL-python'],
'postgresql_python_packages' => ['python-psycopg2'],
'cinder_common_packages' => ['openstack-cinder'],
'cinder_api_packages' => ['python-cinderclient'],
'cinder_api_service' => 'openstack-cinder-api',
'cinder_volume_packages' => [],
'cinder_volume_service' => 'openstack-cinder-volume',
'cinder_scheduler_packages' => [],
'cinder_scheduler_service' => 'openstack-cinder-scheduler',
'cinder_iscsitarget_packages' => ['scsi-target-utils'],
'cinder_iscsitarget_service' => 'tgtd',
'cinder_nfs_packages' => ['nfs-utils', 'nfs-utils-lib'],
'package_overrides' => ''
}
when "suse"
when 'suse'
# operating system user and group names
default["openstack"]["block-storage"]["user"] = "openstack-cinder"
default["openstack"]["block-storage"]["group"] = "openstack-cinder"
default["openstack"]["block-storage"]["platform"] = {
"mysql_python_packages" => ["python-mysql"],
"postgresql_python_packages" => ["python-psycopg2"],
"cinder_common_packages" => ["openstack-cinder"],
"cinder_api_packages" => ["openstack-cinder-api"],
"cinder_api_service" => "openstack-cinder-api",
"cinder_scheduler_packages" => ["openstack-cinder-scheduler"],
"cinder_scheduler_service" => "openstack-cinder-scheduler",
"cinder_volume_packages" => ["openstack-cinder-volume"],
"cinder_volume_service" => "openstack-cinder-volume",
"cinder_iscsitarget_packages" => ["tgt"],
"cinder_iscsitarget_service" => "tgtd",
"cinder_nfs_packages" => ["nfs-utils"]
default['openstack']['block-storage']['user'] = 'openstack-cinder'
default['openstack']['block-storage']['group'] = 'openstack-cinder'
default['openstack']['block-storage']['platform'] = {
'mysql_python_packages' => ['python-mysql'],
'postgresql_python_packages' => ['python-psycopg2'],
'cinder_common_packages' => ['openstack-cinder'],
'cinder_api_packages' => ['openstack-cinder-api'],
'cinder_api_service' => 'openstack-cinder-api',
'cinder_scheduler_packages' => ['openstack-cinder-scheduler'],
'cinder_scheduler_service' => 'openstack-cinder-scheduler',
'cinder_volume_packages' => ['openstack-cinder-volume'],
'cinder_volume_service' => 'openstack-cinder-volume',
'cinder_iscsitarget_packages' => ['tgt'],
'cinder_iscsitarget_service' => 'tgtd',
'cinder_nfs_packages' => ['nfs-utils']
}
when "ubuntu"
when 'ubuntu'
# operating system user and group names
default["openstack"]["block-storage"]["user"] = "cinder"
default["openstack"]["block-storage"]["group"] = "cinder"
default["openstack"]["block-storage"]["platform"] = {
"mysql_python_packages" => ["python-mysqldb"],
"postgresql_python_packages" => ["python-psycopg2"],
"cinder_common_packages" => ["cinder-common"],
"cinder_api_packages" => ["cinder-api", "python-cinderclient"],
"cinder_api_service" => "cinder-api",
"cinder_volume_packages" => ["cinder-volume"],
"cinder_volume_service" => "cinder-volume",
"cinder_scheduler_packages" => ["cinder-scheduler"],
"cinder_scheduler_service" => "cinder-scheduler",
"cinder_iscsitarget_packages" => ["tgt"],
"cinder_iscsitarget_service" => "tgt",
"cinder_nfs_packages" => ["nfs-common"],
"package_overrides" => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
default['openstack']['block-storage']['user'] = 'cinder'
default['openstack']['block-storage']['group'] = 'cinder'
default['openstack']['block-storage']['platform'] = {
'mysql_python_packages' => ['python-mysqldb'],
'postgresql_python_packages' => ['python-psycopg2'],
'cinder_common_packages' => ['cinder-common'],
'cinder_api_packages' => ['cinder-api', 'python-cinderclient'],
'cinder_api_service' => 'cinder-api',
'cinder_volume_packages' => ['cinder-volume'],
'cinder_volume_service' => 'cinder-volume',
'cinder_scheduler_packages' => ['cinder-scheduler'],
'cinder_scheduler_service' => 'cinder-scheduler',
'cinder_iscsitarget_packages' => ['tgt'],
'cinder_iscsitarget_service' => 'tgt',
'cinder_nfs_packages' => ['nfs-common'],
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
}
end