diff --git a/.rubocop.yml b/.rubocop.yml index 7a296ac..888678a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,15 @@ -# UTF-8 headers not generally in these files -Encoding: - Enabled: false +AllCops: + Includes: + - metadata.rb + - Gemfile + - attributes/** + - recipes/** + - spec/** # ignore long lines LineLength: Enabled: false + +# Allow small arrays before forcing %w or %W +WordArray: + MinSize: 3 diff --git a/.tailor b/.tailor deleted file mode 100644 index 99f0dcf..0000000 --- a/.tailor +++ /dev/null @@ -1,25 +0,0 @@ -Tailor.config do |config| - config.formatters "text" - config.file_set '**/*.rb' do |style| - style.max_line_length 80, level: :off - style.allow_camel_case_methods false, level: :error - style.allow_hard_tabs false, level: :error - style.allow_screaming_snake_case_classes false, level: :error - style.allow_trailing_line_spaces false, level: :error - style.allow_invalid_ruby false, level: :warn - style.indentation_spaces 2, level: :error - style.max_code_lines_in_class 300, level: :error - style.max_code_lines_in_method 30, level: :error - style.spaces_after_comma 1, level: :error - style.spaces_after_lbrace 1, level: :error - style.spaces_after_lbracket 0, level: :error - style.spaces_after_lparen 0, level: :error - style.spaces_before_comma 0, level: :error - style.spaces_before_lbrace 1, level: :error - style.spaces_before_rbrace 1, level: :error - style.spaces_before_rbracket 0, level: :error - style.spaces_before_rparen 0, level: :error - style.spaces_in_empty_braces 0, level: :error - style.trailing_newlines 1, level: :error - end -end diff --git a/Berksfile.lock b/Berksfile.lock index d922561..bf5f86b 100644 --- a/Berksfile.lock +++ b/Berksfile.lock @@ -6,20 +6,20 @@ "openstack-image": { "locked_version": "8.0.0", "git": "git://github.com/stackforge/cookbook-openstack-image.git", - "ref": "900c9eef120e22368bb27062473ae549643e9594" + "ref": "2be8d1e01789f4e7a3fc7b6f8a2f43df3fae59c5" }, "openstack-identity": { "locked_version": "8.0.0", "git": "git://github.com/stackforge/cookbook-openstack-identity.git", - "ref": "3b001b7e07758e2c81b5ae4d1bff8e4a1472b24a" + "ref": "f4925084e583c29cb9007d9f2e1894761db264ef" }, "openstack-common": { - "locked_version": "8.0.0", + "locked_version": "8.0.1", "git": "git://github.com/stackforge/cookbook-openstack-common.git", - "ref": "d5f852daf5d0f3001ddbf1688c43a4bb21e8ca00" + "ref": "5e7592dc180bc30348afe7b1ecb3328d0fbacc5e" }, "apt": { - "locked_version": "2.3.0" + "locked_version": "2.3.4" }, "selinux": { "locked_version": "0.6.2" @@ -31,13 +31,13 @@ "locked_version": "1.4.2" }, "yum": { - "locked_version": "2.4.4" + "locked_version": "3.0.2" }, "database": { - "locked_version": "1.4.0" + "locked_version": "1.6.0" }, "mysql": { - "locked_version": "3.0.0" + "locked_version": "4.0.14" }, "openssl": { "locked_version": "1.1.0" diff --git a/Gemfile b/Gemfile index 76065e1..27706b4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,4 @@ +# encoding: UTF-8 source 'https://rubygems.org' gem 'chef', '~> 11.8' diff --git a/Strainerfile b/Strainerfile index bc1e0bb..9a2ec64 100644 --- a/Strainerfile +++ b/Strainerfile @@ -1,11 +1,5 @@ # Strainerfile -rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile --config $SANDBOX/$COOKBOOK/.rubocop.yml -rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/metadata.rb --config $SANDBOX/$COOKBOOK/.rubocop.yml -rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/attributes/ --config $SANDBOX/$COOKBOOK/attributes/.rubocop.yml -rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/recipes/ --config $SANDBOX/$COOKBOOK/recipes/.rubocop.yml -rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/spec/ --config $SANDBOX/$COOKBOOK/spec/.rubocop.yml -# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK -# may want to add rubocop check for Berksfile and Gemfile +rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK knife test: bundle exec knife cookbook test $COOKBOOK foodcritic: bundle exec foodcritic -f any -t ~FC003 $SANDBOX/$COOKBOOK chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec diff --git a/TESTING.md b/TESTING.md index f4d5119..af426d1 100644 --- a/TESTING.md +++ b/TESTING.md @@ -14,15 +14,6 @@ To run the tests: [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 ### - -Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of: - - [Gemfile and metadata.rb](.rubocop.yml) - [attributes/*.rb](attributes/.rubocop.yml) - [recipes/.rubocop.yml](recipes/.rubocop.yml) - [spec/.rubocop.yml](spec/.rubocop.yml) - ## 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. diff --git a/attributes/.rubocop.yml b/attributes/.rubocop.yml deleted file mode 100644 index c158f65..0000000 --- a/attributes/.rubocop.yml +++ /dev/null @@ -1,7 +0,0 @@ -# embedded attributes make for long lines -LineLength: - Enabled: false - -# %w or %W have not generally been used in attribute files -WordArray: - Enabled: false diff --git a/attributes/default.rb b/attributes/default.rb index 66c76f1..0aa593e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -75,11 +75,11 @@ default['openstack']['block-storage']['quota_driver'] = 'cinder.quota.DbQuotaDri 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 -case node["openstack"]["mq"]["service_type"] -when "rabbitmq" - default["openstack"]["block_storage"]["rpc_backend"] = "cinder.openstack.common.rpc.impl_kombu" -when "qpid" - default["openstack"]["block_storage"]["rpc_backend"] = "cinder.openstack.common.rpc.impl_qpid" +case node['openstack']['mq']['service_type'] +when 'rabbitmq' + default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_kombu' +when 'qpid' + default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_qpid' end # MQ options diff --git a/metadata.rb b/metadata.rb index 68470b8..0c87b79 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 name 'openstack-block-storage' maintainer 'AT&T Services, Inc.' maintainer_email 'cookbooks@lists.tfoundry.com' diff --git a/recipes/.rubocop-todo.yml b/recipes/.rubocop-todo.yml deleted file mode 100644 index d5cfdab..0000000 --- a/recipes/.rubocop-todo.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This configuration was generated by `rubocop --auto-gen-config`. -# The point is for the user to remove these configuration records -# one by one as the offences are removed from the code base. - -CollectionMethods: - Enabled: false - -Documentation: - Enabled: false - -HashSyntax: - Enabled: false - -StringLiterals: - Enabled: false diff --git a/recipes/.rubocop.yml b/recipes/.rubocop.yml deleted file mode 100644 index 446ebc4..0000000 --- a/recipes/.rubocop.yml +++ /dev/null @@ -1,3 +0,0 @@ -# embedded attributes make for long lines -LineLength: - Enabled: false diff --git a/recipes/api.rb b/recipes/api.rb index a1267e6..66ceac4 100644 --- a/recipes/api.rb +++ b/recipes/api.rb @@ -25,14 +25,13 @@ class ::Chef::Recipe include ::Openstack end -include_recipe "openstack-block-storage::cinder-common" +include_recipe 'openstack-block-storage::cinder-common' -platform_options = node["openstack"]["block-storage"]["platform"] +platform_options = node['openstack']['block-storage']['platform'] -platform_options["cinder_api_packages"].each do |pkg| +platform_options['cinder_api_packages'].each do |pkg| package pkg do - options platform_options["package_overrides"] - + options platform_options['package_overrides'] action :upgrade end end @@ -44,44 +43,43 @@ platform_options["#{db_type}_python_packages"].each do |pkg| end end -directory ::File.dirname(node["openstack"]["block-storage"]["api"]["auth"]["cache_dir"]) do - owner node["openstack"]["block-storage"]["user"] - group node["openstack"]["block-storage"]["group"] +directory ::File.dirname(node['openstack']['block-storage']['api']['auth']['cache_dir']) do + owner node['openstack']['block-storage']['user'] + group node['openstack']['block-storage']['group'] mode 00700 end -service "cinder-api" do - service_name platform_options["cinder_api_service"] - supports :status => true, :restart => true - +service 'cinder-api' do + service_name platform_options['cinder_api_service'] + supports status: true, restart: true action :enable - subscribes :restart, "template[/etc/cinder/cinder.conf]" + subscribes :restart, 'template[/etc/cinder/cinder.conf]' end -identity_endpoint = endpoint "identity-api" -identity_admin_endpoint = endpoint "identity-admin" -service_pass = get_password "service", "openstack-block-storage" +identity_endpoint = endpoint 'identity-api' +identity_admin_endpoint = endpoint 'identity-admin' +service_pass = get_password 'service', 'openstack-block-storage' -execute "cinder-manage db sync" +execute 'cinder-manage db sync' -template "/etc/cinder/api-paste.ini" do - source "api-paste.ini.erb" - group node["openstack"]["block-storage"]["group"] - owner node["openstack"]["block-storage"]["user"] - mode 00644 +template '/etc/cinder/api-paste.ini' do + source 'api-paste.ini.erb' + group node['openstack']['block-storage']['group'] + owner node['openstack']['block-storage']['user'] + mode 00644 variables( - :identity_endpoint => identity_endpoint, - :identity_admin_endpoint => identity_admin_endpoint, - :service_pass => service_pass - ) + identity_endpoint: identity_endpoint, + identity_admin_endpoint: identity_admin_endpoint, + service_pass: service_pass + ) - notifies :restart, "service[cinder-api]", :immediately + notifies :restart, 'service[cinder-api]', :immediately end -template "/etc/cinder/policy.json" do - source "policy.json.erb" - owner node["openstack"]["block-storage"]["user"] - group node["openstack"]["block-storage"]["group"] - mode 00644 - notifies :restart, "service[cinder-api]" +template '/etc/cinder/policy.json' do + source 'policy.json.erb' + owner node['openstack']['block-storage']['user'] + group node['openstack']['block-storage']['group'] + mode 00644 + notifies :restart, 'service[cinder-api]' end diff --git a/recipes/cinder-common.rb b/recipes/cinder-common.rb index b00e849..b5c2b5c 100644 --- a/recipes/cinder-common.rb +++ b/recipes/cinder-common.rb @@ -17,56 +17,55 @@ class ::Chef::Recipe include ::Openstack end -if node["openstack"]["block-storage"]["syslog"]["use"] - include_recipe "openstack-common::logging" +if node['openstack']['block-storage']['syslog']['use'] + include_recipe 'openstack-common::logging' end -platform_options = node["openstack"]["block-storage"]["platform"] +platform_options = node['openstack']['block-storage']['platform'] -platform_options["cinder_common_packages"].each do |pkg| +platform_options['cinder_common_packages'].each do |pkg| package pkg do - options platform_options["package_overrides"] - + options platform_options['package_overrides'] action :upgrade end end -db_user = node["openstack"]["block-storage"]["db"]["username"] -db_pass = get_password "db", "cinder" -sql_connection = db_uri("volume", db_user, db_pass) +db_user = node['openstack']['block-storage']['db']['username'] +db_pass = get_password 'db', 'cinder' +sql_connection = db_uri('volume', db_user, db_pass) -if node["openstack"]["block-storage"]["mq"]["service_type"] == "rabbitmq" - if node["openstack"]["block-storage"]["rabbit"]["ha"] +if node['openstack']['block-storage']['mq']['service_type'] == 'rabbitmq' + if node['openstack']['block-storage']['rabbit']['ha'] rabbit_hosts = rabbit_servers end - rabbit_pass = get_password "user", node["openstack"]["block-storage"]["rabbit"]["username"] + rabbit_pass = get_password 'user', node['openstack']['block-storage']['rabbit']['username'] end -glance_api_endpoint = endpoint "image-api" +glance_api_endpoint = endpoint 'image-api' -directory "/etc/cinder" do - group node["openstack"]["block-storage"]["group"] - owner node["openstack"]["block-storage"]["user"] +directory '/etc/cinder' do + group node['openstack']['block-storage']['group'] + owner node['openstack']['block-storage']['user'] mode 00750 action :create end -template "/etc/cinder/cinder.conf" do - source "cinder.conf.erb" - group node["openstack"]["block-storage"]["group"] - owner node["openstack"]["block-storage"]["user"] - mode 00644 +template '/etc/cinder/cinder.conf' do + source 'cinder.conf.erb' + group node['openstack']['block-storage']['group'] + owner node['openstack']['block-storage']['user'] + mode 00644 variables( - :sql_connection => sql_connection, - :rabbit_password => rabbit_pass, - :rabbit_hosts => rabbit_hosts, - :glance_host => glance_api_endpoint.host, - :glance_port => glance_api_endpoint.port + sql_connection: sql_connection, + rabbit_password: rabbit_pass, + rabbit_hosts: rabbit_hosts, + glance_host: glance_api_endpoint.host, + glance_port: glance_api_endpoint.port ) end -directory node["openstack"]["block-storage"]["lock_path"] do - group node["openstack"]["block-storage"]["group"] - owner node["openstack"]["block-storage"]["user"] - mode 00700 +directory node['openstack']['block-storage']['lock_path'] do + group node['openstack']['block-storage']['group'] + owner node['openstack']['block-storage']['user'] + mode 00700 end diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index 77ee126..fb87441 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -20,67 +20,63 @@ # limitations under the License. # -require "uri" +require 'uri' -class ::Chef::Recipe +class ::Chef::Recipe # rubocop:disable Documentation include ::Openstack end -identity_admin_endpoint = endpoint "identity-admin" -bootstrap_token = secret "secrets", "openstack_identity_bootstrap_token" +identity_admin_endpoint = endpoint 'identity-admin' +bootstrap_token = secret 'secrets', 'openstack_identity_bootstrap_token' auth_uri = ::URI.decode identity_admin_endpoint.to_s -cinder_api_endpoint = endpoint "volume-api" -service_pass = get_password "service", "openstack-block-storage" -region = node["openstack"]["block-storage"]["region"] -service_tenant_name = node["openstack"]["block-storage"]["service_tenant_name"] -service_user = node["openstack"]["block-storage"]["service_user"] -service_role = node["openstack"]["block-storage"]["service_role"] +cinder_api_endpoint = endpoint 'volume-api' +service_pass = get_password 'service', 'openstack-block-storage' +region = node['openstack']['block-storage']['region'] +service_tenant_name = node['openstack']['block-storage']['service_tenant_name'] +service_user = node['openstack']['block-storage']['service_user'] +service_role = node['openstack']['block-storage']['service_role'] -openstack_identity_register "Register Cinder Volume Service" do +openstack_identity_register 'Register Cinder Volume Service' do auth_uri auth_uri bootstrap_token bootstrap_token - service_name "cinder" - service_type "volume" - service_description "Cinder Volume Service" + service_name 'cinder' + service_type 'volume' + service_description 'Cinder Volume Service' endpoint_region region endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s - action :create_service end -openstack_identity_register "Register Cinder Volume Endpoint" do +openstack_identity_register 'Register Cinder Volume Endpoint' do auth_uri auth_uri bootstrap_token bootstrap_token - service_name "cinder" - service_type "volume" - service_description "Cinder Volume Service" + service_name 'cinder' + service_type 'volume' + service_description 'Cinder Volume Service' endpoint_region region endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s - action :create_endpoint end -openstack_identity_register "Register Cinder Service User" do +openstack_identity_register 'Register Cinder Service User' do auth_uri auth_uri bootstrap_token bootstrap_token tenant_name service_tenant_name user_name service_user user_pass service_pass user_enabled true # Not required as this is the default - action :create_user end -openstack_identity_register "Grant service Role to Cinder Service User for Cinder Service Tenant" do +openstack_identity_register 'Grant service Role to Cinder Service User for Cinder Service Tenant' do auth_uri auth_uri bootstrap_token bootstrap_token tenant_name service_tenant_name user_name service_user role_name service_role - action :grant_role end diff --git a/recipes/scheduler.rb b/recipes/scheduler.rb index 04dcd31..2cdebb5 100644 --- a/recipes/scheduler.rb +++ b/recipes/scheduler.rb @@ -21,13 +21,13 @@ # limitations under the License. # -include_recipe "openstack-block-storage::cinder-common" +include_recipe 'openstack-block-storage::cinder-common' -platform_options = node["openstack"]["block-storage"]["platform"] +platform_options = node['openstack']['block-storage']['platform'] -platform_options["cinder_scheduler_packages"].each do |pkg| +platform_options['cinder_scheduler_packages'].each do |pkg| package pkg do - options platform_options["package_overrides"] + options platform_options['package_overrides'] action :upgrade end @@ -40,30 +40,30 @@ platform_options["#{db_type}_python_packages"].each do |pkg| end end -service "cinder-scheduler" do - service_name platform_options["cinder_scheduler_service"] - supports :status => true, :restart => true +service 'cinder-scheduler' do + service_name platform_options['cinder_scheduler_service'] + supports status: true, restart: true action [:enable, :start] - subscribes :restart, "template[/etc/cinder/cinder.conf]" + 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"] +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"] +if node['openstack']['metering'] + scheduler_role = node['openstack']['block-storage']['scheduler_role'] results = search(:node, "roles:#{scheduler_role}") - cron_node = results.collect { |a| a.name }.sort[0] + cron_node = results.map { |a| a.name }.sort[0] Chef::Log.debug("Volume audit cron node: #{cron_node}") - cron "cinder-volume-usage-audit" do - day node["openstack"]["block-storage"]["cron"]["day"] || '*' - hour node["openstack"]["block-storage"]["cron"]["hour"] || '*' - minute node["openstack"]["block-storage"]["cron"]["minute"] - month node["openstack"]["block-storage"]["cron"]["month"] || '*' - weekday node["openstack"]["block-storage"]["cron"]["weekday"] || '*' + cron 'cinder-volume-usage-audit' do + day node['openstack']['block-storage']['cron']['day'] || '*' + hour node['openstack']['block-storage']['cron']['hour'] || '*' + minute node['openstack']['block-storage']['cron']['minute'] + month node['openstack']['block-storage']['cron']['month'] || '*' + weekday node['openstack']['block-storage']['cron']['weekday'] || '*' 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"] + user node['openstack']['block-storage']['user'] end end diff --git a/recipes/volume.rb b/recipes/volume.rb index 13b30d9..538c2ee 100644 --- a/recipes/volume.rb +++ b/recipes/volume.rb @@ -26,13 +26,13 @@ class ::Chef::Recipe include ::Openstack end -include_recipe "openstack-block-storage::cinder-common" +include_recipe 'openstack-block-storage::cinder-common' -platform_options = node["openstack"]["block-storage"]["platform"] +platform_options = node['openstack']['block-storage']['platform'] -platform_options["cinder_volume_packages"].each do |pkg| +platform_options['cinder_volume_packages'].each do |pkg| package pkg do - options platform_options["package_overrides"] + options platform_options['package_overrides'] action :upgrade end end @@ -44,103 +44,103 @@ platform_options["#{db_type}_python_packages"].each do |pkg| end end -platform_options["cinder_iscsitarget_packages"].each do |pkg| +platform_options['cinder_iscsitarget_packages'].each do |pkg| package pkg do - options platform_options["package_overrides"] + options platform_options['package_overrides'] action :upgrade end end -case node["openstack"]["block-storage"]["volume"]["driver"] -when "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" - node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = get_password "service", "netapp" +case node['openstack']['block-storage']['volume']['driver'] +when 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver' + node.override['openstack']['block-storage']['netapp']['dfm_password'] = get_password 'service', 'netapp' -when "cinder.volume.drivers.RBDDriver" - node.override["openstack"]["block-storage"]["rbd_secret_uuid"] = get_password "service", "rbd" +when 'cinder.volume.drivers.RBDDriver' + node.override['openstack']['block-storage']['rbd_secret_uuid'] = get_password 'service', 'rbd' -when "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" - node.override["openstack"]["block-storage"]["netapp"]["netapp_server_password"] = get_password "service", "netapp-filer" +when 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver' + node.override['openstack']['block-storage']['netapp']['netapp_server_password'] = get_password 'service', 'netapp-filer' - directory node["openstack"]["block-storage"]["nfs"]["mount_point_base"] do - owner node["openstack"]["block-storage"]["user"] - group node["openstack"]["block-storage"]["group"] + directory node['openstack']['block-storage']['nfs']['mount_point_base'] do + owner node['openstack']['block-storage']['user'] + group node['openstack']['block-storage']['group'] action :create end - template node["openstack"]["block-storage"]["nfs"]["shares_config"] do - source "shares.conf.erb" - mode "0600" - owner node["openstack"]["block-storage"]["user"] - group node["openstack"]["block-storage"]["group"] + template node['openstack']['block-storage']['nfs']['shares_config'] do + source 'shares.conf.erb' + mode '0600' + owner node['openstack']['block-storage']['user'] + group node['openstack']['block-storage']['group'] variables( - "host" => node["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"], - "export" => node["openstack"]["block-storage"]["netapp"]["export"] + host: node['openstack']['block-storage']['netapp']['netapp_server_hostname'], + export: node['openstack']['block-storage']['netapp']['export'] ) - notifies :restart, "service[cinder-volume]" + notifies :restart, 'service[cinder-volume]' end - platform_options["cinder_nfs_packages"].each do |pkg| + platform_options['cinder_nfs_packages'].each do |pkg| package pkg do - options platform_options["package_overrides"] + options platform_options['package_overrides'] action :upgrade end end -when "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" +when 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver' file node['openstack']['block-storage']['san']['san_private_key'] do - mode "0400" - owner node["openstack"]["block-storage"]["user"] - group node["openstack"]["block-storage"]["group"] -end + mode '0400' + owner node['openstack']['block-storage']['user'] + group node['openstack']['block-storage']['group'] + end -when "cinder.volume.drivers.lvm.LVMISCSIDriver" - if node["openstack"]["block-storage"]["volume"]["create_volume_group"] - volume_size = node["openstack"]["block-storage"]["volume"]["volume_group_size"] +when 'cinder.volume.drivers.lvm.LVMISCSIDriver' + if node['openstack']['block-storage']['volume']['create_volume_group'] + volume_size = node['openstack']['block-storage']['volume']['volume_group_size'] seek_count = volume_size.to_i * 1024 # default volume group is 40G seek_count = 40 * 1024 if seek_count == 0 - vg_name = node["openstack"]["block-storage"]["volume"]["volume_group"] - vg_file = "#{node["openstack"]["block-storage"]["volume"]["state_path"]}/#{vg_name}.img" + vg_name = node['openstack']['block-storage']['volume']['volume_group'] + vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img" # create volume group - execute "Create Cinder volume group" do + execute 'Create Cinder volume group' do command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})" action :run not_if "vgs #{vg_name}" end - template "/etc/init.d/cinder-group-active" do - source "cinder-group-active.erb" - mode "755" + template '/etc/init.d/cinder-group-active' do + source 'cinder-group-active.erb' + mode '755' variables( - "volume_file" => vg_file + volume_file: vg_file ) - notifies :start, "service[cinder-group-active]", :immediately + notifies :start, 'service[cinder-group-active]', :immediately end - service "cinder-group-active" do - service_name "cinder-group-active" + service 'cinder-group-active' do + service_name 'cinder-group-active' - action [ :enable, :start ] + action [:enable, :start] end end end -service "cinder-volume" do - service_name platform_options["cinder_volume_service"] - supports :status => true, :restart => true +service 'cinder-volume' do + service_name platform_options['cinder_volume_service'] + supports status: true, restart: true action [:enable, :start] - subscribes :restart, "template[/etc/cinder/cinder.conf]" + subscribes :restart, 'template[/etc/cinder/cinder.conf]' end -service "iscsitarget" do - service_name platform_options["cinder_iscsitarget_service"] - supports :status => true, :restart => true +service 'iscsitarget' do + service_name platform_options['cinder_iscsitarget_service'] + supports status: true, restart: true action :enable end -template "/etc/tgt/targets.conf" do - source "targets.conf.erb" +template '/etc/tgt/targets.conf' do + source 'targets.conf.erb' mode 00600 - notifies :restart, "service[iscsitarget]", :immediately + notifies :restart, 'service[iscsitarget]', :immediately end diff --git a/spec/.rubocop-todo.yml b/spec/.rubocop-todo.yml deleted file mode 100644 index f6ad301..0000000 --- a/spec/.rubocop-todo.yml +++ /dev/null @@ -1,17 +0,0 @@ -# This configuration was generated by `rubocop --auto-gen-config`. -# The point is for the user to remove these configuration records -# one by one as the offences are removed from the code base. - -HashSyntax: - Enabled: false - -MethodLength: - Enabled: false - -StringLiterals: - Enabled: false - -### in the .rubocop.yml -# embedded attributes make for long lines -LineLength: - Enabled: false diff --git a/spec/.rubocop.yml b/spec/.rubocop.yml deleted file mode 100644 index 446ebc4..0000000 --- a/spec/.rubocop.yml +++ /dev/null @@ -1,3 +0,0 @@ -# embedded attributes make for long lines -LineLength: - Enabled: false diff --git a/spec/api-opensuse_spec.rb b/spec/api-opensuse_spec.rb index daa81c3..c9678a7 100644 --- a/spec/api-opensuse_spec.rb +++ b/spec/api-opensuse_spec.rb @@ -2,41 +2,41 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::api" do +describe 'openstack-block-storage::api' do before { block_storage_stubs } - describe "opensuse" do + describe 'opensuse' do before do @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS - @chef_run.converge "openstack-block-storage::api" + @chef_run.converge 'openstack-block-storage::api' end - it "installs cinder api packages" do - expect(@chef_run).to upgrade_package "openstack-cinder-api" + it 'installs cinder api packages' do + expect(@chef_run).to upgrade_package 'openstack-cinder-api' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "python-mysql" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'python-mysql' end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::api" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::api' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "python-mysql" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'python-mysql' end - it "starts cinder api on boot" do - expect(@chef_run).to enable_service "openstack-cinder-api" + it 'starts cinder api on boot' do + expect(@chef_run).to enable_service 'openstack-cinder-api' end expect_creates_policy_json( - "service[cinder-api]", "openstack-cinder", "openstack-cinder") + 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder') expect_creates_cinder_conf( - "service[cinder-api]", "openstack-cinder", "openstack-cinder") + 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder') end end diff --git a/spec/api-redhat_spec.rb b/spec/api-redhat_spec.rb index b9e771d..d1a444a 100644 --- a/spec/api-redhat_spec.rb +++ b/spec/api-redhat_spec.rb @@ -2,47 +2,47 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::api" do +describe 'openstack-block-storage::api' do before { block_storage_stubs } - describe "redhat" do + describe 'redhat' do before do @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS - @chef_run.converge "openstack-block-storage::api" + @chef_run.converge 'openstack-block-storage::api' end - it "installs cinder api packages" do - expect(@chef_run).to upgrade_package "python-cinderclient" + it 'installs cinder api packages' do + expect(@chef_run).to upgrade_package 'python-cinderclient' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "MySQL-python" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'MySQL-python' end - it "installs db2 python packages if explicitly told" do + it 'installs db2 python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "db2" - chef_run.converge "openstack-block-storage::api" + node.set['openstack']['db']['volume']['db_type'] = 'db2' + chef_run.converge 'openstack-block-storage::api' - ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| + ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg| expect(chef_run).to upgrade_package pkg end end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::api" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::api' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "MySQL-python" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'MySQL-python' end - it "starts cinder api on boot" do - expect(@chef_run).to enable_service "openstack-cinder-api" + it 'starts cinder api on boot' do + expect(@chef_run).to enable_service 'openstack-cinder-api' end end end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 73b7ac2..2bf467e 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -2,152 +2,152 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::api" do +describe 'openstack-block-storage::api' do before { block_storage_stubs } - describe "ubuntu" do + describe 'ubuntu' do before do @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["syslog"]["use"] = true + n.set['openstack']['block-storage']['syslog']['use'] = true end - @chef_run.converge "openstack-block-storage::api" + @chef_run.converge 'openstack-block-storage::api' end expect_runs_openstack_common_logging_recipe - it "doesn't run logging recipe" do + it 'does not run logging recipe' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS - chef_run.converge "openstack-block-storage::api" + chef_run.converge 'openstack-block-storage::api' - expect(chef_run).not_to include_recipe "openstack-common::logging" + expect(chef_run).not_to include_recipe 'openstack-common::logging' end - it "installs cinder api packages" do - expect(@chef_run).to upgrade_package "cinder-api" - expect(@chef_run).to upgrade_package "python-cinderclient" + it 'installs cinder api packages' do + expect(@chef_run).to upgrade_package 'cinder-api' + expect(@chef_run).to upgrade_package 'python-cinderclient' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "python-mysqldb" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'python-mysqldb' end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::api" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::api' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "python-mysqldb" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'python-mysqldb' end - describe "/var/cache/cinder" do + describe '/var/cache/cinder' do before do - @dir = @chef_run.directory "/var/cache/cinder" + @dir = @chef_run.directory '/var/cache/cinder' end - it "has proper owner" do - expect(@dir.owner).to eq("cinder") - expect(@dir.group).to eq("cinder") + it 'has proper owner' do + expect(@dir.owner).to eq('cinder') + expect(@dir.group).to eq('cinder') end - it "has proper modes" do - expect(sprintf("%o", @dir.mode)).to eq "700" + it 'has proper modes' do + expect(sprintf('%o', @dir.mode)).to eq '700' end end - it "starts cinder api on boot" do - expect(@chef_run).to enable_service "cinder-api" + it 'starts cinder api on boot' do + expect(@chef_run).to enable_service 'cinder-api' end - expect_creates_cinder_conf "service[cinder-api]", "cinder", "cinder" + expect_creates_cinder_conf 'service[cinder-api]', 'cinder', 'cinder' - describe "cinder.conf" do + describe 'cinder.conf' do before do - @file = "/etc/cinder/cinder.conf" + @file = '/etc/cinder/cinder.conf' end - it "runs logging recipe if node attributes say to" do - expect(@chef_run).to render_file(@file).with_content("log_config = /etc/openstack/logging.conf") + it 'runs logging recipe if node attributes say to' do + expect(@chef_run).to render_file(@file).with_content('log_config = /etc/openstack/logging.conf') end - it "doesn't run logging recipe" do + it 'does not run logging recipe' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS - chef_run.converge "openstack-block-storage::api" + chef_run.converge 'openstack-block-storage::api' - expect(chef_run).not_to render_file(@file).with_content("log_config = /etc/openstack/logging.conf") + expect(chef_run).not_to render_file(@file).with_content('log_config = /etc/openstack/logging.conf') end - it "has rbd driver settings" do + it 'has rbd driver settings' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"] = { - "driver" => "cinder.volume.drivers.RBDDriver" + n.set['openstack']['block-storage']['volume'] = { + 'driver' => 'cinder.volume.drivers.RBDDriver' } end - chef_run.converge "openstack-block-storage::api" + chef_run.converge 'openstack-block-storage::api' expect(chef_run).to render_file(@file).with_content(/^rbd_/) expect(chef_run).not_to render_file(@file).with_content(/^netapp_/) end - it "has netapp driver settings" do + it 'has netapp driver settings' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"] = { - "driver" => "cinder.volume.drivers.netapp.NetAppISCSIDriver" + n.set['openstack']['block-storage']['volume'] = { + 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver' } end - chef_run.converge "openstack-block-storage::api" + chef_run.converge 'openstack-block-storage::api' expect(chef_run).to render_file(@file).with_content(/^netapp_/) expect(chef_run).not_to render_file(@file).with_content(/^rbd_/) end end - it "runs db migrations" do - cmd = "cinder-manage db sync" + it 'runs db migrations' do + cmd = 'cinder-manage db sync' expect(@chef_run).to run_execute(cmd) end - expect_creates_policy_json "service[cinder-api]", "cinder", "cinder" + expect_creates_policy_json 'service[cinder-api]', 'cinder', 'cinder' - describe "api-paste.ini" do + describe 'api-paste.ini' do before do - @file = @chef_run.template "/etc/cinder/api-paste.ini" + @file = @chef_run.template '/etc/cinder/api-paste.ini' end - it "has proper owner" do - expect(@file.owner).to eq("cinder") - expect(@file.group).to eq("cinder") + it 'has proper owner' do + expect(@file.owner).to eq('cinder') + expect(@file.group).to eq('cinder') end - it "has proper modes" do - expect(sprintf("%o", @file.mode)).to eq "644" + it 'has proper modes' do + expect(sprintf('%o', @file.mode)).to eq '644' end - it "has signing_dir" do - expect(@chef_run).to render_file(@file.name).with_content("signing_dir = /var/cache/cinder/api") + it 'has signing_dir' do + expect(@chef_run).to render_file(@file.name).with_content('signing_dir = /var/cache/cinder/api') end - it "notifies cinder-api restart" do - expect(@file).to notify("service[cinder-api]").to(:restart) + it 'notifies cinder-api restart' do + expect(@file).to notify('service[cinder-api]').to(:restart) end - it "has auth_uri" do - expect(@chef_run).to render_file(@file.name).with_content("auth_uri = http://127.0.0.1:5000/v2.0") + it 'has auth_uri' do + expect(@chef_run).to render_file(@file.name).with_content('auth_uri = http://127.0.0.1:5000/v2.0') end - it "has auth_host" do - expect(@chef_run).to render_file(@file.name).with_content("auth_host = 127.0.0.1") + it 'has auth_host' do + expect(@chef_run).to render_file(@file.name).with_content('auth_host = 127.0.0.1') end - it "has auth_port" do - expect(@chef_run).to render_file(@file.name).with_content("auth_port = 35357") + it 'has auth_port' do + expect(@chef_run).to render_file(@file.name).with_content('auth_port = 35357') end - it "has auth_protocol" do - expect(@chef_run).to render_file(@file.name).with_content("auth_protocol = http") + it 'has auth_protocol' do + expect(@chef_run).to render_file(@file.name).with_content('auth_protocol = http') end end end diff --git a/spec/cinder_common-opensuse_spec.rb b/spec/cinder_common-opensuse_spec.rb index 9bf16c2..6576d3a 100644 --- a/spec/cinder_common-opensuse_spec.rb +++ b/spec/cinder_common-opensuse_spec.rb @@ -2,21 +2,21 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::cinder-common" do +describe 'openstack-block-storage::cinder-common' do before { block_storage_stubs } before do @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n| - n.set["openstack"]["mq"] = { - "host" => "127.0.0.1" + n.set['openstack']['mq'] = { + 'host' => '127.0.0.1' } - n.set["openstack"]["block-storage"]["syslog"]["use"] = true + n.set['openstack']['block-storage']['syslog']['use'] = true end - @chef_run.converge "openstack-block-storage::cinder-common" + @chef_run.converge 'openstack-block-storage::cinder-common' end - it "installs the openstack-cinder package" do - expect(@chef_run).to upgrade_package "openstack-cinder" + it 'installs the openstack-cinder package' do + expect(@chef_run).to upgrade_package 'openstack-cinder' end end diff --git a/spec/cinder_common-redhat_spec.rb b/spec/cinder_common-redhat_spec.rb index 313945a..829b0e4 100644 --- a/spec/cinder_common-redhat_spec.rb +++ b/spec/cinder_common-redhat_spec.rb @@ -2,21 +2,21 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::cinder-common" do +describe 'openstack-block-storage::cinder-common' do before { block_storage_stubs } before do @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n| - n.set["openstack"]["mq"] = { - "host" => "127.0.0.1" + n.set['openstack']['mq'] = { + 'host' => '127.0.0.1' } - n.set["openstack"]["block-storage"]["syslog"]["use"] = true + n.set['openstack']['block-storage']['syslog']['use'] = true end - @chef_run.converge "openstack-block-storage::cinder-common" + @chef_run.converge 'openstack-block-storage::cinder-common' end - it "installs the openstack-cinder package" do - expect(@chef_run).to upgrade_package "openstack-cinder" + it 'installs the openstack-cinder package' do + expect(@chef_run).to upgrade_package 'openstack-cinder' end end diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb index 396dde4..5032fd7 100644 --- a/spec/cinder_common_spec.rb +++ b/spec/cinder_common_spec.rb @@ -2,224 +2,224 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::cinder-common" do +describe 'openstack-block-storage::cinder-common' do before { block_storage_stubs } before do @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["mq"] = { - "host" => "127.0.0.1" + n.set['openstack']['mq'] = { + 'host' => '127.0.0.1' } end - @chef_run.converge "openstack-block-storage::cinder-common" + @chef_run.converge 'openstack-block-storage::cinder-common' end - it "installs the cinder-common package" do - expect(@chef_run).to upgrade_package "cinder-common" + it 'installs the cinder-common package' do + expect(@chef_run).to upgrade_package 'cinder-common' end - describe "/etc/cinder" do + describe '/etc/cinder' do before do - @dir = @chef_run.directory "/etc/cinder" + @dir = @chef_run.directory '/etc/cinder' end - it "has proper owner" do - expect(@dir.owner).to eq("cinder") - expect(@dir.group).to eq("cinder") + it 'has proper owner' do + expect(@dir.owner).to eq('cinder') + expect(@dir.group).to eq('cinder') end - it "has proper modes" do - expect(sprintf("%o", @dir.mode)).to eq "750" + it 'has proper modes' do + expect(sprintf('%o', @dir.mode)).to eq '750' end end - describe "cinder.conf" do + describe 'cinder.conf' do before do - @file = @chef_run.template "/etc/cinder/cinder.conf" + @file = @chef_run.template '/etc/cinder/cinder.conf' end - it "has proper owner" do - expect(@file.owner).to eq("cinder") - expect(@file.group).to eq("cinder") + it 'has proper owner' do + expect(@file.owner).to eq('cinder') + expect(@file.group).to eq('cinder') end - it "has proper modes" do - expect(sprintf("%o", @file.mode)).to eq "644" + it 'has proper modes' do + expect(sprintf('%o', @file.mode)).to eq '644' end - it "has name templates" do - expect(@chef_run).to render_file(@file.name).with_content("volume_name_template=volume-%s") - expect(@chef_run).to render_file(@file.name).with_content("snapshot_name_template=snapshot-%s") + it 'has name templates' do + expect(@chef_run).to render_file(@file.name).with_content('volume_name_template=volume-%s') + expect(@chef_run).to render_file(@file.name).with_content('snapshot_name_template=snapshot-%s') end - it "has rpc_backend set" do - expect(@chef_run).to render_file(@file.name).with_content("rpc_backend=cinder.openstack.common.rpc.impl_kombu") + it 'has rpc_backend set' do + expect(@chef_run).to render_file(@file.name).with_content('rpc_backend=cinder.openstack.common.rpc.impl_kombu') end - it "has has volumes_dir set" do - expect(@chef_run).to render_file(@file.name).with_content("volumes_dir=/var/lib/cinder/volumes") + it 'has has volumes_dir set' do + expect(@chef_run).to render_file(@file.name).with_content('volumes_dir=/var/lib/cinder/volumes') end - it "has correct volume.driver set" do - expect(@chef_run).to render_file(@file.name).with_content("volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver") + it 'has correct volume.driver set' do + expect(@chef_run).to render_file(@file.name).with_content('volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver') end - it "has rpc_thread_pool_size" do - expect(@chef_run).to render_file(@file.name).with_content("rpc_thread_pool_size=64") + it 'has rpc_thread_pool_size' do + expect(@chef_run).to render_file(@file.name).with_content('rpc_thread_pool_size=64') end - it "has rpc_conn_pool_size" do - expect(@chef_run).to render_file(@file.name).with_content("rpc_conn_pool_size=30") + it 'has rpc_conn_pool_size' do + expect(@chef_run).to render_file(@file.name).with_content('rpc_conn_pool_size=30') end - it "has rpc_response_timeout" do - expect(@chef_run).to render_file(@file.name).with_content("rpc_response_timeout=60") + it 'has rpc_response_timeout' do + expect(@chef_run).to render_file(@file.name).with_content('rpc_response_timeout=60') end - it "has rabbit_host" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_host=127.0.0.1") + it 'has rabbit_host' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_host=127.0.0.1') end - it "does not have rabbit_hosts" do - expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_hosts=") + it 'does not have rabbit_hosts' do + expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_hosts=') end - it "does not have rabbit_ha_queues" do - expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_ha_queues=") + it 'does not have rabbit_ha_queues' do + expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_ha_queues=') end - it "has log_file" do - expect(@chef_run).to render_file(@file.name).with_content("log_file = /var/log/cinder/cinder.log") + it 'has log_file' do + expect(@chef_run).to render_file(@file.name).with_content('log_file = /var/log/cinder/cinder.log') end - it "has log_config when syslog is true" do + it 'has log_config when syslog is true' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["syslog"]["use"] = true + n.set['openstack']['block-storage']['syslog']['use'] = true end - chef_run.converge "openstack-block-storage::cinder-common" + chef_run.converge 'openstack-block-storage::cinder-common' - expect(chef_run).to render_file(@file.name).with_content("log_config = /etc/openstack/logging.conf") + expect(chef_run).to render_file(@file.name).with_content('log_config = /etc/openstack/logging.conf') end - it "has rabbit_port" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_port=5672") + it 'has rabbit_port' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_port=5672') end - it "has rabbit_userid" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_userid=guest") + it 'has rabbit_userid' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_userid=guest') end - it "has rabbit_password" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_password=rabbit-pass") + it 'has rabbit_password' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_password=rabbit-pass') end - it "has rabbit_virtual_host" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_virtual_host=/") + it 'has rabbit_virtual_host' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_virtual_host=/') end - describe "rabbit ha" do + describe 'rabbit ha' do before do @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n| - n.set["openstack"]["block-storage"]["rabbit"]["ha"] = true + n.set['openstack']['block-storage']['rabbit']['ha'] = true end - @chef_run.converge "openstack-block-storage::cinder-common" + @chef_run.converge 'openstack-block-storage::cinder-common' end - it "has rabbit_hosts" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672") + it 'has rabbit_hosts' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672') end - it "has rabbit_ha_queues" do - expect(@chef_run).to render_file(@file.name).with_content("rabbit_ha_queues=True") + it 'has rabbit_ha_queues' do + expect(@chef_run).to render_file(@file.name).with_content('rabbit_ha_queues=True') end - it "does not have rabbit_host" do - expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_host=127.0.0.1") + it 'does not have rabbit_host' do + expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_host=127.0.0.1') end - it "does not have rabbit_port" do - expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_port=5672") + it 'does not have rabbit_port' do + expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_port=5672') end end - describe "qpid" do + describe 'qpid' do before do - @file = @chef_run.template "/etc/cinder/cinder.conf" - @chef_run.node.set['openstack']['block-storage']['mq']['service_type'] = "qpid" + @file = @chef_run.template '/etc/cinder/cinder.conf' + @chef_run.node.set['openstack']['block-storage']['mq']['service_type'] = 'qpid' end - it "has qpid_hostname" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_hostname=127.0.0.1") + it 'has qpid_hostname' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_hostname=127.0.0.1') end - it "has qpid_port" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_port=5672") + it 'has qpid_port' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_port=5672') end - it "has qpid_username" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_username=") + it 'has qpid_username' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_username=') end - it "has qpid_password" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_password=") + it 'has qpid_password' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_password=') end - it "has qpid_sasl_mechanisms" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_sasl_mechanisms=") + it 'has qpid_sasl_mechanisms' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_sasl_mechanisms=') end - it "has qpid_reconnect_timeout" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_timeout=0") + it 'has qpid_reconnect_timeout' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_timeout=0') end - it "has qpid_reconnect_limit" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_limit=0") + it 'has qpid_reconnect_limit' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_limit=0') end - it "has qpid_reconnect_interval_min" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval_min=0") + it 'has qpid_reconnect_interval_min' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_min=0') end - it "has qpid_reconnect_interval_max" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval_max=0") + it 'has qpid_reconnect_interval_max' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_max=0') end - it "has qpid_reconnect_interval" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval=0") + it 'has qpid_reconnect_interval' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval=0') end - it "has qpid_reconnect" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect=true") + it 'has qpid_reconnect' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect=true') end - it "has qpid_heartbeat" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_heartbeat=60") + it 'has qpid_heartbeat' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_heartbeat=60') end - it "has qpid_protocol" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_protocol=tcp") + it 'has qpid_protocol' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_protocol=tcp') end - it "has qpid_tcp_nodelay" do - expect(@chef_run).to render_file(@file.name).with_content("qpid_tcp_nodelay=true") + it 'has qpid_tcp_nodelay' do + expect(@chef_run).to render_file(@file.name).with_content('qpid_tcp_nodelay=true') end end end - describe "/var/lock/cinder" do + describe '/var/lock/cinder' do before do - @dir = @chef_run.directory "/var/lock/cinder" + @dir = @chef_run.directory '/var/lock/cinder' end - it "has proper owner" do - expect(@dir.owner).to eq("cinder") - expect(@dir.group).to eq("cinder") + it 'has proper owner' do + expect(@dir.owner).to eq('cinder') + expect(@dir.group).to eq('cinder') end - it "has proper modes" do - expect(sprintf("%o", @dir.mode)).to eq "700" + it 'has proper modes' do + expect(sprintf('%o', @dir.mode)).to eq '700' end end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 85d361f..b97cfb7 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -2,7 +2,7 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::default" do +describe 'openstack-block-storage::default' do end diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 979dacc..48d9743 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -2,85 +2,85 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::identity_registration" do +describe 'openstack-block-storage::identity_registration' do before do block_storage_stubs @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS - @chef_run.converge "openstack-block-storage::identity_registration" + @chef_run.converge 'openstack-block-storage::identity_registration' end - it "registers cinder volume service" do + it 'registers cinder volume service' do resource = @chef_run.find_resource( - "openstack-identity_register", - "Register Cinder Volume Service" + 'openstack-identity_register', + 'Register Cinder Volume Service' ).to_hash expect(resource).to include( - :auth_uri => "http://127.0.0.1:35357/v2.0", - :bootstrap_token => "bootstrap-token", - :service_name => "cinder", - :service_type => "volume", - :service_description => "Cinder Volume Service", - :endpoint_region => "RegionOne", - :endpoint_adminurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", - :endpoint_internalurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", - :endpoint_publicurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", - :action => [:create_service] + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_name: 'cinder', + service_type: 'volume', + service_description: 'Cinder Volume Service', + endpoint_region: 'RegionOne', + endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s', + endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s', + endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s', + action: [:create_service] ) end - it "registers cinder volume endpoint" do + it 'registers cinder volume endpoint' do resource = @chef_run.find_resource( - "openstack-identity_register", - "Register Cinder Volume Endpoint" + 'openstack-identity_register', + 'Register Cinder Volume Endpoint' ).to_hash expect(resource).to include( - :auth_uri => "http://127.0.0.1:35357/v2.0", - :bootstrap_token => "bootstrap-token", - :service_name => "cinder", - :service_type => "volume", - :service_description => "Cinder Volume Service", - :endpoint_region => "RegionOne", - :endpoint_adminurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", - :endpoint_internalurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", - :endpoint_publicurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", - :action => [:create_endpoint] + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_name: 'cinder', + service_type: 'volume', + service_description: 'Cinder Volume Service', + endpoint_region: 'RegionOne', + endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s', + endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s', + endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s', + action: [:create_endpoint] ) end - it "registers service user" do + it 'registers service user' do resource = @chef_run.find_resource( - "openstack-identity_register", - "Register Cinder Service User" + 'openstack-identity_register', + 'Register Cinder Service User' ).to_hash expect(resource).to include( - :auth_uri => "http://127.0.0.1:35357/v2.0", - :bootstrap_token => "bootstrap-token", - :tenant_name => "service", - :user_name => "cinder", - :user_pass => "cinder-pass", - :user_enabled => true, - :action => [:create_user] + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + tenant_name: 'service', + user_name: 'cinder', + user_pass: 'cinder-pass', + user_enabled: true, + action: [:create_user] ) end - it "grants admin role to service user for service tenant" do + it 'grants admin role to service user for service tenant' do resource = @chef_run.find_resource( - "openstack-identity_register", - "Grant service Role to Cinder Service User for Cinder Service Tenant" + 'openstack-identity_register', + 'Grant service Role to Cinder Service User for Cinder Service Tenant' ).to_hash expect(resource).to include( - :auth_uri => "http://127.0.0.1:35357/v2.0", - :bootstrap_token => "bootstrap-token", - :tenant_name => "service", - :user_name => "cinder", - :role_name => "admin", - :action => [:grant_role] + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + tenant_name: 'service', + user_name: 'cinder', + role_name: 'admin', + action: [:grant_role] ) end end diff --git a/spec/scheduler-opensuse_spec.rb b/spec/scheduler-opensuse_spec.rb index 241002d..546de86 100644 --- a/spec/scheduler-opensuse_spec.rb +++ b/spec/scheduler-opensuse_spec.rb @@ -2,47 +2,47 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::scheduler" do +describe 'openstack-block-storage::scheduler' do before { block_storage_stubs } - describe "opensuse" do + describe 'opensuse' do before do @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS - @chef_run.converge "openstack-block-storage::scheduler" + @chef_run.converge 'openstack-block-storage::scheduler' end - it "installs cinder scheduler packages" do - expect(@chef_run).to upgrade_package "openstack-cinder-scheduler" + it 'installs cinder scheduler packages' do + expect(@chef_run).to upgrade_package 'openstack-cinder-scheduler' end - it "does not upgrade stevedore" do + it 'does not upgrade stevedore' do chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS - chef_run.converge "openstack-block-storage::scheduler" + chef_run.converge 'openstack-block-storage::scheduler' - expect(chef_run).not_to upgrade_python_pip "stevedore" + expect(chef_run).not_to upgrade_python_pip 'stevedore' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "python-mysql" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'python-mysql' end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::scheduler" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::scheduler' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "python-mysql" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'python-mysql' end - it "starts cinder scheduler" do - expect(@chef_run).to start_service "openstack-cinder-scheduler" + it 'starts cinder scheduler' do + expect(@chef_run).to start_service 'openstack-cinder-scheduler' end - it "starts cinder scheduler on boot" do - expect(@chef_run).to enable_service "openstack-cinder-scheduler" + it 'starts cinder scheduler on boot' do + expect(@chef_run).to enable_service 'openstack-cinder-scheduler' end end end diff --git a/spec/scheduler-redhat_spec.rb b/spec/scheduler-redhat_spec.rb index 76703d1..d49ec2b 100644 --- a/spec/scheduler-redhat_spec.rb +++ b/spec/scheduler-redhat_spec.rb @@ -2,58 +2,58 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::scheduler" do +describe 'openstack-block-storage::scheduler' do before { block_storage_stubs } - describe "redhat" do + describe 'redhat' do before do @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS - @chef_run.converge "openstack-block-storage::scheduler" + @chef_run.converge 'openstack-block-storage::scheduler' end - it "installs cinder scheduler packages" do - expect(@chef_run).to upgrade_package "openstack-cinder" + it 'installs cinder scheduler packages' do + expect(@chef_run).to upgrade_package 'openstack-cinder' end - it "does not upgrade stevedore" do + it 'does not upgrade stevedore' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS - chef_run.converge "openstack-block-storage::scheduler" + chef_run.converge 'openstack-block-storage::scheduler' - expect(chef_run).not_to upgrade_python_pip "stevedore" + expect(chef_run).not_to upgrade_python_pip 'stevedore' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "MySQL-python" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'MySQL-python' end - it "installs db2 python packages if explicitly told" do + it 'installs db2 python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "db2" - chef_run.converge "openstack-block-storage::scheduler" + node.set['openstack']['db']['volume']['db_type'] = 'db2' + chef_run.converge 'openstack-block-storage::scheduler' - ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| + ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg| expect(chef_run).to upgrade_package pkg end end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::scheduler" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::scheduler' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "MySQL-python" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'MySQL-python' end - it "starts cinder scheduler" do - expect(@chef_run).to start_service "openstack-cinder-scheduler" + it 'starts cinder scheduler' do + expect(@chef_run).to start_service 'openstack-cinder-scheduler' end - it "starts cinder scheduler on boot" do - expect(@chef_run).to enable_service "openstack-cinder-scheduler" + it 'starts cinder scheduler on boot' do + expect(@chef_run).to enable_service 'openstack-cinder-scheduler' end end end diff --git a/spec/scheduler_spec.rb b/spec/scheduler_spec.rb index 93fdba0..a5b40e5 100644 --- a/spec/scheduler_spec.rb +++ b/spec/scheduler_spec.rb @@ -2,71 +2,71 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::scheduler" do +describe 'openstack-block-storage::scheduler' do before { block_storage_stubs } - describe "ubuntu" do + describe 'ubuntu' do before do @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["syslog"]["use"] = true + n.set['openstack']['block-storage']['syslog']['use'] = true end - @chef_run.converge "openstack-block-storage::scheduler" + @chef_run.converge 'openstack-block-storage::scheduler' end expect_runs_openstack_common_logging_recipe - it "doesn't run logging recipe" do + it 'does not run logging recipe' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS - chef_run.converge "openstack-block-storage::scheduler" + chef_run.converge 'openstack-block-storage::scheduler' - expect(chef_run).not_to include_recipe "openstack-common::logging" + expect(chef_run).not_to include_recipe 'openstack-common::logging' end - it "installs cinder scheduler packages" do - expect(@chef_run).to upgrade_package "cinder-scheduler" + it 'installs cinder scheduler packages' do + expect(@chef_run).to upgrade_package 'cinder-scheduler' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "python-mysqldb" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'python-mysqldb' end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::scheduler" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::scheduler' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "python-mysqldb" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'python-mysqldb' end - it "starts cinder scheduler" do - expect(@chef_run).to start_service "cinder-scheduler" + it 'starts cinder scheduler' do + expect(@chef_run).to start_service 'cinder-scheduler' end - it "starts cinder scheduler on boot" do - expect(@chef_run).to enable_service "cinder-scheduler" + it 'starts cinder scheduler on boot' do + expect(@chef_run).to enable_service 'cinder-scheduler' end - it "doesn't run logging recipe" do - expect(@chef_run).to enable_service "cinder-scheduler" + it 'does not run logging recipe' do + expect(@chef_run).to enable_service 'cinder-scheduler' end - it "doesn't setup cron when no metering" do - expect(@chef_run.cron("cinder-volume-usage-audit")).to be_nil + it 'does not setup cron when no metering' do + expect(@chef_run.cron('cinder-volume-usage-audit')).to be_nil end - it "creates cron metering default" do + it 'creates cron metering default' do ::Chef::Recipe.any_instance.stub(:search) - .with(:node, "roles:os-block-storage-scheduler") - .and_return([OpenStruct.new(:name => "fauxhai.local")]) + .with(:node, 'roles:os-block-storage-scheduler') + .and_return([OpenStruct.new(name: 'fauxhai.local')]) chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["metering"] = true + n.set['openstack']['metering'] = true end - chef_run.converge "openstack-block-storage::scheduler" - cron = chef_run.cron "cinder-volume-usage-audit" - bin_str = "/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log" + chef_run.converge 'openstack-block-storage::scheduler' + cron = chef_run.cron 'cinder-volume-usage-audit' + 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']] @@ -76,27 +76,27 @@ describe "openstack-block-storage::scheduler" do expect(cron.action).to include :create end - it "creates cron metering custom" do + 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")]) + .with(:node, 'roles:os-block-storage-scheduler') + .and_return([OpenStruct.new(name: 'foobar')]) chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["metering"] = true + n.set['openstack']['metering'] = true crontests.each do |k, v| - n.set["openstack"]["block-storage"]["cron"][k.to_s] = v + n.set['openstack']['block-storage']['cron'][k.to_s] = v end - n.set["openstack"]["block-storage"]["user"] = "foobar" + n.set['openstack']['block-storage']['user'] = 'foobar' end - chef_run.converge "openstack-block-storage::scheduler" - cron = chef_run.cron "cinder-volume-usage-audit" + chef_run.converge 'openstack-block-storage::scheduler' + cron = chef_run.cron 'cinder-volume-usage-audit' crontests.each do |k, v| expect(cron.send(k)).to eq v end expect(cron.action).to include :delete end - expect_creates_cinder_conf "service[cinder-scheduler]", "cinder", "cinder" + expect_creates_cinder_conf 'service[cinder-scheduler]', 'cinder', 'cinder' end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fa35f3d..7d6cb5a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,87 +2,87 @@ # # Cookbook Name:: openstack-block-storage -require "chefspec" -require "chefspec/berkshelf" -require "chef/application" -require_relative "support/matcher" +require 'chefspec' +require 'chefspec/berkshelf' +require 'chef/application' +require_relative 'support/matcher' ::LOG_LEVEL = :fatal ::OPENSUSE_OPTS = { - :platform => "opensuse", - :version => "12.3", - :log_level => ::LOG_LEVEL + platform: 'opensuse', + version: '12.3', + log_level: ::LOG_LEVEL } ::REDHAT_OPTS = { - :platform => "redhat", - :version => "6.3", - :log_level => ::LOG_LEVEL + platform: 'redhat', + version: '6.3', + log_level: ::LOG_LEVEL } ::UBUNTU_OPTS = { - :platform => "ubuntu", - :version => "12.04", - :log_level => ::LOG_LEVEL + platform: 'ubuntu', + version: '12.04', + log_level: ::LOG_LEVEL } -def block_storage_stubs +def block_storage_stubs # rubocop:disable MethodLength ::Chef::Recipe.any_instance.stub(:rabbit_servers) - .and_return "1.1.1.1:5672,2.2.2.2:5672" + .and_return '1.1.1.1:5672,2.2.2.2:5672' ::Chef::Recipe.any_instance.stub(:get_password).and_return '' ::Chef::Recipe.any_instance.stub(:secret) - .with("secrets", "openstack_identity_bootstrap_token") - .and_return "bootstrap-token" + .with('secrets', 'openstack_identity_bootstrap_token') + .and_return 'bootstrap-token' ::Chef::Recipe.any_instance.stub(:get_password) - .with("user", "guest") - .and_return "rabbit-pass" + .with('user', 'guest') + .and_return 'rabbit-pass' ::Chef::Recipe.any_instance.stub(:get_password) - .with("service", "openstack-block-storage") - .and_return "cinder-pass" + .with('service', 'openstack-block-storage') + .and_return 'cinder-pass' ::Chef::Application.stub(:fatal!) 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" + it 'runs logging recipe if node attributes say to' do + expect(@chef_run).to include_recipe 'openstack-common::logging' end end -def expect_creates_cinder_conf(service, user, group, action = :restart) - describe "cinder.conf" do +def expect_creates_cinder_conf(service, user, group, action = :restart) # rubocop:disable MethodLength + describe 'cinder.conf' do before do - @file = @chef_run.template "/etc/cinder/cinder.conf" + @file = @chef_run.template '/etc/cinder/cinder.conf' end - it "has proper owner" do + it 'has proper owner' do expect(@file.owner).to eq(user) expect(@file.group).to eq(group) end - it "has proper modes" do - expect(sprintf("%o", @file.mode)).to eq "644" + it 'has proper modes' do + expect(sprintf('%o', @file.mode)).to eq '644' end - it "notifies service restart" do + it 'notifies service restart' do expect(@file).to notify(service).to(action) end end end -def expect_creates_policy_json(service, user, group, action = :restart) - describe "policy.json" do +def expect_creates_policy_json(service, user, group, action = :restart) # rubocop:disable MethodLength + describe 'policy.json' do before do - @file = @chef_run.template "/etc/cinder/policy.json" + @file = @chef_run.template '/etc/cinder/policy.json' end - it "has proper owner" do + it 'has proper owner' do expect(@file.owner).to eq(user) expect(@file.group).to eq(group) end - it "has proper modes" do - expect(sprintf("%o", @file.mode)).to eq "644" + it 'has proper modes' do + expect(sprintf('%o', @file.mode)).to eq '644' end - it "notifies service restart" do + it 'notifies service restart' do expect(@file).to notify(service).to(action) end end diff --git a/spec/volume-opensuse_spec.rb b/spec/volume-opensuse_spec.rb index a08c9cc..f6dfb46 100644 --- a/spec/volume-opensuse_spec.rb +++ b/spec/volume-opensuse_spec.rb @@ -2,66 +2,66 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::volume" do +describe 'openstack-block-storage::volume' do before { block_storage_stubs } - describe "opensuse" do + describe 'opensuse' do before do @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS - @chef_run.converge "openstack-block-storage::volume" + @chef_run.converge 'openstack-block-storage::volume' end - it "installs cinder volume packages" do - expect(@chef_run).to upgrade_package "openstack-cinder-volume" + it 'installs cinder volume packages' do + expect(@chef_run).to upgrade_package 'openstack-cinder-volume' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "python-mysql" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'python-mysql' end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::volume" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "python-mysql" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'python-mysql' end - it "installs cinder iscsi packages" do - expect(@chef_run).to upgrade_package "tgt" + it 'installs cinder iscsi packages' do + expect(@chef_run).to upgrade_package 'tgt' end - it "starts cinder volume" do - expect(@chef_run).to start_service "openstack-cinder-volume" + it 'starts cinder volume' do + expect(@chef_run).to start_service 'openstack-cinder-volume' end - it "starts cinder volume on boot" do - expected = "openstack-cinder-volume" + it 'starts cinder volume on boot' do + expected = 'openstack-cinder-volume' expect(@chef_run).to enable_service expected end - it "starts iscsi target on boot" do - expect(@chef_run).to enable_service "tgtd" + it 'starts iscsi target on boot' do + expect(@chef_run).to enable_service 'tgtd' end - it "installs nfs packages" do + it 'installs nfs packages' do chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver' end - chef_run.converge "openstack-block-storage::volume" + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to upgrade_package "nfs-utils" - expect(chef_run).not_to upgrade_package "nfs-utils-lib" + expect(chef_run).to upgrade_package 'nfs-utils' + expect(chef_run).not_to upgrade_package 'nfs-utils-lib' end - it "has opensuse include" do - file = "/etc/tgt/targets.conf" + it 'has opensuse include' do + file = '/etc/tgt/targets.conf' - expect(@chef_run).to render_file(file).with_content("include /var/lib/cinder/volumes/*") - expect(@chef_run).not_to render_file(file).with_content("include /etc/tgt/conf.d/*.conf") + expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*') + expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf') end end end diff --git a/spec/volume-redhat_spec.rb b/spec/volume-redhat_spec.rb index 726d92a..580dc73 100644 --- a/spec/volume-redhat_spec.rb +++ b/spec/volume-redhat_spec.rb @@ -2,73 +2,73 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::volume" do +describe 'openstack-block-storage::volume' do before { block_storage_stubs } - describe "redhat" do + describe 'redhat' do before do @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS - @chef_run.converge "openstack-block-storage::volume" + @chef_run.converge 'openstack-block-storage::volume' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "MySQL-python" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'MySQL-python' end - it "installs db2 python packages if explicitly told" do + it 'installs db2 python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "db2" - chef_run.converge "openstack-block-storage::volume" + node.set['openstack']['db']['volume']['db_type'] = 'db2' + chef_run.converge 'openstack-block-storage::volume' - ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| + ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg| expect(chef_run).to upgrade_package pkg end end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::volume" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "MySQL-python" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'MySQL-python' end - it "installs cinder iscsi packages" do - expect(@chef_run).to upgrade_package "scsi-target-utils" + it 'installs cinder iscsi packages' do + expect(@chef_run).to upgrade_package 'scsi-target-utils' end - it "starts cinder volume" do - expect(@chef_run).to start_service "openstack-cinder-volume" + it 'starts cinder volume' do + expect(@chef_run).to start_service 'openstack-cinder-volume' end - it "starts cinder volume on boot" do - expected = "openstack-cinder-volume" + it 'starts cinder volume on boot' do + expected = 'openstack-cinder-volume' expect(@chef_run).to enable_service expected end - it "starts iscsi target on boot" do - expect(@chef_run).to enable_service "tgtd" + it 'starts iscsi target on boot' do + expect(@chef_run).to enable_service 'tgtd' end - it "installs nfs packages" do + it 'installs nfs packages' do chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver' end - chef_run.converge "openstack-block-storage::volume" + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to upgrade_package "nfs-utils" - expect(chef_run).to upgrade_package "nfs-utils-lib" + expect(chef_run).to upgrade_package 'nfs-utils' + expect(chef_run).to upgrade_package 'nfs-utils-lib' end - it "has redhat include" do - file = "/etc/tgt/targets.conf" + it 'has redhat include' do + file = '/etc/tgt/targets.conf' - expect(@chef_run).to render_file(file).with_content("include /var/lib/cinder/volumes/*") - expect(@chef_run).not_to render_file(file).with_content("include /etc/tgt/conf.d/*.conf") + expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*') + expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf') end end end diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb index 0aaaf17..862bc7b 100644 --- a/spec/volume_spec.rb +++ b/spec/volume_spec.rb @@ -2,189 +2,189 @@ # # Cookbook Name:: openstack-block-storage -require_relative "spec_helper" +require_relative 'spec_helper' -describe "openstack-block-storage::volume" do +describe 'openstack-block-storage::volume' do before { block_storage_stubs } - describe "ubuntu" do + describe 'ubuntu' do before do @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["syslog"]["use"] = true + n.set['openstack']['block-storage']['syslog']['use'] = true end - @chef_run.converge "openstack-block-storage::volume" + @chef_run.converge 'openstack-block-storage::volume' end expect_runs_openstack_common_logging_recipe - it "doesn't run logging recipe" do + it 'does not run logging recipe' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS - chef_run.converge "openstack-block-storage::volume" + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).not_to include_recipe "openstack-common::logging" + 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" + it 'installs cinder volume packages' do + expect(@chef_run).to upgrade_package 'cinder-volume' end - it "installs mysql python packages by default" do - expect(@chef_run).to upgrade_package "python-mysqldb" + it 'installs mysql python packages by default' do + expect(@chef_run).to upgrade_package 'python-mysqldb' end - it "installs postgresql python packages if explicitly told" do + it 'installs postgresql python packages if explicitly told' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS node = chef_run.node - node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" - chef_run.converge "openstack-block-storage::volume" + node.set['openstack']['db']['volume']['db_type'] = 'postgresql' + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to upgrade_package "python-psycopg2" - expect(chef_run).not_to upgrade_package "python-mysqldb" + expect(chef_run).to upgrade_package 'python-psycopg2' + expect(chef_run).not_to upgrade_package 'python-mysqldb' end - it "installs cinder iscsi packages" do - expect(@chef_run).to upgrade_package "tgt" + it 'installs cinder iscsi packages' do + expect(@chef_run).to upgrade_package 'tgt' end - it "installs nfs packages" do + it 'installs nfs packages' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver' end - chef_run.converge "openstack-block-storage::volume" + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to upgrade_package "nfs-common" + expect(chef_run).to upgrade_package 'nfs-common' end - it "creates the nfs mount point" do + it 'creates the nfs mount point' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver' end - chef_run.converge "openstack-block-storage::volume" + chef_run.converge 'openstack-block-storage::volume' - expect(chef_run).to create_directory "/mnt/cinder-volumes" + expect(chef_run).to create_directory '/mnt/cinder-volumes' end - it "configures netapp dfm password" do - ::Chef::Recipe.any_instance.stub(:get_password).with("service", "netapp") - .and_return "netapp-pass" + it 'configures netapp dfm password' do + ::Chef::Recipe.any_instance.stub(:get_password).with('service', 'netapp') + .and_return 'netapp-pass' chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver' end - chef_run.converge "openstack-block-storage::volume" - n = chef_run.node["openstack"]["block-storage"]["netapp"]["dfm_password"] + chef_run.converge 'openstack-block-storage::volume' + n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password'] - expect(n).to eq "netapp-pass" + expect(n).to eq 'netapp-pass' end - it "configures rbd password" do - ::Chef::Recipe.any_instance.stub(:get_password).with("service", "rbd") - .and_return "rbd-pass" + it 'configures rbd password' do + ::Chef::Recipe.any_instance.stub(:get_password).with('service', 'rbd') + .and_return 'rbd-pass' chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.RBDDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.RBDDriver' end - chef_run.converge "openstack-block-storage::volume" - n = chef_run.node["openstack"]["block-storage"]["rbd_secret_uuid"] + chef_run.converge 'openstack-block-storage::volume' + n = chef_run.node['openstack']['block-storage']['rbd_secret_uuid'] - expect(n).to eq "rbd-pass" + expect(n).to eq 'rbd-pass' end - it "configures storewize private key" do + it 'configures storewize private key' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver' end - chef_run.converge "openstack-block-storage::volume" + chef_run.converge 'openstack-block-storage::volume' - san_key = chef_run.file chef_run.node["openstack"]["block-storage"]["san"]["san_private_key"] + san_key = chef_run.file chef_run.node['openstack']['block-storage']['san']['san_private_key'] expect(san_key.mode).to eq('0400') end - it "configures storewize with iscsi" do + it 'configures storewize with iscsi' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" - n.set["openstack"]["block-storage"]["storwize"]["storwize_svc_connection_protocol"] = "iSCSI" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver' + n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI' end - conf = "/etc/cinder/cinder.conf" - chef_run.converge "openstack-block-storage::volume" + conf = '/etc/cinder/cinder.conf' + chef_run.converge 'openstack-block-storage::volume' # Test that the FC specific options are not set when connected via iSCSI - expect(chef_run).not_to render_file(conf).with_content("storwize_svc_multipath_enabled") + expect(chef_run).not_to render_file(conf).with_content('storwize_svc_multipath_enabled') end - it "configures storewize with fc" do + it 'configures storewize with fc' do chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" - n.set["openstack"]["block-storage"]["storwize"]["storwize_svc_connection_protocol"] = "FC" + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver' + n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC' end - conf = "/etc/cinder/cinder.conf" - chef_run.converge "openstack-block-storage::volume" + conf = '/etc/cinder/cinder.conf' + chef_run.converge 'openstack-block-storage::volume' # Test that the iSCSI specific options are not set when connected via FC - expect(chef_run).not_to render_file(conf).with_content("storwize_svc_iscsi_chap_enabled") + expect(chef_run).not_to render_file(conf).with_content('storwize_svc_iscsi_chap_enabled') end - it "starts cinder volume" do - expect(@chef_run).to start_service "cinder-volume" + it 'starts cinder volume' do + expect(@chef_run).to start_service 'cinder-volume' end - it "starts cinder volume on boot" do - expect(@chef_run).to enable_service "cinder-volume" + it 'starts cinder volume on boot' do + expect(@chef_run).to enable_service 'cinder-volume' end - expect_creates_cinder_conf "service[cinder-volume]", "cinder", "cinder" + expect_creates_cinder_conf 'service[cinder-volume]', 'cinder', 'cinder' - it "starts iscsi target on boot" do - expect(@chef_run).to enable_service "tgt" + it 'starts iscsi target on boot' do + expect(@chef_run).to enable_service 'tgt' end - describe "targets.conf" do + describe 'targets.conf' do before do - @file = @chef_run.template "/etc/tgt/targets.conf" + @file = @chef_run.template '/etc/tgt/targets.conf' end - it "has proper modes" do - expect(sprintf("%o", @file.mode)).to eq "600" + it 'has proper modes' do + expect(sprintf('%o', @file.mode)).to eq '600' end - it "notifies iscsi restart" do - expect(@file).to notify("service[iscsitarget]").to(:restart) + it 'notifies iscsi restart' do + expect(@file).to notify('service[iscsitarget]').to(:restart) end - it "has ubuntu include" do - expect(@chef_run).to render_file(@file.name).with_content("include /etc/tgt/conf.d/*.conf") - expect(@chef_run).not_to render_file(@file.name).with_content("include /var/lib/cinder/volumes/*") + it 'has ubuntu include' do + expect(@chef_run).to render_file(@file.name).with_content('include /etc/tgt/conf.d/*.conf') + expect(@chef_run).not_to render_file(@file.name).with_content('include /var/lib/cinder/volumes/*') end end - describe "create_vg" do + describe 'create_vg' do before do @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| - n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.lvm.LVMISCSIDriver" - n.set["openstack"]["block-storage"]["volume"]["create_volume_group"] = true + n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver' + n.set['openstack']['block-storage']['volume']['create_volume_group'] = true end - stub_command("vgs cinder-volumes").and_return(false) - @filename = "/etc/init.d/cinder-group-active" - @chef_run.converge "openstack-block-storage::volume" + stub_command('vgs cinder-volumes').and_return(false) + @filename = '/etc/init.d/cinder-group-active' + @chef_run.converge 'openstack-block-storage::volume' @file = @chef_run.template(@filename) end - it "cinder vg active" do - expect(@chef_run).to enable_service "cinder-group-active" + it 'cinder vg active' do + expect(@chef_run).to enable_service 'cinder-group-active' end - it "create volume group" do - volume_size = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group_size"] + it 'create volume group' do + volume_size = @chef_run.node['openstack']['block-storage']['volume']['volume_group_size'] seek_count = volume_size.to_i * 1024 - group_name = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group"] - path = @chef_run.node["openstack"]["block-storage"]["volume"]["state_path"] + group_name = @chef_run.node['openstack']['block-storage']['volume']['volume_group'] + path = @chef_run.node['openstack']['block-storage']['volume']['state_path'] vg_file = "#{path}/#{group_name}.img" cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})" expect(@chef_run).to run_execute(cmd) end - it "notifies cinder group active start" do - expect(@file).to notify("service[cinder-group-active]").to(:start) + it 'notifies cinder group active start' do + expect(@file).to notify('service[cinder-group-active]').to(:start) end - it "creates cinder group active template file" do + it 'creates cinder group active template file' do expect(@chef_run).to create_template(@filename) end end