From 032dd3c51af5c5f87b864a9bfdba0948b4f76eee Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Wed, 23 Aug 2017 22:38:10 -0400 Subject: [PATCH] Initial orchestration Pike updates - Switched default linter to cookstyle - Renamed rake tasks to better conform with Chef conventions - Normalized template banner Change-Id: Icc3eca4b2d17a6d1ef66c1c7e75513de0ee3cac9 --- .rubocop.yml | 2 -- .rubocop_todo.yml | 20 -------------------- Rakefile | 14 +++++++------- attributes/default.rb | 8 ++++---- recipes/common.rb | 2 +- recipes/identity_registration.rb | 4 ++-- spec/identity_registration_spec.rb | 2 +- spec/spec_helper.rb | 22 +++++++++++----------- 8 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 5e0be9f..253be24 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,3 @@ -inherit_from: .rubocop_todo.yml - AllCops: Include: - metadata.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 1303559..0000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2017-08-18 10:09:13 +0200 using RuboCop version 0.47.1. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 7 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: - Max: 109 - -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'recipes/common.rb' - - 'recipes/identity_registration.rb' diff --git a/Rakefile b/Rakefile index 676e7d4..c9edb13 100644 --- a/Rakefile +++ b/Rakefile @@ -1,20 +1,20 @@ task default: ["test"] -task :test => [:lint, :style, :unit] +task :test => [:syntax, :lint, :unit] desc "Vendor the cookbooks in the Berksfile" task :berks_prep do sh %{chef exec berks vendor} end -desc "Run FoodCritic (lint) tests" -task :lint do - sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} +desc "Run FoodCritic (syntax) tests" +task :syntax do + sh %{chef exec foodcritic --exclude spec -f any .} end -desc "Run RuboCop (style) tests" -task :style do - sh %{chef exec rubocop} +desc "Run RuboCop (lint) tests" +task :lint do + sh %{chef exec cookstyle} end desc "Run RSpec (unit) tests" diff --git a/attributes/default.rb b/attributes/default.rb index 4758985..d20338e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -44,8 +44,8 @@ default['openstack']['bind_service']['all']['orchestration-api-cloudwatch']['por # Set to some text value if you want templated config files # to contain a custom banner at the top of the written file default['openstack']['orchestration']['custom_template_banner'] = ' -# This file was autogenerated by Chef -# Do not edit, changes will be overwritten +# This file is automatically generated by Chef +# Any changes will be overwritten ' default['openstack']['orchestration']['syslog']['use'] @@ -78,7 +78,7 @@ when 'rhel' 'heat_engine_packages' => ['openstack-heat-engine'], 'heat_engine_service' => 'openstack-heat-engine', 'heat_api_process_name' => 'heat-api', - 'package_overrides' => '' + 'package_overrides' => '', } when 'debian' default['openstack']['orchestration']['user'] = 'heat' @@ -93,6 +93,6 @@ when 'debian' 'heat_api_cloudwatch_service' => 'heat-api-cloudwatch', 'heat_engine_packages' => ['heat-engine'], 'heat_engine_service' => 'heat-engine', - 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'" + 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'", } end diff --git a/recipes/common.rb b/recipes/common.rb index 9eb35ff..3548dc1 100644 --- a/recipes/common.rb +++ b/recipes/common.rb @@ -19,7 +19,7 @@ # limitations under the License. # -class ::Chef::Recipe # rubocop:disable Documentation +class ::Chef::Recipe include ::Openstack end diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index 87e8228..9e2d526 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -20,7 +20,7 @@ require 'uri' -class ::Chef::Recipe # rubocop:disable Documentation +class ::Chef::Recipe include ::Openstack end @@ -56,7 +56,7 @@ connection_params = { openstack_username: admin_user, openstack_api_key: admin_pass, openstack_project_name: admin_project, - openstack_domain_name: admin_domain + openstack_domain_name: admin_domain, } # Register Orchestration Service diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 3f42030..97f1ab4 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -14,7 +14,7 @@ describe 'openstack-orchestration::identity_registration' do openstack_username: 'admin', openstack_api_key: 'admin-pass', openstack_project_name: 'admin', - openstack_domain_name: 'default' + openstack_domain_name: 'default', } service_name = 'heat' service_type = 'orchestration' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 229c6d6..89f5a5a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,17 +10,17 @@ LOG_LEVEL = :fatal REDHAT_OPTS = { platform: 'redhat', version: '7.1', - log_level: ::LOG_LEVEL + log_level: ::LOG_LEVEL, }.freeze UBUNTU_OPTS = { platform: 'ubuntu', version: '16.04', - log_level: ::LOG_LEVEL + log_level: ::LOG_LEVEL, }.freeze SUSE_OPTS = { platform: 'suse', version: '11.3', - log_level: ::LOG_LEVEL + log_level: ::LOG_LEVEL, }.freeze shared_context 'orchestration_stubs' do @@ -130,7 +130,7 @@ shared_examples 'expects to create heat conf' do %r{^heat_waitcondition_server_url = http://127.0.0.1:8000/v1/waitcondition$}, %r{^heat_watch_server_url = http://127.0.0.1:8003$}, %r{^log_dir = /var/log/heat$}, - /^region_name_for_services = RegionOne$/ + /^region_name_for_services = RegionOne$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) end @@ -138,7 +138,7 @@ shared_examples 'expects to create heat conf' do it 'has oslo_messaging_notifications conf values' do [ - /^driver = heat.openstack.common.notifier.rpc_notifier$/ + /^driver = heat.openstack.common.notifier.rpc_notifier$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_notifications', line) end @@ -147,7 +147,7 @@ shared_examples 'expects to create heat conf' do it 'has heat_api binding' do [ /^bind_host = 127.0.0.1$/, - /^bind_port = 8004$/ + /^bind_port = 8004$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('heat_api', line) end @@ -156,7 +156,7 @@ shared_examples 'expects to create heat conf' do it 'has heat_api_cfn binding' do [ /^bind_host = 127.0.0.1$/, - /^bind_port = 8000$/ + /^bind_port = 8000$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('heat_api_cfn', line) end @@ -165,7 +165,7 @@ shared_examples 'expects to create heat conf' do it 'has heat_api_cloudwatch binding' do [ /^bind_host = 127.0.0.1$/, - /^bind_port = 8003$/ + /^bind_port = 8003$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('heat_api_cloudwatch', line) end @@ -193,7 +193,7 @@ shared_examples 'expects to create heat conf' do describe 'has oslo_messaging_rabbit values' do it 'has default rabbit values' do [ - %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$} + %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) end @@ -209,7 +209,7 @@ shared_examples 'expects to create heat conf' do /^project_name = service$/, /^user_domain_name = Default/, /^project_domain_name = Default/, - /^password = heat-pass$/ + /^password = heat-pass$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line) end @@ -223,7 +223,7 @@ shared_examples 'expects to create heat conf' do /^auth_plugin = v3password$/, /^username = heat$/, /^password = heat-pass$/, - /^user_domain_name = Default$/ + /^user_domain_name = Default$/, ].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('trustee', line) end