Initial telemetry Pike updates

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

Change-Id: If802d82561619a0b7951422dc0e1e913f2c4c8b4
This commit is contained in:
Samuel Cassiba 2017-08-23 22:38:32 -04:00
parent 516a5e7a62
commit d6736f20ac
10 changed files with 27 additions and 48 deletions

View File

@ -1,5 +1,3 @@
inherit_from: .rubocop_todo.yml
AllCops:
Include:
- metadata.rb

View File

@ -1,22 +0,0 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-17 14:16:22 +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: 20
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 208
# Offense count: 4
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'recipes/api.rb'
- 'recipes/common.rb'
- 'recipes/gnocchi_configure.rb'
- 'recipes/identity_registration.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

@ -20,8 +20,11 @@
#
# 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']['telemetry']['custom_template_banner'] =
'# This file autogenerated by Chef, changes will be overwritten'
default['openstack']['telemetry']['custom_template_banner'] = '
# This file is automatically generated by Chef
# Any changes will be overwritten
'
# Set the endpoints for the telemetry services to allow all other cookbooks to
# access and use them
%w(telemetry telemetry-metric).each do |ts|
@ -103,7 +106,7 @@ when 'rhel'
'api_service' => 'openstack-ceilometer-api',
'collector_packages' => ['openstack-ceilometer-collector'],
'collector_service' => 'openstack-ceilometer-collector',
'package_overrides' => ''
'package_overrides' => '',
}
when 'debian'
@ -124,6 +127,6 @@ when 'debian'
'api_service' => 'ceilometer-api',
'collector_packages' => ['ceilometer-collector', 'python-mysqldb'],
'collector_service' => 'ceilometer-collector',
'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

View File

@ -20,7 +20,7 @@
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
class ::Chef::Recipe
include ::Openstack
end

View File

@ -38,7 +38,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,
}
%w(telemetry telemetry-metric).each do |telemetry_service|
@ -54,7 +54,7 @@ connection_params = {
interfaces = {
public: { url: public_endpoint(telemetry_service) },
internal: { url: internal_endpoint(telemetry_service) },
admin: { url: admin_endpoint(telemetry_service) }
admin: { url: admin_endpoint(telemetry_service) },
}
service_pass = get_password 'service', "openstack-#{telemetry_service}"

View File

@ -70,7 +70,7 @@ describe 'openstack-telemetry::common' do
/^auth_type = v3password$/,
/^region_name = RegionOne$/,
%r{auth_url = http://127\.0\.0\.1:5000/v3},
/^password = ceilometer-pass$/
/^password = ceilometer-pass$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('keystone_authtoken', line)
@ -87,7 +87,7 @@ describe 'openstack-telemetry::common' do
/^interface = internal$/,
/^region_name = RegionOne$/,
%r{auth_url = http://127\.0\.0\.1:5000/v3},
/^password = ceilometer-pass$/
/^password = ceilometer-pass$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('service_credentials', line)
@ -97,7 +97,7 @@ describe 'openstack-telemetry::common' do
it do
[
/^host = 127\.0\.0\.1$/,
/^port = 8777$/
/^port = 8777$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('api', line)
@ -107,7 +107,7 @@ describe 'openstack-telemetry::common' do
it do
[
%r{url = http://127\.0\.0\.1:8041},
/^filter_project = service$/
/^filter_project = service$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('dispatcher_gnocchi', line)
@ -116,7 +116,7 @@ describe 'openstack-telemetry::common' do
it 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)

View File

@ -28,7 +28,7 @@ describe 'openstack-telemetry::gnocchi_configure' do
/^auth_type = v3password$/,
/^region_name = RegionOne$/,
%r{auth_url = http://127\.0\.0\.1:5000/v3},
/^password = gnocchi-pass$/
/^password = gnocchi-pass$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('keystone_authtoken', line)
@ -38,7 +38,7 @@ describe 'openstack-telemetry::gnocchi_configure' do
it do
[
/^host = 127\.0\.0\.1$/,
/^port = 8041$/
/^port = 8041$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)
.with_section_content('api', line)

View File

@ -29,7 +29,7 @@ describe 'openstack-telemetry::identity_registration' do
openstack_username: 'admin',
openstack_api_key: 'admin-pass',
openstack_project_name: 'admin',
openstack_domain_name: 'default'
openstack_domain_name: 'default',
}
service_user = service_name
url = "http://127.0.0.1:#{port}"

View File

@ -10,12 +10,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: '14.04',
log_level: ::LOG_LEVEL
log_level: ::LOG_LEVEL,
}.freeze
shared_context 'telemetry-stubs' do