Initial dashboard Pike updates

- Switched default linter to cookstyle
- Renamed rake tasks to better conform with Chef conventions
- Normalized the template banner

Change-Id: I80d825722a3218b34a5dee38b60017492e3768e0
This commit is contained in:
Samuel Cassiba 2017-08-23 21:10:06 -04:00
parent 6e44af9d17
commit d7773b69b6
10 changed files with 39 additions and 61 deletions

View File

@ -1,5 +1,3 @@
inherit_from: .rubocop_todo.yml
AllCops:
Include:
- metadata.rb
@ -28,3 +26,12 @@ LineLength:
WordArray:
MinSize: 3
Style/Next:
Description: Use `next` to skip iteration instead of a condition at the end.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
Enabled: true
EnforcedStyle: always
SupportedStyles:
- skip_modifier_ifs
- always

View File

@ -1,28 +0,0 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-17 14:16:07 +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: 26
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 468
# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'recipes/apache2-server.rb'
- 'recipes/horizon.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'spec/horizon_spec.rb'

View File

@ -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"

View File

@ -22,8 +22,8 @@
# 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']['dashboard']['custom_template_banner'] = '
# This file autogenerated by Chef
# Do not edit, changes will be overwritten
# This file is automatically generated by Chef
# Any changes will be overwritten
'
# ****************** OpenStack Dashboard Endpoints ******************************
@ -99,7 +99,7 @@ default['openstack']['dashboard']['webroot'] = '/'
default['openstack']['dashboard']['db_python_packages'] = {
mysql: [],
postgresql: [],
sqlite: []
sqlite: [],
}
# The hash algorithm to use for authentication tokens. This must match the hash
@ -125,7 +125,7 @@ when 'rhel'
default['openstack']['dashboard']['platform'] = {
'horizon_packages' => ['openstack-dashboard'],
'memcache_python_packages' => ['python-memcached'],
'package_overrides' => ''
'package_overrides' => '',
}
default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf"
when 'debian'
@ -143,7 +143,7 @@ when 'debian'
default['openstack']['dashboard']['login_redirect_url'] = nil
default['openstack']['dashboard']['platform'] = {
'memcache_python_packages' => ['python-memcache'],
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'",
}
default['openstack']['dashboard']['platform']['horizon_packages'] = ['node-less', 'openstack-dashboard']
default['openstack']['dashboard']['apache']['sites-path'] = "#{node['apache']['dir']}/sites-available/openstack-dashboard.conf"

View File

@ -24,7 +24,7 @@
require 'uri'
class ::Chef::Recipe # rubocop:disable Documentation
class ::Chef::Recipe
include ::Openstack
end

View File

@ -24,7 +24,7 @@
require 'uri'
class ::Chef::Recipe # rubocop:disable Documentation
class ::Chef::Recipe
include ::Openstack
end
include_recipe 'openstack-identity'

View File

@ -554,7 +554,7 @@ describe 'openstack-dashboard::apache2-server' do
action: [:run],
params: {
enable: false,
name: '000-default'
name: '000-default',
}
)
end
@ -567,7 +567,7 @@ describe 'openstack-dashboard::apache2-server' do
params: {
enable: true,
notifies: [:reload, 'service[apache2]', :immediately],
name: 'openstack-dashboard'
name: 'openstack-dashboard',
}
)
end

View File

@ -32,7 +32,7 @@ describe 'openstack-dashboard::horizon' do
[
%r{^LOGIN_URL = '/auth/login/'$},
%r{^LOGOUT_URL = '/auth/logout/'$},
%r{^LOGIN_REDIRECT_URL = '/'$}
%r{^LOGIN_REDIRECT_URL = '/'$},
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end

View File

@ -50,12 +50,12 @@ describe 'openstack-dashboard::horizon' do
node.set['openstack']['dashboard']['misc_local_settings'] = {
'CUSTOM_CONFIG_A' => {
'variable1' => 'value1',
'variable2' => 'value2'
'variable2' => 'value2',
},
'CUSTOM_CONFIG_B' => {
'variable1' => 'value1',
'variable2' => 'value2'
}
'variable2' => 'value2',
},
}
end
@ -68,7 +68,7 @@ describe 'openstack-dashboard::horizon' do
['CUSTOM_CONFIG_B = {',
' \'variable1\': \'value1\',',
' \'variable2\': \'value2\',',
'}']
'}'],
].each do |content|
expect(chef_run).to render_file(file.name).with_content(build_section(content))
end
@ -237,7 +237,7 @@ describe 'openstack-dashboard::horizon' do
[
/^LOGIN_URL =$/,
/^LOGOUT_URL =$/,
/^LOGIN_REDIRECT_URL =$/
/^LOGIN_REDIRECT_URL =$/,
].each do |line|
expect(chef_run).to_not render_file(file.name).with_content(line)
end
@ -254,7 +254,7 @@ describe 'openstack-dashboard::horizon' do
node.set['openstack']['dashboard']['volume_api_version'] = 'volume_api_version_value'
[
/^\s*"identity": identity_api_version_value,$/,
/^\s*"volume": volume_api_version_value$/
/^\s*"volume": volume_api_version_value$/,
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
@ -264,7 +264,7 @@ describe 'openstack-dashboard::horizon' do
node.set['openstack']['api']['auth']['version'] = 'v3.0'
[
/^\s*"identity": 3,$/,
/^\s*"volume": 2$/
/^\s*"volume": 2$/,
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
@ -456,10 +456,9 @@ describe 'openstack-dashboard::horizon' do
/^\s*'PASSWORD': 'test-passes',$/,
/^\s*'HOST': '#{service_type}_host',$/,
/^\s*'PORT': '#{service_type}_port',$/].each do |cfg|
unless service_type == 'sqlite'
it "configures the #{service_type} backend with #{cfg}" do
expect(chef_run).to render_file(file.name).with_content(cfg)
end
next if service_type == 'sqlite'
it "configures the #{service_type} backend with #{cfg}" do
expect(chef_run).to render_file(file.name).with_content(cfg)
end
end
end
@ -497,7 +496,7 @@ describe 'openstack-dashboard::horizon' do
sync_db_environment = {
'PYTHONPATH' => '/etc/openstack-dashboard:' \
'/usr/share/openstack-dashboard:' \
'$PYTHONPATH'
'$PYTHONPATH',
}
it 'does not execute when session_backend is not sql' do

View File

@ -8,12 +8,12 @@ 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
# Build a regex for a section of lines